Program running

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, 2pi) { // Bottom circle
x = r
cos(t);
y = r*sin(t);
}

border b2(t=0, 2pi) { // 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);

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” ?

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?

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

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.

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) ?

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.

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

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.

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);

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 = rcos(t);y = r*sin(t); label=1;};
But I cannot rename the other boundary.
Can you help me to do this?

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.

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