Error using MMG3D_Set_localParameter


Initially I will explain briefly what I am trying to do. Suppose I have a volume (terrain) as shown in the figure 1, when I try to remesh it considering a metric based on the distance of some buildings (set of triangles), apart from remeshing in that area, I generate smaller elements between the edges of the contour faces (see second figure), to avoid this, we generate a list of local parameters with their specific properties ie maximum and minimum size and its corresponding local haussdorff values.

Figure 1

Figure 2

Before updating mmg everything worked fine but after updating I get this error.

MMG3D_Set_localParameter: You must set the number of local parameters with the MMG3D_Set_iparameters function before setting values in local parameters structure.

I understand that something has changed in the library, and that I am giving the wrong input to the method. Could you help me with this?


In my understanding, this message is telling that, before calling MMG3D_Set_localParameter on a specific boundary, Mmg needs to know how many boundaries with custom parameters you want to set. This means that before calling MMG3D_Set_localParameter you need to do a call like:

MMG3D_Set_iparameter( mesh, sol, MMG3D_IPARAM_numberOfLocalParam, nparam )

with nparam = the number of boundaries on which you impose local parameters (you can check the syntax of API functions and all the MMG3D_*PARAM* parameters in libmmg3d.h).

Anyway, I have the feeling that this behaviour is not new, like I have used it for years… Can you specify what versions of Mmg are you using (before and after the problem)?

Hope this helps!

Thanks for the help.
I know that the error is telling that I need to set the number of local parameters but MMG3D_Set_iparameter( mesh, sol, MMG3D_IPARAM_numberOfLocalParam, nparam ) it is been called before setting the local parameters, that is why I don’t understand why it is happenning.
If it is well for you I will insert here two links:

This solution as I told you previously was working fine with this version of mmg commit cf9bb59920584cf015a8262de2014392b75f92e5 (15 Oct 2021) and the problems appear when I use this version of mmg commit adf56d607e5d3f36a7b392c5e4996a32346fb3f5 (Dec 19 18:11:38 2022 )

I hope everything is clear and once again thanks for your help and time
Best regards

Thank you very much for the clarification, I was missing a bit of context :slight_smile:
I will have a look at the pull request and the code changes, and come back to you if I need to reproduce the problem by running Kratos+Mmg in a debugger.


Sorry for the late reply.
I have had a look at the Mmg code, and I don’t see any functional changes that could explain the issue.
There have been a change in the Mmg integer datatype and some changes in the headers path, but I can’t say if the issue comes from these without debugging the case.

What I can suggest to do is to attach a debugger like gdb , and to put a breakpoint in the MMG3D_Set_iparameter function around line 2219 in src/mmg3d/API_functions_3d.c to inspect the value of the mesh->info.npar variable (which is the one counting the number of local parameters you are setting). If the variable still looks fine, I would put a watchpoint on it to check if it is changed before it is used by MMG3D_Set_localParameter at line 2435.

If you could share the test case related to the Kratos pull request 10087 and the instruction to run it, I could recompile and try to help in debugging it.


For future reference, the problem appeared to be due to an unlucky mixing of old and new library headers (that do change a bit with the new Mmg version), and it has been solved with a complete reinstallation :tada: .