"Unable to build ghost mesh” with parameters["ghost_mode"] = "shared_facet"

I would like to save mesh with mesh partitioning information and read it again but do not know how to solve the error message. Here is a MWE and error message. parameters["ghost_mode"] = “shared_facet” is necessary for the problem I’m solving since I have n(+) with interior boundaries (dS)

from dolfin import *

parameters["ghost_mode"] = "shared_facet"


assert MPI.size(MPI.comm_world) != 1 # Parallel only
# Generate mesh and save to file 
mesh = UnitSquareMesh(10, 10)
with HDF5File(mesh.mpi_comm(), 'mesh.h5', 'w') as f:
    f.write(mesh, 'mesh')

# Read mesh from file
with HDF5File(mesh.mpi_comm(), 'mesh.h5', 'r') as f:
    mesh = Mesh()
    f.read(mesh, 'mesh', True)

*** Error: Unable to build ghost mesh.
*** Reason: Ghost cell information not available.
*** Where: This error was encountered inside MeshPartitioning.cpp.
*** Process: 0
*** DOLFIN version: 2019.1.0
*** Git changeset:

To Me it doesn’t seem like f.write mesh stores the ghost information:
Bitbucket which becomes a problem here: Bitbucket
and in turn here when reading the mesh back in:
Bitbucket

2 Likes