This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Define internal facet during mesh construction.

+1 vote

I would like to create a domain consisting of a rectangle minus a circle in the middle. I am using the following code :

from dolfin import *
from mshr import*
rect = Rectangle(Point(0, 0), Point(10, 5))
circ = Circle(Point(5, 5), 1)
domain = rect  - circ
N = 20
mesh = generate_mesh(domain, N)
File("rectangle-less-circle.xdmf") << mesh

The code produces the mesh : enter image description here

However I would also like my mesh to have an interior facet running through the center of the circle (0<=x<=10, y=5) so that the nodes will be exactly on this line.
I tried creating two separate rectangles and adding them up, but the mesh blends together and produces the same as the initial code.

from dolfin import *
from mshr import *
rect1 = Rectangle(Point(0, 0), Point(10, 5))
rect2 = Rectangle(Point(0, 5), Point(10, 10))
circ = Circle(Point(5, 5), 1)
domain = rect1 + rect2  - circ
N = 20
mesh = generate_mesh(domain, N)

Does anyone know how to define an internal boundary while creating the mesh so that I can , for example, integrate a function over it later or create a tensor that picks out the nodes lying exactly on this line ?

asked Mar 6, 2015 by Katianefs FEniCS Novice (200 points)

1 Answer

+1 vote

Have you tried with gmsh? It should be capable of doing what you want.

answered Mar 6, 2015 by chris_richardson FEniCS Expert (31,740 points)
...