Struct MeshToVtkBuilder

pub struct MeshToVtkBuilder { /* private fields */ }
Expand description

Builder implementation for MeshToVtk configuration

The fields of MeshToVtk are left public for direct use but the module also implements a builder.

For those not familiar, the builder allows for chained setter calls for a functional approach that could be considered more readable. Any number of parameters can be set this way (including none).

To get the final MeshToVtk from the builder, call build().

// Make a new builder, change some values
let converter = MeshToVtk::builder()
    .include_errors(true)
    .energy_groups(vec![0])     // first energy group
    .time_groups(vec![1, 2])    // second and third time groups
    .compressor(Compressor::LZMA)
    .byte_order(ByteOrder::LittleEndian)
    .resolution(3)
    .build();

// Convert the mesh using the parameters set
let vtk = converter.convert(&mesh);

// Write to "output.vtk" using the old ASCII text format
write_vtk(vtk, "./output.vtk", VtkFormat::LegacyAscii).unwrap();

This helps separate the configuration from the actual conversion logic, and is often a style preference for many users.

Implementations§

§

impl MeshToVtkBuilder

pub fn new() -> Self

Create a new instance of the builder with default parameters

pub fn build(self) -> MeshToVtk

Build the MeshToVtk type

pub fn energy_groups(self, groups: Vec<usize>) -> Self

Target energy group(s)

By default all energy groups are included in the vtk. Specific energy groups can be provided to reduce file sizes.

pub fn time_groups(self, groups: Vec<usize>) -> Self

Target time group(s)

By default all time groups are included in the vtk. Specific time groups can be provided to reduce file sizes.

pub fn include_errors(self, include: bool) -> Self

Include errors mesh in output files

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, which is fine in most cases.

pub fn resolution(self, resolution: u8) -> Self

Cylindrical mesh resolution

Warning: Every vertex is defined explicitly, so large values will significantly increase memory usage and file size.

Integer value for increasing angular resolution of cylindrical meshes. Cylinders are approximated to straight edge segments so it can be useful to round this off by splitting voxels into multiple smaller segments.

e.g. 4 theta bins gives 4 edges and therefore looks square. Using --resolution 3 generates 12 edges instead and looks more rounded in plots.

pub fn byte_order(self, order: ByteOrder) -> Self

Set the byte ordering

Note that Visit being Visit only reads big endian, even though most systems are little endian. The byte order has one variant of the ByteOrder, defaulting to big endian for convenience.

pub fn compressor(self, xml_compressor: Compressor) -> Self

Set the compression method for xml file formats

Generally just use LZMA but other options are available:

  • lzma (default)
  • lz4
  • zlib
  • none

Trait Implementations§

§

impl Default for MeshToVtkBuilder

§

fn default() -> Self

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

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> 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.