Problem with marking boundary

4 months ago by
Hi all,

Some time ago I posted a question about code of mine that didn't work properly. Fortunately I found out that it is marking the boundary that couses the problem. To be more precise, after calling
        # Mark boundaries
        boundaries = MeshFunction('size_t', mesh, mesh.topology().dim() - 1)
        left.mark(boundaries, 1)
        right.mark(boundaries, 4)
        bypass.mark(boundaries, 2)
        File('mesh.xml') << mesh
        File('mesh_func.xml') << boundaries​​

when I open the file mesh_func.xml almost all facets have 0 as their value. I know, that boundaries.set_all(0) is the culprit. However I can't understand why other markings don't work.

To have a fuller picture here is how I defined mesh and boundaries
        # Generate domain
        def domain():
            C1 = Rectangle(Point(-l1/2, -r1), Point(l1/2, r1))
            C2 = Rectangle(Point(-l2, -r2), Point(0.0, r2))
            C2_alpha = CSGRotation(C2, Point(0.0, 0.0), -alpha)
            return C1 + C2_alpha

        # Generate mesh
        mesh = generate_mesh(domain(), 32)

        # Define left blood vessel boundary
        class Left(SubDomain):
                def inside(self, x, on_boundary):
                        return (abs(x[0] + l1/2) < DOLFIN_EPS) and on_boundary
        # Define right blood vessel boundary
        class Right(SubDomain):
                def inside(self, x, on_boundary):
                        return (abs(x[0] - l1/2) < DOLFIN_EPS) and on_boundary
        # Define upper bypass boundary
        class Bypass(SubDomain):
                def inside(self, x, on_boundary):
                        return (abs(cos(alpha)*x[0] - sin(alpha)*x[1] + l2) \
                                < DOLFIN_EPS) and on_boundary

        # Initialize sub-domain instances
        left = Left()
        right = Right()
        bypass = Bypass()​

Especially classes Left and Right are very basic and when I compered them with other examples from tutorial this how boundaries looked like. Also, I tried to work with denser meshes or instead of DOLFIN_EPS use for example tol = 1e-3 and none of these worked.

I attach the mesh.xml file.
File attached: mesh_func.xml (331.78 KB)


Community: FEniCS Project
This example is not a mwe: what are the variables l1, r1, etc. ?
written 3 months ago by Eleonora Piersanti  
Please login to add an answer/comment or follow this question.

Similar posts:
Search »