# Limit the number of elements/nodes when refining a mesh using mmg3d

**URL:** <https://community.freefem.org/t/limit-the-number-of-elements-nodes-when-refining-a-mesh-using-mmg3d/3066>\
**Category:** General Discussion\
**Created:** [March 26, 2024, 6:13am UTC](https://community.freefem.org/t/limit-the-number-of-elements-nodes-when-refining-a-mesh-using-mmg3d/3066 "2024-03-26T06:13:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jacoban90](https://avatars.discourse-cdn.com/v4/letter/j/65b543/32.png) [@Jacoban90](https://community.freefem.org/u/Jacoban90)\
**Post date:** [March 26, 2024, 6:13am UTC](https://community.freefem.org/t/limit-the-number-of-elements-nodes-when-refining-a-mesh-using-mmg3d/3066/1 "2024-03-26T06:13:31Z")

</div>

Hello everyone,

I am trying to define an adaptative 3d mesh by using mmg3d based on a level set function phi. The results obtained are smoother compared with tetgenreconstruction.

length = max(hmin, min(hmax,abs(phi)));  
Tht = mmg3d(Tht, metric = length);

However i ended up obtaining a mesh with too many elements to handle it locally on my computer, and i want that this not surpasses a predefined amount of elements. For this reason, is it possible to define a restriction in the resulting mesh similar to nbvx in adaptmesh?

Thank you very much in advance.  
Regards  
Jacob

---

<div class="post-metadata">

**Author:** ![frederichecht](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/frederichecht/32/15_2.png) [@frederichecht](https://community.freefem.org/u/frederichecht)\
**Post date:** [March 28, 2024, 7:21pm UTC](https://community.freefem.org/t/limit-the-number-of-elements-nodes-when-refining-a-mesh-using-mmg3d/3066/2 "2024-03-28T19:21:42Z")

</div>

The number of node are proportional the length ,  
so multiyply length by a constant, to get the correcte number!.

---

<div class="post-metadata">

**Author:** ![Jacoban90](https://avatars.discourse-cdn.com/v4/letter/j/65b543/32.png) [@Jacoban90](https://community.freefem.org/u/Jacoban90)\
**Post date:** [April 11, 2024, 7:39am UTC](https://community.freefem.org/t/limit-the-number-of-elements-nodes-when-refining-a-mesh-using-mmg3d/3066/3 "2024-04-11T07:39:58Z")

</div>

Dear Professor Hecht,

Thank you very much for your prompt and helpful response. The suggestion to adjust the length by multiplying it with a constant is exactly what I was looking for. Now, I can scale the mesh size to fit the computational capabilities of my PC. I appreciate your guidance on this matter.

Best regards, Jacob

---

<div class="post-metadata">

**Author:** ![frederichecht](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/frederichecht/32/15_2.png) [@frederichecht](https://community.freefem.org/u/frederichecht)\
**Post date:** [April 16, 2024, 2:34pm UTC](https://community.freefem.org/t/limit-the-number-of-elements-nodes-when-refining-a-mesh-using-mmg3d/3066/4 "2024-04-16T14:34:23Z")

</div>

The number of node is proportional to (metric)^-1/2 to the so if you multi  
multi metric by c the number of vertices are of order 1/c^2 , this this rule you can build a mesh with the good number of node.
