| Crates.io | plot3d |
| lib.rs | plot3d |
| version | 0.1.2 |
| created_at | 2025-10-31 20:55:31.030312+00 |
| updated_at | 2025-11-02 21:47:01.96981+00 |
| description | Utilities for reading, writing, and manipulating NASA PLOT3D structured grids. |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1910756 |
| size | 277,696 |
Rust utilities for reading, writing, and analysing NASA PLOT3D structured grids. The crate draws heavily on the excellent plot3d Python project maintained by NASA. If you are looking for a battle-tested Python implementation with a rich set of examples, start there. This repository is a Rust reimagining that keeps the same data model while taking advantage of Rust’s type safety, performance, and interoperability.
Block structuresMany algorithms mirror the behaviour of the Python utilities one-for-one, making it straightforward to port workflows between languages or compare outputs across implementations.
Add the crate to your Cargo.toml:
[dependencies]
plot3d = "0.1"
Can also do add by running cargo add plot3d
The crate uses the 2021 edition of Rust and depends on common ecosystem crates such as serde, ndarray, and reqwest for optional test helpers.
use plot3d::{read_plot3d_ascii, connectivity_fast};
fn main() -> anyhow::Result<()> {
// Read an ASCII PLOT3D file into blocks
let blocks = read_plot3d_ascii("VSPT_ASCII.xyz")?;
// Compute face-to-face connectivity and remaining outer faces
let (matches, outer_faces) = connectivity_fast(&blocks);
println!("Found {} matched interfaces", matches.len());
println!("Remaining outer faces: {}", outer_faces.len());
Ok(())
}
For rotational periodicity detection:
use plot3d::{read_plot3d_ascii, connectivity_fast, rotated_periodicity};
fn main() -> anyhow::Result<()> {
let blocks = read_plot3d_ascii("VSPT_ASCII.xyz")?;
let (matches, outer) = connectivity_fast(&blocks);
// Rotate about the x-axis by 360/55 degrees, reducing the mesh by the shared GCD
let (periodic, remaining) = rotated_periodicity(&blocks, &matches, &outer, 360.0 / 55.0, 'x', true);
println!("Periodic interfaces: {}", periodic.len());
println!("Remaining outer faces: {}", remaining.len());
Ok(())
}
The original Python implementation includes comprehensive notebooks, example data, and a GUI. plot3d-rs strives to remain API-compatible where possible:
plot3d.read_plot3D and friendsconnectivity, connectivity_fast, periodicity detection) follow the same logic and produce comparable resultsFaceRecord, FaceMatch, PeriodicPair) are direct translations of the Python dictionaries used in the NASA projectWhen uncertain about the expected behaviour, use the Python utilities as ground truth. The Rust crate is intentionally lightweight and pragmatic, making it well-suited for embedding PLOT3D workflows in larger Rust applications or integrating with other numerical codes.
Bug reports, feature suggestions, and pull requests are welcome. If you find a discrepancy between this crate and the Python reference, please open an issue referencing the relevant Python behaviour so we can keep the implementations aligned.
This project is licensed under the MIT license.