I am trying to implement adaptivity for a simple eliptic problem posed on “pacman” domain. I defined the domain by
from dolfin import *
from fenics import *
from mshr import *
import matplotlib.pyplot as plt
# Define 2D geometry
square = Rectangle(Point(0.0, 0.0), Point(1.0,1.0))
circle = Circle(Point(0.0,0.0), 1)
domain = circle - square
# Generate and plot mesh
mesh2d = generate_mesh(domain, 2)
plot(mesh2d, "2D mesh")
plt.show()
and then I refine the mesh with
mesh2dref = adapt(mesh2d)#, cell_markers)
plot(mesh2dref, "2D mesh")
plt.show()
or with
cell_markers = MeshFunction("bool", mesh2d,mesh2d.topology().dim())
cell_markers.set_all(False)
for cell in cells(mesh2d):
cell_markers[cell] = True
mesh2dref = adapt(mesh2d)#, cell_markers)
plot(mesh2dref, "2D mesh")
plt.show()
I obtain this pictures
The refined mesh does not take into account the boundary of the original domain. I would like to ask if there is a way to obtain the right refinement for the initial domain.
Thank you!