Use MMG3D_mmg3dlib() mmgMesh output as MMG3D_mmg3dls() input

Hi Algiane,

I am using MMG3D_mmg3dls(mmgMesh, mmgLs, NULL) to obtain my level set discretization. Prior to this I am using MMG3D_mmg3dlib(mmgMesh, mmgMet) to remesh the initial mesh based on parameters derived from my level set functions that ensure the mesh is of an adequate size, i.e. that it can accurately capture the level set but is at the same time not finer than necessary to avoid unnecessary slowdown. If use an intermediate mmgMeshB created by either copying the data or loading it from a temporary .mesh file it all works. However, I would prefer to be able to reuse the mmgMesh I get from MMG3D_mmg3dlib() right away when I call MMG3D_mmg3dls(). Just giving MMG3D_mmg3dls() the mmgMesh I get from MMG3D_mmg3dlib() results in the following error:
## Problem in setting boundary. Exit program.
BAD ENDING OF MMG3DLS: UNABLE TO SAVE MESH

My guess is that this is because I need to reset some stuff in mmgMesh. I considered trying to reset stuff manually myself to see if I can get it to work but figured it’s probably a very bad idea since as mmg continues developing such a dirty fix will surely break at some point (and there is probably a better way). If this is indeed the problem what the best way for me to ‘reset’ the necessary stuff in mmgMesh? and if its not this, perhaps you can point me to what the problem is.

Another problem I expect I will get, since I saw something mentioned about it in one of the examples, and am not sure how to deal with, is that I have not set MMG3D_Set_iparameter(mmgMesh,mmgLs,MMG3D_IPARAM_iso, 1) != 1 ) prior to loading the mesh as it is first used by MMG3D_mmg3dlib(). Or maybe this is actually whats causing my problem?

Hopefully you can help me out.

Regards,
K

Hello Karl,

You are guessing right, there are some boundary entities that are not freed (internally, by mmg) when entering the new call to mmg3dls. This is not related to the value of MMG3D_IPARAM_iso, that needs to be set to 1 only for MMG3D_mmg3dls() to recognize your variable mmgLs as a level-set function.

I am testing a solution to free those entities internally, without bothering the user. We will write you back soon.

Yours,
Luca

P.S. Sorry for the late reply, due to summer holidays we can only guarantee limited user support until August 15th.

Hi Luca,

Thanks for the reply. I look forward to the solution!

Regards,
K

Hello Karl,

You can start testing it from this branch https://github.com/MmgTools/mmg/tree/hotfix/mmgd3ls-restart while we wait for Algiane’s opinion to merge it into develop.

Please do not hesitate to come back to us if it still gives you problems!

Yours,
Luca

Dear Luca,

Thanks for the fast fix! I have just been trying it out and while now it does finish and I get an output that does looks optically fine I am getting the following error after phase 3 of the call to MMG3D_mmg3dls() is completed, that is to say phase 3 of the second time I use my mmgMesh.

Error: MMG5_defsizreg: at least 1 wrong point qualification : xp ? 0.

Hopefully you can shed some light on the issue.

Regards,
K

Hi Karl,

I have pushed a new commit in the hotfix/mmgd3ls-restart branch (f595a0cc). I think that it will solve this second issue: Is it possible to test it?

To complete Luca’s answer to your initial question, the setting of the MMG3D_IPARAM_iso parameter is not needed inside the mmg3dls function (because this function is dedicated to the level-set mode so Mmg don’t need any parameter to know that we are in level-set mode) but it may be needed by other functions that can be called from another mode (such as adaptation) to perform a specific treatment in level-set case: for now I think that it concerns mainly the loadMesh function (because old domains must be deleted only in level-set mode).

I hope that everything will work now.

Regards,
Algiane

Hi Algiane,

I have just tested it and I don’t get the error anymore. I have ,however, noticed that I am getting the following notices in the Phase 3 output which I don’t get when I use an intermediate mmgMesh:
*** 487 tetras with at least 2 boundary faces.
*** 1133 internal edges connecting boundary points.

Regards,
K

P.S.: I checked and these notices are also present before the hotfix.

Hi Karl,

You are right, this was due to another internal value that needs to be resetted between two library call. Sorry for that! It must be fixed by the last commit (fc0ce5a).

Regards,
Algiane

Hi Algiane,

Just tested it and it seems its working similar to when I was using the intermediate mmgMesh.

Thanks so much to both of you!

Regards,
K

Thank you for your feedback: the correction is merged in the develop branch now!

Regards,
Algiane