# Program running

**URL:** <https://community.freefem.org/t/program-running/3526>\
**Category:** General Discussion\
**Created:** [October 1, 2024, 5:34am UTC](https://community.freefem.org/t/program-running/3526 "2024-10-01T05:34:32Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![mamun0954](https://avatars.discourse-cdn.com/v4/letter/m/57b2e6/32.png) [@mamun0954](https://community.freefem.org/u/mamun0954)\
**Post date:** [October 1, 2024, 5:34am UTC](https://community.freefem.org/t/program-running/3526/1 "2024-10-01T05:34:32Z")

</div>

Hello everyone  
Good afternoon. I am new in freefem++, so I cannot run this in freefem++. Can anyone help to correct my program. Thanks in advance.

// Parameters  
real r = 1; // Cylinder radius  
real h = 2; // Cylinder height  
int n = 32; // Number of segments (discretization along the circumference)  
int m = 10; // Number of layers along the height

// Mesh generation  
border b1(t=0, 2_pi) { // Bottom circle  
x = r_cos(t);  
y = r\*sin(t);  
}

border b2(t=0, 2_pi) { // Top circle  
x = r_cos(t);  
y = r\*sin(t) + h;  
}

// Creating the mesh from the borders  
mesh Th = buildmesh(b1(n) + b2(n));

// Adding sides  
// Add lateral surface based on the bottom and top borders  
for(int i=0; i\<n; i++) {  
Th += triangle(b1[i], b1[(i+1)%n], b2[i]);  
Th += triangle(b2[i], b1[(i+1)%n], b2[(i+1)%n]);  
}

// Visualize the mesh  
plot(Th);

---

<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:** [October 2, 2024, 7:04am UTC](https://community.freefem.org/t/program-running/3526/2 "2024-10-02T07:04:49Z")

</div>

Hello,  
I do not understand the shape of the mesh you want to create. You have two disjoint circles, but then ? Do you want some kind of “stadium” ?

---

<div class="post-metadata">

**Author:** ![vlaude](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/vlaude/32/939_2.png) [@vlaude](https://community.freefem.org/u/vlaude)\
**Post date:** [October 2, 2024, 7:19am UTC](https://community.freefem.org/t/program-running/3526/3 "2024-10-02T07:19:23Z")

</div>

Hello,  
Lines 8, 9, 13, 14 you miss a " \* " (multiplication): ‘2 \* pi’ and ‘r \* cos(t)’  
Lines 21-26 I don’t get the code. Have you defined a function triangle() somewhere else?

---

<div class="post-metadata">

**Author:** ![mamun0954](https://avatars.discourse-cdn.com/v4/letter/m/57b2e6/32.png) [@mamun0954](https://community.freefem.org/u/mamun0954)\
**Post date:** [October 2, 2024, 7:42am UTC](https://community.freefem.org/t/program-running/3526/4 "2024-10-02T07:42:53Z")

</div>

Thanks for your reply. Actually, I want to make a domain like cylinder by separating lower circle name and upper circle name. I want to use this domain for freefem++ simulation. I can make a cylinder domain but cannot by separating their circle names. Hope you understand. Thanks

 ![NmrTdZms](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/f/f892ae793b6af7cee374dfb642d3888fb67ece50.jpeg)

---

<div class="post-metadata">

**Author:** ![mamun0954](https://avatars.discourse-cdn.com/v4/letter/m/57b2e6/32.png) [@mamun0954](https://community.freefem.org/u/mamun0954)\
**Post date:** [October 2, 2024, 7:44am UTC](https://community.freefem.org/t/program-running/3526/5 "2024-10-02T07:44:32Z")

</div>

Thanks for your reply. Actually, I want to make a domain like cylinder by separating lower circle name and upper circle name. I want to use this domain for freefem++ simulation. I can make a cylinder domain but cannot by separating their circle names. Hope you understand. Can you help me to find such domain? Thanks in advance.

 ![NmrTdZms](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/f/f892ae793b6af7cee374dfb642d3888fb67ece50.jpeg)

---

<div class="post-metadata">

**Author:** ![jbl](https://avatars.discourse-cdn.com/v4/letter/j/e47c2d/32.png) [@jbl](https://community.freefem.org/u/jbl)\
**Post date:** [October 2, 2024, 7:57am UTC](https://community.freefem.org/t/program-running/3526/6 "2024-10-02T07:57:37Z")

</div>

to be sure of your code and avoid the copy/paste errors can you modify your initial post and put the code using the function “preformatted text” (ctrl+e) ?

---

<div class="post-metadata">

**Author:** ![mamun0954](https://avatars.discourse-cdn.com/v4/letter/m/57b2e6/32.png) [@mamun0954](https://community.freefem.org/u/mamun0954)\
**Post date:** [October 2, 2024, 8:28am UTC](https://community.freefem.org/t/program-running/3526/7 "2024-10-02T08:28:38Z")

</div>

Thanks for your reply. Actually, I want to make a domain like cylinder by separating lower circle name and upper circle name. I want to use this domain for freefem++ simulation. I can make a cylinder domain but cannot by separating their circle names. Hope you understand. Can you help me to find such domain? Thanks in advance.

---

<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:** [October 2, 2024, 8:35am UTC](https://community.freefem.org/t/program-running/3526/8 "2024-10-02T08:35:40Z")

</div>

Do you mean to make a cylinder in 3d ? or a 2d “stadium” like domain ?

---

<div class="post-metadata">

**Author:** ![mamun0954](https://avatars.discourse-cdn.com/v4/letter/m/57b2e6/32.png) [@mamun0954](https://community.freefem.org/u/mamun0954)\
**Post date:** [October 2, 2024, 8:49am UTC](https://community.freefem.org/t/program-running/3526/9 "2024-10-02T08:49:44Z")

</div>

Thanks. I want to make a cylinder in 3D. I want to name like as, the bottom circle (z = 0) will have label 1, the top circle (z = height) will have label 2, the curved surface of the cylinder will have label 3. But I cannot do that. Can you help me to make such domain? Thanks in advance.

---

<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:** [October 2, 2024, 10:03am UTC](https://community.freefem.org/t/program-running/3526/10 "2024-10-02T10:03:44Z")

</div>

```auto
load "msh3"

// Parameters
real r = 1.; // Cylinder radius
real h = 2.; // Cylinder height
int n = 32; // Number of segments (discretization along the circumference)
int m = 10; // Number of layers along the height

// Mesh generation
border b1(t=0.,2.*pi){x = r*cos(t);y = r*sin(t);};
mesh disc=buildmesh(b1(n));

int[int] rdown=[0,1],rup=[0,2],rmid=[1,3];
mesh3 Th=buildlayers(disc,m,zbound=[0.,h],labeldown=rdown,labelup=rup,labelmid=rmid);

plot(Th);

```

---

<div class="post-metadata">

**Author:** ![mamun0954](https://avatars.discourse-cdn.com/v4/letter/m/57b2e6/32.png) [@mamun0954](https://community.freefem.org/u/mamun0954)\
**Post date:** [October 7, 2024, 1:33am UTC](https://community.freefem.org/t/program-running/3526/11 "2024-10-07T01:33:08Z")

</div>

Thanks for your reply and sorry for late reply. I understand your code. But how can I rename the boundary of surfaces. I want to rename as lower circle boundary ‘a’, upper circle boundary ‘b’ and cylinder surface ‘c’.  
I can rename the lower boundary as follows,  
border b1(t=0.,2._pi){x = r_cos(t);y = r\*sin(t); label=1;};  
But I cannot rename the other boundary.  
Can you help me to do this?

---

<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:** [October 7, 2024, 10:22am UTC](https://community.freefem.org/t/program-running/3526/12 "2024-10-07T10:22:19Z")

</div>

The labeling of the three boundaries is done as  
`int[int] rdown=[0,a],rup=[0,b],rmid=[1,c];`  
with a,b,c as you asked for.  
The `0` refers to the interior of the disc, and the `1` refers to the boundary of the disc.

---

<div class="post-metadata">

**Author:** ![mamun0954](https://avatars.discourse-cdn.com/v4/letter/m/57b2e6/32.png) [@mamun0954](https://community.freefem.org/u/mamun0954)\
**Post date:** [October 11, 2024, 7:48am UTC](https://community.freefem.org/t/program-running/3526/13 "2024-10-11T07:48:23Z")

</div>

Thanks for your reply. I understand very clearly dear prof. Thanks for your clarification.
