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 !
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)