Preservation of Mesh surface during implicit meshing

Hello mmg community,

First of all, thank you so much for all your efforts rendering the task of creating complex geometries soooo easy!!
I have a question regarding implicit meshing, that hopefully you can help me with. I am trying to implement 3D shape optimization for inverse homogenization using FreeFem++, By nature of the application, I have to use 3d periodic FE spaces in a cube with FreeFem++, and FreeFem’s constraint is that for us to be able to define periodic boundary conditions ont two given faces, these faces must be absolutely identical. My first attempt was to use a fixed cubic mesh, and do shape optimization with a level set to define my interface (inclusion of two crossing cylinders inside the cubic cell), but the results are not so accurate.
I would like to try and mesh my interface better using mesh evolution, and it seems the only obstacle is to make sure mmg will only remesh the interior of my domain, and leave the cube surfaces unchanged, or ideally, if we were to split two identical cube surfaces with respect to two identical inclusions (a disk), we get two identical remeshed surfaces.
Thank you in advance for any help or explanation you can point me to.
Sincerly your,

Hi @Salah ,

Thank your for using Mmg!

  • If your level-set don’t intersect the bounding box faces, you can ask Mmg to not remesh some entities by specifying its as required. In your case, you will have to provide the list of triangles that belongs to the periodic boundaries as required (see this post for how to do that using Mmg). I am not a FreeFem++ expert but it seems that it exposes a way to set directly all triangles of a given reference as required using the “requiredTriangle” option (see this example).

  • if your level-set intersect the bounding box, there is no simple way to obtain the same mesh on both periodic BC. If the walls are required (as in the previous explanation), only the triangles splitted by the level-set will be modified (so you will have a bad quality mesh) but you will have no guarantee that they will be splitted in the same way on both boundaries. To decide the splitting pattern that we apply (when two patterns can be applied), we use the global numbering of nodes. Thus, if the order of the numbering of the nodes along the two matching periodic boundaries are the same, I think that you will have the same mesh on both walls (but I am not sure as I have not tested). Note that, even in this case, the triangles must stay required as it will forbid boundary modifications due to the volume remeshing.

I hope that it will help a little,

Best Regards,

Thank you so much for the quick reply. In my applications I consider both cases for the interface, I am working with mmg in library mode, and just to make sure I understood, given a list of surface triangles, I can maybe do a loop to tell mmg these triangles are required and this will ensure my periodic spaces will remain well defined during every iteration of the optimization process … I believe this solves it for the case of the interface not intersecting the box faces.

For the second case, I guess I’ll have to settle for a fixed mesh optimization.

Thank you so much for your help Algiane ^^


If you use Mmg in library mode, setting the required triangles inside a loop (with the MMG3D_Set_requiredTriangle) is the easiest thing to do. If you manage very large meshes, you can also provide an array that contains the list of indices of the triangles that should be required and call only once the MMG3D_Set_requiredTriangles (with a s) function.
It should solve the case where the interface don’t intersect the box yes!

Have a nice day,

Good morning Algiane,

I confirm that this method works and it solved the case of non touching interface!! I ended up adapting everything to work on FreeFem, as the requiredTriangle option of mmg3d takes in as argument the surface label and sets all of the surface triangles to required … works like a charm on every iteration! Thanks again for the precious help, the next time you drop by the LMAP in Pau, gratitude coffee is on me.

Best regards,

Thanks for the feedback,

I will not forget for the coffee ;-).