Hello, I am trying to figure out how to relate face indices on a BoundaryMesh with the relevant indices on the parent mesh. In the minimal code below I attempt to extract the faces on the bottom of a cube using MeshFunction but I must not be understanding how BoundaryMesh.entity_map() works. Any help as to why the first example doesn’t work but the second one does would be very much appreciated… Thank you!
from dolfin import * # volumetric mesh and its boundary mesh vmesh = UnitCubeMesh(10, 10, 10) bmesh = BoundaryMesh(vmesh, "exterior") # meshfunctions of dimension 2 for the volumetric/boundary mesh mfv = MeshFunction("size_t", vmesh, 2) mfb = MeshFunction("size_t", vmesh, 2) # maps face indices on the boundary mesh to indices on the full mesh facemap = bmesh.entity_map(2) # expect smv to extract all faces on the boundary pointing downward from vmesh for f in faces(bmesh): if Facet(vmesh, cellmap[f.index()]).normal().z() < -0.5: mfv[facemap[f.index()]] = 1 smv = SubMesh(vmesh,mfv,1) # meanwhile somehow this code works # expect mf to have value "1" for each face on boundary mesh pointing downward for f in faces(bmesh): if Facet(vmesh, cellmap[f.index()]).normal().z() < -0.5: mfb[f] = 1 smb = SubMesh(bmesh,mfb,1) vtkfile("smv.pvd") << smv vtkfile("smb.pvd") << smb
SubMesh from mfv:
[since I am a new user it won’t let me upload a screenshot of the SubMesh from mfb but the result is as expected (just the bottom surface of the cube)]
Edit: This is on the latest stable version of fenics using docker