Crate ntools_mesh

Expand description

Mesh tally tools and file parsing

Module for storing and using mesh data from all output formats and geometry types.

All of the parsing and reader logic is re-exported to make reading files very simple, regardless of format. For example:

// Extract ALL meshes from a file into a Vec<Mesh>
let mesh_list = read("/path/to/meshtal.msht").unwrap();

// Extract just one target Mesh from a file
let mesh = read_target("/path/to/meshtal.msht", 104).unwrap();

§Supported output formats

For more detail, see the OUT keyword for the FMESH card definition in the MCNPv6.2 or MCNPv6.3 user manuals.

Output formatSupported?Description
XDMF/HDF5YesMCNP >6.3 runtape HDF5 format
COLYesColumn data (MCNP default)
CFYesColumn data including voxel volume
IJYes2D matrix of I (col) and J (row) data, grouped by K
IKYes2D matrix of I (col) and K (row) data, grouped by J
JKYes2D matrix of J (col) and K (row) data, grouped by I
CUV (UKAEA)YesUKAEA Cell-under-Voxel column data
NONEN/ANONE or unknown output format

Note that HDF5 formats require the hdf5 shared library to be installed on your system. e.g.

sudo apt-get install libhdf5-dev

HDF5 is opt-in and will be enabled with the --hdf5 feature flag.

§Supported mesh geometries

All functionality is fully supported for both rectangular and cylindrical meshes.

Mesh geometrySupported?MCNP designators
RectangularYesrec, xyz
CylindricalYescyl, rzt
SphericalNosph, rpt

Spherical meshes are not currently supported because barely anyone knows about them, let alone uses them. They are a low priority.

§Quickstart example

Example to read in a mesh tally and perform varius operations.

fn main() {
    // Read mesh 104 from the meshtal file
    let mut mesh = read_target("./data/meshes/fmesh_104.msht", 104).unwrap();

    // print a summary of the mesh (Display trait impemented)
    println!("{mesh}");

    // rescale, get data, do whatever is needed
    mesh.scale(1.0e+06);
    println!("Maximum flux: {:?}", mesh.maximum());
    println!("Minimum flux: {:?}", mesh.minimum());
    println!("Average flux: {:?}", mesh.average());

    // Convert to VTK with the default configuration
    let vtk = mesh_to_vtk(&mesh);

    // Write the VTK to a file in one of several formats
    write_vtk(vtk, "my_output.vtk", VtkFormat::Xml).unwrap();
}

Modules§

reader
Parsers and logic for reading meshtal files
vtk
Conversion to Visual Toolkit (VTK) formats

Structs§

Mesh
Common data structure representing a mesh tally
Point
Generic representation of a point in the mesh geometry
Voxel
Representation of a single voxel in the mesh
VoxelCoordinate
Convenience structure for collecting voxel coordiante information

Enums§

BoundaryTreatment
Method variants for dealing with a Point on boundaries
Error
The error type for ntools-mesh
Format
Meshtal output formats, e.g. COL, JK, CUV
Geometry
Mesh geometry types, i.e. Rectangular, Cylindrical
Group
Energy/Time groups are either Total or an upper bin edge
Particle
Complete collection of MCNP particle variants
PointKind
Variants for the type of Point coordinates

Traits§

VoxelSliceExt
Extension trait for slices of voxels

Functions§

mesh_to_vtk
Convert a mesh tally to vtk using default options
read
Read all meshes in a meshtal file
read_target
Read only the specified mesh from a meshtal file
read_target_pb
Read only the specified mesh, with progress bar
write_vtk
Write any vtk to file