Keep region attribute?

Hello mmg community,

In both .mesh and .msh file format supported by mmg, it is possible to define an attribute per element (for instance a region, each cells which belong to the same region will have the same attribute.)

I was wondering if somehow, it is possible to keep this attribute during the remeshing process ?

Thanks in advance,


Hi Antoine,

Yes, this attributes (references in Medit vocabulary or tags in Gmsh one) are normally preserved during the remeshing process. In the case of .msh files we preserve only the physical tag and not the geometrical one (because the geometrical tag is only linked with the way the mesh has been built).

Do not hesitate if you need more help.



Thanks Algiane,

I was looking the code and I was also wondering which data member of MMG5_Tetra (for instance ) should I set if I use the C API of mmg ?

Hi Antoine,

Using the Mmg API allows you to ignore the internal Mmg structures (such as the MMG5_Tetra one) and allows us to modify this data without impacting our users.

The prototypes of the API functions (C and Fortran) are available in the libmmg3d.h, libmmg2d.h and libmmgs.h files.

For example:
I suppose that I have a mesh in which the tetra number 4 has for vertices the points number 1, 5, 3 and 8. This tetra belongs to a domain of attribute 2 (i.e. the reference associated to the tetra is 2).
I can provide this tetra to Mmg with the following API call :

 MMG3D_Set_tetrahedron(mesh,  1,  5,  3,  8, 2, 4);

The first argument is the Mmg mesh (of type MMG5_pMesh), the 4 next arguments are the tetra connectivity, the next one, the tetra reference and the last one the tetra position in the mesh.

Internally, it fills:

  • the mesh->tetra[4].v array by the tetra connectivity;
  • the mesh->tetra[4].ref field by the tetra reference;

The advantage of using the API is that if I decide to rename the v array of the tetra into vert, you will have nothing to do. If you use directly the tetra structure, you will need to update it (which is pretty annoying :wink: ).

You can find a detailed example on how to give a mesh to Mmg using the C API in the ~/mmg/libexamples/mmg3d/adaptation_example0/example0_b/ directory of Mmg (main.c file).