Adapting MeshFunction to refined mesh

I want to transfer the boundary ID information stored in the "MeshFunction " to a refined mesh. The link here provides how to do it for old version of FEniCS. I have adapted it to dolfin 2019.1.0. It works quite well for default refinement method. However, if I used “regular_cut” refinement algorithm I get following error

*** Error: Unable to adapt mesh function.
*** Reason: Unable to extract information about parent mesh entities.
*** Where: This error was encountered inside adapt.cpp.
*** Process: 0


*** DOLFIN version: 2019.1.0
*** Git changeset: 74d7efe1e84d65e9433fd96c50f1d278fa3e3f3f

The example code snippet is as follows

from dolfin import *
parameters[“refinement_algorithm”]= “regular_cut”
mesh=UnitSquareMesh(2,2)
cell_markers = MeshFunction(“bool”, mesh,1)
cell_markers.set_all(True)
mesh1=refine(mesh, cell_markers)
f=MeshFunction(“size_t”,mesh,2)
f.set_all(0)
f.array()[2:5]=1
f_refined = adapt(f,mesh1)

I would be grateful for any advise.

I am quite certain you need to use the plaza_with_parent_facets to be able to refine MeshFunctions, as you need this information to be able to refine the facet markers appropriately.

1 Like