About this, XDMF is a bit buggy when you write multiple functions. I reported this in this issue. Not only it duplicates the data so that it occupies more memory, the coloring of a dataset can be “hidden” by the other one somehow. See the MWE below:
from dolfinx import mesh, io, fem
from mpi4py import MPI
nels_per_side = 2
mesh = mesh.create_unit_square(MPI.COMM_WORLD, nels_per_side, nels_per_side, mesh.CellType.quadrilateral)
V = fem.functionspace(mesh, ("Lagrange", 1))
D = fem.functionspace(mesh, ("DG",0))
u1, u2 = fem.Function(V, name="u1"), fem.Function(D, name="u2")
u1.interpolate( lambda x : x[0]**2 )
u2.interpolate( lambda x : x[1]**2 )
writer = io.XDMFFile(mesh.comm,"test.xdmf", 'w')
writer.write_mesh(mesh)
writer.write_function(u1)
writer.write_function(u2)
writer.close()
If I only write u2
, the correct number of elements is written and I can see the coloring of u2
:
If I write u1
and u2
, a multiblock dataset is written, the elements are duplicated (it takes twice the memory) and I can neither see the coloring of u1
nor u2
:
I am using Paraview 5.12. I think there used to be a fix for this in dolfin
(see this post). The issue is similar in VTK except for some reason I can still see the coloring of both fields.
Thank you for the update on VTXWriter, it works well. I might give a try to implementing the changes although I am not sure my coding would be up to the standards of your project. From the code in ADIOSWriters.h
, it looks like the main tasks are to modify _is_piecewise_constant
into an array and modify impl_vtx::extract_function_names
to return two vectors of strings for the nodal and DG0 functions repectively.