|
| 1 | +--- |
| 2 | +title: Adaptive Metric |
| 3 | +permalink: /docs_v7/Adaptive-Metric/ |
| 4 | +--- |
| 5 | + |
| 6 | +This page explains how to compute the adaptive metric for anisotropic mesh adaptation: the options, the sensors and the output fields. For the theory, see [Metric-Based Anisotropic Mesh Adaptation](../Metric-Based-Mesh-Adaptation/). For worked examples, see the tutorials [Adaptive Metric with Built-In Sensors](/tutorials/Adaptive_Metric_Builtin_Sensors/) and [Adaptive Metric with a Custom Sensor](/tutorials/Adaptive_Metric_Custom_Sensor/). |
| 7 | + |
| 8 | +--- |
| 9 | + |
| 10 | +- [Limitations](#limitations) |
| 11 | +- [Workflow](#workflow) |
| 12 | +- [Options](#options) |
| 13 | +- [Sensors](#sensors) |
| 14 | + - [Built-In Sensors](#built-in-sensors) |
| 15 | + - [Custom Sensors](#custom-sensors) |
| 16 | +- [Choosing the Norm](#choosing-the-norm) |
| 17 | +- [Size and Aspect Ratio Limits](#size-and-aspect-ratio-limits) |
| 18 | +- [Steady and Unsteady Flows](#steady-and-unsteady-flows) |
| 19 | +- [Output Fields](#output-fields) |
| 20 | + |
| 21 | +--- |
| 22 | + |
| 23 | +## Limitations |
| 24 | + |
| 25 | +- SU2 computes the metric field only. Generating the adapted mesh (remeshing) and the adaptation loop are not yet supported. |
| 26 | +- The metric is available for single-zone flow problems only. SU2 stops with an error for periodic boundaries, multizone problems, harmonic balance and the discrete adjoint. |
| 27 | +- Only the Green-Gauss Hessian is available (`NUM_METHOD_HESS= GREEN_GAUSS`). |
| 28 | +- Each sensor gets its own metric; metric intersection (to combine several sensors) and size gradation are not available. |
| 29 | +- Only feature-based metrics are available; goal-oriented (adjoint-based) metrics are not, and the `GOAL` sensor is rejected. |
| 30 | +- For unsteady flows, SU2 computes a single metric over the entire time series; adaptation over several time sub-intervals is not yet supported. |
| 31 | + |
| 32 | +## Workflow |
| 33 | + |
| 34 | +1. Choose one or more *sensors*, the scalar fields whose interpolation error the adapted mesh should control, for example the pressure and the Mach number. |
| 35 | +2. Set `COMPUTE_ADAPTIVE_METRIC= YES` and list the sensors in `ADAPTIVE_METRIC_SENSOR`. |
| 36 | +3. Set the target complexity (approximately the number of vertices of the adapted mesh), the norm and the size limits. |
| 37 | +4. Add `ADAPTIVE_METRIC` to `VOLUME_OUTPUT` and run `SU2_CFD` (or the Python wrapper for custom sensors). |
| 38 | +5. Pass the metric of the volume or restart output to a remesher. |
| 39 | + |
| 40 | +For example: |
| 41 | + |
| 42 | +``` |
| 43 | +COMPUTE_ADAPTIVE_METRIC= YES |
| 44 | +ADAPTIVE_METRIC_SENSOR= ( PRESSURE, MACH ) |
| 45 | +ADAPTIVE_METRIC_NORM= 2 |
| 46 | +ADAPTIVE_METRIC_COMPLEXITY= 10000 |
| 47 | +ADAPTIVE_METRIC_HMIN= 1e-6 |
| 48 | +ADAPTIVE_METRIC_HMAX= 10.0 |
| 49 | +% |
| 50 | +VOLUME_OUTPUT= ( COORDINATES, SOLUTION, PRIMITIVE, ADAPTIVE_METRIC ) |
| 51 | +``` |
| 52 | + |
| 53 | +## Options |
| 54 | + |
| 55 | +The options are listed in the [Option Reference](../Option-Reference-adaptation-options/), with their defaults. The main ones are: |
| 56 | + |
| 57 | +| Option | Meaning | Default | |
| 58 | +| --- | --- | --- | |
| 59 | +| `COMPUTE_ADAPTIVE_METRIC` | Compute the adaptive metric of each sensor. | `NO` | |
| 60 | +| `ADAPTIVE_METRIC_SENSOR` | List of sensors (case-insensitive), see [Sensors](#sensors). | none, at least one is required | |
| 61 | +| `ADAPTIVE_METRIC_CUSTOM_SENSOR` | Sensors of `ADAPTIVE_METRIC_SENSOR` filled through the Python wrapper. | `NONE` | |
| 62 | +| `NORMALIZE_ADAPTIVE_METRIC` | Perform the $$L^p$$-norm normalization. With `NO`, the metric is the absolute value of the Hessian (integrated in time for unsteady flows). | `YES` | |
| 63 | +| `ADAPTIVE_METRIC_NORM` | Norm p of the normalization, see [Choosing the Norm](#choosing-the-norm). | `2` | |
| 64 | +| `ADAPTIVE_METRIC_COMPLEXITY` | Target complexity N. | `10000` | |
| 65 | +| `ADAPTIVE_METRIC_HMIN` | Minimum cell size, one value or one per sensor. | `1e-8` | |
| 66 | +| `ADAPTIVE_METRIC_HMAX` | Maximum cell size, one value or one per sensor. | `100` | |
| 67 | +| `ADAPTIVE_METRIC_ARMAX` | Maximum cell aspect ratio, one value or one per sensor. | `1e6` | |
| 68 | + |
| 69 | +The sizes are in mesh units. `ADAPTIVE_METRIC_HGRAD`, `ADAP_ITER` and `ADAP_COMPLEXITIES` are read only by the Python tools of the adaptation loop, not by `SU2_CFD`. |
| 70 | + |
| 71 | +## Sensors |
| 72 | + |
| 73 | +Each sensor in `ADAPTIVE_METRIC_SENSOR` gets its own metric, normalized with the same norm and complexity. SU2 does not combine the metrics of several sensors into one (metric intersection) yet. |
| 74 | + |
| 75 | +### Built-In Sensors |
| 76 | + |
| 77 | +SU2 matches each sensor name, case-insensitively, against these fields, in this order: |
| 78 | + |
| 79 | +1. a custom sensor listed in `ADAPTIVE_METRIC_CUSTOM_SENSOR` (see below); |
| 80 | +2. a primitive variable of the flow solver, for example `PRESSURE`, `DENSITY`, `TEMPERATURE`, `VELOCITY_X`, `VELOCITY_Y`, `VELOCITY_Z`, `LAMINAR_VISCOSITY` or `EDDY_VISCOSITY`; |
| 81 | +3. a computed quantity: `VELOCITY` (velocity magnitude) or `MACH` (compressible solvers only); |
| 82 | +4. a solution variable of another solver: `NU_TILDE` (SA), `TKE` and `DISSIPATION` (SST), `INTERMITTENCY` and `RE_THETA_T` (LM transition), `SPECIES_<i>` (species transport). |
| 83 | + |
| 84 | +An unknown name stops SU2 with an error that lists the available sensors. At startup, SU2 prints how it resolved each sensor, for example for the 2D compressible solver: |
| 85 | + |
| 86 | +``` |
| 87 | + Sensor 'PRESSURE': primitive variable 3. |
| 88 | + Sensor 'MACH': computed. |
| 89 | +``` |
| 90 | + |
| 91 | +### Custom Sensors |
| 92 | + |
| 93 | +Any other scalar field can be used as a sensor through the Python wrapper. List it in both `ADAPTIVE_METRIC_SENSOR` and `ADAPTIVE_METRIC_CUSTOM_SENSOR`: |
| 94 | + |
| 95 | +``` |
| 96 | +ADAPTIVE_METRIC_SENSOR= ( TOTAL_PRESSURE, MACH ) |
| 97 | +ADAPTIVE_METRIC_CUSTOM_SENSOR= ( TOTAL_PRESSURE ) |
| 98 | +``` |
| 99 | + |
| 100 | +Then register a function that returns the sensor value at each node with `CustomSensorRegistry` (from `SU2.adaptive_metric`), and call `populate` after the flow solution and before `Postprocess`, where SU2 computes the metric: |
| 101 | + |
| 102 | +```python |
| 103 | +from mpi4py import MPI |
| 104 | +import pysu2 |
| 105 | +from SU2.adaptive_metric import CustomSensorRegistry |
| 106 | + |
| 107 | +comm = MPI.COMM_WORLD |
| 108 | +driver = pysu2.CSinglezoneDriver("config.cfg", 1, comm) |
| 109 | +custom_sensors = CustomSensorRegistry({"TOTAL_PRESSURE": total_pressure}) |
| 110 | +custom_sensors.initialize(driver) |
| 111 | + |
| 112 | +driver.Preprocess(0) |
| 113 | +driver.Run() |
| 114 | +custom_sensors.populate(driver) |
| 115 | +driver.Postprocess() |
| 116 | +driver.Update() |
| 117 | +driver.Monitor(0) |
| 118 | +driver.FinalizeAdaptiveMetric() |
| 119 | +driver.Output(0) |
| 120 | +driver.Finalize() |
| 121 | +``` |
| 122 | + |
| 123 | +Each function takes the driver and returns the sensor values at the owned nodes of the current MPI rank. The [custom sensor tutorial](/tutorials/Adaptive_Metric_Custom_Sensor/) shows a complete example. |
| 124 | + |
| 125 | +## Choosing the Norm |
| 126 | + |
| 127 | +The norm p sets how the vertices are distributed (see [Optimal Metric](../Metric-Based-Mesh-Adaptation/#optimal-metric)). A larger p concentrates them in the regions of strongest curvature of the sensor, such as shocks and boundary layers, while a smaller p spreads them more evenly and also resolves weaker features. Recommended values: |
| 128 | + |
| 129 | +- **Inviscid flows:** p = 1 or 2. |
| 130 | +- **Viscous (RANS) flows:** p = 4. Both Park, Balan et al. (2019) and Alauzet and Frazza (2021) found that p = 4 converges faster than p = 2 for RANS, since p = 2 under-refines the boundary layers on coarse adapted meshes: |
| 131 | + - M. A. Park, A. Balan et al., "Verification of unstructured grid adaptation components", AIAA 2019-1723, 2019. [doi:10.2514/6.2019-1723](https://doi.org/10.2514/6.2019-1723) |
| 132 | + - F. Alauzet, L. Frazza, "Feature-based and goal-oriented anisotropic mesh adaptation for RANS applications in aeronautics and aerospace", *J. Comput. Phys.* 439, 110340, 2021. [doi:10.1016/j.jcp.2021.110340](https://doi.org/10.1016/j.jcp.2021.110340) |
| 133 | + |
| 134 | +## Size and Aspect Ratio Limits |
| 135 | + |
| 136 | +After the normalization, SU2 clips each metric so that the requested cell sizes lie between `ADAPTIVE_METRIC_HMIN` and `ADAPTIVE_METRIC_HMAX`, and the requested aspect ratio is at most `ADAPTIVE_METRIC_ARMAX`. Each limit takes either one value for all sensors, or one value per sensor of `ADAPTIVE_METRIC_SENSOR`, in the same order: |
| 137 | + |
| 138 | +``` |
| 139 | +ADAPTIVE_METRIC_SENSOR= ( PRESSURE, MACH ) |
| 140 | +ADAPTIVE_METRIC_HMIN= ( 1e-4, 1e-3 ) |
| 141 | +ADAPTIVE_METRIC_HMAX= 10.0 |
| 142 | +``` |
| 143 | + |
| 144 | +The limits keep the metric well defined: `ADAPTIVE_METRIC_HMAX` and `ADAPTIVE_METRIC_ARMAX` bound the sizes where the Hessian is singular, for example in regions of nearly constant flow, and `ADAPTIVE_METRIC_HMIN` prevents null sizes, for example at discontinuities. They affect the complexity whenever they are active. |
| 145 | + |
| 146 | +## Steady and Unsteady Flows |
| 147 | + |
| 148 | +- **Steady flows.** SU2 computes the metric once, from the final solution. |
| 149 | +- **Unsteady flows.** SU2 integrates the absolute value of the Hessians in time with the trapezoidal rule, using the time step that the solver actually takes (which may vary, for example with `UNST_CFL_NUMBER`). The first sample is the solution after the first time step, or the restart solution of an unsteady restart. SU2 normalizes the metric when the run stops (at `TIME_ITER`, `MAX_TIME` or time convergence), so only the last volume output holds the final metric; earlier outputs hold the running time integral. With the Python wrapper, call `driver.FinalizeAdaptiveMetric()` before the last `driver.Output()`. |
| 150 | + |
| 151 | +SU2 prints the global integral used by the $$L^p$$-norm normalization for each sensor (even when normalization is disabled): |
| 152 | + |
| 153 | +``` |
| 154 | +Global adaptive metric normalization integral for sensor PRESSURE: 18523.8 |
| 155 | +``` |
| 156 | + |
| 157 | +## Output Fields |
| 158 | + |
| 159 | +With `COMPUTE_ADAPTIVE_METRIC= YES`, the following volume output groups are available. In the field names, `<Sensor>` is the sensor name with only its first letter capitalized, for example `Pressure` or `Total_pressure`. |
| 160 | + |
| 161 | +| Group | Fields | Content | |
| 162 | +| --- | --- | --- | |
| 163 | +| `SENSOR_VALUE` | `Sensor_<Sensor>` | Sensor value | |
| 164 | +| `SENSOR_GRADIENT` | `Gradient_<Sensor>_x`, `_y` (, `_z`) | Green-Gauss gradient of the sensor | |
| 165 | +| `SENSOR_HESSIAN` | `Hessian_<Sensor>_xx`, `_xy`, `_yy` (, `_xz`, `_yz`, `_zz`) | Green-Gauss Hessian of the sensor | |
| 166 | +| `ADAPTIVE_METRIC` | `AdaptiveMetric_<Sensor>_xx`, `_xy`, `_yy` (, `_xz`, `_yz`, `_zz`) | Adaptive metric of the sensor | |
| 167 | + |
| 168 | +The ParaView writers (`PARAVIEW`, `PARAVIEW_ASCII`, `PARAVIEW_LEGACY`) group the gradients as vectors and the Hessians and metrics as symmetric tensors, named `Gradient_<Sensor>`, `Hessian_<Sensor>` and `AdaptiveMetric_<Sensor>`. In 2D, the z components of the tensors are written as zero. By default, the restart file only contains the variables needed to restart the solver; with `WRT_RESTART_COMPACT= NO`, it also contains these fields, one column per component. The [built-in sensor tutorial](/tutorials/Adaptive_Metric_Builtin_Sensors/) shows how to visualize the metric in ParaView. |
0 commit comments