Struct MeshToVtk

pub struct MeshToVtk {
    pub energy_groups: Vec<usize>,
    pub time_groups: Vec<usize>,
    pub include_errors: bool,
    pub byte_order: ByteOrder,
    pub compressor: Compressor,
    pub resolution: u8,
}
Expand description

Convert mesh tallies to vtk formats for plotting

All of the of logic for converting voxel data into the right VTK types and formats is implemented here. This includes calculating verticies for cylindrical cases as an unstructured mesh.

The fields remain public for direct use, but for convenience and style preference a builder pattern is also implemented and recommended.

§General properties

§Error meshes

Error meshes omitted by default to save space.

If enabled, every mesh will have a corresponding relative uncertainty dataset. Of course, this ~doubles file size, but that is fine in most cases.

// Include error meshes for each result
let converter = MeshToVtk::builder()
    .include_errors(true)
    .build();

§Target specific voxel groups

Important: By default all energy groups are included in the vtk.

Specific energy groups can be provided to reduce file sizes. This is also especially useful if only certain groups are of interest.

For specific energy/time groups:

// Choose specific energy and time groups by group index
let converter = MeshToVtk::builder()
    .energy_groups(vec![0, 1, 2, 6])
    .build();

If the groups indicies are unknown the index may be found with:

// Find the group index of a 20 MeV particle and index of the "total" group
let e_idx = vec![
    mesh.energy_index_from_group(Group::Value(20.0)).unwrap(),
    mesh.energy_index_from_group(Group::Total).unwrap()
];

§Vtk formatting

Included are a couple of more advanced options for VTK preferences.

Most useful is the byte ordering, which is important for binary file compatability with plotting software. ParaView does not care, but something like Visit only likes big endian. This is the default for convenience but is completely up to the user.

// Change the byte ordering to little endian
let converter = MeshToVtk::builder()
    .byte_order(ByteOrder::LittleEndian)
    .build();

Perhaps less useful is the compression method for XML file formats, but it is included for completeness anyway.

// Select the LZMA compression method
let converter = MeshToVtk::builder()
    .compressor(Compressor::LZMA)
    .build();

Generally just use LZMA but other options are available:

  • lzma (default)
  • lz4
  • zlib
  • none

§A note on Cylindrical meshes

There is no VTK representation of cylindrical meshes, so an unstructured mesh is generated from verticies based on the RZT bounds.

Unfortunately, this can result in “low-resolution” plots for meshes with few theta bins. The number of theta bins can be increased to round off these edges. This simply subdivides the voxels by an integer number of theta bins.

Cylindrical mesh resolution option

For example:

// Split every theta bin into 3 to round off the edges
let converter = MeshToVtk::builder()
    .resolution(3)
    .build();

Setting the resolution to 3 will subbdivide the theta bins into 3, thereby tripling the number of edges plotted from 8 to 24 for a more rounded look.

Note that this can increase memory usage and file size significantly but is a nice feature for generating more accurate cylinders.

Fields§

§energy_groups: Vec<usize>

Target energy group(s)

§time_groups: Vec<usize>

Target energy group(s)

§include_errors: bool

Include errors mesh in output files

§byte_order: ByteOrder

Byte ordering as big or little endian

§compressor: Compressor

compression method for xml file formats

§resolution: u8

Cylindrical mesh resolution

Implementations§

§

impl MeshToVtk

pub fn new() -> MeshToVtk

Start with the default configuration

pub fn builder() -> MeshToVtkBuilder

Get an instance of the MeshToVtkBuilder

pub fn convert(&self, mesh: &Mesh) -> Vtk

Convert a Mesh to vtkio::Vtk object

Once the configuration is set through either the builder or changing the fields directly, convert any Mesh into a Vtk ready for writing or futher processing.

§

impl MeshToVtk

This impl block contains no items.

Common use implementations

§

impl MeshToVtk

This impl block contains no items.

Implementations for proecessing Rectangular mesh types

§

impl MeshToVtk

This impl block contains no items.

Implementations for proecessing Cylindrical mesh types

Trait Implementations§

§

impl Debug for MeshToVtk

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl Default for MeshToVtk

§

fn default() -> MeshToVtk

Returns the “default value” for a type. Read more
§

impl PartialEq for MeshToVtk

§

fn eq(&self, other: &MeshToVtk) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl StructuralPartialEq for MeshToVtk

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.