Reading xdmf file in the new version of dolfinx


I would like to know how I can read an xdmf file in the new version of dolfinx. I know that there exists a tool called adios4dolfinx but I have not found any example regarding its implementation with an xdmf file. My xdmf file contains the mesh and a multiblock function.

with XDMFFile(MPI.COMM_WORLD, "mesh.xdmf", "r") as xdmf:
    mesh = xdmf.read_mesh(name="Grid")
    ct = xdmf.read_meshtags(mesh, name="Grid")
mesh.topology.create_connectivity(mesh.topology.dim, mesh.topology.dim - 1)
with XDMFFile(MPI.COMM_WORLD, "mt.xdmf", "r") as xdmf:
    ft = xdmf.read_meshtags(mesh, name="Grid")

More detail are in Defining subdomains for different materials .

Thank you so much. My problem is more with displacements function, how can I read them? If I do the read_mesh I get the coordinates of the mesh but I think I do not get other functions

Mayabe you can re-mesh in python? For my case, I write a function to re-define the boundary in every time step.

Checkpointing of solutions (e.g., your displacement functions) is only available through adios4dolfinx, at least for the time being.

Thank you for your answers. Yes, it is only possible through adios4dolfinx but the examples I have seen they talk about a .bp file, not a xdmf file. When I try to repeat changing the extension, I get errors. However, in the description of the tool it says that it is possible. So I was wondering if there exists an example that I can follow to import the results I have saved in a xdmf file and use them again in dolfinx using that tool.

As I said, no, it does not. You can export in bp format using a writer which is different from XDMFFile (VTXFile, for instance), but you cannot read back in the solution.