Surface reference values

Dear developers,

When meshing an implicit domain MMG will give the isosurface the reference value 10 and the surfaces not belonging to the isosurface the reference value 1. Is there some way to split the surface not belonging to the isosurface based on the sharp edges and assign each resulting region a different reference value when using MMG as a library? For example, if we would have a cube with some isosurface inside it, the isosurface would have the reference value 10 and each of the sides of the cube would have their own different reference instead of the collective value of 1 it has by default.

Kind regards,
K

Hi @Karl ,

It is not possible with one run of Mmg but maybe you can try the following hack (it depends on how much your process has to be automatic and fast and if you need specific references for the surface domains):

  • discretize your level-set as usually using Mmg;
  • remove triangles in the resulting mesh:
    • using library mode it is sufficient to not call the MMG3D_Get_triangle function;
    • using files I/O you can prepend a 0 to the number of triangles. I attach an example of the diff for a file that contains 3088 triangles.
< 3088
---
> 0 3088
  • then you can run again Mmg in analysis mode (-noinsert -noswap -nomove): Mmg will creates the missing boundaries and each triangle will be assign the reference of the tetra that holds the triangle;

Please, let me know if it can work in your workflow.

Best Regards,
Algiane

Dear @Algiane,

Won’t that lead to all faces having the same reference given that all tetras in contact with the surface have the same reference? Or am I missing something?

Kind regards,
K

P.S.: The process needs to be automatic but speed is not critical nor do I require a specific reference, as long as they are different for each section.

Hi,

Sorry, I have totally misread the initial message :sweat_smile: !

It is a pretty specific needs so Mmg don’t allow to do this but with a small knowledge of the internal data structures of Mmg it is pretty easy to implement. I attach a patch (color-assignment.patch (2.5 KB))
that should do the job.

You can apply it to master branch with: git apply color-assignment.patch.

To add an easy way (with no implementation) to enable or disable the surface coloring I have used the MMG_COLOR_SURFAREA environment variable.
By default, surface coloring is disabled, if you export the variable with export MMG_COLOR_SURFAREA=1, surface area are colored. You can unexport the variable using: unset MMG_COLOR_SURFAREA.

I hope that it is a better answer :joy: .
Best

Dear @Algiane,

No worries, good to see I am not the only one to whom this happens on occasion. :rofl:

It works beautifully, thank you so much!!!

Kind regards,
K