Skip to content

Regrid round trip and input contract ​

IDGroupMilestoneBackendsFigureRegression
RG (rg0, rg1, rg2)Runtime AMR (M5)M5 (#74)CPU (rg0, a host program); rg1 and rg2 CPU, FNLno—

Case and scope ​

Until M5 nothing ran amr_update after initialisation and no test ever derefined. rg0 exercises the library regrid step on its own: a block is refined, then its children derefined, on a field known in every cell; rg1 and rg2 pin the two input keys of runtime AMR.

What the case catches:

  • inconsistent bookkeeping over the ranks: the redistribution moves blocks, and the leaves and the blocks summed over the ranks must agree after every step;
  • an inexact transfer where an exact one is possible: a linear field must be reproduced by the refine; with the conservative prolongation the round trip must return the initial state and ∑qΔV must not change;
  • a prolongation that leaves the range of the data: a steep front must stay in (0.01,1), so a positive variable stays positive;
  • a silent input: a negative frequency, a frequency > 0 without markers, an unknown regrid_prolongation.

The conservative prolongation ​

Each parent cell is split along the refined axes into children set, variable by variable, to

qc=q+ϕ∑dσdsd4,σd=±1,

with sd the monotonized-central slope of the parent along axis d (in parent-cell units, from its two face neighbours) and ϕ∈[0,1] the largest factor that keeps every child in the range of the parent and its face neighbours (Barth and Jespersen 1989). The offsets cancel over the children, so their mean is the parent: the mean restriction undoes the prolongation exactly and ∑qΔV does not change. The MC limit bounds each axis on its own, not the sum over the axes a corner child takes; ϕ closes that gap. Linear data keep ϕ=1 and are reproduced exactly.

Models and numerics ​

ItemChoiceCode
Regrid steptree adapted with 2:1 balance, interior data prolonged or restricted, blocks redistributed, maps rebuiltamr_update, check_blocks_number, adam_adam_object.F90; adapt, adam_field_object.F90
linear prolongationtensor linear (weights 1/4, 3/4); the library defaultrefine2D, refine3D, adam_field_object.F90
conservative prolongationlimited MC slopes with the Barth–Jespersen factor ϕ (#74 D-M5-2); the FLUME defaultrefine_conservative, adam_field_object.F90
Restrictionthe mean of the childrenderefine2D, derefine3D, adam_field_object.F90
[amr] regrid_prolongationread by the library; FLUME resolves an absent key to conservative and logs itload_from_file, prolongation_name, adam_amr_object.F90; check_runtime_amr, adam_flume_common_object.F90
[amr] frequency0: the AMR of the initial condition only; n>0: a regrid every n steps, which needs markerscheck_runtime_amr, adam_flume_common_object.F90; input

The regrid algorithms are described in numerics.

Initial and boundary conditions ​

LegSetup
rg0tests/amr/test_amr_regrid_roundtrip on 1, 2 and 3 ranks. Domain [0,1]3; a realm refined uniformly to level 1: octree (ratio = 8, 83 cells per block, 8 blocks) and quadtree (ratio = 4, 8×8×1 cells, z null, 4 blocks), ngc = 3. The field is set in every cell, ghosts included (a perfect ghost fill, so the transfers are tested alone). The block at the origin is refined, then its children derefined, with each prolongation
rg0 fieldslinear f=1+0.3x+0.7y+0.5z; quadratic, f+2x2+1.5y2+xy; a steep front from 1 to 0.01, 0.505+0.495tanh⁡((c−s)/0.03), a tanh half a coarse cell wide across s=x+y+z=c=0.45 on the octree, s=x+y=c=0.3 on the quadtree
rg1the regression sod-x input (Sod) to t=0.002, 2 ranks, with [amr] frequency = 0, −1, 5 (and no markers)
rg2the same input with [amr] regrid_prolongation absent, linear, conservative, bogus

Input files ​

FileRole
src/tests/amr/test_amr_regrid_roundtrip.F90the rg0 unit test (fobis build --mode test-amr-regrid-roundtrip-gnu)
src/tests/flume/verification/regrid/check.sh --legs rg0,rg1,rg2runs the legs (FLUME_EXE selects the backend of rg1 and rg2)
src/tests/flume/regression/sod-x/input.inithe base input of rg1 and rg2
bash
cd src/tests/flume/verification/regrid && ./check.sh --legs rg0,rg1,rg2                    # CPU
FLUME_EXE=$PWD/../../../../../exe/adam_flume_fnl ./check.sh --legs rg1,rg2                # FNL

No figure: the legs are a transfer identity and an input contract (#85).

Results ​

rg0 asserts:

  • the leaves and the blocks summed over the ranks agree: octree 8 → 15 → 8, quadtree 4 → 7 → 4;
  • a linear field exact after the refine, with both prolongations;
  • with conservative, the round trip returns the initial state and ∑qΔV is unchanged after the refine and after the round trip, on every field, to round-off (10−13 of the field scale); the front stays in (0.01,1);
  • with linear, the quadratic field drifts (the negative control).

Every leg passes on 1, 2 and 3 ranks, with the same numbers (CPU):

FieldTreelinear: drift of ∑qΔVlinear: round tripconservative: driftconservative: round trip
quadraticoctree1.3⋅10−43.4⋅10−404⋅10−17
quadraticquadtree2.7⋅10−43.4⋅10−402⋅10−17
frontoctree2.6⋅10−21.8⋅10−14.8⋅10−151⋅10−16
frontquadtree1.8⋅10−21.3⋅10−12.6⋅10−161⋅10−16

Drift is relative to the initial integral, after the refine; round trip is the largest |q−f| over the field scale after refine then derefine.

LegInputExpectedCPUFNL
rg1frequency = 0runspasspass
rg1frequency = -1fatal: "must be 0 (no runtime regridding) or positive"passpass
rg1frequency = 5, no markersfatal: "nothing would mark a block"passpass
rg2regrid_prolongation absentruns, resolved to conservativepasspass
rg2linear, conservativeruns, taken as givenpasspass
rg2bogusfatal: unknown [amr].(regrid_prolongation) "bogus"passpass

The FNL column of rg1 and rg2 is read from the logs of the work-adam_flume_fnl-* directories of regrid/check.sh.

Related cases: the regrids during a FLUME run are runtime regrids; the inviscid conservation of static AMR is Euler AMR conservation.

Findings ​

  • The linear prolongation is second order (a quadratic field's children miss by 2.6⋅10−4 of the scale, the conservative one's by 1.1⋅10−4) but changes the integral at every refine.
  • The bound scaling is load-bearing: with ϕ=1 forced (a mutation run), an octree child of the front reaches −0.094, below zero, and the leg fails; on the quadtree the MC limit alone suffices for this front.