Mesh Adaptation (2D)

This page describes how to use the tools dedicated to mesh adaptation using the Mmg remeshing library (

Using the remeshing solver require to install Mmg and provide the direction to the header files and library using the CMake arguments “MMG_INCLUDE_DIR” and “MMG_LIBRARY”:

   -DMMG_INCLUDE_DIR=/path/to/MmgInstallDir/include \

Make sure that Mmg has been compiled using the -fPIC flag in order to be able to be linked to Elmer. You can achieve that for instance by providing a cache-file to the cmake building process of Mmg


Examples can be found under the test directories “MMG2D_Aniso1”, “MMG2D_Aniso2” and “MMG2D_Iso”. These tests have the label elmerice-fast and can be executed alone using

ctest -L mmg

Anisotropic metric definition

The metric M , used to define the element size, derives from a geometric error estimate based on an upper bound for the interpolation error of a continuous field to piecewise linear elements (Frey and Alauzet, 2005).

For a variable v, M depends on the eigenvalues lambda_i and eigenvector matrix R of the hessian matrix of v, H (i.e. small elements are required where the curvature is the highest):

M=R.Lambda.R^{-1} with Lambda=(matrix{2}{2}{lambda_1 0  0 lambda_2}) and \lambda_i=min ( max ( {{c|\lambda_i|}/{epsilon_v}},{{1}/{l^2_{max}}} ), {{1}/{l^2_min}} ),    (1)


  • c is a geometric constant equal to 2/9 in 2D
  • l_min (resp. l_max) is a prescribed minimal (resp. maximal) edge size
  • epsilon_v is the prescribed maximum error

Computing second derivatives in linear elements in not straightforward. Following Buscaglia and Dari (1997), this is done in two steps:

  • First, we compute the nodal gradient g_i={{\partial v}/{\partial x_i}} using the Compute2DNodalGradient Solver
  • Second, we compute the hessian matrix H by solving the diffusive equation H_ij+k ∇(H_ij) = 1/2 (dq_i/dx_j+dq_j/dx_i), where k is a diffusivity proportionnal to the local element size. The metric M is then computed from Eq. (1). This is done using the MMG2D_MetricAniso Solver.

Metric intersection

Sometimes it can be desirable to use several variables to compute the metric, if we want, for example, to capture with the same mesh different physical phenomena represented by different variables.

The intersection M_{1∩2}=M_1 ∩ M_2 of two metrics M_1 and M_2 is given by (Alauzet et al., 2007):

M_{1∩2}=^{T}P^{-1} (matrix{2}{2}{{max(mu^1_{1},mu^2_{1})} 0  0 {max(mu^1_{2},mu^2_{2})}})P^{-1}

with P the matrix where the columns are the normalised eigenvectors (e_i)_{i=1,2}, of N=M^{-1}_{1}M_2 and μ^j_{i}=^{T}e_{i}M_{j}e_i.

Nodal values of M_{1∩2} are computed using the MMG2D_MetricIntersect Solver.

Mesh adaptation

The mesh adaptation step is performed using the Mmg 2D library.

The MMG2DSolver Solver pass the mesh topology and required (isotropic or anisotropc) metric to the library then create the new mesh structure from the adapted mesh returned by the library.


An example for isotropic mesh adaptation can be found under [ELMER_TRUNK]/elmerice/Tests/MMG2D_Iso. Examples for anisotropic mesh adaptation can be found under [ELMER_TRUNK]/elmerice/Tests/MMG2D_Aniso1 and [ELMER_TRUNK]/elmerice/Tests/MMG2D_Aniso2, where the mesh size is adapted using 1 or 2 variables (i.e. combining metric informations), respectively.

mesh/meshadaptation.txt · Last modified: 2017/07/21 14:56 by tzwinger
CC Attribution-Share Alike 4.0 International Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0