A workaround would be using VTK Files:
from dolfinx import io, fem, mesh
from mpi4py import MPI
import numpy as np
file = io.VTKFile(MPI.COMM_WORLD, 'testout/output.pvd', 'w') # Open the .pvd file with paraview
for time in range(1,4):
msh = mesh.create_rectangle(comm=MPI.COMM_WORLD,
points=((0.0, 0.0), (2.0, 1.0)), n=(32, time*2),
cell_type=mesh.CellType.triangle,)
V = fem.VectorFunctionSpace(msh, ('CG', 1), dim=2)
u = fem.Function(V)
u.interpolate(lambda x: np.array([x[0], x[1] + time])) # Arbitrary function value dependent on time
file.write_mesh(msh, time) # Now possible with VTK-File
file.write_function(u, time)
file.close() # Outside of loop, only called once
I added some values to the function, you can see a transient update of the mesh and the function using paraview. I could not find a workaround using XDMF Files.