How to get a map which relates the new vertices to the old triangles?

Hi all,

I have a question regarding a functionality which I don’t know if it is available in MMG or not.
After a mesh adaptation process one may want to interpolate a FEM function over the new created mesh. For this purpose, it would be computationally advantageous to know in advance the triangle index of the old mesh which contains a new created vertex in the new mesh. Is it possible to do that in MMG 2D?

If not: would it be computationally advantageous to take track of edge splitting-coarsening-swapping and so modify such map for each of this operation inside MMG, with respect to usual algorithms to find the triangle containing a vertex? If yes, any tips on how to do that?

Thanks in advance for any help.

ps. I refer to P1 FEM functions

Hi Marcus,

Welcome to this forum.

Mmg doesn’t compute the location of the new vertices within the old mesh but you are right, it will probably be easier for us to give this data than for an external user. However, I am not sure that it will be very efficient because Mmg uses an iterative process that pass through a large amount of transitionnal operators (splits, collapses…). You can see the number of each call if you raise the Mmg verbosity to 5 (-v 5).

Moreover, we choose to not provide the node location because the needed data depends on the method of interpolation that the user will use.
For example: the location of the new nodes within the old mesh is sufficient for non-conservative interpolation but for conservative interpolation, you will need to know the supermesh of the old and new meshes.

  • If you don’t want to code the P1 interpolation by yourself you can use the mshint software available within the repository (developped by Pascal Frey): it uses the same file format than Mmg (the Medit file format).

  • Otherwise, a way to find the location of a point inside a mesh is to start from a random triangle and to compute the barycentric coordinates of the point inside this triangle. These coordinates will allow to know if the point is inside the triangle or, if it is outside, in which direction you will need to travel (following the adjacency relationships and the barycentric coor in the successive triangles you will find the suitable triangle).

I hope that it will help you.