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