Rodin/IO/MFEM.h file

Declarations in MFEM.h.

Namespaces

namespace Rodin
The Rodin library for finite element methods and shape optimization.
namespace Rodin::IO
Reading and writing meshes, fields, and associated data.

Classes

struct Rodin::IO::MFEM::MeshVersion
Version information for MFEM mesh format.
struct Rodin::IO::MFEM::MeshHeader
Header information for MFEM mesh files.
struct Rodin::IO::MFEM::GridFunctionHeader
Header information for MFEM grid function files.
struct Rodin::IO::MFEM::FaceOrderEntry
Face index and vertex ordering used when emitting MFEM face DOFs.
struct Rodin::IO::MFEM::ParseUnsignedInteger
Parser for unsigned integers in MFEM format.
class Rodin::IO::MFEM::ParseVertex
Parser for vertex coordinates in MFEM format.
struct Rodin::IO::MFEM::ParseGeometry
Parser for geometry (element) information in MFEM format.
struct Rodin::IO::MFEM::ParseGeometry::Data
Parsed geometry data.
struct Rodin::IO::MFEM::ParseEmptyLine
Parser for empty lines.
struct Rodin::IO::MFEM::ParseEmptyLineOrComment
Parser for empty lines or comment lines.
struct Rodin::IO::MFEM::ParseKeyword
Parser for MFEM keywords.
class Rodin::IO::MFEM::ParseMeshHeader
Parser for MFEM mesh file headers.
template<size_t K>
class Rodin::IO::MFEM::TriangleNodes
MFEM-style nodal set on the reference triangle (0,0)-(1,0)-(0,1).
template<size_t K>
class Rodin::IO::MFEM::VandermondeTriangle
Vandermonde matrix on the triangle using MFEM's nodal set.
template<size_t K>
class Rodin::IO::MFEM::TetrahedronNodes
MFEM-style nodal set on the reference tetrahedron (0,0,0)-(1,0,0)-(0,1,0)-(0,0,1).
template<size_t K>
class Rodin::IO::MFEM::VandermondeTetrahedron
Vandermonde matrix on the tetrahedron using MFEM's nodal set.
template<size_t K>
class Rodin::IO::MFEM::WedgeNodes
MFEM-style nodal set on the reference wedge / prism.
template<size_t K>
class Rodin::IO::MFEM::WedgeChange
Change of nodes from Rodin wedge nodes to MFEM wedge nodes.
template<>
class Rodin::IO::MeshLoader<IO::FileFormat::MFEM, Context::Local>
Specialization for loading sequential meshes in MFEM format.
template<>
class Rodin::IO::MeshPrinter<FileFormat::MFEM, Context::Local>
Specialization for printing sequential meshes in MFEM format.
template<class Range>
class Rodin::IO::GridFunctionLoader<FileFormat::MFEM, Variational::P1<Range, Geometry::Mesh<Context::Local>>, Math::Vector<typename FormLanguage::Traits<Range>::ScalarType>>
Specialization for loading P1 grid functions from MFEM format.
template<size_t K, class Range>
class Rodin::IO::GridFunctionLoader<FileFormat::MFEM, Variational::H1<K, Range, Geometry::Mesh<Context::Local>>, Math::Vector<typename FormLanguage::Traits<Range>::ScalarType>>
Specialization for loading H1 grid functions from MFEM format.
template<class Range>
class Rodin::IO::GridFunctionLoader<FileFormat::MFEM, Variational::P0<Range, Geometry::Mesh<Context::Local>>, Math::Vector<typename FormLanguage::Traits<Range>::ScalarType>>
Loader for P0 (piecewise constant) grid functions in MFEM format.
template<class Range, class Context, class Data>
class Rodin::IO::GridFunctionPrinterBase<FileFormat::MFEM, Variational::P0<Range, Geometry::Mesh<Context>>, Data>
Base class for printing P0 (piecewise constant) grid functions in MFEM format.
template<class Range, class Context, class Data>
class Rodin::IO::GridFunctionPrinterBase<FileFormat::MFEM, Variational::P1<Range, Geometry::Mesh<Context>>, Data>
Base class for printing P1 (continuous Lagrange) grid functions in MFEM format.
template<size_t K, class Range, class Context, class Data>
class Rodin::IO::GridFunctionPrinterBase<FileFormat::MFEM, Variational::H1<K, Range, Geometry::Mesh<Context>>, Data>
Base class for printing H1 (continuous Lagrange) grid functions in MFEM format.
template<class FES, class Scalar>
class Rodin::IO::GridFunctionPrinter<FileFormat::MFEM, FES, Math::Vector<Scalar>>
Final specialization for printing grid functions with vector data in MFEM format.
template<size_t K, class Range, class Scalar>
class Rodin::IO::GridFunctionPrinter<FileFormat::MFEM, Variational::H1<K, Range, Geometry::Mesh<Context::Local>>, Math::Vector<Scalar>>
Specialization for printing H1 grid functions with vector data in MFEM format.
template<class FES, class Scalar>
class Rodin::IO::GridFunctionLoader<FileFormat::MFEM, FES, Math::Vector<Scalar>>
Loads each MFEM component through the scalar family's node mapping.

Enums

enum class Keyword { Dimension, Elements, Boundary, Vertices }
Keywords used in MFEM mesh file format.
enum Ordering { Nodes = 0, VectorDimension = 1 }
Data ordering for grid function storage.

Functions

auto toCharString(Keyword kw) -> const char* constexpr
Converts a keyword enum to its string representation.
auto operator==(const std::string& str, Keyword kw) -> bool
Compares the operands for equality.
auto operator==(Keyword kw, const std::string& str) -> bool
Compares the operands for equality.
auto operator==(Keyword kw, const char* str) -> bool
Compares the operands for equality.
auto operator==(const char* str, Keyword kw) -> bool
Compares the operands for equality.
auto operator!=(const char* str, Keyword kw) -> bool
Compares the operands for inequality.
auto operator!=(const std::string& str, Keyword kw) -> bool
Compares the operands for inequality.
auto operator!=(Keyword kw, const std::string& str) -> bool
Compares the operands for inequality.
auto operator<<(std::ostream& os, Keyword kw) -> std::ostream&
Stream output operator for MFEM keywords.
auto toKeyword(const char* str) -> Optional<Keyword>
Converts a C-style string to a keyword enum.
auto getline(std::istream& is, std::string& line, size_t& currentLineNumber) -> std::istream&
auto skipEmptyLinesAndComments(std::istream& is, size_t& currentLineNumber) -> std::string
auto readGridFunctionHeader(std::istream& is, size_t& lineNumber) -> GridFunctionHeader
Reads and validates the common MFEM field header.
auto getSortedEdgeKey(Index v0, Index v1) -> std::array<Index, 2>
Constructs an orientation-independent edge key.
auto getTriangleFaceKey(Index v0, Index v1, Index v2) -> std::array<Index, 3>
Constructs an orientation-independent triangular face key.
auto getQuadrilateralFaceKey(Index v0, Index v1, Index v2, Index v3) -> std::array<Index, 3>
Constructs an orientation-independent quadrilateral face key.
template<class Callback>
void forEachMFEMLocalEdge(Geometry::Polytope::Type geometry, Callback&& callback)
Enumerates local edges in MFEM order.
template<class Callback>
void forEachMFEMLocalFace(Geometry::Polytope::Type geometry, Callback&& callback)
Enumerates local faces in MFEM order.
auto getMFEMEdgeOrder(const Geometry::Mesh<Context::Local>& mesh) -> std::vector<Index>
Orders mesh edges for MFEM output.
auto getMFEMFaceOrder(const Geometry::Mesh<Context::Local>& mesh) -> std::vector<FaceOrderEntry>
Orders mesh faces and their vertices for MFEM output.
template<size_t K>
auto getTriangleNodeIndex(size_t bary0, size_t bary1, size_t bary2) -> size_t
Flattens an integer barycentric triangle-node coordinate.
template<size_t K>
auto getTriangleNodeMap(const Geometry::Polytope::Key& sourceVertices, const std::vector<Index>& targetVertices) -> std::vector<size_t>
Maps triangular node indices between vertex orderings.
template<size_t K>
auto getQuadrilateralNodeIndex(size_t i, size_t j) -> size_t
Flattens an integer quadrilateral-node coordinate.
template<size_t K>
auto getQuadrilateralCornerCoordinates(int vertex) -> std::pair<size_t, size_t>
Gets lattice coordinates of a quadrilateral corner.
template<size_t K>
auto applyQuadrilateralTransform(int transform, size_t i, size_t j) -> std::pair<size_t, size_t>
Applies a quadrilateral rotation or reflection to lattice coordinates.
template<size_t K>
auto getQuadrilateralNodeMap(const Geometry::Polytope::Key& sourceVertices, const std::vector<Index>& targetVertices) -> std::vector<size_t>
Maps quadrilateral node indices between vertex orderings.
auto getGeometry(GeometryType t) -> Optional<Rodin::Geometry::Polytope::Type> constexpr
Converts MFEM geometry type to Rodin polytope type.
auto getGeometry(Geometry::Polytope::Type t) -> Optional<GeometryType> constexpr
Converts Rodin polytope type to MFEM geometry type.

Enum documentation

enum class Keyword

Keywords used in MFEM mesh file format.

These keywords identify different sections of an MFEM mesh file.

Enumerators
Dimension

Dimension section keyword.

Elements

Elements section keyword.

Boundary

Boundary section keyword.

Vertices

Vertices section keyword.

enum Ordering

Data ordering for grid function storage.

Specifies how vector-valued grid function data is organized in memory.

Enumerators
Nodes

Node-major ordering: XXX..., YYY..., ZZZ... (all x-components, then all y-components, etc.).

VectorDimension

Vector dimension-major ordering: XYZ, XYZ, ... (interleaved components).

Function documentation

const char* toCharString(Keyword kw) constexpr

Converts a keyword enum to its string representation.

Parameters
kw Keyword to convert
Returns C-style string representation of the keyword

bool operator==(const std::string& str, Keyword kw)

Compares the operands for equality.

Parameters
str Text to compare or convert to a format keyword.
kw Format keyword to compare or write.
Returns True when the operands compare equal.

bool operator==(Keyword kw, const std::string& str)

Compares the operands for equality.

Parameters
kw Format keyword to compare or write.
str Text to compare or convert to a format keyword.
Returns True when the operands compare equal.

bool operator==(Keyword kw, const char* str)

Compares the operands for equality.

Parameters
kw Format keyword to compare or write.
str Text to compare or convert to a format keyword.
Returns True when the operands compare equal.

bool operator==(const char* str, Keyword kw)

Compares the operands for equality.

Parameters
str Text to compare or convert to a format keyword.
kw Format keyword to compare or write.
Returns True when the operands compare equal.

bool operator!=(const char* str, Keyword kw)

Compares the operands for inequality.

Parameters
str Text to compare or convert to a format keyword.
kw Format keyword to compare or write.
Returns True when the operands compare unequal.

bool operator!=(const std::string& str, Keyword kw)

Compares the operands for inequality.

Parameters
str Text to compare or convert to a format keyword.
kw Format keyword to compare or write.
Returns True when the operands compare unequal.

bool operator!=(Keyword kw, const std::string& str)

Compares the operands for inequality.

Parameters
kw Format keyword to compare or write.
str Text to compare or convert to a format keyword.
Returns True when the operands compare unequal.

std::ostream& operator<<(std::ostream& os, Keyword kw)

Stream output operator for MFEM keywords.

Parameters
os Output stream
kw Keyword to output
Returns Reference to the output stream

Optional<Keyword> toKeyword(const char* str)

Converts a C-style string to a keyword enum.

Parameters
str String to convert
Returns Optional keyword if conversion succeeds, empty otherwise

std::istream& getline(std::istream& is, std::string& line, size_t& currentLineNumber)

Parameters
is Input stream from which a line is read.
line Storage receiving the extracted line.
currentLineNumber Line counter incremented for each consumed line.
Returns Reference to the input stream after extraction.

std::string skipEmptyLinesAndComments(std::istream& is, size_t& currentLineNumber)

Parameters
is Input stream from which a line is read.
currentLineNumber Line counter incremented for each consumed line.
Returns Next data line, or an empty string when the stream is exhausted.

GridFunctionHeader readGridFunctionHeader(std::istream& is, size_t& lineNumber)

Reads and validates the common MFEM field header.

Parameters
is Field input stream.
lineNumber Running line counter used in diagnostics.
Returns Initialized collection, component count and supported ordering.

std::array<Index, 2> getSortedEdgeKey(Index v0, Index v1)

Constructs an orientation-independent edge key.

Parameters
v0 Vertex index of the entity.
v1 Vertex index of the entity.
Returns The two vertex indices in ascending order.

std::array<Index, 3> getTriangleFaceKey(Index v0, Index v1, Index v2)

Constructs an orientation-independent triangular face key.

Parameters
v0 Vertex index of the entity.
v1 Vertex index of the entity.
v2 Vertex index of the entity.
Returns The three vertex indices in ascending order.

std::array<Index, 3> getQuadrilateralFaceKey(Index v0, Index v1, Index v2, Index v3)

Constructs an orientation-independent quadrilateral face key.

Parameters
v0 Vertex index of the entity.
v1 Vertex index of the entity.
v2 Vertex index of the entity.
v3 Vertex index of the entity.
Returns The three smallest vertex indices, in ascending order.

template<class Callback>
void forEachMFEMLocalEdge(Geometry::Polytope::Type geometry, Callback&& callback)

Enumerates local edges in MFEM order.

Parameters
geometry Reference-cell geometry whose local entities are enumerated.
callback Callable receiving the local vertex indices of each entity.

template<class Callback>
void forEachMFEMLocalFace(Geometry::Polytope::Type geometry, Callback&& callback)

Enumerates local faces in MFEM order.

Parameters
geometry Reference-cell geometry whose local entities are enumerated.
callback Callable receiving the local vertex indices of each entity.

std::vector<Index> getMFEMEdgeOrder(const Geometry::Mesh<Context::Local>& mesh)

Orders mesh edges for MFEM output.

Parameters
mesh Mesh whose entities are traversed.
Returns Rodin edge indices in first-encounter order under MFEM local edge traversal.

std::vector<FaceOrderEntry> getMFEMFaceOrder(const Geometry::Mesh<Context::Local>& mesh)

Orders mesh faces and their vertices for MFEM output.

Parameters
mesh Mesh whose entities are traversed.
Returns Face indices and MFEM vertex orderings in first-encounter order over the cells.

template<size_t K>
size_t getTriangleNodeIndex(size_t bary0, size_t bary1, size_t bary2)

Flattens an integer barycentric triangle-node coordinate.

Parameters
bary0 Integer barycentric coordinate; the coordinates sum to the polynomial order.
bary1 Integer barycentric coordinate; the coordinates sum to the polynomial order.
bary2 Integer barycentric coordinate; the coordinates sum to the polynomial order.
Returns Node index in row-major triangular lattice ordering.

template<size_t K>
std::vector<size_t> getTriangleNodeMap(const Geometry::Polytope::Key& sourceVertices, const std::vector<Index>& targetVertices)

Maps triangular node indices between vertex orderings.

Parameters
sourceVertices Vertices in the source entity ordering.
targetVertices The same vertices in the target entity ordering.
Returns Map indexed by target node index, with the corresponding source node index as its value.

template<size_t K>
size_t getQuadrilateralNodeIndex(size_t i, size_t j)

Flattens an integer quadrilateral-node coordinate.

Parameters
i First supporting vertex index.
j Second supporting vertex index.
Returns Node index with the first coordinate varying fastest.

template<size_t K>
std::pair<size_t, size_t> getQuadrilateralCornerCoordinates(int vertex)

Gets lattice coordinates of a quadrilateral corner.

Parameters
vertex Local corner index, from zero to three.
Returns Integer corner coordinates at the specified polynomial order.

template<size_t K>
std::pair<size_t, size_t> applyQuadrilateralTransform(int transform, size_t i, size_t j)

Applies a quadrilateral rotation or reflection to lattice coordinates.

Parameters
transform Quadrilateral symmetry index, from zero to seven.
i First supporting vertex index.
j Second supporting vertex index.
Returns Transformed integer node coordinates.

template<size_t K>
std::vector<size_t> getQuadrilateralNodeMap(const Geometry::Polytope::Key& sourceVertices, const std::vector<Index>& targetVertices)

Maps quadrilateral node indices between vertex orderings.

Parameters
sourceVertices Vertices in the source entity ordering.
targetVertices The same vertices in the target entity ordering.
Returns Map indexed by target node index, with the corresponding source node index as its value.

Optional<Rodin::Geometry::Polytope::Type> getGeometry(GeometryType t) constexpr

Converts MFEM geometry type to Rodin polytope type.

Parameters
t in MFEM geometry type
Returns Optional Rodin polytope type, empty if conversion not supported

Maps MFEM's internal geometry type enumeration to Rodin's polytope type system.

Optional<GeometryType> getGeometry(Geometry::Polytope::Type t) constexpr

Converts Rodin polytope type to MFEM geometry type.

Parameters
t in Type of polytope to construct.
Returns Optional MFEM geometry type, empty if conversion not supported

Maps Rodin's polytope type system to MFEM's internal geometry type enumeration.