```
One simple way to combine two metrics is by simply averaging them entry-by-entry.
Another is to *intersect* them, which amounts to choosing the greatest level of
refinement in each direction. These operations are available in PETSc through
the routines
```
DMPlexMetricAverage(DM dm, PetscInt numMetrics, PetscReal weights[], Vec metrics[], Vec metricAvg);
DMPlexMetricIntersection(DM dm, PetscInt numMetrics, Vec metrics[], Vec metricInt);
```
However, before combining metrics, it is important that they are scaled in the same
way. Scaling also allows the user to control the number of vertices in the adapted
mesh (in an approximate sense). This is achieved using the $L^p$ normalization
framework, with the routine
```
DMPlexMetricNormalize(DM dm, Vec metricIn, PetscBool restrictSizes, PetscBool restrictAnisotropy, Vec metricOut, Vec determinant);
```
There are two important parameters for the normalization: the normalization order
$p$ and the target metric complexity, which is analogous to the vertex count.
They are controlled using
```
DMPlexMetricSetNormalizationOrder(DM dm, PetscReal p);
DMPlexMetricSetTargetComplexity(DM dm, PetscReal target);
```
or the command line arguments
```console
-dm_plex_metric_p
-dm_plex_metric_target_complexity
```
Two different metric-based mesh adaptation tools are available in PETSc:
- [Pragmatic](https://meshadaptation.github.io/);
- [Mmg/ParMmg](https://www.mmgtools.org/).
Mmg is a serial package, whereas ParMmg is the MPI version.
Note that surface meshing is not currently supported and that ParMmg
works only in three dimensions. Mmg can be used for both two and three dimensional problems.
Pragmatic, Mmg and ParMmg may be specified by the command line arguments
```
-dm_adaptor pragmatic
-dm_adaptor mmg
-dm_adaptor parmmg
```
Once a metric has been constructed, it can be used to perform metric-based
mesh adaptation using the routine
```
DMAdaptMetric(DM dm, Vec metric, DMLabel bdLabel, DMLabel rgLabel, DM dmAdapt);
```
where `bdLabel` and `rgLabel` are boundary and interior tags to be
preserved under adaptation, respectively.
```{rubric} Footnotes
```
[^boundary-footnote]: In three dimensions, the boundary of a cell (sometimes called an element) is its faces, the boundary of a face is its edges and the boundary of an edge is the two vertices.
```{eval-rst}
.. bibliography:: /petsc.bib
:filter: docname in docnames
```