How to keep original region label after MMG update

Dear developers,

I met a problem when using MMG2d/3d to update mesh based on the level set function.

My original mesh contains 3 regions, with different region labels, as below:

Then I use the following command line to update the mesh based on the level set function:
mmg2d_O3 ./LvSet.mesh -sol ./LvSet.sol -ls -nr -hmax 8.0e-3 -hmin 5.0e-3

After that I checked the region label again, and found that the mesh was merged into a big region, as below:

So, would it be possible to keep the original region label after MMG2d/3d?

I uploaded the original mesh, and level set solution file. Please check.

Sincerely yours,
HaoLvSet.mesh (237.2 KB) LvSet.sol (12.0 KB)


By default Mmg erases the input regions to create the 2 new regions defined by the level-set (this new regions are labelled with references 2 and 3).

In 2D, the develop branch of Mmg allows to provide to Mmg an additional file (of same basename than the mesh but with .mmg2d extension) that contains the input references and their mapping on two new references (it is not yet implemented in 3D and the API aren’t available but it is planned for the end of the year). I detail here how is made the LvSet.mmg2d (37 Bytes) file and I attach it so you can directly test the reference mapping:

10 11 10
4 5 4
0 1 0
  • LSReferences means that we will define the reference mapping during the level-set discretization;
  • 3 is the number of input references for which we provide a mapping;
  • 10 11 10 means that the domain 10 become the domains 11 and 10 if splitted by the level-set (to map the reference 10 onto 11 and 12 we must write 10 11 12);
  • 4 5 4 means that the domain 4 become the domains 5 and 4;
  • 0 1 0 means that the domain 0 become the domains 1 and 0;
  • Note that you can also ask to not split a given domain even if it is intersected by the level-set: 10 nosplit forbid the splitting of the domain 10.

I hope that it will be sufficient for your current needs.


question. Does this only affect to the develop branch?

Yes, I think that it works, but I was not sure that the master version is fully up to date (but it seems).


Therefore I will need to update the implementation…

Dear Algiane,

Thanks for your very helpful note, I have tested your reference mapping, and it works well. Now the new mesh (after MMG2D) has kept the original region number, as below:

May I confirm with you about LSReferences?
4 5 4 means that domain 4 become domains 5 and 4;
0 1 0 means that domain 0 becomes domains 1 and 0;

And I check the region label and found that domain 4 and 0 remain 4 and 0. There is no domain 5 and 1.
Is this because the domain 4 and 0 are not splitted by the level set?

And we are looking forward to the latest version at the end of the year. We hope this feature will be available in MMG3D, together with MM3D parallelization.

Best regards,


Yes, the line 4 5 4 means that if the ref 4 is splitted by the level-set, the negative part of the level-set becomes the ref 5, the positive one the ref 4.

A small remark: the first release of the parallel library will only provide parallel mesh adaptation and only inside the volume (ther is some additionnal work to do for the surfacic interpolation and the parallel analysis of geometric feature). Once the parallel surface remeshing will be ready, adding the level-set discretization will be very easy.



If you can wait few weeks we plan a release for December (before the Mmg day).


Dear Algiane,

Thanks for your answer and small remark. Sure, we are waiting to hearing from you.

Best regards,