Adaptive Mesh Refinement Module
The amr module refines and coarsens the mesh using solution sensors or
geometric regions. It can adapt the initial mesh or adapt between physical
time steps and transfer the solution to the new mesh.
Basic Setup
The sample below shows how to load the amr module, select request sources, and specify a number of adaptations.
This example checks the velocity and pressure sensors every 100 physical time steps, starting at time step 100, and
permits up to three adaptations. A mesh change only happens when cells are marked for refinement or coarsening. That is,
if no cells meet any criteria for refinement or coarsening, no mesh change occurs and the next check is deferred to the next eligible time step.
loadModule: amr
{
adaptRequestSources: scaledError
adaptSensor: Perror, Uerror
adaptStart: 100
adaptFrequency: 100
maxAdaptSteps: 3
}
adaptRequestSources is required when maxAdaptSteps is positive. It lists
the sources that may request refinement or coarsening. Use scaledError for
the sensors selected by adaptSensor, or name sources provided by modules
or refinement regions. Separate names with commas to
combine sources. As a rule, refinement takes precedence over coarsening. Use none
for an empty global list, with optional regional selections.
Adaptation Timing
Input |
Default |
Meaning |
|---|---|---|
|
|
First physical time-step number eligible for runtime adaptation |
|
|
Interval between runtime checks; |
|
|
Maximum adaptations, including initial adaptation; |
|
|
Maximum adaptations before time stepping; must not exceed |
Runtime checks occur at multiples of adaptFrequency at or after
adaptStart. For example, adaptStart: 150 and adaptFrequency: 100
make step 200 the first eligible check.
Initial Adaptation
To adapt before advancing the solution, set adaptInitializationSteps.
The example below shows how to specify two initial adaptations with no subsequent runtime adaptation thereafter.
adaptRequestSources: scaledError
adaptSensor: Rerror
adaptInitializationSteps: 2
maxAdaptSteps: 2
adaptFrequency: 0
Initial conditions are reevaluated on each new mesh. Adaptation stops at the limit or when no cells are marked.
To allow later runtime adaptation, increase maxAdaptSteps and use a
positive adaptFrequency. adaptStart applies only to runtime checks.
Solution Sensors
adaptSensor accepts a comma-separated list. Sensors measure jumps between
neighboring cells and require the corresponding solution fields.
Sensor |
Measures |
Units |
|---|---|---|
|
Pressure jump |
Pa |
|
Density jump |
kg/m3 |
|
Velocity-jump magnitude |
m/s |
|
Temperature jump |
K |
|
Species mass-fraction vector jump; requires species transport |
Dimensionless |
|
One species mass-fraction jump; requires species transport |
Dimensionless |
|
Mixture-fraction and progress-variable jumps; requires |
Dimensionless |
|
Selected material-volume-fraction jumps; see Adaptive Mesh Refinement |
Dimensionless |
|
Largest liquid or gas volume-fraction jump; see Adaptive Mesh Refinement |
Dimensionless |
For YspeciesError, select a species by name:
adaptRequestSources: scaledError
adaptSensor: Perror, YspeciesError
adaptSpeciesName: O2
The name must appear in the simulation’s species list. If omitted, the first species is used.
By default, each sensor is normalized by subtracting its mesh-wide mean and dividing by its standard deviation. Constant sensors contribute zero. Each cell uses the largest normalized value among its selected sensors. Regional controls can select local normalization.
Input |
Default |
Meaning |
|---|---|---|
|
|
Refine above this normalized threshold; lowering it selects more cells |
|
|
Coarsen below the negative of this threshold; increasing it selects fewer cells |
Both thresholds are dimensionless. coarsenSensitivity: 0 does not disable
coarsening. Size limits and regional controls can restrict requests.
Coarsening also requires compatible groups of previously refined cells.
For coarsening based on absolute sensor limits, see Coarsening Tolerances.
Mesh Controls
Input |
Default |
Meaning |
|---|---|---|
|
|
|
|
|
Positive minimum cell size in meters; suppresses refinement at or below this size |
|
|
|
|
|
Target cell count in millions; fractional values allowed. Zero or negative disables the limit. |
|
|
Positive face-fold threshold restricting refinement of highly twisted faces |
|
|
|
adaptMinEdgeLength limits refinement of current cells. Newly created
cells can be smaller. diameter avoids size underestimation from
subdivided faces. Adjust size targets when changing metrics: a cube of side
h has diameter sqrt(3)*h, or sqrt(2)*h in 2D mode.
maxAdaptCellCount: 0.5 targets 500,000 cells across all refinement sources.
Requests with target sizes take priority. Mesh balancing can exceed this target.
Solution Transfer
adaptInterpolationOrder controls transfer to child cells after runtime
adaptation. It is separate from the flow solver’s spatial discretization.
Value |
Effect |
|---|---|
|
Each child receives its parent’s value |
|
Limited linear reconstruction from the parent cell |
Coarsening uses volume-weighted averaging for either order.
Runtime AMR preserves accepted face-flux histories across remeshing. Use timeIntegrator: BDF, BDF2 or CN with
inviscidFlux: FOU or SOU. Boundaries may be inlet, outlet, no-slip, slip or symmetry.
Restart and Output
Restart
AMR checkpoints restore the adapted mesh and solution. Keep amr loaded,
set adaptInitializationSteps: 0, and retain the complete restart
directory. For example:
stream -q solution case 200
Output Variables
Request AMR fields with plot_output:
plot_output: refFlag, combinedErrorFactor
Variable |
Meaning |
|---|---|
|
Request after size masks and the cell budget, before mesh balancing:
|
|
Combined normalized sensor value |
|
Active region ID; |
|
Effective minimum cell size, m |
|
Effective refinement sensitivity |
|
Effective statistical coarsening sensitivity |
|
|
All fields are optional. Each node reports the maximum adjacent cell value.
Post-Processing
Use the standard output controls. extract
selects the matching mesh:
extract -vtk case 200
When old and new meshes share an output label, the old output receives an
_amrN suffix. N identifies the mesh, starting at zero. To extract
the original-mesh output preserved at step 200:
extract -vtk case 200_amr0
With plot_output_iteration: on or nonzero plot_modulo, retained
numeric output labels are preserved at each mesh change.
Regional Controls
Region controls accept inBox(p1=..., p2=...) and
inSphere(center=..., radius=...) with length units. Regions stay fixed
in physical coordinates and select cells by their current centers.
Boxes must span all three directions, including the thickness of layered
2D meshes. Radii must be positive. Box boundaries are included, and sphere boundaries are excluded.
Target Sizes
adaptRegionRequests defines named refinement sources with target cell
sizes. Select their names in adaptRequestSources or regional
requestSources lists. An example below shows the specification for a 1 mm wake region.
adaptRequestSources: wake
adaptRegionRequests: <
wake=[region=inBox(p1=[15 mm, -12 mm, -1 mm], p2=[80 mm, 12 mm, 3 mm]),
edgeLength=1 mm]
>
Entry |
Default |
Meaning |
|---|---|---|
|
Required |
Box or sphere |
|
Required |
Positive target size measured with |
|
All cells |
Restrict to named mesh volumes, for example |
Several named regions may be supplied. Names must start with a letter and contain only letters, digits, or underscores. Volume-tag lists must contain distinct existing names. These naming rules also apply to regional overrides.
Regions request refinement when the selected size exceeds the target. Minimum sizes and adaptation budgets still apply, so reaching the target may require several adaptations.
Refinement and Coarsening Restrictions
adaptIncludeRegions permits selected actions only inside its regions.
adaptExcludeRegions blocks them inside its regions. The example below illustrates
this for a box and a sphere.
adaptIncludeRegions: <
regions=[inBox(p1=[0 m, 0 m, 0 m], p2=[1 m, 1 m, 1 m])],
actions=[refine, coarsen]
>
adaptExcludeRegions: <
regions=[inSphere(center=[0.5 m, 0.5 m, 0.5 m], radius=0.1 m)],
actions=[refine, coarsen]
>
actions defaults to [refine]; it also accepts [coarsen] or
[refine, coarsen]. Exclusion takes precedence over inclusion. Restrictions
apply to all request sources, but mesh balancing can refine neighboring
cells outside the permitted regions.
Regional Overrides
Use adaptRegionControls to override global settings in named regions:
adaptRequestSources: scaledError
adaptSensor: Perror
adaptMinEdgeLength: 0.001
adaptRegionControls: <
shearLayer=[region=inBox(p1=[0 m, -10 mm, -1 mm], p2=[100 mm, 10 mm, 1 mm]),
sensors=[Uerror, Rerror], minSize=0.2 mm,
adaptSensitivity=0.8, coarsenSensitivity=0.3]
>
Entry |
Default |
Meaning |
|---|---|---|
|
Required |
Box or sphere |
|
All cells |
Restrict to named mesh volumes |
|
|
Integer; highest priority wins in overlaps. Equal highest priorities are errors. |
|
Global selection |
Distinct sensor names replacing the global selection; |
|
Global selection |
Source names replacing the global selection; |
|
|
Positive minimum size with length units, using |
|
Global value |
Nonnegative refinement threshold |
|
Global value |
Nonnegative statistical coarsening threshold |
|
Global value |
|
|
Global limits |
Per-sensor overrides, for example |
|
|
|
|
|
Integer of at least two; minimum included samples for a nonzero regional statistical score |
Outside regions, global settings apply. Omitted entries in the winning
region, including individual sensor tolerances, also use global values.
Species/material selections remain global. minSize limits refinement
from all sources. sensors selects metrics for scaledError. Other
selected sources use their own criteria.
To use scaledError only inside a box:
adaptRequestSources: none
adaptSensor: Perror
adaptRegionControls: <
refinedZone=[region=inBox(p1=[0 m, 0 m, 0 m], p2=[1 m, 1 m, 0.01 m]),
requestSources=[scaledError]]
>
To request adaptation only outside the box, set adaptRequestSources: scaledError
and requestSources=none. Source selection preserves sensor sampling and
normalization settings.
Regional Statistics
Select statisticsScope=region when a region needs its own sensor mean
and standard deviation. For example:
adaptRequestSources: scaledError
adaptRegionControls: <
wake=[region=inBox(p1=[0 m, -10 mm, -1 mm], p2=[100 mm, 10 mm, 1 mm]),
sensors=[Uerror, Rerror], statisticsScope=region,
minSize=0.2 mm, adaptSensitivity=0.8, coarsenSensitivity=0.3]
>
The population contains valid sensor samples from cells where this policy
has the highest priority. Higher-priority overlays therefore remove cells
from its population. Volume-tag and sensor sampling restrictions also apply.
Refinement masks, size limits, and cell budgets do not change the population.
global continues to sample the whole eligible mesh, including other regions.
Samples have equal weight, and standard deviation uses sample variance.
A constant sensor or a population below statisticsMinSamples contributes
zero to the combined statistical score. Raw coarsening tolerances and
geometric requests still apply. Jump sensors continue to use neighboring
solution values across region boundaries.
Regional Reports
Set adaptRegionReport: summary to print a compact report at each eligible
adaptation check, including checks that mark no cells. Each policy shows its
cell count, admitted and candidate refinement/coarsening counts, masked requests,
budget denials, and deferred size requests. Selected sensors show their
population scope, sample count, and status.
The default is off. Select csv for detailed output in
amr_regions_<mesh>_<cycle>.csv; mesh is the remesh counter and
cycle is the physical step number. Repeating a check with the same labels
replaces that file.
CSV reports contain effective policy settings, cell counts, and each selected
sensor’s sample count, mean, standard deviation, minimum, maximum, and
population status. A sensor row with scope=global describes the mesh-wide
normalizer, even when a named region uses it. Empty populations have blank statistics.
Standard deviation is blank when only one sample is available.
All decision counts describe cells before remeshing. Admitted tags request changes; mesh balancing and sibling compatibility determine the resulting topology.
Coarsening Tolerances
The default coarsenMode is statistical, using
coarsenSensitivity. Select tolerance to coarsen only when every
selected sensor’s magnitude is at or below its specified limit:
adaptRequestSources: scaledError
adaptSensor: Perror, Uerror
coarsenMode: tolerance
coarsenTolerances: <Perror=10, Uerror=0.01>
The example limits are 10 Pa and 0.01 m/s. Limits use the
sensor units before normalization or weighting. Each
selected sensor needs a nonnegative limit; zero permits only an
exactly zero sensor. coarsenSensitivity is unused in this mode.
Refinement still uses adaptSensitivity and takes precedence. A sensor
above its limit also blocks coarsening requested by geometry or distance
controls. With no selected sensors, those controls remain active.
Model-Specific Options
Compressible Gas
For the base gas solver (eos_type: gas), cell-state transfer conserves
species mass, momentum, and total energy when using total energy or total
enthalpy on fixed Cartesian meshes, with double flux off, no axisymmetry,
and no interface boundaries. This transfer is selected automatically;
other configurations use independent-field or module-specific transfer.
Turbulence scalars are transferred independently.
The transferred state must have nonnegative species densities, positive
total density, and temperature within TclipMin and TclipMax.
If second-order transfer violates these bounds, Stream retries at first
order. Failure at first order stops the run; energy is not clipped.
Overset Grids
Runtime AMR can refine and coarsen a stationary background grid while rigid
components move. Keep the moving-component grids at fixed resolution and use
BDF or BDF2. Region requests can select the background with
volumeTags=[background]; see Target Sizes.
For startup refinement near overset component surfaces, provide the component
geometry, select streamGeometry in adaptRequestSources, and set
adaptGeometryEdgeLength:
Input |
Default |
Meaning |
|---|---|---|
|
Not set |
Target cell size near component surfaces, m, using |
|
|
Thickness of the transition from the target size to coarser cells |
Startup sensors sample solved cells.
Cavitation
For cavitation, use SIMPLEC and the following settings with the basic AMR controls:
loadModule: cavitation_nist
loadModule: amr
{
pressureBasedMethod: SIMPLEC
momentumInterpolationOptions: <form=old>
adaptInterpolationOrder: 1
}