Migration Guide: Transitions to io4dolfinx#
This guide outlines the necessary steps to transition your code from io4dolfinx new API introduced in io4dolfinx.
Major Changes#
The library has undergone a major refactor to support multiple IO backends.
io4dolfinx now supports both ADIOS2 and h5py backends.
This allows users to choose between the high-performance, adaptable ADIOS2 framework and the standard HDF5 format via h5py.File, all using the same high-level API.
It also opens the door for new backends in the future.
Key API Updates#
Backend Agnosticism: You can now switch between
adios2.ADIOS(default) andh5py.Fileby passing abackendargument.Engine Configuration: The explicit
engineargument (e.g., “BP4”, “HDF5”, see ADIOS2 Engine Types) has been removed from function signatures. It is now passed via a dictionarybackend_args. This is because different backends may have different engine options. For exampleadios2.ADIOSsupports “BP4” and “HDF5”, whileh5pydoes not use engines.
Example Transition#
Writing a Mesh#
import io4dolfinx
io4dolfinx.write_mesh("mesh.bp", mesh, engine="BP4")
import io4dolfinx
io4dolfinx.write_mesh("mesh.bp", mesh, backend="adios2", backend_args={"engine": "BP4"})
import io4dolfinx
io4dolfinx.write_mesh("mesh.bp", mesh, backend="h5py")
Writing a Function#
import io4dolfinx
io4dolfinx.write_function("solution.bp", u, time=0.0, engine="BP4")
import io4dolfinx
io4dolfinx.write_function("solution.bp", u, time=0.0, backend="adios2", backend_args={"engine": "BP4"})
import io4dolfinx
io4dolfinx.write_function("solution.bp", u, time=0.0, backend="h5py")