Read results from xdmf/h5 file to calculate the difference

Hi guys,
I am trying to read the velocity function i stored in xdmf/h5 file.

I tried this: with h5py.File(velocity.h5, ‘r’) as h5file:
print(h5file.keys())
for i in range(3):
dataset_name = f’/Function/f_0/{i}’
data = h5file[dataset_name]
the data has the size of (#nodes, dim=3), since i am running 3d test.
However to be able to calculate say the error i need to integrate over the domain, so i need to have u = fem.Function(V), which u.x.array[:] has length of the number of freedom.
Can anyone help me with that?

Thanks a lot!

See: GitHub - jorgensd/adios4dolfinx: Interface of ADIOS2 for DOLFINx
and
checkpointing slides

Thank you for your quick response! I am looking at it right now!

Sorry when i install dolfinx from conda on my virtual enviroment, it turns out i installed dolfinx 0.5.2:
DOLFINx version: 0.5.2 based on GIT commit: b76d44782540fa8dc1e59cd09a20e55f178d11bf of GitHub - FEniCS/dolfinx: Next generation FEniCS problem solving environment
MPI.COMM_WORLD.rank=0, MPI.COMM_WORLD.size=1
Traceback (most recent call last):
File “=write_checking.py”, line 15, in
adx.write_mesh(domain, checkpoint_file, engine=“BP4”)
File “=miniconda/envs/fenicsx-env/lib/python3.10/site-packages/adios4dolfinx/checkpointing.py”, line 53, in write_mesh
io.DefineAttribute(“LagrangeVariant”, np.array([mesh.geometry.cmap.variant], dtype=np.int32))
AttributeError: ‘dolfinx.cpp.fem.CoordinateElement’ object has no attribute ‘variant’

And this is the erorr when i try to run the code i provided in my dolfinx 0.6

Hi I try to install dolfinx 0.6.0 on my virtual environment, when I run the example (which works well on my local computer), returns me the following error:
The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “/ix/wlayton/rui/write_checking.py”, line 16, in
adx.write_mesh(domain, mesh_checkpoint_file, engine=“BP4”)
File “/ix/wlayton/ruf10/miniconda3/envs/fenicsx-env/lib/python3.10/site-packages/adios4dolfinx/checkpointing.py”, line 53, in write_mesh
io.DefineAttribute(“LagrangeVariant”, np.array([mesh.geometry.cmap.variant], dtype=np.int32))
TypeError: Unable to convert function return value to a Python type! The signature was
(arg0: dolfinx.cpp.fem.CoordinateElement) → basix::element::lagrange_variant

Could you please help me with that soon?