# Access function in time dependent XDMFFile

**URL:** <https://fenicsproject.discourse.group/t/access-function-in-time-dependent-xdmffile/359>\
**Category:** Uncategorized\
**Created:** [March 12, 2019, 12:18pm UTC](https://fenicsproject.discourse.group/t/access-function-in-time-dependent-xdmffile/359 "2019-03-12T12:18:23Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![RemDelaporteMathurin](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/remdelaportemathurin/32/4543_2.png) [@RemDelaporteMathurin](https://fenicsproject.discourse.group/u/RemDelaporteMathurin)\
**Post date:** [July 17, 2019, 9:08am UTC](https://fenicsproject.discourse.group/t/access-function-in-time-dependent-xdmffile/359/6 "2019-07-17T09:08:48Z")

</div>

It works now, but apparently I can’t write several times as the file is “still open”. Is there a particular argument that need to be passed to the function ?

Thanks anyway for your help !

```python
from fenics import *

mesh = UnitSquareMesh(2, 2)
V = FunctionSpace(mesh, 'P', 1)
ini_u = Expression("0", degree=2)
u = interpolate(ini_u, V)

#write
with XDMFFile("u.xdmf") as file:
    file.write_checkpoint(u, "u_out", 0)

#read
u1 = Function(V)
with XDMFFile("u.xdmf") as file:
    file.read_checkpoint(u1, "u_out", 0)

with XDMFFile("u.xdmf") as file:    
    file.write_checkpoint(u1, "u_out", 1)
    file.write_checkpoint(u1, "u_out", 2)

```

---

_[View the full topic](https://fenicsproject.discourse.group/t/access-function-in-time-dependent-xdmffile/359)._
