pub struct VtuGrid {
pub points: Vec<[f64; 3]>,
pub cells: Vec<Vec<usize>>,
pub cell_types: Vec<VtkCellType>,
pub point_data: Vec<VtkDataArray>,
pub cell_data: Vec<VtkDataArray>,
}Expand description
VTK XML Unstructured Grid.
Build up a grid with VtuGrid::add_point / VtuGrid::add_cell, attach
field data via the add_point_* / add_cell_* helpers, then call
VtuGrid::to_vtu_string to obtain a ready-to-write VTU XML string.
Fields§
§points: Vec<[f64; 3]>3-D coordinates of every point.
cells: Vec<Vec<usize>>Connectivity list: each entry is the ordered point indices of one cell.
cell_types: Vec<VtkCellType>VTK cell type for each cell (parallel to VtuGrid::cells).
point_data: Vec<VtkDataArray>Per-point data arrays.
cell_data: Vec<VtkDataArray>Per-cell data arrays.
Implementations§
Source§impl VtuGrid
impl VtuGrid
Sourcepub fn add_point(&mut self, p: [f64; 3]) -> usize
pub fn add_point(&mut self, p: [f64; 3]) -> usize
Append a point and return its zero-based index.
Sourcepub fn add_cell(&mut self, connectivity: Vec<usize>, cell_type: VtkCellType)
pub fn add_cell(&mut self, connectivity: Vec<usize>, cell_type: VtkCellType)
Append a cell defined by connectivity (point indices) and a cell_type.
Sourcepub fn add_point_scalar(&mut self, name: &str, values: Vec<f64>)
pub fn add_point_scalar(&mut self, name: &str, values: Vec<f64>)
Attach a per-point scalar field.
Sourcepub fn add_point_vector(&mut self, name: &str, values: Vec<[f64; 3]>)
pub fn add_point_vector(&mut self, name: &str, values: Vec<[f64; 3]>)
Attach a per-point 3-component vector field.
Sourcepub fn add_cell_scalar(&mut self, name: &str, values: Vec<f64>)
pub fn add_cell_scalar(&mut self, name: &str, values: Vec<f64>)
Attach a per-cell scalar field.
Sourcepub fn to_vtu_string(&self) -> String
pub fn to_vtu_string(&self) -> String
Serialise the grid to a VTU XML string.
The output is ASCII-encoded and compatible with ParaView / VisIt.
Sourcepub fn write_pvd_collection(
base_name: &str,
time_steps: &[(f64, String)],
) -> String
pub fn write_pvd_collection( base_name: &str, time_steps: &[(f64, String)], ) -> String
Write a PVD collection file that references a series of VTU snapshots.
Returns the PVD XML as a String. The caller is responsible for writing
it to disk and ensuring that the referenced VTU files are co-located.
§Arguments
base_name– e.g."simulation"(currently used as the collection title).time_steps– slice of(time, vtu_filename)pairs.
Sourcepub fn from_points(positions: &[[f64; 3]]) -> Self
pub fn from_points(positions: &[[f64; 3]]) -> Self
Create a point-cloud grid: each position becomes a Vertex cell.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for VtuGrid
impl RefUnwindSafe for VtuGrid
impl Send for VtuGrid
impl Sync for VtuGrid
impl Unpin for VtuGrid
impl UnsafeUnpin for VtuGrid
impl UnwindSafe for VtuGrid
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.