Skip to content

Self-gravity under runtime AMR ​

IDGroupMilestoneBackendsFigureRegression
SV-11Self-gravityM8 (#81), P5cCPU, FNLyes—

Case and scope ​

Under runtime AMR the grid, and with it the solver, change during the run. Every regrid must:

  • set up the right solver: the FFT on a uniform grid, the multigrid on an AMR one;
  • solve Φ from the regridded state;
  • rebuild the flux register the seam gravity work rides on.

What changes and what does not. The regrid itself conserves ρ, ρu and E (conservative prolongation and restriction). W=12∑ρΦV, though, is the energy of the grid's own discrete Laplacian, so a regrid that changes the grid changes W, and E+W jumps by a truncation-sized amount. Between regrids the scheme stays exact (SV-10). The leg separates the two.

What the case catches:

  • a regrid that keeps the old solver or the old potential: the step changes of E+W between regrids leave the time-integration level;
  • a jump of E+W off a regrid step (a leak that is not the change of the discrete W);
  • a momentum or mass leak through the regrid.

Isolated boundaries under runtime AMR, refused here until #87, are verified with the polytrope (SV-14), with the refusal of a regrid that refines a boundary block.

Models and numerics ​

ItemChoiceCode
Equationscompressible Euler, γ=5/3, periodic self-gravitymodels
Regridevery 5 steps ([amr] frequency = 5), one level above the base, a Löhner estimator on the density (mode 4): refine above 0.3, derefine below 0.1regrid_forest, adam_flume_cpu_object.F90, adam_flume_fnl_object.F90; numerics
Solver after a regridset_potential sets the solver up on the new grid (FFT if the leaves are at one level, multigrid otherwise) and solves Φ from the regridded state; the FNL backend copies it to the deviceset_potential, adam_flume_common_object.F90; refresh_potential, adam_flume_fnl_object.F90
Seam gravity workin the per-stage refluxadd_seam_gravity_work, adam_flume_common_object.F90; reflux_stage, adam_flume_cpu_object.F90
Space, timeWENO5 flux splitting (weno), SSP-RK3, CFL 0.4numerics

Initial and boundary conditions ​

ItemValue
Casejeansc2d: the collapse of SV-4, G=9π/2, amplitude 10−2, the box [1/8,9/8]2 (sine-wave, wave_mode = jeans)
Gridbase 322 (4×4 blocks of 82, two uniform levels), at most one level more by the regrid; 4 ghosts
Boundariesevery active face periodic
Refluxper stage (reflux_cadence = stage)
Ranks2
Endt=0.4 (the figure's run: a checkpoint every 10 steps)

Input files ​

FileRole
src/tests/flume/verification/selfgravity/make_jeans.py--regrid N writes the Löhner marker and [amr] frequency
src/tests/flume/verification/selfgravity/jeans.shleg sv11 (FLUME_EXE selects the backend)
src/tests/flume/verification/selfgravity/jeans_oracle.pyregrid: the grid must change; every jump of E+W (a step change above 100 times the median) on a regrid step; the other step changes, the momentum and the mass bounded
src/tests/flume/verification/make_doc_runs.sh, group amrsv11-regrid, a checkpoint every 10 steps
src/tests/flume/verification/make_doc_figures.py, fig_selfgravity_amr_regriddraws the figure (--only selfgravity-amr-regrid)
bash
cd src/tests/flume/verification/selfgravity && ./jeans.sh --legs sv11                       # CPU
FLUME_EXE=$PWD/../../../../../exe/adam_flume_fnl_fft ./jeans.sh --legs sv11                   # FNL

Results ​

SV-11: the change of E + W through the regrid, the blocks, and the density on the final composite grid

Left: E+W drifts at the time integration's level until the regrid at t=0.35 refines the ridge (16 → 52 blocks), then jumps once and stays flat. Right: the final density, the refined blocks along the ridge.

AssertedBoundCPUFNL (WSL GPU)
the grid changes (blocks of the first and the last checkpoint)must differ16 → 5216 → 52
every jump of E+W on a regrid stepyesone jump, at step 60: −2.3⋅10−4the same, −2.3⋅10−4
the largest other step change of E+W, relative10−67.6⋅10−87.6⋅10−8
max |momentum|; mass drift10−14; 10−142.9⋅10−18; 04.7⋅10−18; 1.1⋅10−16

Related cases: the same collapse on a static AMR grid is SV-10, on a uniform grid SV-4; runtime regridding without gravity is runtime regrids.

Findings ​

  • The regrid jump is the change of the discrete W. At the regrid E is unchanged and W moves by 1.4⋅10−3 of itself, the size of the O(h2) truncation at 322. It does not converge in a resolution ladder, because the refinement happens at different stages of the collapse (at base 642 the ridge crosses the threshold later, when it is sharper). The jumps are reported, not bounded.
  • Correcting E at each regrid would make the regrid conserve E+W; it is not done.
  • The solver follows the grid. With refine and derefine thresholds of 0.1 and 0.03 the same collapse refines everywhere by t=0.27, so the grid becomes uniform again and the FFT solver takes over. That run passes the same oracle, with jumps at steps 40 and 50.
  • No regression case freezes self-gravity under runtime AMR; selfgravity-amr-stage covers the per-stage reflux on a static grid.