# Number of elements different from what is imposed with buildmesh

**URL:** <https://community.freefem.org/t/number-of-elements-different-from-what-is-imposed-with-buildmesh/3593>\
**Category:** General Discussion\
**Created:** [November 22, 2024, 2:40pm UTC](https://community.freefem.org/t/number-of-elements-different-from-what-is-imposed-with-buildmesh/3593 "2024-11-22T14:40:43Z")\
**Posts on this page:** 3\
**Page:** 1

<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:** [November 22, 2024, 2:40pm UTC](https://community.freefem.org/t/number-of-elements-different-from-what-is-imposed-with-buildmesh/3593/1 "2024-11-22T14:40:43Z")

</div>

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

```auto
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?

---

<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:** [November 22, 2024, 4:02pm UTC](https://community.freefem.org/t/number-of-elements-different-from-what-is-imposed-with-buildmesh/3593/2 "2024-11-22T16:02:52Z")

</div>

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`.

---

<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:** [November 25, 2024, 8:11am UTC](https://community.freefem.org/t/number-of-elements-different-from-what-is-imposed-with-buildmesh/3593/3 "2024-11-25T08:11:43Z")

</div>

Thank you for your reply
