I am trying to load a Fenics-generated XDMF file in Fenics. The code is:
def load_solution(xdmf_file):
with XDMFFile(MPI.COMM_WORLD, xdmf_file, "r") as f:
mesh = f.read_mesh()
V = fem.functionspace(mesh, ("Lagrange", 1))
u = fem.Function(V)
f.read(u, "u_sol")
return mesh, u
However, I get various errors along the lines of:
AttributeError: 'XDMFFile' object has no attribute 'read'
I have tried about 5-6 different API call versions (read, read_function, f.read_function, io.read_function) but none of them exist in this particular FenicsX install. Is there a way to load XDMF files in 0.9.0?
The XDMF was generated like this:
name = f"advection-reaction-diffusion-steady-2d-{str(i)}.xdmf"
with io.XDMFFile(dom.comm, name, "w") as xdmf:
xdmf.write_mesh(dom)
xdmf.write_function(u_sol)
where dom is a unit square mesh.