Mesh adaptation¶
This section describes the adaptation routine in mmg2d. In all modes (mesh generation, mesh adaptation, isosurface discretization and lagrangian movement), mesh adaptation is performed by the function:
-
int MMG2D_mmg2d1n(MMG5_pMesh mesh, MMG5_pSol met)¶
Mesh adaptation — new version of mmg2d1.c
- Parameters:
mesh – pointer to the mesh structure.
sol – pointer to the sol structure.
- Returns:
1 if success, 0 if strongly fail.
Step 1: Creation of a geometric mesh¶
The first step of mesh adaptation is performed by the following function:
-
int MMG2D_anatri(MMG5_pMesh mesh, MMG5_pSol met, int8_t typchk)¶
In this first call to this function, \(\tt{typchk}\) is set to 1. This variable indicates which kind of criterion is considered when computing edge lengths. With \(\tt{typchk = 1}\), length criteria are based on the actual length of the edges, whereas \(\tt{typchk = 2}\) means that edge lengths are computed with respect to the metric prescription.
Function \(\tt{MMG2D_anatri}\) is an iterative procedure where operations are applied as long as:
the maximal number of iterations has not been reached
at least one modification has been performed on the mesh during the last iteration.
An iteration consists of three sub-steps, each dedicated to one type of mesh modification:
Edge splits, performed by \(\tt{MMG2D_anaelt}\), where edges that are too long are split by adding a new point along them.
Edge collapses, performed by \(\tt{MMG2D_colelt}\) where edges that are too short are deleted.
Edge swaps, performed by \(\tt{MMG2D_swpmsh}\), which does not alter vertex positions, but modifies adjacency relations.
Edge split¶
This step is performed by calling:
-
MMG5_int MMG2D_anaelt(MMG5_pMesh mesh, MMG5_pSol met, int typchk)¶
This functions procedes as follows:
Step 1: Travel the mesh, compute edge lengths, and tags edges that should be split.
Step 2: Make flags consistent over the whole mesh. If an edge is tagged in a given triangle, all other triangles that share this edge should have it tagged as well.
Step 3: Simulate splits and cancel those leading to an invalid configuration.
Step 4: Perform the actual splits.
Once edge splitting has been done for this iteration, adjacency needs to be updated. This is then done by calling:
-
int MMG2D_hashTria(MMG5_pMesh mesh)¶
Create adjacency relations between the triangles in the mesh
- Parameters:
mesh – pointer to the mesh
- Returns:
1 if success, 0 if fail
Edge collapse¶
The edge collapse step is performed by:
-
MMG5_int MMG2D_colelt(MMG5_pMesh mesh, MMG5_pSol met, int typchk, double lmax)¶
Note that both edge splitting and edge collapsing may be skipped by using the \(\tt{-noinsert}\) command line option.
Edge swap¶
The last substep is done by calling:
-
MMG5_int MMG2D_swpmsh(MMG5_pMesh mesh, MMG5_pSol met, int typchk)¶
This step may be skipped by using the \(\tt{-noswap}\) command line option.
Step 2: Creation of a computational mesh¶
The second step of mesh adaptation consists in calling the same function \(\tt{MMG2D_anatri}\) as in the previous step, with \(\tt{typchk = 2}\). This implies that a metric must be prescribed. To do so, several functions are used to define and compute metric data.
Firstly, a size map needs to be computed. By default, an isotropic size map is computed. This is done by calling the function:
-
int MMG2D_defsiz_iso(MMG5_pMesh mesh, MMG5_pSol met)¶
New version for the definition of a size map; takes into account the curvature of the external and internal curves present in the mesh
- Parameters:
mesh – pointer to the mesh
met – pointer to the metric
- Returns:
0 if fail, 1 otherwise
In the case where anisotropic mode is activated (by specifying an anisotropic input metric or by activating the mode via the API), the following function is called instead:
-
int MMG2D_defsiz_ani(MMG5_pMesh mesh, MMG5_pSol met)¶
Definition of an anisotropic metric tensor field based on the geometry of the domain; this tensor field is intersected by a user-defined tensor field
- Parameters:
mesh – pointer to the mesh
met – pointer to the metric
- Returns:
0 if fail, 1 if success
If the gradation option has been activated (using the command line tool $tt{-hgrad}), gradation will be enforced through the size map by calling either:
-
int MMG5_gradsiz_iso(MMG5_pMesh mesh, MMG5_pSol met)¶
Isotropic mesh gradation routine. The points belonging to a required edge are treated in gradsizreq_iso.
- Parameters:
mesh – pointer to the mesh
met – pointer to the metric
- Returns:
0 if fail, 1 otherwise
or:
-
MMG5_int MMG5_gradsiz_ani(MMG5_pMesh mesh, MMG5_pSol met, int *it)¶
Standard gradation procedure.
- Parameters:
mesh – pointer to the mesh structure.
met – pointer to the metric structure.
it – number of performed iteration (to fill)
- Returns:
nup, the number of points updated.
Then, gradation over required points is dealt with by using either:
-
int MMG5_gradsizreq_iso(MMG5_pMesh mesh, MMG5_pSol met)¶
Isotropic mesh gradation routine. The points belonging to a required entity are treated in gradsizreq_iso.
- Parameters:
mesh – pointer to the mesh
met – pointer to the metric
- Returns:
the number of updated metrics.
or:
-
int MMG5_gradsizreq_ani(MMG5_pMesh mesh, MMG5_pSol met)¶
Enforces mesh gradation (on required entities) by truncating metric field.
- Parameters:
mesh – pointer to the mesh structure.
met – pointer to the metric structure.
- Returns:
1
Finally, the same adaptation routine as in step 1 is performed by calling:
-
int MMG2D_anatri(MMG5_pMesh mesh, MMG5_pSol met, int8_t typchk)
with \(\tt{typchk = 2}\).
Step 3: Fine mesh improvements¶
The final step of mesh adaptation is done by calling the following function:
-
int MMG2D_adptri(MMG5_pMesh mesh, MMG5_pSol met)¶
