How to map facet indices on SubMesh boundary back to original mesh?

8 months ago by

I'd like to find a way to map the facet indices on the boundary of a SubMesh back to the corresponding facet indices on the parent mesh. See minimum example below.

mesh = UnitSquareMesh(11, 11)

hmin = mesh.hmin()
top_region = CompiledSubDomain('x[1] >= 0.5')
bottom_region = CompiledSubDomain('x[1] <= 0.5')

top_region_submesh = SubMesh(mesh, top_region)
bottom_region_submesh = SubMesh(mesh, bottom_region)

top_region_boundarymesh = BoundaryMesh(top_region_submesh, 'exterior')
bottom_region_boundarymesh = BoundaryMesh(bottom_region_submesh, 'exterior')

def inside_top_region_boundary(x, on_boundary):
    return top_region.inside(x, on_boundary) and on_boundary

def inside_bottom_region_boundary(x, on_boundary):
    return bottom_region.inside(x, on_boundary) and on_boundary

top_region_boundary = AutoSubDomain(inside_top_region_boundary)
bottom_region_boundary = AutoSubDomain(inside_bottom_region_boundary)


top_region_boundary_facets = FacetFunction('size_t', top_region_submesh)
bottom_region_boundary_facets = FacetFunction('size_t', bottom_region_submesh)

bottom_region_boundary.mark(bottom_region_boundary_facets, 1)
top_region_boundary.mark(top_region_boundary_facets, 2)

I'd like to do something like

boundary_facets = FacetFunction('size_t', mesh)
top_region_submesh_indices = top_region_boundary_facets.array() == 2
boundary_facets.array()[top_facets_submesh_map[top_region_submesh_indices]] = 2

but I don't know how the "top_facets_submesh_map" array should be constructed.

Community: FEniCS Project

1 Answer

8 months ago by
Oh snap!

ha ha !
Thanks for the reply. I saw that answer but it's not quite what I want, unless I create the facet mapping myself inside the SubMesh code. Right now it only has vertices and cells. I was hoping this was already implemented somewhere in the code.
written 8 months ago by Chaffra Affouda  
Once you have the vertices, use a FacetIterator over the "big" mesh facets and use boolean logic to test if its vertices are in the set of "small" mesh vertices.
written 8 months ago by pf4d  
Please login to add an answer/comment or follow this question.

Similar posts:
Search »