Error in saving time evolving meshes as xdmf files

In my code, I have time steps of 10000. With each time step the mesh and the solution evolves. I want to save all 10000 evolutions. So creating pvd and vtu files takes up a lot of space. So I need to save in a more compact format. I searched through some of the posts and got the idea of saving them as xdmf files. But it is generating an error. Here is a sketch of what I tried:

vtkfile = XDMFFile("mesh_evolution.xdmf")
vtkfile.parameters["flush_output"] = True

for t in range(0,10000):
     ### Solve for some variational problem to get u(t)
     ### Apply solution u(t) to a submesh
     vtkfile.write(submesh,t)
     

This generates the error message

vtkfile.write(submesh,t)
 'dolfin.cpp.mesh.SubMesh' object has no attribute '_cpp_object'

But with similar codes, I am having no trouble saving time evolving solutions as xdmf files!

I am not sure what I am doing wrong here. Any help or suggestion would be greatly appreciated.

Hello, maybe this is naive, is it critical to save submesh instead of your whole mesh ? I think in terms of storage it’s only saved once in an xdmf file.

Maybe use another name for your xdmf file ? It’s misleading :smile:

Hi @hawkspar ,

It is in fact critical for saving the submesh instead of the whole mesh. Moreover, if an xdmf file is able to save a time evolving “whole mesh” for several time steps, then it must be able to do the same for a submesh.

The name for the xdmf file is in fact misleading. Got accustomed to using vtkfile for pvd file systems. Forgot to change it.