tk::ExodusIIMeshReader class

ExodusII mesh-based data reader

Mesh reader class facilitating reading from mesh-based field data a file in ExodusII format.

Constructors, destructors, conversion operators

ExodusIIMeshReader(const std::string& filename, int cpuwordsize = sizeof(double), int iowordsize = sizeof(double)) explicit
Constructor.
~ExodusIIMeshReader() noexcept
Destructor.
ExodusIIMeshReader(const ExodusIIMeshReader& x)
Copy constructor: in terms of copy assignment.
ExodusIIMeshReader(ExodusIIMeshReader&& x)
Move constructor: in terms of move assignment.

Public functions

void readMesh(UnsMesh& mesh)
Read ExodusII mesh from file.
auto npoin() -> std::size_t
Return total number of mesh points in mesh file.
void readMeshPart(std::vector<std::size_t>& ginpoel, std::vector<std::size_t>& inpoel, std::vector<std::size_t>& triinp, std::unordered_map<std::size_t, std::size_t>& lid, tk::UnsMesh::Coords& coord, int numpes = 1, int mype = 0)
auto readCoords(const std::vector<std::size_t>& gid) const -> std::array<std::vector<tk::real>, 3>
Read coordinates of a number of mesh nodes from ExodusII file.
void readSidesetFaces(std::map<int, std::vector<std::size_t>>& bface, std::map<int, std::vector<std::size_t>>& faces)
Read face list of all side sets from ExodusII file.
void readFaces(std::vector<std::size_t>& conn) const
Read face connectivity of a number boundary faces from file.
auto readSidesetNodes() -> std::map<int, std::vector<std::size_t>>
Read node list of all side sets from ExodusII file.
void readNode(std::size_t fid, std::size_t mid, std::vector<tk::real>& x, std::vector<tk::real>& y, std::vector<tk::real>& z) const
Read coordinates of a single mesh node from ExodusII file.
void readNode(std::size_t id, std::array<tk::real, 3>& coord) const
Read coordinates of a single mesh node from ExodusII file.
auto readNodes(const std::vector<std::size_t>& gid) const -> std::array<std::vector<tk::real>, 3>
Read coordinates of a number of mesh nodes from ExodusII file.
auto readElemBlockIDs() -> std::size_t
Read element block IDs from file.
void readElements(const std::array<std::size_t, 2>& ext, tk::ExoElemType elemtype, std::vector<std::size_t>& conn) const
Read element connectivity of a number of mesh cells from file.
auto readNodemap() -> std::vector<std::size_t>
Read local to global node-ID map.
auto triinpoel(std::map<int, std::vector<std::size_t>>& belem, const std::map<int, std::vector<std::size_t>>& faces, const std::vector<std::size_t>& ginpoel, const std::vector<std::size_t>& triinp) const -> std::vector<std::size_t>
Generate triangle face connectivity for side sets.
void readNodeVarNames(std::vector<std::string>& nv) const
Read the names of nodal output variables from ExodusII file.
void readTimeValues(std::vector<tk::real>& tv) const
Read time values from ExodusII file.
void readNodeScalars(std::size_t ntime, std::size_t nvar, std::vector<std::vector<std::vector<tk::real>>>& var) const
Read node scalar fields from ExodusII file.
auto nelem(tk::ExoElemType elemtype) const -> std::size_t
Return number of elements in a mesh block in the ExodusII file.
auto operator=(const ExodusIIMeshReader& x) -> ExodusIIMeshReader&
Copy assignment.
auto operator=(ExodusIIMeshReader&& x) -> ExodusIIMeshReader&
Move assignment.

Function documentation

tk::ExodusIIMeshReader::ExodusIIMeshReader(const std::string& filename, int cpuwordsize = sizeof(double), int iowordsize = sizeof(double)) explicit

Constructor.

Parameters
filename in File to open as ExodusII file
cpuwordsize in Set CPU word size, see ExodusII documentation
iowordsize in Set I/O word size, see ExodusII documentation

void tk::ExodusIIMeshReader::readMesh(UnsMesh& mesh)

Read ExodusII mesh from file.

Parameters
mesh in Unstructured mesh object

void tk::ExodusIIMeshReader::readMeshPart(std::vector<std::size_t>& ginpoel, std::vector<std::size_t>& inpoel, std::vector<std::size_t>& triinp, std::unordered_map<std::size_t, std::size_t>& lid, tk::UnsMesh::Coords& coord, int numpes = 1, int mype = 0)

Parameters
ginpoel in/out Container to store element connectivity of this PE's chunk of the mesh (global ids)
inpoel in/out Container to store element connectivity with local node IDs of this PE's mesh chunk
triinp in/out Container to store triangle element connectivity (if exists in file) with global node indices
lid in/out Container to store global->local node IDs of elements of this PE's mesh chunk
coord in/out Container to store coordinates of mesh nodes of this PE's mesh chunk
numpes in Total number of PEs (default n = 1, for a single-CPU read)
mype in This PE (default m = 0, for a single-CPU read)

Read part of the mesh (graph and coords) from file

Total number of PEs defaults to 1 for a single-CPU read, this PE defaults to 0 for a single-CPU read.

std::array<std::vector<tk::real>, 3> tk::ExodusIIMeshReader::readCoords(const std::vector<std::size_t>& gid) const

Read coordinates of a number of mesh nodes from ExodusII file.

Parameters
gid in Global node IDs whose coordinates to read
Returns Vector of node coordinates read from file

void tk::ExodusIIMeshReader::readSidesetFaces(std::map<int, std::vector<std::size_t>>& bface, std::map<int, std::vector<std::size_t>>& faces)

Read face list of all side sets from ExodusII file.

Parameters
bface in/out Elem ids of side sets to read into
faces in/out Elem-relative face ids of tets of side sets

void tk::ExodusIIMeshReader::readFaces(std::vector<std::size_t>& conn) const

Read face connectivity of a number boundary faces from file.

Parameters
conn in/out Connectivity vector to push to

This function reads in the total number of boundary faces, also called triangle-elements in the EXO2 file, and their connectivity.

std::map<int, std::vector<std::size_t>> tk::ExodusIIMeshReader::readSidesetNodes()

Read node list of all side sets from ExodusII file.

Returns Node lists mapped to side set ids

void tk::ExodusIIMeshReader::readNode(std::size_t fid, std::size_t mid, std::vector<tk::real>& x, std::vector<tk::real>& y, std::vector<tk::real>& z) const

Read coordinates of a single mesh node from ExodusII file.

Parameters
fid in Node id in file whose coordinates to read
mid in Node id in memory to which to put new cordinates
in/out Vector of x coordinates to push to
in/out Vector of y coordinates to push to
in/out Vector of z coordinates to push to

void tk::ExodusIIMeshReader::readNode(std::size_t id, std::array<tk::real, 3>& coord) const

Read coordinates of a single mesh node from ExodusII file.

Parameters
id in Node id whose coordinates to read
coord in/out Array of x, y, and z coordinates

std::array<std::vector<tk::real>, 3> tk::ExodusIIMeshReader::readNodes(const std::vector<std::size_t>& gid) const

Read coordinates of a number of mesh nodes from ExodusII file.

Parameters
gid in Node IDs whose coordinates to read
Returns Mesh node coordinates

std::size_t tk::ExodusIIMeshReader::readElemBlockIDs()

Read element block IDs from file.

Returns Total number of nodes in mesh

void tk::ExodusIIMeshReader::readElements(const std::array<std::size_t, 2>& ext, tk::ExoElemType elemtype, std::vector<std::size_t>& conn) const

Read element connectivity of a number of mesh cells from file.

Parameters
ext in Extents of element IDs whose connectivity to read: [from...till), using zero-based element IDs, where 'from' >=0, inclusive and 'till < 'maxelements', where 'maxelements' is the total number of elements of all element blocks in the file of the requested cell type. Note that 'maxelements' can be queried by nelem().
elemtype in Element type
conn in/out Connectivity vector to push to

This function takes the extents of element IDs in a zero-based fashion. These input extents can be thought of "absolute" extents that denote lowest and the largest-1 element IDs to be read from file.

std::vector<std::size_t> tk::ExodusIIMeshReader::readNodemap()

Read local to global node-ID map.

Returns node_map Vector mapping the local Exodus node-IDs to global node-IDs

The node-map is required to get the "Exodus-global" node-IDs from the "Exodus-internal" node-IDs, which are returned from the exodus APIs. The node-IDs in the exodus file are referred to as the "Exodus-global" node-IDs or "fileIDs".

std::vector<std::size_t> tk::ExodusIIMeshReader::triinpoel(std::map<int, std::vector<std::size_t>>& belem, const std::map<int, std::vector<std::size_t>>& faces, const std::vector<std::size_t>& ginpoel, const std::vector<std::size_t>& triinp) const

Generate triangle face connectivity for side sets.

Parameters
belem in/out File-internal elem ids of side sets
faces in Elem-relative face ids of side sets
ginpoel in Tetrahedron element connectivity with global nodes
triinp in Triangle element connectivity with global nodes (if exists in file)
Returns Triangle face connectivity with global node IDs of side sets

This function takes lists of file-internal element ids (in belem) for side sets and does two things: (1) generates face connectivity (with global node IDs) for side sets, and (2) converts the (ExodusII) file-internal element IDs to face ids so that they can be used to index into the face connectivity. The IDs in belem are modified and the face connectivity (for boundary faces only) is returned.

void tk::ExodusIIMeshReader::readNodeVarNames(std::vector<std::string>& nv) const

Read the names of nodal output variables from ExodusII file.

Parameters
nv in/out Nodal variable names

void tk::ExodusIIMeshReader::readTimeValues(std::vector<tk::real>& tv) const

Read time values from ExodusII file.

Parameters
tv in Vector of time values at which field data is saved

void tk::ExodusIIMeshReader::readNodeScalars(std::size_t ntime, std::size_t nvar, std::vector<std::vector<std::vector<tk::real>>>& var) const

Read node scalar fields from ExodusII file.

Parameters
ntime in Number of time steps to read
nvar in Number of variables to read
var in Vector of nodal variables to read to: inner vector: nodes, middle vector: (physics) variable, outer vector: time step

std::size_t tk::ExodusIIMeshReader::nelem(tk::ExoElemType elemtype) const

Return number of elements in a mesh block in the ExodusII file.

Parameters
elemtype in Element type
Returns Number of elements in all blocks for the elem type