# 2D simply supported beam boundary conditions

**URL:** <https://fenicsproject.discourse.group/t/2d-simply-supported-beam-boundary-conditions/8975>\
**Category:** mesh\
**Created:** [August 10, 2022, 2:09pm UTC](https://fenicsproject.discourse.group/t/2d-simply-supported-beam-boundary-conditions/8975 "2022-08-10T14:09:03Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![dries](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dries/32/4059_2.png) [@dries](https://fenicsproject.discourse.group/u/dries)\
**Post date:** [August 10, 2022, 2:09pm UTC](https://fenicsproject.discourse.group/t/2d-simply-supported-beam-boundary-conditions/8975/1 "2022-08-10T14:09:03Z")

</div>

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.

```auto
# 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)
boundaries.set_all(0)
leftload.mark(boundaries,1)
rightload.mark(boundaries,2)

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

```

---

<div class="post-metadata">

**Author:** ![nate](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/nate/32/17_2.png) [@nate](https://fenicsproject.discourse.group/u/nate)\
**Post date:** [August 10, 2022, 2:10pm UTC](https://fenicsproject.discourse.group/t/2d-simply-supported-beam-boundary-conditions/8975/2 "2022-08-10T14:10:54Z")

</div>

Please see [Read before posting: How do I get my question answered?](https://fenicsproject.discourse.group/t/read-before-posting-how-do-i-get-my-question-answered/21) regarding how to construct a MWE.

---

<div class="post-metadata">

**Author:** ![dries](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dries/32/4059_2.png) [@dries](https://fenicsproject.discourse.group/u/dries)\
**Post date:** [August 11, 2022, 1:16pm UTC](https://fenicsproject.discourse.group/t/2d-simply-supported-beam-boundary-conditions/8975/3 "2022-08-11T13:16:44Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![nate](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/nate/32/17_2.png) [@nate](https://fenicsproject.discourse.group/u/nate)\
**Post date:** [August 11, 2022, 1:18pm UTC](https://fenicsproject.discourse.group/t/2d-simply-supported-beam-boundary-conditions/8975/4 "2022-08-11T13:18:26Z")

</div>

Your code is incomplete. Your error message states:

```auto
 “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.

---

<div class="post-metadata">

**Author:** ![dries](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dries/32/4059_2.png) [@dries](https://fenicsproject.discourse.group/u/dries)\
**Post date:** [August 11, 2022, 1:23pm UTC](https://fenicsproject.discourse.group/t/2d-simply-supported-beam-boundary-conditions/8975/5 "2022-08-11T13:23:52Z")

</div>

Thank you. This is how I defined my mesh.

```auto
# 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)

```

---

<div class="post-metadata">

**Author:** ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)\
**Post date:** [August 11, 2022, 2:45pm UTC](https://fenicsproject.discourse.group/t/2d-simply-supported-beam-boundary-conditions/8975/6 "2022-08-11T14:45:52Z")

</div>

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

I would suggest you write

> [@dries](#):
>
> ```auto
> boundaries = MeshFunction("size_t", mesh, mesh.topology().dim() - 1)
> boundaries.set_all(0)
> leftload.mark(boundaries,1)
> rightload.mark(boundaries,2)
> 
> ```

`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.

---

<div class="post-metadata">

**Author:** ![dries](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dries/32/4059_2.png) [@dries](https://fenicsproject.discourse.group/u/dries)\
**Post date:** [August 11, 2022, 3:15pm UTC](https://fenicsproject.discourse.group/t/2d-simply-supported-beam-boundary-conditions/8975/7 "2022-08-11T15:15:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)\
**Post date:** [August 11, 2022, 3:23pm UTC](https://fenicsproject.discourse.group/t/2d-simply-supported-beam-boundary-conditions/8975/8 "2022-08-11T15:23:52Z")

</div>

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.
