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.
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:
mesh->tetra.v array by the tetra connectivity;
mesh->tetra.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 ).
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).