How to recover boundary markers from a file after using MeshView?

Hello,

I am using FEniCS dev version with Docker on macOS Catalina. I am getting trouble to recover boundary markers from a XDMF file after defining a submesh with MeshView.

I have a complex GMSH mesh with two subdomains and various physical groups. The mesh is loaded in FEniCS with this converter, and I get a MeshFunction corresponding to the boundary markers. Then, I generate two submeshes with MeshView. Now, I would like to apply a boundary condition on a part of the boundary for a function defined on one submesh. The problem is that the MeshFunction corresponding to the boundary markers is defined on the parent mesh. Is there an easy way to transpose it to a MeshFunction defined on the child mesh ?

To illustrate my problem, here is a simple example : a circle inside a hole. The circle is marked 1, the rest of the domain is marked 2 and the left side is marked 3 as below.

Here are the mesh files, and here is the code.

from dolfin import *
from msh2xdmf import import_mesh_from_xdmf


# Load mesh and subdomains from XDMF file
mesh, boundaries, subdomains, association_table = import_mesh_from_xdmf(
    prefix = "mwe", dim = 2, subdomains = True)

# Define submeshes
mesh_1 = MeshView.create(subdomains, 1)            
mesh_2 = MeshView.create(subdomains, 2)

# Define function space
P1 = VectorElement("CG", mesh_2.ufl_cell(), 1)
V = FunctionSpace(mesh_2, P1)

# Define boundary condition
bc = DirichletBC(V, Constant((0, 0)), boundaries, 3)

I get an error because boundaries is a MeshFunction of mesh, but V is a FunctionSpace of mesh_2.

I would like to get a MeshFunction with the same values as boundaries, but defined on mesh_2. Note that in this case it would be easy to mark the boundary 3 with an explicit geometrical condition, but it may not be possible for more complex geometries.

Thank you for your help !

Related posts : How to recover BoundaryMesh or equivalent SubMesh from facet_region, Parent facet map, MeshView submesh vertex map to parent mesh.