# Regions and Boundaries

**URL:** <https://community.freefem.org/t/regions-and-boundaries/789>\
**Category:** General Discussion\
**Created:** [February 8, 2021, 5:48pm UTC](https://community.freefem.org/t/regions-and-boundaries/789 "2021-02-08T17:48:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Xaxou](https://avatars.discourse-cdn.com/v4/letter/x/45deac/32.png) [@Xaxou](https://community.freefem.org/u/Xaxou)\
**Post date:** [February 8, 2021, 5:48pm UTC](https://community.freefem.org/t/regions-and-boundaries/789/1 "2021-02-08T17:48:52Z")

</div>

Hi there!  
I’m trying to model some cylinders thanks to FreeFem++. I did following:  
0/ Define some constant values  
1/ Define borders  
border S1(parametre=0,2_pi){ x=rinfini_cos(parametre); y=rinfini_sin(parametre); label=FirstBorder;}  
border S2(parametre=0,2_pi){ x=rb_cos(parametre); y=rb_sin(parametre); label=SecondBorder; }  
2/ Mesh 2D  
`mesh Thdeuxdim=buildmesh( S1(maillage)+S2(maillage) )`  
3/ Apply buildlayers  
mesh3 Th=buildlayers(Thdeuxdim, nombreextrusions, zbound=[fond,surface]);  
fespace Vh(Th,P03d);

If I want to get the region number knowing some coordinates (x,y,z), for example (1.,2.,0.) I can do following:  
Vh regions=region;  
int labelcylindre=regions(1., 2., 0.)  
labelcylindre is an integer with the number of a cylinder.

Now, I’d like to apply a boundary condition on a face of the cylinder, let’s say the bottom face z=fond.  
Is there a similar method to get the number of the face ? Maybe something like following?  
Vh faces=border;  
int labelface=faces(1.,2.,fond)

Thank you for your help, have a good evening!  
Xavier

---

<div class="post-metadata">

**Author:** ![julienG](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/julieng/32/222_2.png) [@julienG](https://community.freefem.org/u/julienG)\
**Post date:** [February 9, 2021, 9:24am UTC](https://community.freefem.org/t/regions-and-boundaries/789/2 "2021-02-09T09:24:48Z")

</div>

Hi, you can specify the labels for the boundaries when you do the `buildlayer` :

> int[int] rup=[0,labsTop], rdown=[0,labsBottom], rmid=[0,labsSide];  
> mesh TT2d=buildmesh(circle(npts));  
> TT=buildlayers(TT2d,Zpts,zbound=[Zm,ZM],labelmid=rmid,  
> labelup=rup, labeldown=rdown);

where `labsTop, labsBottom, labsSide` are the labels you choose

---

<div class="post-metadata">

**Author:** ![Xaxou](https://avatars.discourse-cdn.com/v4/letter/x/45deac/32.png) [@Xaxou](https://community.freefem.org/u/Xaxou)\
**Post date:** [February 9, 2021, 11:19am UTC](https://community.freefem.org/t/regions-and-boundaries/789/3 "2021-02-09T11:19:17Z")

</div>

Thank you Julien !

I’ll test it as soon as possible. Just to be sure that I understand: if I want to apply my boundary condition on the bottom face of the cylinder which contains the point (x,y,z)=(1.,2.,0.), then I can use following:

> +on((reg,labsBottom), u=condition)  
> where reg=regions(1., 2., 0.) and labsBottom is computed thanks to the 4 lines you wrote ?

Good afternoon,  
Xavier

---

<div class="post-metadata">

**Author:** ![julienG](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/julieng/32/222_2.png) [@julienG](https://community.freefem.org/u/julienG)\
**Post date:** [February 9, 2021, 12:11pm UTC](https://community.freefem.org/t/regions-and-boundaries/789/4 "2021-02-09T12:11:55Z")

</div>

I would say just

> +on(labsBottom, u=condition)

the label `labsBottom` denotes the whole lower disc of your cylinder

---

<div class="post-metadata">

**Author:** ![Xaxou](https://avatars.discourse-cdn.com/v4/letter/x/45deac/32.png) [@Xaxou](https://community.freefem.org/u/Xaxou)\
**Post date:** [February 9, 2021, 3:28pm UTC](https://community.freefem.org/t/regions-and-boundaries/789/5 "2021-02-09T15:28:10Z")

</div>

It sounds a bit strange to me : as you can state, I defined 2 circles S1 and S2. The first one is the full domain where I want to compute the FEM, the second one is the object which produces a thermal effect. “Thdeuxdim”, that is “TT2d” in your message, is the mesh with these 2 objects.

If I follow your logic, I do not understand how the computer should “know” that my boundary condition is to be applied on the bottom face of my second object, and not on the bottom face of both (that is : including the full domain) ?
