Memory fault using mmgls

Hello everyone,
I have been using mmgls as part of a FEM. Each time step I use the level set function provided by mmgls (5.5.2 - tried the develop branch too) but I find that sometimes I get the following error when calling mmgls using the API:

mmg3d/tools_3d.c:552: MMG5_BezierNom: Assertion `( p0->tag & MG_NOM ) && ( p1->tag & MG_NOM )’ failed.

Unexpected error: *** potential lack of memory.

I have provided two examples in attached zip file along with a .F90 script which tests the levelset function using the same parameters as set in the model. I often avoid the error when testing it like this by changing the Hausdorff distance but since I cannot do this when using the FEM, I was wondering if there was a more robust solution. Additionally, is it possible to handle such errors in mmg with an error output so an exception can be written to save the model falling over?

mmgexamples.zip (282.7 KB)

Thanks in advance for any help!

Iain

Hi lain,

I am looking at your bug to understand what happens.

Your test case is difficult to remesh because you discretize a level-set almost merged with the mesh bounding box and you ask for a coarse mesh size. The remesher must be very robust to avoid topological errors when remeshing such meshes (the robustification of the level-set discretization mode is a work in progress but it asks lot of time…).

As we don’t know the physical meanings of your level-set in Mmg we can’t choose to merge or shift it but if you can do this job in your application it will greatly help Mmg.

Regarding the error handling, you can build Mmg in Release mode to avoid the assertion calls. In this case, Mmg should return “MMG5_SUCCESS” if it success, “MMG5_LOWFAILURE” if it fails but your mesh is likely conformal, “MMG5_STRONGFAILURE” if it fails and the output mesh can’t be use.

I will keep you aware if I find how to fix the issue arising on your test case.

Regards,
Algiane

Hi Algiane,

Thanks for your feedback. I understand that the remeshing and level set implementation is always going to have slight issues, particularly with difficult geometries. Once I’d built mmg in release mode I find I can solve most of the issues by implementing an exception to alter Hmin, Haus etc. within the FEM for that particular time step.

Best,
Iain