How to mesh annulus?

Hi,

I tried to mesh annulus with different number of nodes on the inner radius:

real r1 = 1.0;
real r2 = 1.3;
border outter(t = 0, pi / 2.){x = r2 * cos(t); y = r2 * sin(t); label=1;}
border inner(t = 0, pi / 2.){x = r1 * cos(t); y = r1 * sin(t); label=2;}
border left(t = 0, 1){x = 0; y = r1 + (r2 - r1) * t; label=3;}
border bottom(t = 0, 1){x = r1 + (r2 - r1) * t; y = 0; label=4;}
mesh Th = buildmesh(left(30) + outter(50) + bottom(30) + inner(30));
if (makePlot) {
    plot(Th, wait=1, cmm="Initial mesh");
}

But this does not work for some reason.

The expected result is something like this:

Sorry, I cannot write full functional example. but I hope this will help

// TT : the mesh
// Rrad : ring radii [Rout,Rin]
// Aangle : angular sector (in units of pi)
// npts : the nb of points on the perimeter
// labs : array of labels of segments of the boundary
// labs[0] : outter disk border
// labs[1] : inner disk border
// labs[2] : axis 1
// labs[3] : axis 2
real LCout=Aangle*pi*Rrad[0], LCin=Aangle*pi*Rrad[1], LZ=Rrad[0]-Rrad[1];
int CptsIn= int(npts*LCin/(LCin+LCout+2*LZ)); // pts on the circle-axis sides
int CptsOut= int(npts*LCout/(LCin+LCout+2*LZ)); // pts on the circle-axis sides
int Zpts= int(npts*LZ/(LCin+LCout+2*LZ)); // pts on the z-axis sides
border circleOut (t=0.0,Aangle*pi){
x=Rrad[0]*cos(t);
y=Rrad[0]*sin(t);
label = labs[0];}
border circleIn (t=Aangle*pi,0){
x=Rrad[1]*cos(t);
y=Rrad[1]*sin(t);
label = labs[1];}
border axis1 (t=Rrad[0],Rrad[1]){
x=t*cos(Aangle*pi);
y=t*sin(Aangle*pi);label = labs[2];}
border axis2 (t=Rrad[1],Rrad[0]){x=t;y=0;label = labs[3];}
TT=buildmesh(circleOut(CptsOut)+axis1(Zpts)+circleIn(CptsIn)+axis2(Zpts));

1 Like

Simply change your mesh definition to this and it works.

mesh Th = buildmesh(left(-30) + outter(50) + bottom(30) + inner(-30)); // notice the - signs
1 Like