Reading function at certain time with adios4dolfinx

Lets assume we run the Cahn-Hilliard example and we write the solution at each timestep into a “.bp”(seems to be the best supported format of “adios4dolfinx”) file like this:

from dolfinx.io import VTXWriter
import adios4dolfinx as ad
import pathlib

# Step in time
t = 0.0
T = 30 * dt
counter = 0

# Get the sub-space for c and the corresponding dofs in the mixed space
# vector
V0, dofs = ME.sub(0).collapse()


c = u.sub(0)
u0.x.array[:] = u.x.array



with VTXWriter(MPI.COMM_WORLD, f"cahn_hilliard-{element_dof}.bp", [c], engine="BP4") as vtx:
    vtx.write(t)

    while (t < T): # (t < T)
        counter += 1
        t += dt
        r = solver.solve(u)
        print(f"Step {int(t/dt)}: num iterations: {r[0]}")
        u0.x.array[:] = u.x.array
        vtx.write(t)

Now assume I want to reuse one of the solutions at a certain timestep.
Posts from this forum like I/O from XDMF/HDF5 files in dolfin-x
suggests to use adios4dolfinx.
Since v0.2.0 it seemingly can read mesh and function from the same file.
But it is still not able to extract it a certain time?
Do I have to change the way I save the timeseries?

Each file store the mesh and function at a single time step.

If you want to reuse the checkpoint within the same simulation, see:
http://jsdokken.com/checkpointing-presentation/#/4/0/0
and onwards, as it explains how to do a snapshot checkpoint.

2 Likes

If I understand your slides correctly, checkpoint writes the times to the same file, but can only read the last one?

If I store into multiple files, is there a certain naming convention, so I could also visualize the time i.e. paraview?

You should as of now store a single checkpoint in a single file. I’ve not Added the stepping functionality for reading checkpoint from a file with multiple checkpoints.

Checkpoints cannot be visualized in paraview, due to limitations in the Fides/VTX adios2 formats, that makes them unsuitable for checkpointing.

I would suggest reading through the whole presentation I just linked you to, as it explains a lot of these things.

1 Like