Number of elements different from what is imposed with buildmesh

Hello,
I am doing a simple simulation on a domain with 2 triangular elements. Unfortunately I noticed that the build mesh command sometimes creates 4 triangular elements.
For example I did this

real l =40;
real h =3;
int nelx=1;
int nely=1;

mesh ThRef = square(nelx,nely,[l*x,h*y]);

border c01(t=0,1){x=l*t;y=0;label=1001;};
border c02(t=0,1){x=l;y=h*t;label=1002;};
border c03(t=0,1){x=l*t;y=h;label=1003;};
border c04(t=0,1){x=0;y=h*t;label=1004;};

mesh ThCompar = buildmesh(c01(nelx)+c02(nely)+c03(-nelx)+c04(-nely));

plot(ThRef, wait =1 , cmm ="Square");
plot(ThCompar, wait =1 , cmm ="buildmesh");

Here the square mesh is built with 2 elements but not the buildmesh mesh. Is there a command or parameter that buildmesh takes to force it to have 2 elements?

In the buildmesh command you can set fixeborder=true so that FreeFem will not change the border.
Otherwise if you want to fix everything you can define the mesh by a file and read it with readmesh.

1 Like

Thank you for your reply