Input, output, and visualization
Choose a file format, export a field, and inspect the result.
Mesh files describe geometry and topology. Field files describe values in a finite element space. Visualization output brings the two together so a viewer can interpret a field on its mesh.
Choose a format
Select the format according to the required mesh, field or visualization operation. MFEM and MEDIT both use .mesh, so mesh loading requires an explicit format. XDMF output uses the dedicated IO::XDMF writer.
| Task | Starting point | Files |
|---|---|---|
| View a computed field in ParaView | IO::XDMF | XML metadata and HDF5 data |
| Exchange a mesh with MMG | IO::FileFormat::MEDIT | MEDIT mesh |
| Exchange MFEM-compatible meshes and fields | IO::FileFormat::MFEM | Mesh and grid-function files |
| Store supported mesh or field data in binary form | IO::FileFormat::HDF5 | HDF5 data |
Format support depends on the data being stored. See the mesh-format guide and grid-function guide for the relevant interfaces. A complete simulation checkpoint includes the saved fields, application state and restart logic.
Plot colors and presentation
Solution fields and numerical plots use the Turbo colormap. In ParaView, choose Turbo from the color-map presets. Comparison panels retain the same field range so that equal values have equal colors. Signed fields use a symmetric range about zero.
Line plots sample their curve colors from Turbo and distinguish series with markers and line styles. Mesh edges, reference outlines and categorical material regions use separate, consistent colors. Figure backgrounds remain transparent; captions and labels use the body font, Manrope, with Computer Modern LaTeX lettering for mathematical expressions. Text adapts to the light or dark theme while field colors remain unchanged. Documentation videos use 30 or 60 fps and preserve simulation-time playback.
Export a field for visualization
XDMF separates the description of a dataset from its numerical data. Open the .xdmf metadata file in ParaView; keep the referenced HDF5 files beside it. Link the application against Rodin::IO to use the writer.
The following complete program interpolates the known field on a triangular mesh of the unit square and exports it. It needs no PDE solve, making it a small check of the visualization workflow.
#include <Rodin/Geometry.h> #include <Rodin/Variational.h> #include <Rodin/IO/XDMF.h> using namespace Rodin; using namespace Rodin::Geometry; using namespace Rodin::Variational; int main() { Mesh mesh = Mesh().UniformGrid(Polytope::Type::Triangle, {16, 16}); mesh.scale(1.0 / 15.0); P1 vh(mesh); GridFunction field(vh); field = [](const Geometry::Point& p) { return p.x() * p.y(); }; IO::XDMF xdmf("Field"); xdmf.grid().setMesh(mesh).add("u", field); xdmf.write().flush(); return 0; }
The writer observes the mesh and field. Keep them alive until output is finished; construct them before the writer as shown above. The explicit name "u" identifies the field in the viewer.
Inspect the exported data
- Open
Field.xdmfin ParaView and select Apply. - Select the point field u for coloring.
- Choose the Turbo color-map preset.
- Use Surface With Edges to inspect the mesh.
- Optionally apply Warp By Scalar to lift the field above the plane.
For this example, the nodal values range from zero to one. The field is zero on the two coordinate axes and reaches one at the opposite corner. This provides a simple check that the coordinates and field were exported together.
Record a time series
Register the mesh and field once, update the field, and call write(time) after each update. For example, the following fragment writes two snapshots of using the objects above.
for (const Real time : {0.0, 1.0}) { field = [time](const Geometry::Point& p) { return time * p.x() * p.y(); }; xdmf.write(time); } xdmf.flush();
This fragment replaces the single write() call in the complete program. Each call records the current data. For changing geometry, named grids, multiple fields, and mesh policies, see XDMF format.
Exchange a mesh
Loading a MEDIT mesh and saving it in MFEM format uses two explicit format selections.
Mesh mesh; mesh.load("input.mesh", IO::FileFormat::MEDIT); mesh.save("output.mesh", IO::FileFormat::MFEM);
Conversion transfers the existing mesh through the selected file interfaces. Format-specific metadata are mapped to the target representation. See Mesh file formats.
Store a finite element field
A saved coefficient field must be interpreted with its mesh, finite element space, and numbering. Preserve those together when exchanging field data. A grid function can be saved and loaded using the supported format interfaces.
field.save("field.gf", IO::FileFormat::MFEM); field.load("field.gf", IO::FileFormat::MFEM);
The receiving field must have a compatible space. See Grid function I/O for complete save/load examples.
Continue with a complete solve
The Poisson tutorial exports a computed PDE solution using this workflow. The I/O examples cover mesh exchange and time-dependent visualization separately.