# For boundary conditions combining roller boundary and enforced displacement

**URL:** https://community.freefem.org/t/for-boundary-conditions-combining-roller-boundary-and-enforced-displacement/3698
**Category:** General Discussion
**Created:** [January 21, 2025, 6:01am UTC](https://community.freefem.org/t/for-boundary-conditions-combining-roller-boundary-and-enforced-displacement/3698 "2025-01-21T06:01:05Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![Ayataka](https://avatars.discourse-cdn.com/v4/letter/a/848f3c/32.png) [@Ayataka](https://community.freefem.org/u/Ayataka)
#### Post date: [January 21, 2025, 6:01am UTC](https://community.freefem.org/t/for-boundary-conditions-combining-roller-boundary-and-enforced-displacement/3698/1 "2025-01-21T06:01:05Z")

</div>

Hi FF++'s developers and users.

Suppose the boundary condition is such that one side of a square is pulled along the x-axis in the right direction for a unit length and is not enforced along the y-axis on that side.  
If the two sides of the square are parallel to both the x and y axes, this should simply require a enforced displacement in the x axis direction only (the y axis direction is free).  
Now, how would one implement a forced displacement of a square so that one side of the square is along a straight line at an angle of 45 degrees?

I would like some advice on this.  
Thank you in advance.  
Ayataka

 ![250121_FF++_COMMUNITY](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/6/67c9770a020cc2819eaede68072aa5f22015a167.png)

---

<div class="post-metadata">

### Author: ![fb77](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/fb77/32/3796_2.png) [@fb77](https://community.freefem.org/u/fb77)
#### Post date: [January 21, 2025, 1:56pm UTC](https://community.freefem.org/t/for-boundary-conditions-combining-roller-boundary-and-enforced-displacement/3698/2 "2025-01-21T13:56:26Z")

</div>

I think that the BC could be  
u\cdot W=1, and \sigma N-(\sigma N)\cdot W\ W=0 on \Gamma,  
Where W is a unitary vector defined on the boundary (direction of traction), possibly not constant. Here u is the velocity vector, \sigma is the stress tensor, N is the normal to the boundary. The second condition can be also written (\sigma N)\times W=0.  
Next, if your momentum equation is -\mathop{\rm div}\sigma=f, the variational formulation would be u\cdot W=1 on \Gamma,  
\int\_\Omega\sigma:Dv-\int\_\Omega f\cdot v=0, for all test v such that v\cdot W=0 on \Gamma.  
Here Dv is the symmetric gradient Dv=(\nabla v+(\nabla v)^t)/2.

---

<div class="post-metadata">

### Author: ![Ayataka](https://avatars.discourse-cdn.com/v4/letter/a/848f3c/32.png) [@Ayataka](https://community.freefem.org/u/Ayataka)
#### Post date: [January 28, 2025, 4:16am UTC](https://community.freefem.org/t/for-boundary-conditions-combining-roller-boundary-and-enforced-displacement/3698/3 "2025-01-28T04:16:51Z")

</div>

Dear François Bouchut

Thank you very much for your reply.  
I spent a few days considering it, but could not find out the essentials.  
Is **u** a displacement?  
We can find the unitary vector _ **W** _ whose outer product with _ **σN** _ is zero (i.e. _ **W** _ and _ **σN** _are parallel) and set the Dirichlet condition (_ **u** _=_ **W** _^-1) on the boundary gamma.

Could you please show us FF++ sample code to perform this analysis?

Sincereley  
Ayataka

---

<div class="post-metadata">

### Author: ![fb77](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/fb77/32/3796_2.png) [@fb77](https://community.freefem.org/u/fb77)
#### Post date: [January 28, 2025, 9:18am UTC](https://community.freefem.org/t/for-boundary-conditions-combining-roller-boundary-and-enforced-displacement/3698/4 "2025-01-28T09:18:53Z")

</div>

Dear Ayataka,  
In my statements, u is the velocity field, not the displacement. I was considering an imposed velocity 1 in the direction of W, u\cdot W=1. I realize that it is not what you asked for, you stated an imposed displacement. Thus it has to be modified.  
Anyway to complete the equations we need some constitutive relations, characterizing the material. In general it could be elasto-visco-plastic, compressible or not. If elasticity is dominant (like steel), considering equations on the displacement is mandatory. The equations can be simple if you consider small deformations, or complicate if you want to consider large deformations. Are you thinking of Hooke’s law for elastic small deformations?  
There is an example here [Normal boundary condition - #12 by k-matsushima-19](https://community.freefem.org/t/normal-boundary-condition/341/12)

---

<div class="post-metadata">

### Author: ![Ayataka](https://avatars.discourse-cdn.com/v4/letter/a/848f3c/32.png) [@Ayataka](https://community.freefem.org/u/Ayataka)
#### Post date: [January 28, 2025, 9:55am UTC](https://community.freefem.org/t/for-boundary-conditions-combining-roller-boundary-and-enforced-displacement/3698/5 "2025-01-28T09:55:59Z")

</div>

Dear François Bouchut

Thank you very much for your reply and your patients.  
I consider employing the linear easticity (Hooke’s law).

Referring the topic you gave me , [Normal boundary condition - #12 by k-matsushima-19](https://community.freefem.org/t/normal-boundary-condition/341/12)  
is this how I should do it?

Add a penalty term to prevent movement normal to the roller boundary?..

Sincereley  
Ayataka

---

<div class="post-metadata">

### Author: ![fb77](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/fb77/32/3796_2.png) [@fb77](https://community.freefem.org/u/fb77)
#### Post date: [January 28, 2025, 10:03am UTC](https://community.freefem.org/t/for-boundary-conditions-combining-roller-boundary-and-enforced-displacement/3698/6 "2025-01-28T10:03:46Z")

</div>

There is also an example explained in the Free Fem documentation p.65

> **[FreeFEM-documentation.pdf](https://doc.freefem.org/pdf/FreeFEM-documentation.pdf)**
>
> 33.85 MB

Adapting it to your case gives  
[elasticity.edp](https://community.freefem.org/uploads/short-url/vt4cSWlZ86OVyaSssy2bj1o69h1.edp) (874 Bytes)

---

<div class="post-metadata">

### Author: ![Ayataka](https://avatars.discourse-cdn.com/v4/letter/a/848f3c/32.png) [@Ayataka](https://community.freefem.org/u/Ayataka)
#### Post date: [February 3, 2025, 11:50am UTC](https://community.freefem.org/t/for-boundary-conditions-combining-roller-boundary-and-enforced-displacement/3698/7 "2025-02-03T11:50:34Z")

</div>

Dear François Bouchut

Thank you for your reply and coding the sample!  
I have created the code as attached, using your reference code and previous examples.  
Have I done what you intended me to do???

Sincereley

[250203\_Slide and Roller B.C…edp](https://community.freefem.org/uploads/short-url/tM8u5rfWcptW3PYSEjbiA7DXNov.edp) (2.3 KB)

---

<div class="post-metadata">

### Author: ![Ayataka](https://avatars.discourse-cdn.com/v4/letter/a/848f3c/32.png) [@Ayataka](https://community.freefem.org/u/Ayataka)
#### Post date: [February 3, 2025, 11:50am UTC](https://community.freefem.org/t/for-boundary-conditions-combining-roller-boundary-and-enforced-displacement/3698/8 "2025-02-03T11:50:56Z")

</div>

![250203_Slide and Roller B.C._Deformation](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/8/85886d4ba592635923c1e759727343e385d79983.png)

---

<div class="post-metadata">

### Author: ![Ayataka](https://avatars.discourse-cdn.com/v4/letter/a/848f3c/32.png) [@Ayataka](https://community.freefem.org/u/Ayataka)
#### Post date: [February 3, 2025, 12:08pm UTC](https://community.freefem.org/t/for-boundary-conditions-combining-roller-boundary-and-enforced-displacement/3698/9 "2025-02-03T12:08:07Z")

</div>

Alternatively, can we give a condition on the right boundary such that u N = f(y)?  
Where, f(y) = 1./sqrt(2.)\*(1.-y), N is unit vector at 45° diagonally to the upper right.

---

<div class="post-metadata">

### Author: ![Ayataka](https://avatars.discourse-cdn.com/v4/letter/a/848f3c/32.png) [@Ayataka](https://community.freefem.org/u/Ayataka)
#### Post date: [February 3, 2025, 12:38pm UTC](https://community.freefem.org/t/for-boundary-conditions-combining-roller-boundary-and-enforced-displacement/3698/10 "2025-02-03T12:38:56Z")

</div>

Dear François Bouchut

I apologise again and again.  
Here’s the thing.

Sincereley  
Ayataka  
[250203\_Slide and Roller B.C.\_rev.edp](https://community.freefem.org/uploads/short-url/kRyXAlckfhLP4k6La9rYNdA260j.edp) (2.5 KB)

 ![250203_Slide and Roller B.C._rev_Deformation.PNG](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/6/66d27b2dbfb83ddb58bc8eebae1c5e2734768db7.jpeg)

---

<div class="post-metadata">

### Author: ![Ayataka](https://avatars.discourse-cdn.com/v4/letter/a/848f3c/32.png) [@Ayataka](https://community.freefem.org/u/Ayataka)
#### Post date: [February 4, 2025, 12:26am UTC](https://community.freefem.org/t/for-boundary-conditions-combining-roller-boundary-and-enforced-displacement/3698/11 "2025-02-04T00:26:45Z")

</div>

Dear François Bouchut and FF++ users

I’d like to apply the code developed on the basis of the above discussion to a hexagon.  
Assuming a linear elastic body, we consider a boundary condition where the right half of the regular hexagon is under tension with a strain of 1 (see attached image 1).  
However, the result is as shown in the attached image 2, where a mesh inversion occurs near the corners of the hexagon.  
It may be possible to suppress this if a boundary condition is given at this corner point where the vertical displacement is zero…  
If you have any good ideas, please let me know.

 ![250204_FF++_COMMUNITY_1](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/6/6beabddeb192c7d4c2137cadaa76bc128e966441.png)  
 ![250204_FF++_COMMUNITY_2](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/8/8fbe3f205e154335fde19c191f39aa223651454d.jpeg)  
[250204\_Hexagon.edp](https://community.freefem.org/uploads/short-url/UFZ7fq5biYF9dLeqA9f1oylPGd.edp) (4.2 KB)

---

<div class="post-metadata">

### Author: ![fb77](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/fb77/32/3796_2.png) [@fb77](https://community.freefem.org/u/fb77)
#### Post date: [February 4, 2025, 3:39pm UTC](https://community.freefem.org/t/for-boundary-conditions-combining-roller-boundary-and-enforced-displacement/3698/12 "2025-02-04T15:39:57Z")

</div>

Dear Ayataka,  
Your first code (rectangle) looks correct. For the hexagon I don’t know, I don’t understand why there could be a difference in terms of behaviour with respect to the rectangle.

---

<div class="post-metadata">

### Author: ![Ayataka](https://avatars.discourse-cdn.com/v4/letter/a/848f3c/32.png) [@Ayataka](https://community.freefem.org/u/Ayataka)
#### Post date: [February 4, 2025, 11:33pm UTC](https://community.freefem.org/t/for-boundary-conditions-combining-roller-boundary-and-enforced-displacement/3698/13 "2025-02-04T23:33:59Z")

</div>

Dear François Bouchut

Thank you very much for your answers to my questions.  
Is there something mathematically wrong with a hexagon …?  
I will continue trial and error …

Sincereley  
Ayataka
