# Error in saving time evolving meshes as xdmf files

**URL:** <https://fenicsproject.discourse.group/t/error-in-saving-time-evolving-meshes-as-xdmf-files/7928>\
**Category:** Uncategorized\
**Created:** [March 28, 2022, 4:37pm UTC](https://fenicsproject.discourse.group/t/error-in-saving-time-evolving-meshes-as-xdmf-files/7928 "2022-03-28T16:37:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![avishmj](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/avishmj/32/2017_2.png) [@avishmj](https://fenicsproject.discourse.group/u/avishmj)\
**Post date:** [March 28, 2022, 4:37pm UTC](https://fenicsproject.discourse.group/t/error-in-saving-time-evolving-meshes-as-xdmf-files/7928/1 "2022-03-28T16:37:06Z")

</div>

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:

```auto
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

```auto
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.

---

<div class="post-metadata">

**Author:** ![hawkspar](https://avatars.discourse-cdn.com/v4/letter/h/b487fb/32.png) [@hawkspar](https://fenicsproject.discourse.group/u/hawkspar)\
**Post date:** [March 31, 2022, 11:47am UTC](https://fenicsproject.discourse.group/t/error-in-saving-time-evolving-meshes-as-xdmf-files/7928/2 "2022-03-31T11:47:57Z")

</div>

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 😄

---

<div class="post-metadata">

**Author:** ![avishmj](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/avishmj/32/2017_2.png) [@avishmj](https://fenicsproject.discourse.group/u/avishmj)\
**Post date:** [April 1, 2022, 3:36pm UTC](https://fenicsproject.discourse.group/t/error-in-saving-time-evolving-meshes-as-xdmf-files/7928/3 "2022-04-01T15:36:18Z")

</div>

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.
