# Impose boundary conditions

**URL:** <https://community.freefem.org/t/impose-boundary-conditions/923>\
**Category:** General Discussion\
**Created:** [April 16, 2021, 2:09am UTC](https://community.freefem.org/t/impose-boundary-conditions/923 "2021-04-16T02:09:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Emma87](https://avatars.discourse-cdn.com/v4/letter/e/e47774/32.png) [@Emma87](https://community.freefem.org/u/Emma87)\
**Post date:** [April 16, 2021, 2:09am UTC](https://community.freefem.org/t/impose-boundary-conditions/923/1 "2021-04-16T02:09:04Z")

</div>

Hi everyone!  
I want to know how I can impose Dirichlet boundary condition on \Gamma\_ {E2} a different value than in the cases ! [mesh|690x365](https://community.freefem.org/uploads/short-url/9ic0Yf6DibyqgQZenwOUFJPvCpx.jpeg) Gamma\_ {E3} = \Gamma\_ {E1} \< \Gamma\_ {E2}, in FreeFem. Is there an example of how to build my mesh that way?

Best regards,

---

<div class="post-metadata">

**Author:** ![jmorvan](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/jmorvan/32/2928_2.png) [@jmorvan](https://community.freefem.org/u/jmorvan)\
**Post date:** [April 20, 2021, 5:34pm UTC](https://community.freefem.org/t/impose-boundary-conditions/923/2 "2021-04-20T17:34:00Z")

</div>

Dear Emmanuel,

You want to divide the boundary \Gamma\_{east} into three in order to impose Dirichlet boundary condition with a different value in each of those sub-boundaries, right? One way to do that is creating three rectangular meshes and then you can glue them. Here is one example with two rectangles:

> int m = 2 ; int n = m;  
> real x0= 0.0 , x1= 2.0 ;  
> real y0= 0.0 , y1= 0.5 , y2= 1.0;  
> int[int] l1 = [1,2,3,4] ;  
> int[int] l2 = [3,2,6,4] ;  
> mesh Th1 = square(20_n,10_m,[x0+(x1-x0)_x,y0+(y1-y0)y],label=l1,flags=0);  
> mesh Th2 = square(20n,10_m,[x0+(x1-x0)\*x,y1+(y2-y1)\*y],label=l2,flags=0);  
> mesh Th = Th1+Th2;

Hope it helps you.  
Best regards,  
Jorge Morvan

---

<div class="post-metadata">

**Author:** ![Emma87](https://avatars.discourse-cdn.com/v4/letter/e/e47774/32.png) [@Emma87](https://community.freefem.org/u/Emma87)\
**Post date:** [April 21, 2021, 4:17pm UTC](https://community.freefem.org/t/impose-boundary-conditions/923/3 "2021-04-21T16:17:09Z")

</div>

Thanks, Jorge  
I built it in another way:  
border G1 (t=0,1){x=10_t; y=0; label=1;}  
border G21(t=0,1){x=10; y=4_t; label=2;}  
border G22(t=0,1){x=10; y=4+4_t; label=3;}  
border G23(t=0,1){x=10; y=8+2_t; label=4;}  
border G3 (t=0,1){x=10-10_t;y=10; label=5;}  
border G4 (t=0,1){x=0; y=10-10_t; label=6;}  
mesh Th = buildmesh(G1(80)+G21(80)+G22(80)+G23(80)+G3(80)+G4(80));
