HDF files in latest fenics version

Hi there,

I have used HDF files in fenics 2016 version with the following MWE code

from dolfin import *
from mpi4py import MPI as mpi

def Load(h5name, h5group, func):
	group1 = "{}/function".format(h5group)

    # Open file and read
	with HDF5File(mpi_comm_world(), h5name, "r") as h5file:
		h5file.read(func, group1)

mesh = Mesh(mpi.COMM_WORLD,'abc.xml')
F_ele = VectorElement("Quadrature", mesh.ufl_cell(), 4, quad_scheme = "default")
f = FunctionSpace(mesh,F_ele)
Load('xyz.h5','f_0',f_0)

However with the latest fenics version (Ubuntu PPA build) i get error once i use the above code

Can anyone from the group kindly guide me regarding latest syntax that i should use for reading HDF files in fenics.
Thanks

The following modified MWE runs without error for me using version 2019.2:

from dolfin import *
from mpi4py import MPI as mpi

def Load(h5name, h5group, func):
    group1 = "{}/function".format(h5group)
    # Open file and read
    #with HDF5File(mpi_comm_world(), h5name, "r") as h5file:
    #	h5file.read(func, group1)
    with HDF5File(MPI.comm_world, h5name, "r") as h5file:
        h5file.read(func, group1)

#mesh = Mesh(mpi.COMM_WORLD,'abc.xml')
mesh = UnitSquareMesh(16,16)
F_ele = VectorElement("Quadrature", mesh.ufl_cell(), 4, quad_scheme = "default")
f = FunctionSpace(mesh,F_ele)

f_0 = Function(f)
xyz = HDF5File(MPI.comm_world,"xyz.h5","w")
xyz.write(f_0,"f_0/function")
xyz.close()

Load('xyz.h5','f_0',f_0)

Aside from replacing the XML mesh with a UnitSquareMesh and writing a file 'xyz.h5' to load, the main modification was just changing mpi_comm_world() to MPI.comm_world.

2 Likes