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

FeatureMFEMMEDIT
FormatTextText
Extension.mesh.mesh
VerticesYesYes
ElementsYesYes
Boundary markersAttributesReferences
Region markersAttributesReferences
Best forMFEM workflowsMMG, INRIA tools

See Also