Hello,
I would like to write and read .xdmf or .h5 files in dolfinx, and I don’t need a parallel implementation. I am trying out the following code:
import numpy as np
import ufl
from dolfinx import fem, io, mesh, plot, geometry
from mpi4py import MPI
from petsc4py.PETSc import ScalarType
from dolfinx.io import XDMFFile
import h5py as h5py
domain = mesh.create_rectangle(comm=MPI.COMM_WORLD,
points=((0.0, 0.0), (2.0, 1.0)), n=(32, 16),
cell_type=mesh.CellType.triangle,)
V = fem.FunctionSpace(domain, ("Lagrange", 1))
uh = fem.Function(V, name = "Test")
with io.XDMFFile(domain.comm, "output/output.xdmf", "w") as xdmf:
xdmf.write_mesh(domain)
xdmf.write_function(uh)
f0 = fem.Function(V)
with h5py.File('output/output.h5', 'r') as ifile:
y = ifile['/Function/Test/0']
and I get the following error message:
File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
File "/opt/anaconda3/envs/fenicsx-0.6.0/lib/python3.10/site-packages/h5py/_hl/group.py", line 357, in __getitem__
oid = h5o.open(self.id, self._e(name), lapl=self._lapl)
File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
File "h5py/h5o.pyx", line 241, in h5py.h5o.open
KeyError: 'Unable to synchronously open object (component not found)'
Any help is very welcome!
Many thanks.