Imposing Dirichlet bc on the boundary of a hole embedded in a continuum body

Hello,
I am solving an elasticity problem in which the domain is a rectangle (150x120) with two circular voids (radius = 4) (shaped like a videotape). I would like to apply Dirichlet BC on the boundary of the voids and to apply other Dirichlet BC on the right boundary of the rectangle. When I run my code I get the error:
*** Warning: Found no facets matching domain for boundary condition.
I checked the similar question asked here:https://fenicsproject.discourse.group/t/dirichlet-bcs-on-an-annulus/1711
but I was hoping for a new answer since 2 years have passed. I understand the problem is probably with the BC on the voids.
So, the way I wrote it is:

# Boundary conditions
right= CompiledSubDomain("near(x[0], 150.0) && x[1] < 120.0 && x[1] >= 0.0 && on_boundary")

tondo_top = CompiledSubDomain("(x[0]-25.00)*(x[0]-25.00)+(x[1]-87.50)*(x[1]-87.50)-16.00 < 0.001 && (x[0]-25.00)*(x[0]-25.00)+(x[1]-87.50)*(x[1]-87.50)-16.00 > -0.001  && x[1]-87.50 >= 0.0  && on_boundary")
tondo_bot = CompiledSubDomain("(x[0]-25.00)*(x[0]-25.00)+(x[1]-32.50)*(x[1]-32.50)-16.00 < 0.001 && (x[0]-25.00)*(x[0]-25.00)+(x[1]-32.50)*(x[1]-32.50)-16.00 > -0.001  && x[1]-32.50 >= 0.0  && on_boundary")

load_top = Expression("t", t = 0.0, degree=1)
load_bot = Expression("t", t = 0.0, degree=1)

bc_tondo_top= DirichletBC(W.sub(1), load_top, tondo_top)
bc_tondo_bot= DirichletBC(W.sub(1), load_bot, tondo_bot)
bcright= DirichletBC(W, Constant((0.0,0.0)), right) 

bc_u = [bc_tondo_top, bc_tondo_bot, bcright]
boundaries = MeshFunction("size_t", mesh, mesh.topology().dim() - 1)
boundaries.set_all(0)
tondo_top.mark(boundaries,1)
ds = Measure("ds")(subdomain_data=boundaries)
n = FacetNormal(mesh)

The reason I am defining ā€œnā€ is because at the end of the code I ask for the dot product of a tensor and ā€œnā€ (this is not necessary).
Can anyone help?

As you have not supplied your mesh file, it is not very easy to help you. Please not that if you create your mesh with an external mesh creator (say GMSH) you can mark your boundaries in the creation step and import them, as covered in:

2 Likes

I changed the lines:

tondo_top = CompiledSubDomain("(x[0]-25.00)*(x[0]-25.00)+(x[1]-87.50)*(x[1]-87.50)-16.00 < 0.001 && (x[0]-25.00)*(x[0]-25.00)+(x[1]-87.50)*(x[1]-87.50)-16.00 > -0.001  && x[1]-87.50 >= 0.0  && on_boundary")
tondo_bot = CompiledSubDomain("(x[0]-25.00)*(x[0]-25.00)+(x[1]-32.50)*(x[1]-32.50)-16.00 < 0.001 && (x[0]-25.00)*(x[0]-25.00)+(x[1]-32.50)*(x[1]-32.50)-16.00 > -0.001  && x[1]-32.50 >= 0.0  && on_boundary")

with the following:

def tondo_top(x, on_boundary):
return abs((x[0]-25.00)**2+(x[1]-87.50)**2 - 16.00) >= 1E-6 and on_boundary

def tondo_bot(x, on_boundary):
return abs((x[0]-25.00)**2+(x[1]-87.50)**2 - 16.00) >= 1E-6 and on_boundary

and the error disappeared. Unfortunately, now I cannot assign any label to boundaries and get an error for ā€œnā€. I tried to fix it as dokken suggested by generating the mesh on freefem (.mesh file) and labeling there the various boundaries.

As you are not staying what error you are obtaining, and you do not provide a minimal code example reproducing the error, I cannot provide you much more help.