# Trouble defining region id numbers on a 3D mesh

**URL:** <https://community.freefem.org/t/trouble-defining-region-id-numbers-on-a-3d-mesh/4223>\
**Category:** General Discussion\
**Created:** [February 20, 2026, 9:33pm UTC](https://community.freefem.org/t/trouble-defining-region-id-numbers-on-a-3d-mesh/4223 "2026-02-20T21:33:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![EChase](https://avatars.discourse-cdn.com/v4/letter/e/b9e5f3/32.png) [@EChase](https://community.freefem.org/u/EChase)\
**Post date:** [February 20, 2026, 9:33pm UTC](https://community.freefem.org/t/trouble-defining-region-id-numbers-on-a-3d-mesh/4223/1 "2026-02-20T21:33:21Z")

</div>

Hello everyone,

I am stumped and could use some assistance. I cannot understand how to define the regions for assigning boundary conditions for a 3D mesh of a cylinder.

The mesh is created as follows:

load “msh3”  
load “medit”

// ------ Geometry -------  
real d = 3.0_2.54/100, h = 0.07_2.54/100;

// Parameters  
int nni = 9; // number of elements along circumference (90 degree arc)  
int nnr = 7; // number of radial elements  
int nnz = 5; // number of elements through the thickness

func zmin = 0;  
func zmax = 2\*pi;

/\* the geometry will be built using radial symmetry.  
A square of dimensions d/2xh is rotated about the z axis  
The whole thing will then be rotated so the Z-Axis is the through thickness axis  
This hopefully will allow sides to be defined for boundary conditions \*/

// mesh 2D  
mesh Th = square(nnr, nnz, [(d/2)_x, h_y]); // cross section for axial symmetry

// mesh 3D  
int[int] rup = [0, 3]; // The element faces on the upper surface,  
int[int] rlo = [0, 1]; // The element faces on the lower surface,  
int[int] rmid = [0, 4]; // The elements along the axial centerline

func fx = x_cos(z);  
func fy = x_sin(z);  
func fz = y;  
mesh3 Th3 = buildlayers(Th, 36, zbound=[zmin, zmax], transfo=[fx,fy,fz], labelup = rup, labeldown = rlo, labelmid = rmid);

The 2D rectangular mesh is rotated from the X-Y plane to the X-Z plane, the rotated around the Z axis. I would like to be able to apply boundary conditions to the bottom circular face, the top circular face, and the axial centerline - however this code won’t get me there.

I would really appreciate some advice on how to identify the three regions for defining the boundary conditions.

Thank you immensely.

Ed

---

<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:** [February 21, 2026, 2:29pm UTC](https://community.freefem.org/t/trouble-defining-region-id-numbers-on-a-3d-mesh/4223/2 "2026-02-21T14:29:47Z")

</div>

Some correction

1)remark after transformation the logical top and bottom before transformation merge ( so non bound

1. the label come from the 2d mesh Th (see comment)

2. I add some deraffimement close of axis with coef=max(2.\*x/d,0.3)

[Untitled-1.edp](https://community.freefem.org/uploads/short-url/1CybqLiu1V17nl0iRFA66vLwxAU.edp) (1.3 KB)

the visu of the mesh (2 in yellow, 3 is green)

 ![Untitled](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/f/f843c918f7982487809210171bc9753caa534b76.png)

---

<div class="post-metadata">

**Author:** ![EChase](https://avatars.discourse-cdn.com/v4/letter/e/b9e5f3/32.png) [@EChase](https://community.freefem.org/u/EChase)\
**Post date:** [February 25, 2026, 4:40pm UTC](https://community.freefem.org/t/trouble-defining-region-id-numbers-on-a-3d-mesh/4223/3 "2026-02-25T16:40:12Z")

</div>

Thank you very much for helping me with this.
