I’m encountering an interesting problem when working (in parallel) on a mesh resulting from local refinement (in serial). Try running the following MWE, first in serial to generate the refined mesh, and then in parallel to trigger a (hard) error:
To me this seems like an issue with the original mesh (and therefore the following refinement causes even more issues), as I cannot reproduce it with a built in mesh.
from dolfin import *
parameters["refinement_algorithm"] = "plaza_with_parent_facets"
parameters["ghost_mode"] = "shared_facet"
#parameters["ghost_mode"] = None # Stops failing with this
if MPI.size(MPI.comm_world) == 1:
mesh = UnitCubeMesh(3, 3, 3)
markers = MeshFunction("bool", mesh, 3)
markers[0] = True
#markers.set_all(True) # Stops failing with this
info("Refining mesh")
mesh = refine(mesh, markers, True)
info("Writing mesh")
hdf = HDF5File(MPI.comm_world, "mesh1.h5", "w")
hdf.write(mesh, "/mesh")
hdf.close()
else:
mesh = Mesh()
hdf = HDF5File(MPI.comm_world, "mesh1.h5", "r")
hdf.read(mesh, "/mesh", False)
hdf.close()
V = FunctionSpace(mesh, "CG", 2) # This fails
info("Defined V on mesh1")
@chris and I built a mesh checker to look for topological issues, which is available at:
It checks if the mesh is only connected through vertices or edges, or if an edge exists in more than two surface facets.
Running the script with (needs h5py, networkx and meshio
Thanks Jørgen! Could you say a bit more about the output of the script? In particular,
(1) What does mesh_out show? and
(2) What does “a list of surfaces edges in four facets” mean?
mesh_out.xdmf highlight the cells that are connected to “bad_edges”.
Going from all exterior facets (those only connected to one cell, lets call them “surface facets”), we can find all edges that lie on the exterior of the mesh. Let’s call them “surface edges”.
A “surface edge” should only exist in two “surface facets”. If they exist in more than two surface facets, it implies that a set of cells are only connected through an edge or vertex.