# Normal boundary condition

**URL:** <https://community.freefem.org/t/normal-boundary-condition/341>\
**Category:** General Discussion\
**Created:** [April 10, 2020, 1:55pm UTC](https://community.freefem.org/t/normal-boundary-condition/341 "2020-04-10T13:55:58Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![michaellevitin](https://avatars.discourse-cdn.com/v4/letter/m/46a35a/32.png) [@michaellevitin](https://community.freefem.org/u/michaellevitin)\
**Post date:** [April 10, 2020, 1:55pm UTC](https://community.freefem.org/t/normal-boundary-condition/341/1 "2020-04-10T13:55:58Z")

</div>

When solving some (vector) BVP for 2d elasticity, I’d like to specify a Dirichlet boundary condition for the **normal** component of a vector field [u,v], as, say, …`+on(1, u*N.x+v*N.y=0)`.  
I understand that the syntax of `on` command does not allow this. Is there a good workaround? Thanks!

---

<div class="post-metadata">

**Author:** ![paolopiers](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/paolopiers/32/48_2.png) [@paolopiers](https://community.freefem.org/u/paolopiers)\
**Post date:** [April 11, 2020, 9:52am UTC](https://community.freefem.org/t/normal-boundary-condition/341/2 "2020-04-11T09:52:50Z")

</div>

Hi @michaellevitin , I have run up against the same problem as yours and I got around it using a penalty-based approach.  
If you are integrating your PDE on a 2D domain `Th`, and you are interested in imposing a homogeneous Neumann boundary condition on a portion of the boundary labelled as `1`, you can try

`int1d(Th,1)(tgv*dn(u)*v)`

where the normal derivative is defined via the following macro

`macro dn(u)(dx(u)*N.x+dy(u)*N.y)//EOM`.

I hope this helps.

---

<div class="post-metadata">

**Author:** ![michaellevitin](https://avatars.discourse-cdn.com/v4/letter/m/46a35a/32.png) [@michaellevitin](https://community.freefem.org/u/michaellevitin)\
**Post date:** [April 14, 2020, 11:30am UTC](https://community.freefem.org/t/normal-boundary-condition/341/3 "2020-04-14T11:30:20Z")

</div>

Thanks, Paolo! It is not exactly what I need - I am solving a vector eigenvalue problem for elasticity, see [FreeFem manual](https://doc.freefem.org/tutorials/elasticity.html) and want to impose mixed boundary conditions: tangential component of traction to vanish (which is automatic due to the weak formulation), and the normal component of the vector field `[u,v]`, that is `u*N.x+v*N.y` to vanish as well. It’s the second one I’m struggling with.  
M.

---

<div class="post-metadata">

**Author:** ![Hong](https://avatars.discourse-cdn.com/v4/letter/h/b2d939/32.png) [@Hong](https://community.freefem.org/u/Hong)\
**Post date:** [April 22, 2020, 7:29pm UTC](https://community.freefem.org/t/normal-boundary-condition/341/4 "2020-04-22T19:29:06Z")

</div>

@michaellevitin Hi, do you work out this problem? I encountered the same problem with you. I also use the code on(1, u_nx+v_ny=0), but it does not work. I solve the Navier slip boundary condition at curved wall. the tangential velocity is given by 1/b_v_t, and the normal velocity vanishes, which means that u_nx+v_ny=0 at curved wall.  
Could you tell me how to address this. I have found that the FreeFEM can handle this problem. A Ph.D. thesis entitled Effective Slip Lengths for Stokes Flow over Rough, Mixed-Slip Surfaces use the FreeFem++ to solve the Navier slip BC and no-penetration BC on curved wall. I contact the author but recieve no reply.  
Many thanks.

---

<div class="post-metadata">

**Author:** ![zese](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/zese/32/917_2.png) [@zese](https://community.freefem.org/u/zese)\
**Post date:** [January 17, 2022, 2:43pm UTC](https://community.freefem.org/t/normal-boundary-condition/341/5 "2022-01-17T14:43:00Z")

</div>

@michaellevitin  
Dear Michael

Did you find an answer for your question?  
I have the same trouble as I have the BC on 1 I have a jet normal to the boundary with the amplitude of Aj.  
I don’t know how to define it.

Best regards,

---

<div class="post-metadata">

**Author:** ![felric](https://avatars.discourse-cdn.com/v4/letter/f/5f8ce5/32.png) [@felric](https://community.freefem.org/u/felric)\
**Post date:** [May 6, 2022, 10:18pm UTC](https://community.freefem.org/t/normal-boundary-condition/341/6 "2022-05-06T22:18:37Z")

</div>

Dear all,

I have the same problem as @michaellevitin : I have a 3D elasticity problem with symmetry conditions on a equilateral triangle. Displacement vector is [ux,uy,uz]. On the base “1” of the triangle (y=0, x=[-a/2 a/2]) I can simply add …+on(1, uy=0). However on the other two sides of the triangle, being not aligned to x or y axis, I tried …+on(2, ux_N.x+uy_N.y) but of course is not working. In fact I should put into relations ux with uy and therefore it is not possible to simply putting the diagonal elements to a tgv value.  
Is there a way to impose symmetry conditions (e.g., Dirichlet boundary condition for the normal component of a vector field) on boundaries that are NOT aligned to x, y and z axis?  
Thanks very much in advance

---

<div class="post-metadata">

**Author:** ![frederichecht](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/frederichecht/32/15_2.png) [@frederichecht](https://community.freefem.org/u/frederichecht)\
**Post date:** [May 7, 2022, 6:03pm UTC](https://community.freefem.org/t/normal-boundary-condition/341/7 "2022-05-07T18:03:28Z")

</div>

The problem the put fixed (Dirichlet) boundary condition on normal componant and Neuman on tangent for example.

At math level the correct (not to bad) weak formulation is take basic fonction in space Vh0  
of function with a zero on u.N =0 on boundary node. If N (the normal ) is not a parallel of axis then  
you have a coupling of all componante.

You can use a kind of penalization to enforce the u.N =0 by add term like in 2d

- int1d(Th)( penal\* (N’_[u1,u2])_( (N’\*[v1,v2]))

where penal est a big constant but not to big …

a small example for Stokes problem

> **[BC-STOKES.pdf](https://www.ljll.math.upmc.fr/hecht/ftp/NSF03/BC-STOKES.pdf)**
>
> 159.69 KB

and the associed example  
[Stokes-BC.edp](https://community.freefem.org/uploads/short-url/9J4nzJca5E15Rxc7eyO8NV5elOQ.edp) (1.9 KB)

---

<div class="post-metadata">

**Author:** ![jna1g18](https://avatars.discourse-cdn.com/v4/letter/j/77aa72/32.png) [@jna1g18](https://community.freefem.org/u/jna1g18)\
**Post date:** [September 20, 2023, 12:23pm UTC](https://community.freefem.org/t/normal-boundary-condition/341/8 "2023-09-20T12:23:05Z")

</div>

Hi Paolo, what is tgv? I’ve seen it mentioned in parts of the documentation related to Dirichlet BCs, but I’m not sure of what it is. Is it a very large value?

---

<div class="post-metadata">

**Author:** ![frederichecht](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/frederichecht/32/15_2.png) [@frederichecht](https://community.freefem.org/u/frederichecht)\
**Post date:** [September 21, 2023, 8:38am UTC](https://community.freefem.org/t/normal-boundary-condition/341/9 "2023-09-21T08:38:20Z")

</div>

It is a technique to in force simply Dirichlet Boundary Condition. (call BC)

See the section 7.6 (sorry in french) of [https://www.ljll.math.upmc.fr/hecht/ftp/NM406/NotesdeCoursMN406.pdf](https://www.ljll.math.upmc.fr/hecht/ftp/NM406/NotesdeCoursMN406.pdf)

otherwise if the make real penalization not exact (only on the diagonal term of the matrix )  
you need to have enough digit in you floating number to take 2 things ons for the BC and one for the equation. (see [Penalty method - Wikipedia](https://en.wikipedia.org/wiki/Penalty_method) )

---

<div class="post-metadata">

**Author:** ![mas](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/mas/32/2160_2.png) [@mas](https://community.freefem.org/u/mas)\
**Post date:** [March 19, 2024, 4:41am UTC](https://community.freefem.org/t/normal-boundary-condition/341/10 "2024-03-19T04:41:24Z")

</div>

Hello, Prof. Hecht,

I’m facing a similar situation, but something seems to go wrong.

> [@frederichecht](#):
>
> int1d(Th)( penal\* (N’_[u1,u2])_( (N’\*[v1,v2]))

Here, do you mean the following?

```auto

macro u [u1,u2] //	displacement vector
macro v [v1,v2] //	test function for displacement
macro e(u) [dx(u[0]),dy(u[1]),(dx(u[1])+dy(u[0]))] // strain tensor

// define governing equation 
problem gov(u,v)
		=
		-int2d(Sh)((D*e(u))'*e(v))
		+int1d(Sh,2)(penaltyParameter * (u1*N.x + u2*N.y) * (v1*N.x + v2*N.y)) // u.N=0
		+on(1,u1=0.1*N.x,u2=0.1*N.y) // other boundary conditions
		;

```

I tried the above, but did not get the expected results.  
The following is the result plotting [u1,u2].

 ![horizontal](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/b/b0436c2f96c3e908db39831965e2060b1944ecb8.jpeg)

In this case, the results seem reasonable, but if we only rotate the boundaries and domains, we see a different result as follows.

 ![diagonal](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/3/396ef4dc406f13a5845649d38f4c70e7ba85e5a5.jpeg)

Below is the code I ran.

[2Delastic-slider-Single-240319a.edp](https://community.freefem.org/uploads/short-url/rES4sMlFVULUoJfOCKxhNx3OIn8.edp) (2.1 KB)

Do you have any ideas how to solve this strange behavior?

Thank you for your kind cooperation.

---

<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:** [March 19, 2024, 12:15pm UTC](https://community.freefem.org/t/normal-boundary-condition/341/11 "2024-03-19T12:15:05Z")

</div>

There are two mistakes in your code:  
– the coef `4*mu` should be `2.*mu`, this is why your code is not frame invariant  
– the sign of the first term in your variational formulation should be “+” instead of “-”

Also probably you miss a constant sqrt(2.):  
`macro e(u) [dx(u[0]),dy(u[1]),(dx(u[1])+dy(u[0]))/sqrt(2.)]`

---

<div class="post-metadata">

**Author:** ![k-matsushima-19](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/k-matsushima-19/32/2170_2.png) [@k-matsushima-19](https://community.freefem.org/u/k-matsushima-19)\
**Post date:** [March 20, 2024, 11:27am UTC](https://community.freefem.org/t/normal-boundary-condition/341/12 "2024-03-20T11:27:05Z")

</div>

You can use the Lagrange multiplier method if you don’t like the penalization.

For example, let \Omega be a bounded domain of \mathbb{R}^d with boundary \partial\Omega = \overline{\Gamma\_N \cup \Gamma\_S} and consider the following linear elasticity problem:

-\mathrm{div}(C:\varepsilon(u)) = 0 \text{ in }\Omega \\ (C:\varepsilon(u))n = t \text{ on }\Gamma\_N \\ u\cdot n = 0 \text{ on }\Gamma\_S

with the standard fourth-order elasticity tensor C, given traction t\in H^{-1/2}(\Gamma\_N)^d and second-order strain tensor \varepsilon(u). This problem can be rewritten as the variational problem on H^1(\Omega)^d:

\min\_{u\in H^1(\Omega)^d} \frac{1}{2}\int\_\Omega \varepsilon(u):C:\varepsilon(u) dx - \int\_{\Gamma\_N} t\cdot u\mathrm{d}s \\ \text{subject to }u\cdot n = 0 \text{ on }\Gamma\_S.

To solve this, we define the Lagrange functional \mathcal{L}:H^1(\Omega)^d\times H^{-1/2}(\Gamma\_S)\to\mathbb{R} by

\mathcal{L}(u,\varphi) = \frac{1}{2}\int\_\Omega \varepsilon(u):C:\varepsilon(u) dx - \int\_{\Gamma\_N} t\cdot u\mathrm{d}s + \langle \varphi,u\cdot n\rangle\_{H^{1/2}(\Gamma\_S)},

where \langle\cdot,\cdot\rangle\_{H^{1/2}(\Gamma\_S)} is the usual duality pairing. A solution of the variational problem is sought as a stationary point of \mathcal{L}, i.e.,

0 = \langle d\_u\mathcal{L}(u,\varphi),v\rangle\_{H^1(\Omega)^d} = \int\_\Omega \varepsilon(u):C:\varepsilon(v) dx - \int\_{\Gamma\_N} t\cdot v\mathrm{d}s + \langle \varphi,v\cdot n\rangle\_{H^{1/2}(\Gamma\_S)}, \\ 0 = \langle d\_\varphi\mathcal{L}(u,\varphi),\psi\rangle\_{H^{-1/2}(\Gamma\_S)} = \langle \psi,u\cdot n\rangle\_{H^{1/2}(\Gamma\_S)},

for all (v,\psi)\in H^1(\Omega)^d\times H^{-1/2}(\Gamma\_S). In summary, our problem is to find (u,\varphi)\in H^1(\Omega)^d\times H^{-1/2}(\Gamma\_S) such that

\int\_\Omega \varepsilon(u):C:\varepsilon(v) dx + \langle \varphi,v\cdot n\rangle\_{H^{1/2}(\Gamma\_S)} + \langle \psi,u\cdot n\rangle\_{H^{1/2}(\Gamma\_S)} = \int\_{\Gamma\_N} t\cdot v\mathrm{d}s

for all (v,\psi)\in H^1(\Omega)^d\times H^{-1/2}(\Gamma\_S).

To solve this using FreeFEM, we need an fespace corresponding to the product space H^1(\Omega)^d\times H^{-1/2}(\Gamma\_S). Thanks to the [new feature](https://doc.freefem.org/documentation/composite.html) in the latest release, this can be easily implemented.

[lagrange.edp](https://community.freefem.org/uploads/short-url/fbPxHyqMaoBPiFSz3WTIWPKjyAK.edp) (2.4 KB)  
[penalty.edp](https://community.freefem.org/uploads/short-url/e8aHE9vlCrsaVdy3U30D8GIA1A1.edp) (2.1 KB)
