Hello,
In this minimal working example
from __future__ import print_function
from fenics import *
mesh = UnitSquareMesh(96, 96)
V = FunctionSpace(mesh, "Lagrange", 1)
v = Function( V )
w = Function( V )
expr = Expression("p*x[0]", degree = 1, p = 1.0)
v.interpolate(expr)
# write to XDMF file, this creates v.xdmf and v.h5
XDMF_file_v = XDMFFile( 'v.xdmf' )
XDMF_file_v.write(v)
#read back from v.h5 and store the result in w
HDF5_file_read = HDF5File( MPI.comm_world, "v.h5", "r" )
HDF5_file_read.read(w, "/f" )
HDF5_file_read.close()
i write the function v
to an xdmf file: this creates an .xdmf and an .h5 file. Then I read back the .h5 file and write the result into the function w
, but I get the following error:
HDF5-DIAG: Error detected in HDF5 (1.10.0-patch1) MPI-process 0:
#000: ../../../src/H5L.c line 873 in H5Lexists(): no name specified
major: Invalid arguments to routine
minor: Bad value
HDF5-DIAG: Error detected in HDF5 (1.10.0-patch1) MPI-process 0:
#000: ../../../src/H5O.c line 663 in H5Oget_info_by_name(): no name
major: Invalid arguments to routine
minor: Bad value
Traceback (most recent call last):
File "example.py", line 21, in <module>
HDF5_file_read.read(w, "/f" )
RuntimeError:
*** -------------------------------------------------------------------------
*** DOLFIN encountered an error. If you are not able to resolve this issue
*** using the information listed below, you can ask for help at
***
*** fenics-support@googlegroups.com
***
*** Remember to include the error message listed below and, if possible,
*** include a *minimal* running example to reproduce the error.
***
*** -------------------------------------------------------------------------
*** Error: Unable to read function from file.
*** Reason: Group with name "/f" does not exist.
*** Where: This error was encountered inside HDF5File.cpp.
*** Process: 0
***
*** DOLFIN version: 2019.1.0
*** Git changeset: 74d7efe1e84d65e9433fd96c50f1d278fa3e3f3f
*** -------------------------------------------------------------------------
With the same reading lines above I can successfully read an .h5 file which I created (without an .xdmf file) by setting “/f” as a group name, with
HDF5_file_write = HDF5File( "v.h5", "w" )
HDF5_file_write.write( v, "/f" )
HDF5_file_write.close()
However, I don’t know that the group name is when the .h5 file is created with an .xdmf file. How do I find out ? How may I change it ?
Thank you