2D simply supported beam boundary conditions

Hi. I am trying to model 2D simply supported beam in Fenics but I am getting “Warning: Found no facets matching domain for boundary condition”. Thank you.
The code is below.

# Boundary conditions
leftsup = CompiledSubDomain("(near(x[0], 0.0) && near(x[1], 0.0))")
rightsup = CompiledSubDomain("(near(x[0], 40.0) && near(x[1], 0.0))")
leftload = CompiledSubDomain("(near(x[0], 10.0) && near(x[1], 4.0))")
rightload = CompiledSubDomain("(near(x[0], 30.0) && near(x[1], 4.0))")

load = Expression("t", t = 0.0, degree=1)

bcleftsup= DirichletBC(W, Constant((0.0,0.0)), leftsup, "pointwise")
bcrightsup= DirichletBC(W, Constant((0.0,0.0)), rightsup, "pointwise")
bcleftload = DirichletBC(W.sub(1), load, leftload, "pointwise")
bcrightload = DirichletBC(W.sub(1), load, rightload, "pointwise")

bc_u = [bcleftsup, bcrightsup, bcleftload, bcrightload]
boundaries = MeshFunction("size_t", mesh, mesh.topology().dim() - 1)

ds = Measure("ds")(subdomain_data=boundaries)
n = FacetNormal(mesh)

Please see Read before posting: How do I get my question answered? regarding how to construct a MWE.

I edited my post. Could you please answer my question now?

Your code is incomplete. Your error message states:

 “Warning: Found no facets matching domain for boundary condition”

which is an issue with your geometry. But we cannot help without seeing how your mesh is defined.

Thank you. This is how I defined my mesh.

# mesh
from dolfin import *
mesh = Mesh('beam.xml')

# Define Space
V = FunctionSpace(mesh, 'CG', 1)
W = VectorFunctionSpace(mesh, 'CG', 1)
WW = FunctionSpace(mesh, 'DG', 0)
p, q = TrialFunction(V), TestFunction(V)
u, v = TrialFunction(W), TestFunction(W)

As you are using an xml file one cannot reproduce your issue.

I would suggest you write

boundaries to file and visualize in paraview to make sure it works as expected.
Similarly you should mark the other boundaries as well to make sure they do what they expect.

1 Like

When I do that, I just see the mesh. The boundaries are not present.

That means that your markers are not working as you think they should.
This means that you need to either:

  1. Revisit the creation of the mesh, and for instance import markers from the xml/xmdf file of the mesh directly.
  2. Rethink your markers, as they are not marking anything, are you sure they are expressing the correct condition.