I am creating a sub mesh by marking the subdomains. Following code I am using for this
mesh = UnitSquareMesh(2, 2)
class Left(SubDomain):
def inside(self, x, on_boundary):
return (x[0] < DOLFIN_EPS) and on_boundary
sub_domains = MeshFunction("size_t", mesh, mesh.topology().dim()-1)
left = Left()
sub_domains.set_all(0)
left.mark(sub_domains, 1)
sub_mesh = SubMesh(mesh, sub_domains, 1)
# coordinates of the sub mesh
sub_mesh.coordinates()
I am getting the following coordinates (0,0), (0,0.5), (0.5, 0.5) while in the original mesh, this subdomain has the mesh coordinates (0,0), (0,0.5),(0,1) .
Why is this happening? Is there any problem with my code?
SubMesh is not made for meshes of co-dimension 1 (i.e. facets).
You can check this by print(submesh.topology().dim()).
To create a submesh of facets, either use BoundaryMesh or MeshView.
Personally, I would advice you to move to DOLFINx, as the support for these kind of operations have been vastly improved (on main branch).