General concepts » I/O in Rodin » 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::External::MMG module, the MEDIT format is used for mesh exchange:

#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

FeatureMFEMMEDITHDF5XDMF
FormatTextTextBinaryXML + HDF5
Extension.mesh.mesh.h5.xdmf, .h5
Mesh loadingYesYesYesNo
Mesh savingYesYesYesVisualization output
VerticesYesYesYesYes
ElementsYesYesYesYes
Boundary markersAttributesReferencesAttributesAttributes
Region markersAttributesReferencesAttributesAttributes
Best forMFEM workflowsMMG, INRIA toolsPersistence/checkpointingParaView visualization

Geometry Coverage

Mesh I/O tests cover every local polytope geometry used by Rodin:

DimensionGeometries
0DPoint
1DSegment
2DTriangle, Quadrilateral
3DTetrahedron, 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.

See Also