Mesh File Formats
MFEM and MEDIT mesh file formats.
Introduction
Rodin supports several mesh file formats for reading and writing meshes. Each format has its own strengths and is suited to different workflows.
MFEM Format
The MFEM format is a text-based mesh format used by the MFEM finite element library.
Saving
Mesh mesh; mesh = mesh.UniformGrid(Polytope::Type::Triangle, {16, 16}); mesh.save("output.mesh", IO::FileFormat::MFEM);
Loading
Mesh mesh; mesh.load("input.mesh", IO::FileFormat::MFEM);
MEDIT Format
The MEDIT format (also known as .mesh format from INRIA) is commonly used with the MMG remeshing platform and other INRIA tools.
Saving
mesh.save("output.mesh", IO::FileFormat::MEDIT);
Loading
Mesh mesh; mesh.load("input.mesh", IO::FileFormat::MEDIT);
Using with MMG
When working with the MMG remeshing tools through Rodin's Rodin::
#include <RodinExternal/MMG.h> // Load mesh in MEDIT format MMG::Mesh mesh; mesh.load("domain.mesh", IO::FileFormat::MEDIT); // ... perform remeshing operations ... // Save result mesh.save("remeshed.mesh", IO::FileFormat::MEDIT);
Format Conversion
Converting between formats is straightforward — simply load in one format and save in another:
Mesh mesh; mesh.load("input.mesh", IO::FileFormat::MEDIT); mesh.save("output.mesh", IO::FileFormat::MFEM);
Comparison
| Feature | MFEM | MEDIT | HDF5 | XDMF |
|---|---|---|---|---|
| Format | Text | Text | Binary | XML + HDF5 |
| Extension | .mesh | .mesh | .h5 | .xdmf, .h5 |
| Mesh loading | Yes | Yes | Yes | No |
| Mesh saving | Yes | Yes | Yes | Visualization output |
| Vertices | Yes | Yes | Yes | Yes |
| Elements | Yes | Yes | Yes | Yes |
| Boundary markers | Attributes | References | Attributes | Attributes |
| Region markers | Attributes | References | Attributes | Attributes |
| Best for | MFEM workflows | MMG, INRIA tools | Persistence/checkpointing | ParaView visualization |
Geometry Coverage
Mesh I/O tests cover every local polytope geometry used by Rodin:
| Dimension | Geometries |
|---|---|
| 0D | Point |
| 1D | Segment |
| 2D | Triangle, Quadrilateral |
| 3D | Tetrahedron, Hexahedron, Wedge |
MEDIT and MFEM are tested with string round trips for all of these geometries. HDF5 persistence and XDMF visualization output are tested over the same set. The 0D case is represented as point topology embedded in a coordinate space so that formats with coordinate arrays can still store the vertex position.