[WIP] Anisotropic mesh adaptation part 1: feature-based metric tensor by bmunguia · Pull Request #2613 · su2code/SU2
Proposed Changes
This PR is part of a joint effort with Alberto Perlini (@xla27) and Andrea Rausa (@rois1995) to implement anisotropic mesh adaptation in SU2. In our SU2 conference talks this year, I presented updates to the metric tensor computation in my fork for unsteady adaptation, and Alberto presented updates to the Python adaptation loop to use the open-source MMG remesher, as well as results for incompressible Euler/NS and NEMO.
Part 1 will focus on my contributions in SU2's post-processing/output to calculate metric tensor fields for feature-based adaptation. Part 2 will focus on the implementation of the adaptation loop in Python, including conversion between SU2 restarts/meshes and the .meshb format.
For the metric tensor field computation, I have implemented:
- CVariable containers to store adaptation sensor variable/gradient/Hessian/metric tensor
- We only store the lower-triangular elements of the Hessian/metric, so the size of the array at each point is $nSymMat = 3*(nDim-1)$
- CSolver function
SetPrimitive_Adapt()to store the chosen adaptation sensor - Green-Gauss Hessian calculation in
computeGradientsGreenGauss.hppwhich calculates the Hessian field for the chosen sensor and stores the lower triangle - Integration of the Hessian (symmetric positive definite by construction) determinant and Lp-norm normalization (see references) in
computeMetrics.hpp - Integration of the Hessian field in time for unsteady adaptation
- Output of metric tensor for different flow solvers, and updates to Paraview XML filewriter to allow for proper parsing of symmetric tensors
The following relevant config options have been added:
- COMPUTE_METRIC (bool) - whether to calculate the sizing metric in post-processing (default False)
- NORMALIZE_METRIC (bool) - whether to perform the Lp-norm normalization of Hessians (default True)
- NUM_METHOD_HESS (str) - gradient method for Hessian calculation (only GG for now)
- METRIC_SENSOR (str) - field to use for sizing metric
- METRIC_NORM (unsigned short) - choice of norm for Lp-norm normalization
- METRIC_COMPLEXITY (unsigned long) - target mesh size
- METRIC_HMAX (float) - maximum cell size (constraint on minimum metric tensor eigenvalue)
- METRIC_HMIN (float) - minimum cell size (constraint on maximum metric tensor eigenvalue)
- METRIC_ARMAX (float) - maximum cell aspect ratio (constraint on ratio of hmax to hmin)
PR Checklist
- I am submitting my contribution to the develop branch.
- My contribution generates no new compiler warnings (try with --warnlevel=3 when using meson).
- My contribution is commented and consistent with SU2 style (https://su2code.github.io/docs_v7/Style-Guide/).
- I used the pre-commit hook to prevent dirty commits and used
pre-commit run --allto format old commits. - I have added a test case that demonstrates my contribution, if necessary.
- I have updated appropriate documentation (Tutorials, Docs Page, config_template.cpp), if necessary.
References
- Loseille and Alauzet. “Continuous mesh framework part I: well-posed continuous interpolation error,” 2011.
- Alauzet and Loseille. “A decade of progress on anisotropic mesh adaptation for computational fluid dynamics,” 2016.
- Perlini. "Mesh adaptation in SU2: current status and perspectives," 2025.
- Munguía. "Towards a deep learning framework for time-accurate anisotropic mesh adaptation," 2025.