How to correctly define a generic boundary subdomain and submesh from bmesh?

Hi,

I have a quarter disk mesh as shown on the below picture. I am correctly defining Left and Bottom boundary subdomains (green and blue) and I would like to define the Curved boundary subdomain (part in red) in a generic way. Since, the Curved Boundary is going to move and I would like not to define it with a “fixed” function x**2 + y**2 ~ radius.

I would rather like to have something like:

bmesh = BoundaryMesh(mesh, "exterior") 

class CurvedBoundary(fenics.SubDomain): 
    def inside(self, x, on_boundary):
         tol = 1E-3
         bmesh_coords = bmesh.coordinates()
         return x[0] != 0.0 and x[1] != 0.0 and x in bmesh_coords

But using that definition, and then plotting it actually provides me an empty boundary mesh

Could you please help me finding the correct way to write it?

Many thanks in advance,
Anne

Please provide a reproducible example, rather than a snippet of your code lacking several definitions.

I would recommend you to use an external mesh tool such as GMSH to tag boundaries, if you are lacking information about the geometry.

In general, using x in bmesh_coords is not safe, as you are prone to have some machine precision errors.