Saving single subdomain to mesh file (mmg3d)

Hi all,

I have used mmg3dls() in order to obtain a mesh divided in sub-domains. I would like to separate the regions in the resulting mesh for saving and have seen that when using mmg2d as an application a simple tag allows to select the sub-domain to export. I have not been able to find anything like this in the 3d version. I have looked into using the MMG3D_Get_tetrahedron() to manually create the mesh file but this becomes a bit cumbersome quite fast since I have not found a way to automatically also get all the corresponding vertices and triangle information for the selected sub-domain. Is there perhaps a build in way to accomplish this like for mmg2d that I have missed? and if not, is there a better way to accomplish this than doing it manually?

Regards,
Karl

Hi Karl,

There is no easy way for now to save only a given subdomain in 3D.

In fact it is also difficult in 2D because the option you found (-nsd in command line or MMG2D_IPARAM_numsubdomain using the API functions) is available only for the mesh generation mode.

I agree with you that it can be useful to save only one given domain so I will try to clean this option and to extend it to the 3 codes and to the different modes of Mmg (adaptation, isovalue discretization, etc.).
I keep you aware of the implementation state.

Regards,
Algiane

Hi Algiane,

Thanks for your reply! I look forward to the future implementation of this option and will go for the less easy approach in the mean time.

Regards,
Karl

Hi Karl,

I have merged the possibility to save only one subdomain in the develop branch (commit 8aaca). You can activate this option using the -nsd <idx> argument in command line (where must be replace by the index of the domain that you want to save) or by the call to the API function:

MMG3D_Set_iparameter(mesh,met,MMG3D_IPARAM_numsubdomain,<idx>)

Note that the subdomain extraction is post-processed so you can probably improve the quality of your output mesh if you run Mmg3d in optimization mode on it (because you don’t have anymore the constraints of the domains that have been removed).

Regards,

Algiane

Hi Algiane,

It works like a charm. Thank you so much!

I have a question though. I think using the Set_iparameter to select your domain you are basically committing to that one domain and you lose access to the other. Or is there a way to change the domain to another one afterwards if you are interested in both domains but you need save them separately for example.

Regards,
Karl

Hi Karl,

You are right, once selected, this option deletes the spurious domains to keep only the wanted one (so you can’t get back the deleted domains).

For now, the only way to keep access to all the domains is:

  1. to run Mmg without selecting a given domain (in your case, in ls mode): your output mesh will contains multiple domains.
  2. to run Mmg in analysis mode (-noinsert -noswap -nomove options) and with subdomain selection (-nsd <idx>) to get the wanted subdomain. As soon as you preserve the output mesh of the first step, you can run Mmg on it to select various subdomains.

It is less convenient in API mode but you can do something similar:

  1. call the wanted mmg library;
  2. copy the resulting mesh in a new one (I recognize that this step is tedious);
  3. call the MMG3D_mmg3dlib function in analysis mode and with the wanted subdomain preservation to obtain your new mesh. Again, if you want to get different subdomains, you must preserve the output mesh of the step 1 and repeat the steps 2 and 3 on that mesh.

I attach a C example (8.4 KB). The part domain selection without remeshing shows how to copy a mesh in another one and how to run Mmg in analysis mode to preserve only a given subdomain.

I will add to the todo list to create API functions allowing to get the mesh by subdomain without the preservation of the entire mesh but it will not be done in the coming months.

Regards,
Algiane

Hi Algiane,

Thanks again, that gets the job done!

Regards,
K