Reading boundary indicators from h5 file

Hi everyone,

I have developed a code in dolfin 2017.2.0, and now want to run it on a cluster that has dolfin 2019.1.0 installed on it. In my scripts I read the mesh, and its volume and boundary indicators with the following lines of code:

from dolfin import Mesh, XDMFFile, FacetFunction, CellFunction

mesh_file = "mesh/2D_mesh_short.h5"
mesh = Mesh()
hdf = HDF5File(mesh.mpi_comm(), mesh_file, "r"), "/mesh", False)
cd = CellFunction("size_t", mesh), "/cd")
boundaries = MeshFunction("size_t", mesh), "/fd")

However, on the cluster with dolfin 2019.1.0 installed I get the error:
ImportError: cannot import name ‘FacetFunction’ from ‘dolfin’.
I read somewhere that this function may not be present in the updated dolfin package… Does someone know how to work around this with other functions?

Instead of CellFunction/FacetFunction etc. you can try using

MeshFunction('size_t', mesh, dim)

where dim is the dimension of the mesh entity you want the function for. E.g. in a 3D mesh you want a CellFunction, then dim=3.

Do you maybe also have an idea to replace Cellsize? I used this to put the sizes of my elements in a function, but looks like Dolfin also deleted this function…

You can try with the function


as mentioned in the Changelog