Skip to main content

io4dolfinx - A framework for reading and writing data to various mesh formats

io4dolfinx is an extension for DOLFINx that provides advanced input/output capabilities. It focuses on N-to-M checkpointing (writing data on N processors, reading on M processors) and supports reading/writing various mesh formats using interchangeable backends.

Installation

The library is compatible with DOLFINx v0.10.0 and newer, including the nightly release.

Workarounds for API differences between DOLFINx versions live in fenicsx-compat, which io4dolfinx depends on.

python3 -m pip install io4dolfinx

For specific backend requirements (like ADIOS2 or H5PY), see the Installation Guide.

Quick Start

Here is a minimal example of saving and loading a simulation state (Checkpointing).

from pathlib import Path
from mpi4py import MPI
import dolfinx
import io4dolfinx

# 1. Create a mesh and function
comm = MPI.COMM_WORLD
mesh = dolfinx.mesh.create_unit_square(comm, 10, 10)
V = dolfinx.fem.functionspace(mesh, ("Lagrange", 1))
u = dolfinx.fem.Function(V)
u.interpolate(lambda x: x[0] + x[1])
u.name = "my_function"

# 2. Write checkpoint
# The mesh must be written before the function
filename = Path("checkpoint.bp")
io4dolfinx.write_mesh(filename, mesh)
io4dolfinx.write_function(filename, u, time=0.0)

# 3. Read checkpoint
# This works even if the number of MPI processes changes (N-to-M)
mesh_new = io4dolfinx.read_mesh(filename, comm)
V_new = dolfinx.fem.functionspace(mesh_new, ("Lagrange", 1))
u_new = dolfinx.fem.Function(V_new)
io4dolfinx.read_function(filename, u_new, time=0.0, name="my_function")

Features and Backends

io4dolfinx supports custom user backends. You can switch backends by passing backend="name" to IO functions.

Checkpointing (N-to-M)

Many finite element applications requires storage of functions that cannot be associated with the nodes or cells of the mesh. Therefore, we have implemented our own, native checkpointing format that supports N-to-M checkpointing (write data on N processors, read in on M) through the following backends:

  • h5py: Requires HDF5 with MPI support to work, but can store, meshes, partitioning info, meshtags, function data and more.
  • adios2: Requires ADIOS 2 compiled with MPI support and Python bindings. Supports the same set of operations as the h5py backend.

The code uses the ADIOS2/Python-wrappers and h5py module to write DOLFINx objects to file, supporting N-to-M (recoverable) and N-to-N (snapshot) checkpointing. See: Checkpointing in DOLFINx - FEniCS 23 or the examples in the Documentation for more information.

For scalability, the code uses MPI Neighbourhood collectives for communication across processes.

Mesh IO (Import/Export)

Most meshing formats supports associating data with the nodes of the mesh (the mesh can be higher order) and the cells of the mesh. The node data can be read in as P-th order Lagrange functions (where P is the order of the grid), while the cell data can be read in as piecewise constant (DG-0) functions.

  • VTKHDF: The new scalable format from VTK, called VTKHDF is supported by the vtkhdf backend.
  • XDMF (eXtensible Model Data Format): .xdmf. The xdmf backend supports the HDF5 encoding, to ensure performance in parallel.
  • Gmsh: .msh files (MSH 2.2 and 4.1, ASCII and binary) are read and written with the Gmsh Python API by the gmsh backend, including physical groups as mesh tags and time-dependent point and cell data.
  • openCARP: Linear triangle, quadrilateral, tetrahedral and hexahedral meshes with region tags, fibers and markers are written to and read from the ASCII format of the cardiac simulator openCARP (.pts, .elem, .lon, .vtx, .surf) by the opencarp backend.
  • Nastran: Meshes and property IDs (PSOLID, PSHELL) of Nastran bulk data files (.bdf, .nas) are read with the Gmsh Python API by the nastran backend, including meshes with several cell types, such as hexahedra, pyramids and tetrahedra. GRID IDs are read as point data and vertex tags.
  • OpenFOAM: Meshes, cell and point fields, boundary patches and cell zones of OpenFOAM cases (.foam), including multi-region cases, are read through the VTK OpenFOAM reader of pyvista by the openfoam backend.
  • PyVista (IO backend is meshio): The pyvista backend uses {py:func}pyvista.read to read in meshes, point data and cell data. pyvista relies on meshio for most reading operations (including the XDMF ascii format).

Advanced Usage

The repository contains detailed documented examples in the docs folder:

For a full API reference and backend details, see the Documentation.

Legacy DOLFIN Support

io4dolfinx can read checkpoints created by the legacy version of DOLFIN (Lagrange or DG functions).

  • Reading meshes from DOLFIN HDF5File-format.
  • Reading checkpoints from DOLFIN HDF5File and XDMFFile.

Project Background

Relation to adios4dolfinx

This library is an evolution of adios4dolfinx. It includes all functionality of the original library but has been refactored to support multiple IO backends (not just ADIOS2), making it easier to interface with different meshing formats while keeping the library structure sane.

Statement of Need

As large-scale, long-running simulations on HPC clusters become more common, the need to store intermediate solutions is crucial. If a system crashes or a computational budget is exceeded, checkpoints allow the simulation to resume without restarting from scratch. io4dolfinx extends DOLFINx with this essential functionality.

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Testing

io4dolfinx includes a comprehensive test suite that ensures functionality across different backends and compatibility with legacy data formats, see the Testing Guide for details.

Releasing

Versions are managed with bump-my-version, configured in pyproject.toml. Between releases the version is a development version, X.Y.Z.devN; a release drops the suffix. Each bump commits the version change, so start from a clean working tree.

To release the current development version, e.g. 2.1.0.dev0, and start the next one:

bump-my-version bump release --no-tag  # 2.1.0.dev0 -> 2.1.0
bump-my-version bump minor --no-tag    # 2.1.0 -> 2.2.0.dev0

For a patch release of 2.1, bump patch instead of minor (2.1.0 -> 2.1.1.dev0), then release (2.1.1.dev0 -> 2.1.1). bump-my-version show-bump previews what each bump gives.

The bumps do not tag. A v* tag publishes to PyPI and the documentation, so tag the release commit (Bump version: 2.1.0.dev0 → 2.1.0) as v2.1.0, for instance by creating a GitHub release from it.

Releasing a new minor version also adds it to .github/docs-versions.toml, which lists the versions on the documentation website, built in the DOLFINx image of the previous one; edit that image afterwards if a newer DOLFINx release should be used. A patch release needs no entry, as each minor version is built from its newest tag.

LICENSE

This project is licensed under the MIT License - see the LICENSE file for details.

Metadata

Release files for io4dolfinx 2.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for io4dolfinx 2.1.0
File Size Uploaded Provenance Actions
io4dolfinx-2.1.0.tar.gz 234.9 kB With provenance Details for io4dolfinx-2.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for io4dolfinx 2.1.0
File Interpreter ABI Platform Actions
io4dolfinx-2.1.0-py3-none-any.whl Python 3 none any Details for io4dolfinx-2.1.0-py3-none-any.whl

Total release size: 415.0 kB

Release files / io4dolfinx-2.1.0.tar.gz

Download URL io4dolfinx-2.1.0.tar.gz
Size 234.9 kB
Tags Source
SHA-256 checksum
How to use checksums
b517af1e25247126e89c5569397f7b07d16de3af7b0f2b8e15c6fad793e52f65
BLAKE2b-256 checksum
How to use checksums
97410b5f12ab842ded2ac05043711593d6eb696c4d5a67436f334589622d4791
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

Release files / io4dolfinx-2.1.0-py3-none-any.whl

Download URL io4dolfinx-2.1.0-py3-none-any.whl
Size 180.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
583ede71dad6cd2ff7a29540f44f734b9fdba3c5e8b390505c082be62307e79c
BLAKE2b-256 checksum
How to use checksums
c0dcb99ebd64f64038dc1ac3ef9593b90ed8532fe6e3c2ca5f1459a5aad7eae0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

Security for io4dolfinx 2.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for io4dolfinx-2.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page