# Boundary condition

**URL:** <https://community.freefem.org/t/boundary-condition/2945>\
**Category:** General Discussion\
**Created:** [February 8, 2024, 5:33am UTC](https://community.freefem.org/t/boundary-condition/2945 "2024-02-08T05:33:30Z")\
**Posts on this page:** 1\
**Showing post:** 6

<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 12, 2024, 11:07am UTC](https://community.freefem.org/t/boundary-condition/2945/6 "2024-03-12T11:07:50Z")

</div>

If you want to avoid using a Lagrange multiplier (because it enlarges the matrix to invert), some other ways to penalize the normal boundary conditions are possible.

In 3D you can use for example the boundary vertices. You have to define first a continuous approximate normal on the boundary (label `1` is for boundary)

```auto
fespace Vh1(Th,[P2,P2,P2]);
varf bdryn([w1,w2,w3],[v1,v2,v3])=int2d(Th,1)(v1*N.x+v2*N.y+v3*N.z);
Vh1 [normalappx,normalappy,normalappz];
normalappx[]=bdryn(0,Vh1);

```

Then you can add to your problem

```auto
 +int2d(Th,qft=qf1pTlump,1)(1e10*(u1*normalappx+u2*normalappy+u3*normalappz)*(v1*normalappx+v2*normalappy+v3*normalappz))

```

Setting `qft=qf1pTlump` is a trick to get the integral on the boundary triangle performed on the three vertices of the triangle. Thus the `int2d` plays the role of an `int0d` on the boundary vertices.

Another way is to use the boundary edges:

```auto
+int2d(Th,qft=qf2pT,1)(1e10*(u1*normalappx+u2*normalappy+u3*normalappz)*(v1*normalappx+v2*normalappy+v3*normalappz))

```

This edge formula will work if your velocity `fespace` is `P2`, but not for `P1` (there are too many edges compared to the boundary degrees of freedom of `P1`).  
You can find the explainations in  
[https://perso.math.u-pem.fr/bouchut.francois/normal.pdf](https://perso.math.u-pem.fr/bouchut.francois/normal.pdf)

Example files (2d and 3d) are:  
[normal2d.edp](https://community.freefem.org/uploads/short-url/rLXcrk5xGrCfQnv8e3Bp7HvLeMa.edp) (1.3 KB)

[normal3d.edp](https://community.freefem.org/uploads/short-url/mnSb3DfORi0yFFMrB2O0BPLmMks.edp) (2.1 KB)

---

_[View the full topic](https://community.freefem.org/t/boundary-condition/2945)._
