# Region assignment

**URL:** <https://community.freefem.org/t/region-assignment/4149>\
**Category:** General Discussion\
**Created:** [December 9, 2025, 2:59pm UTC](https://community.freefem.org/t/region-assignment/4149 "2025-12-09T14:59:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shyam](https://avatars.discourse-cdn.com/v4/letter/s/dfb087/32.png) [@Shyam](https://community.freefem.org/u/Shyam)\
**Post date:** [December 9, 2025, 2:59pm UTC](https://community.freefem.org/t/region-assignment/4149/1 "2025-12-09T14:59:11Z")

</div>

Hello all,

I am working wth a particular special geometry for my problem. I glued two bodies with a simple ‘mesh3 body1 + body2;‘ command. However, I now want to identify these two bodies as two different regions. How do I do it? At the end, the new body became a single region but I want it to be two.

Here’s my code:

load “msh3”

load “medit”

// Parameters

real H = 10;

real HH = 1;

real L = 30;

real B = 40;

real W = 15;

int nn=10;

// \_ \_

//| | | |

//| |\_ \_ \_ \_ \_| |-\>4

//|\_ \_ \_ \_ \_ \_|

// | | 3

// | |-\>2

// |\_|

// 1

// 2D mesh

border C1(t=0, H){x=t ; y=0 ; label=1;}

border C2(t=0, 2\*H){x=H ; y=t ; label=2;}

border C3(t=H, 3\*H){x=t ; y=2\*H ; label=3;}

border C4(t=2\*H, 5\*H){x=3\*H ; y=t ; label=4;}

border C5(t=0, H){x=3\*H-t ; y=5\*H ; label=5;}

border C6(t=0, 2\*H){x=2\*H ; y=5\*H-t; label=6;}

border C7(t=0, 3\*H){x=2\*H-t ; y=3\*H ; label=7;}

border C8(t=3\*H, 5\*H){x=-H ; y=t ; label=8;}

border C9(t=0, H){x=-H-t; y=5\*H ; label=9;}

border C10(t=0, 3\*H){x=-2\*H ; y=5\*H-t ; label=10;}

border C11(t=0, 2\*H){x=-2\*H+t; y=2\*H ; label=11;}

border C12(t=0, 2\*H){x=0 ; y=2\*H-t ; label=12;}

mesh Th = buildmesh(C1(nn)+C2(nn)+C3(nn)+C4(nn)+

```auto
    C5(nn)+C6(nn)+C7(nn)+C8(nn)+

    C9(nn)+C10(nn)+C11(nn)+C12(nn));

```

int reg1 = Th(5,20).region;

int[int] regv = [0,1];

cout\<\<"2D base region ID "\<\<reg1\<\<endl;

//plot(Th, wait=true);

func zmin = 0.;

func zmax = H;

int MaxLayer = 5;

int[int] r1 = [12,13];

mesh3 Th3 = buildlayers(Th, MaxLayer, zbound=[zmin, zmax], region = regv);

//plot(Th3);

mesh3 Block = cube(nn, nn, nn, [L\*x, B\*y, W\*z], region = 2);

Block = movemesh(Block,[x-10,y+30,z-2.5]);

//plot(Block);

mesh3 Popsicle = Th3 + Block;

plot(Popsicle);

int body1= Popsicle(5.,30.,5.5).region;

int body2 = Popsicle(5.,20.,1).region;

cout\<\<"body1 region "\<\<Imp\<\<endl;

cout\<\<"body2 region "\<\<Bone\<\<endl;

---

<div class="post-metadata">

**Author:** ![Shyam](https://avatars.discourse-cdn.com/v4/letter/s/dfb087/32.png) [@Shyam](https://community.freefem.org/u/Shyam)\
**Post date:** [December 12, 2025, 12:38pm UTC](https://community.freefem.org/t/region-assignment/4149/2 "2025-12-12T12:38:15Z")

</div>

I defined a special heavy function and achieved my objective.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/1X/501c33921a7354ada089c77234cfeab824cd6625.png) [@system](https://community.freefem.org/u/system)\
**Post date:** [July 29, 2026, 10:06pm UTC](https://community.freefem.org/t/region-assignment/4149/3 "2026-07-29T22:06:54Z")

</div>



---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/1X/501c33921a7354ada089c77234cfeab824cd6625.png) [@system](https://community.freefem.org/u/system)\
**Post date:** [August 1, 2026, 2:10pm UTC](https://community.freefem.org/t/region-assignment/4149/4 "2026-08-01T14:10:55Z")

</div>


