Module vtk
Expand description
Conversion to Visual Toolkit (VTK) formats
This module handles all the conversions of various mesh types to Visual Toolkit formats, and is mostly a coupling layer between internal types and the vtkio crate.
§Overview
The intended workflow is to:
- Configure the converter
- Convert into a
vtkio
VTK - Write to file in the required format with write_vtk()
Often the default configuration will suffice. The convenience function mesh_to_vtk() will quickly convert to a VTK ready for writing with write_vtk().
// Get a mesh
let mesh = read_target("path/to/file.msht", 104).unwrap();
// Convert to VTK with the default configuration
let vtk = mesh_to_vtk(&mesh);
// Wite the VTK to a file in one of several formats
write_vtk(vtk, "output.vtk", VtkFormat::Xml).unwrap();
For more comprehensive examples, see the relevant struct documentation and the next section.
§Manual conversion
The fields of MeshToVtk are left public for direct use but builder patterns are also implemented. A builder helps separate the configuration from the conversion logic, and is often a style preference.
The following examples are therefore equivalent.
§The builder approach:
// Make a new builder, change some values
let converter = MeshToVtk::builder()
.include_errors(true)
.energy_groups(vec![0]) // first group
.resolution(3)
.build();
// Convert the mesh using the parameters set
let vtk = converter.convert(&mesh);
§The direct approach:
// Make a new instance, change some values
let mut converter = MeshToVtk::new();
converter.include_errors = true;
converter.energy_groups = vec![0]; // first group
converter.resolution = 3;
// Convert the mesh using the parameters set
let vtk = converter.convert(&mesh);
In the background, a call to MeshToVtk::new() simply returns a default configuration generated by the builder anyway.
Structs§
- Mesh
ToVtk - Convert mesh tallies to vtk formats for plotting
- Mesh
ToVtk Builder - Builder implementation for MeshToVtk configuration
- Vertex
- Vertex for use in cylindrical and unstructured mesh types
Enums§
- VtkFormat
- Enum of VTK output formats
Functions§
- mesh_
to_ vtk - Convert a mesh tally to vtk using default options
- write_
vtk - Write any vtk to file