Does XDMF read_checkpoint avaliable in DOLFINX

Hello,

I want to use XDMF file to store my dolfinx::fem:::function, and use is later, but I couldn’t find any functions similar to read_checkpoint like legacy_DOLFIN in this page DOLFINx XDMF.

Does anyone know what functional will be suitable in my case, I just need to store a single function.
Thanks in advance.

Currently it is only supported in Python through ADIOS4DOLFINx.
There has been several proposals to GSOC 2024 regarding porting it to C++.
We will keep you posted if we get any of them accepted.

If you simply want to store a solution to use in later in the same simulation, it doesn’t take many lines to make a snapshot checkpoint, see:
https://jsdokken.com/checkpointing-presentation/#/6
https://jsdokken.com/checkpointing-presentation/#/6
or the adios4dolfinx documentation or source code.

1 Like

Hi @dokken,

I tried your proposed solution with methods snapshot_checkpoint_write and snapshot_checkpoint_read, it works perfectly when importing the fem function.
However, I noticed a problem on the tabulation side of the DOFs, which results, in my case, in uncosistency from the physical point of view in case I want to exploit the imported function for new analysis.
Consider, for example, a classic magnetostatic problem in which you have a DG0 function for the current density J in a coil with very small cross section (cylindrical reference system).
Let J1 be the function before export and J2 the imported one, I get:

assert np.allclose(J1.x.array, J2.x.array) [True]
assert np.allclose(J1.function_space.tabulate_dof_coordinates(), J2.function_space.tabulate_dof_coordinates()) [False]

I get an assertion error for dofs tabulation and using J2 for a new magnetostatic analysis results in a different magnetic flux map than expected precisely because of the different dofs tabulation.
I would also need to have the same tabulation of dofs between the two functions.

How can I solve this problem? Thank you in advance.

Please provide a minimal reproducible example.
It is unclear to me why you have a new function space J2, as snapshot_checkpoint is meant to be used with the same space it was written with, see the presentation in the previous post

Thank you @dokken for the quick reply.

I tried to implement 1:1 your example and there are no problems with tabulating dofs either.

In my code, I noticed a problem on the import/export side of the mesh with XDMF, that seems to be the cause of the different tabulation of DOFs.

Thanks again for the support, in case I don’t solve I will attach a small reproducible example for help.

I wouldnt mix XDMFFile + checkpointing, except if you go for Checkpoint on input mesh — ADIOS2Wrappers

without an example it is very hard to Give any further guidance than asking you to look at the documentation.