Removing only positive or negative parasitic components

Dear developers,

I have been using the option MMG3D_DPARAM_rmc to remove parasitic components when using MMG3D as a library. Now I am facing a case where I would like to only remove positive or negative parasitic bubbles, but not both. Is this possible? I searched but found nothing about this posibility.

Kind regards,
Karl

Dear Karl,
You have guessed it right, for the moment it is only possible to remove both parasitic components.
Is the removal of only one parasitic component something you would use for a lot of applications? (It could be taken into consideration for a future roadmap).

Kind regards,
Luca

Dear Luca,

At the moment it would be only for one application, but it would remove the need to post-process manually every time I create a mesh with it. So it would be handy for me. Especially if I could not only chose to provide the parameter for one of them, but I could also chose to set both to different values, for example remove positive bubbles for a value =< 1e-5 and negative bubbles for a value =< 1e-3, just to say something. But it’s not like its critical.

I had a quick look at the source code and found that removal of bubbles takes place in function MMG3D_rmc(MMG5_pMesh mesh, MMG5_pSol sol). From wat I saw you seem to consider positive and negative bubbles separately. So I will see if for now I can solve this by commenting out the section that processes the bubbles I don’t want removed. It’s not a pretty solution but if it works for now, I am happy.

Kind regards,
K

Dear Karl,
Yes, it can be cumbersome to provide two different command line parameters for all users if this application remains rare, but changing the MMG3D_rmc is definitely the way to deal with it. Now this function processes the two types of bubbles separately in two loops, but uses the same mesh->info.rmc value on both. Changing this value in one of the two loops would do the trick.

If you change these values often, I can show you how to read two mesh->info.rmc parameters from command line or library, or provide you a patch.

Kind regards,
Luca

Dear Luca,

As it may vary every now and then it may indeed be more convenient if I can pass on two mesh->info.rmc parameters. But I am more than happy to implement the change myself if you can show me how to (I use it as a library).

Kind regards,
K

Dear Karl,
It is quite straightforward to implement a new argument, but there are a few steps to be followed:

  1. In the structure MMG5_Info, create a variable for your new argument (for example rmc1) here: https://github.com/MmgTools/mmg/blob/583b835071c6db360145bf5e49467d0f9f206244/src/common/libmmgtypes.h#L477.
  2. Create a parameter for you new argument (for example MMG3D_PARAM_rmc1) to be added here https://github.com/MmgTools/mmg/blob/583b835071c6db360145bf5e49467d0f9f206244/src/mmg3d/libmmg3d.h#L100.
  3. In the function MMG3D_Set_dparameter add the handling of your new argument like here https://github.com/MmgTools/mmg/blob/583b835071c6db360145bf5e49467d0f9f206244/src/mmg3d/API_functions_3d.c#L2387.
  4. In the function MMG3D_parsar add the reading of the new argoment -rmc1 as it is done here https://github.com/MmgTools/mmg/blob/583b835071c6db360145bf5e49467d0f9f206244/src/mmg3d/libmmg3d_tools.c#L411 (it calls MMG3D_Set_dparameter).

(Steps 2 to 4 are to be repeated also for Mmg2d and Mmgs if needed.)

Let me know if it works or if I skipped something!

Yours,
Luca

Dear Luca,

Just tried it and it works perfectly. Thanks you very much!

For the sake of completeness, in case someone else wants to control the removal of small positive and negative parasitic components individually, the last steps would be:

  1. In the function MMG3D_rmc replace info.rmc by info.rmc1 for either the positive connected components https://github.com/MmgTools/mmg/blob/583b835071c6db360145bf5e49467d0f9f206244/src/mmg3d/mmg3d2.c#L864 or the negative connected components https://github.com/MmgTools/mmg/blob/583b835071c6db360145bf5e49467d0f9f206244/src/mmg3d/mmg3d2.c#L945. Don’t change it for both!

  2. In the function MMG3D_mmg3d2 include the new argument rmc1 when checking if there was an error in the removal of small parasitic components. https://github.com/MmgTools/mmg/blob/583b835071c6db360145bf5e49467d0f9f206244/src/mmg3d/mmg3d2.c#L2239

Thanks again Luca,
K

1 Like