I’m trying to export a function from a DG function space to XDMF but obtain the following error:
File "/home/remidm/festimx/mwe.py", line 14, in <module>
xdmf_file.write_function(u)
File "/home/remidm/miniconda3/envs/dolfinx/lib/python3.11/site-packages/dolfinx/io/utils.py", line 235, in write_function
super().write_function(getattr(u, "_cpp_object", u), t, mesh_xpath)
RuntimeError: Function and Mesh dof layouts do not match. Maybe the Function needs to be interpolated?
Obtained with the following MWE:
from dolfinx import mesh, fem
from mpi4py import MPI
from dolfinx.io import XDMFFile
msh = mesh.create_unit_square(MPI.COMM_WORLD, 8, 8)
V = fem.FunctionSpace(msh, ("DG", 1))
u = fem.Function(V)
xdmf_file = XDMFFile(MPI.COMM_WORLD, "u.xdmf", "w")
xdmf_file.write_mesh(msh)
xdmf_file.write_function(u)
This is an explicit change to highlight the limitations of the XDMF file format, as in comparison to VTX.
In DOLFINx<0.7.0 any function was interpolated into the function space of the mesh geometry (N-th order Lagrange space, N usually 1).
Now you have to interpolate this function into (“CG”, 1) explicitly to save it to xdmf, or use the VTXWriter, which supports arbitrary order “CG”/“DG” elements.
We are not aiming for long term support of XDMF, as it is no longer actively developed (Xdmf / Xdmf · GitLab, no commit in three years), and thus we are not aiming to add checkpointing to it.
I was working on an ADIOS2 based checkpoint/visualization code, but hit some speed-bumps, such as:
and thus I don’t have a good proposal for a format that can be both used as a checkpoint and be visualized with tools such as Paraview.
Progress: now Paraview doesn’t hang anymore but I have this error
ERROR: In vtkADIOS2CoreImageReader.cxx, line 648
vtkADIOS2CoreImageReader (000002A5F7ABD6D0): Can not use the dimension of array NumberOfEntities to set the dimension of image data. Its size is neither 2 nor 3