# Local mesh refinement

**URL:** <https://forum.mmgtools.org/t/local-mesh-refinement/667>\
**Category:** User Help\
**Created:** [October 17, 2022, 5:04am UTC](https://forum.mmgtools.org/t/local-mesh-refinement/667 "2022-10-17T05:04:40Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![alexgh1993](https://forum.mmgtools.org/user_avatar/forum.mmgtools.org/alexgh1993/32/494_2.png) [@alexgh1993](https://forum.mmgtools.org/u/alexgh1993)\
**Post date:** [October 17, 2022, 5:04am UTC](https://forum.mmgtools.org/t/local-mesh-refinement/667/1 "2022-10-17T05:04:40Z")

</div>

Hello! I use mmgs to solve strength problems. I need to refine the mesh in the high stress zone. Can I apply the size map to only some nodes? At the same time, let mmgs find the metric in other nodes according to -hgrad and -hausd parameters.

---

<div class="post-metadata">

**Author:** ![Algiane](https://forum.mmgtools.org/user_avatar/forum.mmgtools.org/algiane/32/30_2.png) [@Algiane](https://forum.mmgtools.org/u/Algiane)\
**Post date:** [October 17, 2022, 7:22am UTC](https://forum.mmgtools.org/t/local-mesh-refinement/667/2 "2022-10-17T07:22:39Z")

</div>

Hello,

It is not possible to do that natively but using the library you can :

- call the `MMG\_doSol function to let Mmg compute the size map;
- travel your vertices to overwrite the value setted by Mmg at wanted nodes (using the `MMG<X>_Set_scalarSol` API function).
- call the `MMG<X>_mmg<x>lib` function to trigger the mesh adaptation process.

Best regards,  
Algiane

---

<div class="post-metadata">

**Author:** ![alexgh1993](https://forum.mmgtools.org/user_avatar/forum.mmgtools.org/alexgh1993/32/494_2.png) [@alexgh1993](https://forum.mmgtools.org/u/alexgh1993)\
**Post date:** [October 17, 2022, 8:43am UTC](https://forum.mmgtools.org/t/local-mesh-refinement/667/3 "2022-10-17T08:43:50Z")

</div>

Thank you for the quick response! Is it possible to do the same thing by running mmgs\_O3.exe with command line parameters?

---

<div class="post-metadata">

**Author:** ![Algiane](https://forum.mmgtools.org/user_avatar/forum.mmgtools.org/algiane/32/30_2.png) [@Algiane](https://forum.mmgtools.org/u/Algiane)\
**Post date:** [October 17, 2022, 9:01am UTC](https://forum.mmgtools.org/t/local-mesh-refinement/667/4 "2022-10-17T09:01:17Z")

</div>

No, it is not possible using command line, sorry.

---

<div class="post-metadata">

**Author:** ![alexgh1993](https://forum.mmgtools.org/user_avatar/forum.mmgtools.org/alexgh1993/32/494_2.png) [@alexgh1993](https://forum.mmgtools.org/u/alexgh1993)\
**Post date:** [October 17, 2022, 11:01am UTC](https://forum.mmgtools.org/t/local-mesh-refinement/667/5 "2022-10-17T11:01:08Z")

</div>

What if do this:

1. Fix the mesh vertices before rebuilding the mesh in mmgs
2. Run mmgs and get sol file with fixed vertices
3. Find old fixed vertices by coordinates in the sol file
4. Change the metric for given vertices

Is it possible to fix vertices in a mesh file? Like “RequiredTriangles” for example.

---

<div class="post-metadata">

**Author:** ![Algiane](https://forum.mmgtools.org/user_avatar/forum.mmgtools.org/algiane/32/30_2.png) [@Algiane](https://forum.mmgtools.org/u/Algiane)\
**Post date:** [October 18, 2022, 8:54am UTC](https://forum.mmgtools.org/t/local-mesh-refinement/667/6 "2022-10-18T08:54:51Z")

</div>

Hi,

You can use the `RequiredVertices` keyword to fix vertices.

Beside, I am not sure if it is needed to fix it : you can run mmgs without authorizing the remeshing operators (only analysis and size map computation is performed) with `-noinsert -noswap -nomove` command line arguments. So I think that your process can be changed by:

1. Run mmgs in analysis mode : `mmgs -noinsert -noswap -nomove ...`
2. Change the output metric in the saved `.sol` file for given vertices.

I hope that it will help,  
Regards,  
Algiane

---

<div class="post-metadata">

**Author:** ![alexgh1993](https://forum.mmgtools.org/user_avatar/forum.mmgtools.org/alexgh1993/32/494_2.png) [@alexgh1993](https://forum.mmgtools.org/u/alexgh1993)\
**Post date:** [November 5, 2022, 10:00am UTC](https://forum.mmgtools.org/t/local-mesh-refinement/667/7 "2022-11-05T10:00:33Z")

</div>

Thank you! It really helped.
