omega_h
Reliable mesh adaptation
Classes | Typedefs | Enumerations | Functions
Omega_h::exodus Namespace Reference

Classes

struct  FieldComponent
 

Typedefs

typedef std::vector< std::string > FieldNames
 

Enumerations

enum  ClassifyWith { NODE_SETS = 0x1 , SIDE_SETS = 0x2 }
 

Functions

int open (filesystem::path const &path, bool verbose)
 
void close (int exodus_file)
 
int get_num_time_steps (int exodus_file)
 
void read_nodal_fields (int exodus_file, Mesh *mesh, int time_step, std::string const &prefix="", std::string const &postfix="", bool verbose=false, bool merge_components=false)
 Read nodal (vertex) fields from an open Exodus file into a mesh. More...
 
void read_element_fields (int exodus_file, Mesh *mesh, int time_step, std::string const &prefix="", std::string const &postfix="", bool verbose=false, bool merge_components=false)
 Read element fields from an open Exodus file into a mesh. More...
 
void read_mesh (int exodus_file, Mesh *mesh, bool verbose=false, int classify_with=NODE_SETS|SIDE_SETS)
 Read an Exodus II file into an Omega_h::Mesh and assign geometric classification. More...
 
Mesh read_sliced (filesystem::path const &path, CommPtr comm, bool verbose=false, int classify_with=NODE_SETS|SIDE_SETS, int time_step=-1, bool merge_components=false)
 Collectively read an Exodus II file into a distributed Omega_h::Mesh. More...
 
bool isExcludedField (FieldNames excludedNodalFields, std::string fieldName)
 
void write_nodal_fields (int exodus_file, Mesh *mesh, int time_step, std::string const &prefix, std::string const &postfix, FieldNames excludedNodalFields, bool verbose)
 
void write (filesystem::path const &path, Mesh *mesh, bool verbose=false, int classify_with=NODE_SETS|SIDE_SETS, FieldNames excludedNodalFields=FieldNames())
 Write an Omega_h::Mesh to an Exodus II file. More...
 

Detailed Description

Functions supporting Exodus II file I/O

Function Documentation

◆ read_element_fields()

void Omega_h::exodus::read_element_fields ( int  exodus_file,
Mesh mesh,
int  time_step,
std::string const &  prefix = "",
std::string const &  postfix = "",
bool  verbose = false,
bool  merge_components = false 
)

Read element fields from an open Exodus file into a mesh.

Identical to exodus::read_nodal_fields() except that element variables (EX_ELEM_BLOCK) are read and stored as tags on the element dimension (mesh->dim()) rather than on vertices.

◆ read_mesh()

void Omega_h::exodus::read_mesh ( int  exodus_file,
Mesh mesh,
bool  verbose = false,
int  classify_with = NODE_SETS|SIDE_SETS 
)

Read an Exodus II file into an Omega_h::Mesh and assign geometric classification.

Builds the Omega_h::Mesh from element blocks and derives entity classification from those blocks plus optional node sets and/or side sets, controlled by the classify_with bitmask (bitwise-OR of NODE_SETS and/or SIDE_SETS).

Classification is assigned as follows:

  • Elements (dim d): each element's class_id is set to its element block ID and class_dim is set to d.
  • Sides (dim d-1): boundary sides are initially given class_id=0.
    • Side sets: each (element, local-side-index) entry provided by Exodus identifies a side, which is assigned class_id equal to the side set ID and class_dim = d-1.
    • Node sets: a side is part of the node set if and only if both of its vertices are in the set (via upward adjacency, see mark_up_all). Those sides are assigned class_id = node_set_id + max_side_set_id (offset to avoid collision with side set IDs) and class_dim = d-1.
  • Vertices (dim 0): never classified directly from sets. Classification is derived by finalize_classification(), which projects downward from sides: a vertex shared by sides of the same model entity inherits that entity's classification; a vertex at the junction of sides belonging to different model entities is classified on a lower-dimensional model entity (e.g., a model vertex, with class_id=-1).

Node set, side set, and element block names are recorded in Omega_h::Mesh::class_sets map (keyed by name, paired with their classification dimension and ID), and optionally written to the .osh file, for later retrieval when writing back to Exodus or another format.

Warning
Overlapping sets are not supported. If a side (or the sides implied by a node set) appears in more than one set, the last write wins and earlier classification is silently overwritten.
Parameters
[in]exodus_fileOpen Exodus file handle.
[in,out]meshOutput mesh; populated and classified by this call.
[in]verboseIf true, print progress information to stdout.
[in]classify_withBitmask selecting classification sources: NODE_SETS, SIDE_SETS, or both.

◆ read_nodal_fields()

void Omega_h::exodus::read_nodal_fields ( int  exodus_file,
Mesh mesh,
int  time_step,
std::string const &  prefix = "",
std::string const &  postfix = "",
bool  verbose = false,
bool  merge_components = false 
)

Read nodal (vertex) fields from an open Exodus file into a mesh.

Reads all nodal variables at the given 0-based time_step and adds them as tags on Mesh::VERT. The mesh must already be populated by exodus::read_mesh(). Each Exodus variable named <name> becomes an Omega_h tag named prefix + name + postfix.

When merge_components is true, variables matching <base>_<N> (zero- or one-based N) are combined into a single multi-component tag named <base>.

Parameters
[in]exodus_fileOpen Exodus file handle.
[in,out]meshMesh to add tags to.
[in]time_step0-based time step index to read.
[in]prefixPrepended to each tag name (default "").
[in]postfixAppended to each tag name (default "").
[in]verboseIf true, print variable names to stdout.
[in]merge_componentsIf true, reassemble <base>_N variables into a single multi-component tag.

◆ read_sliced()

Mesh Omega_h::exodus::read_sliced ( filesystem::path const &  path,
CommPtr  comm,
bool  verbose = false,
int  classify_with = NODE_SETS|SIDE_SETS,
int  time_step = -1,
bool  merge_components = false 
)

Collectively read an Exodus II file into a distributed Omega_h::Mesh.

Opens the Exodus file in parallel via MPI-IO and distributes contiguous slices of nodes and elements across all ranks of comm.

Requires Omega_h built with -DOmega_h_USE_MPI=ON and an Exodus library compiled with PARALLEL_AWARE_EXODUS; otherwise calls Omega_h_fail.

The Exodus file must contain:

  • coordx/y/z — nodal coordinates (NetCDF variables)
  • connect<N> — element-to-node connectivity per element block (1-based)
Warning
Node sets and side sets are not read; boundary classification is limited to exposed-side detection.
Parameters
[in]pathPath to the .e / .exo file.
[in]commOmega_h communicator; all ranks must call collectively.
[in]verboseIf true, rank 0 prints progress to stdout.
[in]classify_withAccepted for API consistency; currently ignored.
[in]time_step0-based time step to read (-1 = last step). Ignored when the file has no transient data.
[in]merge_componentsIf true, reassemble <base>_N nodal variables into a single multi-component tag.
Returns
A fully distributed Omega_h::Mesh.

◆ write()

void Omega_h::exodus::write ( filesystem::path const &  path,
Mesh mesh,
bool  verbose = false,
int  classify_with = NODE_SETS|SIDE_SETS,
FieldNames  excludedNodalFields = FieldNames() 
)

Write an Omega_h::Mesh to an Exodus II file.

Writes mesh topology, nodal coordinates, geometric classification, and all floating-point nodal tags to a new Exodus file (clobbers any existing file). Element blocks are written one per unique element class_id; block names come from Mesh::class_sets or default to block_<id>. Boundary surfaces are written as side sets and/or node sets depending on classify_with. Multi-component nodal tags are split into separate scalar Exodus variables named <tag_name>_<component_index>.

Parameters
[in]pathPath to the output .e / .exo file.
[in]meshMesh to write.
[in]verboseIf true, print progress information to stdout.
[in]classify_withBitmask of NODE_SETS and/or SIDE_SETS controlling which boundary set types to write.
[in]excludedNodalFieldsNames of vertex tags to omit from output.