# Loading xdmf data back in

**URL:** <https://fenicsproject.discourse.group/t/loading-xdmf-data-back-in/1925>\
**Category:** I/O\
**Created:** [November 19, 2019, 1:45am UTC](https://fenicsproject.discourse.group/t/loading-xdmf-data-back-in/1925 "2019-11-19T01:45:48Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)\
**Post date:** [November 19, 2019, 1:59pm UTC](https://fenicsproject.discourse.group/t/loading-xdmf-data-back-in/1925/4 "2019-11-19T13:59:49Z")

</div>

`write` saves the data at the vertices, efficiently projecting the solution to a CG-1 function space. `write_checkpoint` saves the data with the appropriate function space, and can therefore be read into dolfin again, to the appropriate function space.  
You are not saving multiple time steps to your file as you have not changed the append kwarg in write\_checkpoint (see: [https://fenicsproject.org/docs/dolfin/latest/cpp/de/d71/classdolfin\_1\_1XDMFFile.html#a9ef9031aec7bfec8f289d5210a1c811c](https://fenicsproject.org/docs/dolfin/latest/cpp/de/d71/classdolfin_1_1XDMFFile.html#a9ef9031aec7bfec8f289d5210a1c811c)). The following works:

```auto
from dolfin import *
nx = ny = 8 
mesh = UnitSquareMesh(nx, ny) 
V = FunctionSpace(mesh, 'P', 1) 
    
alpha = 3; beta = 1.2 
f = Expression('1 + x[0]*x[0] + alpha*x[1]*x[1] + beta*t', degree=2, alpha=alpha, beta=beta, t=0) 
 
f_out = XDMFFile("test.xdmf") 
f_out.write_checkpoint(project(f, V), "f", 0, XDMFFile.Encoding.HDF5, False) # Not appending to file
for j in range(1,5): 
    t = float(j/5) 
    f.t = t 
f_out.write_checkpoint(project(f,V), "f",t, XDMFFile.Encoding.HDF5, True) #appending to file
    
f_out.close() 
     
f1 = Function(V) 
f_in = XDMFFile("test.xdmf") 
   
f_in.read_checkpoint(f1,"f",0) 
f_in.read_checkpoint(f1,"f",1)   

```

---

_[View the full topic](https://fenicsproject.discourse.group/t/loading-xdmf-data-back-in/1925)._
