Skip to content

The order of the energy source ​

IDGroupMilestoneBackendsFigureRegression
GV-9 (G2a)External gravityM7 (#73)CPU, FNLyes—

Case and scope ​

The fluxes of a finite-difference scheme are point values of the primitive function h of ρu (ρu=1Δx∫h over the cell), not of ρu. G1's energy source 12g(Fi−1/2ρ+Fi+1/2ρ) is then gρui+O(Δx2), and it took the whole scheme to second order on any smooth flow under gravity. None of the G1 legs measured an order: free fall is uniform, and the conservation legs are exact at any order.

G2a adds the correction 124g(−Fi−3/2ρ+Fi−1/2ρ+Fi+1/2ρ−Fi+3/2ρ), which makes the source the cell value of h to fourth order. The case that measures it is a density wave falling freely in a periodic box: the momentum source is exact on it, the energy source is not (its (ρu)″ is not zero), and p is uniform, so any pressure error is the energy source's. A second-order energy source fails the asserted order of 3.5.

Models and numerics ​

ItemChoiceCode
Equationscompressible Euler, ideal gas, γ=1.4models
Energy source∑dgd(−Fi−3/2ρ+13Fi−1/2ρ+13Fi+1/2ρ−Fi+3/2ρ)/24: the face form plus the fourth-order correction, from the high-order face mass fluxes of the stage, before any blendingadd_gravity_sources, compute_gravity_correction, compute_gravity_correction_faces, adam_flume_cpu_object.F90; compute_gravity_correction_faces_dev, adam_flume_fnl_kernels.F90
Block-end facesthe faces i±3/2 of the block-end cells lie beyond the block: two edge kernels, one per face family, compute them from the ghostsadd_gravity_edge_correction, adam_flume_cpu_face_kernels_agnostic.INC (weno), adam_flume_cpu_riemann_face_kernels_agnostic.INC (weno-riemann); add_gravity_edge_correction_dev, adam_flume_fnl_face_kernels_agnostic.INC
Ghost cellsone more layer than the WENO stencil, ngc >= S + 1 (with weno-riemann max(S, 2) + 1), fatal otherwisecheck_ngc_number, adam_flume_common_object.F90
Limiterthe correction is a high-order cell source, scaled by Λ with the rest of the face formadd_gravity_limited_correction, adam_flume_cpu_object.F90; numerics
Space, wenoWENO5 (weno-u-5) flux splitting on characteristic variablescompute_residuals_weno, adam_flume_cpu_object.F90; numerics
Space, weno-riemannWENO5 interpolation, HLLC, sixth-order flux correction (flux_correction = 6th, sensor weno)compute_residuals_riemann, adam_flume_cpu_object.F90; adam_flume_cpu_euler_hllc_kernels.F90; numerics
TimeSSP Runge–Kutta, 3 stages (runge-kutta-ssp-33), CFL 0.4(32/N)2/3 so the RK3 error stays below the spatial oneadam_rk_object.F90
Boundariesevery face periodicboundary conditions
FNL backendthe same kernels on the deviceadam_flume_fnl_object.F90

Initial and boundary conditions ​

ItemValue
Casewave2d
Domain[0,1]2, null z
Gridquadtree, 4×4 blocks of n2 cells, n=8,16,32 (N=32,64,128), two uniform levels, ngc = 4
Ranks2
Initial conditionsine-wave, wave_mode = entropy, wave_angle = 45, wave_amplitude = 0.2, wavelength =1/2: ρ=1+0.2sin⁡(2π(x+y))
Stateu0=(1,0.5), p=1
Gravityg=(−0.6,−0.8)
Exact solutionthe wave advected by u0t+gt2/2, u=u0+gt, p uniform
Boundariesevery face periodic
Final timet=0.2
Assertedthe L1 orders of ρ and p on the finest pair at least 3.5, on weno and on weno-riemann

Input files ​

FileRole
src/tests/flume/verification/gravity/make_atmosphere.pywrites wave2d (--cells, --cfl, --time-max, --riemann hllc)
src/tests/flume/verification/gravity/check.shruns the ladder on both schemes with the force legs (GV-9, --legs gv9)
src/tests/flume/verification/gravity/atmosphere_oracle.pywave: the L1 errors against the exact falling wave and their orders (--min-order 3.5)
src/tests/flume/verification/make_doc_runs.sh (group gravity)re-runs wave-{weno,riemann}-{8,16,32}
src/tests/flume/verification/make_doc_figures.py (fig_gravity_order)draws the figure
bash
cd src/tests/flume/verification/gravity
./check.sh --np 2 --cases iso2d                                          # CPU (GV-9 runs with the force legs)
FLUME_EXE=$PWD/../../../../../exe/adam_flume_fnl ./check.sh --np 2 --cases iso2d   # FNL

Results ​

GV-9: L1 errors of the falling density wave against N, weno and weno-riemann

L1 errors of ρ and p of the falling density wave against N, weno and weno-riemann (HLLC).

The two schemes lie on top of each other, ρ at slope 5 and p at 4.6 on the finest pair. The pressure error is the energy source's: on this wave the momentum source is exact and p is uniform, so any pressure error comes from the energy equation. The control is not drawn (it needs a special build); its errors are in the table.

CPU and FNL agree to every digit shown:

SchemeL1 p/p1 at N=32,64,128Orders (ρ, p), finest pair: boundCPUFNL
G1 face form alone (weno, negative control)1.1⋅10−5, 2.8⋅10−6, 7.0⋅10−7—2.12, 2.00the same
weno3.3⋅10−7, 1.2⋅10−8, 5.2⋅10−10≥3.55.01, 4.57the same
weno-riemann (HLLC)3.4⋅10−7, 1.3⋅10−8, 5.3⋅10−10≥3.55.00, 4.59the same

At N=128 the pressure error falls 1300-fold. The negative control is a build with the correction switched off, not a run-time option; it is not part of check.sh.

The other GV legs re-run with the correction (CPU and FNL) are tabulated in the gravity force: GV-1 unchanged, GV-3 conserving W to ≤1.2⋅10−14, box2d-lim with 107 984 limited faces, GV-6 and NV-5 bitwise, GV-7 ≤7.9⋅10−14.

Related cases: the gravity force (the face form and the closed boxes); the second-order potential path of self-gravity runs the same wave in SV-1.

Findings ​

  • The face form alone is second order on a finite-difference scheme; the fourth-order correction restores the order of the scheme (5 in ρ, 4.6 in p) on both face families.
  • Conservation. Each face's weights still sum to one over the cells, so E+ρΦ stays conserved exactly with periodic boundaries and across block interfaces.
  • The invariant at reflecting walls (owner decision: W is the invariant). At a wall the correction of the wall cell reads the face beyond it: the mirrored ghosts give F−1=−F1 and F0=0, and the wall row's mass balance F1=−Δxdρ1/dt turns the left-over gΔx(F1−F−1)/24 into d/dt(−gΔxρ1V/12). The exactly conserved total energy is then W=∑(E+ρΦ)V+∑lower wallgnΔxnρV/12−∑upper wallgnΔxnρV/12, an O(Δx2) wall term away from the plain sum. Dropping the correction flux at walls would keep the plain sum but cost the wall cells an O(Δx) energy source error. GV-3 asserts W and reports the plain sum (the gravity force).
  • One more ghost layer. The faces i±3/2 of the block-end cells lie beyond the block, so gravity takes ngc >= S + 1, fatal otherwise; every gravity input has ngc = 4.
  • With the positivity limiter the correction is a high-order cell source, scaled by Λ with the rest of the face form; box2d-lim limits more faces than at G1 (107 984 against 74 304) for that reason.