Skip to content

Numerical methods ​

FLUME discretises the conservation laws with high-order finite differences on point values: the state qi is the value at the centre of cell i of a uniform Cartesian block, and the semi-discrete update is the conservative flux difference

dqidt=−∑dF^d,i+1/2−F^d,i−1/2Δxd+S(qi),

integrated in time by an explicit Runge–Kutta scheme. The numerical flux F^i+1/2 is built so that the difference is a high-order approximation of ∂F/∂x (Shu & Osher 1989). Three space operators are available, selected by [numerics] scheme_space:

scheme_spaceFace fluxModels
wenoWENO reconstruction of the Lax–Friedrichs-split fluxes, per characteristic fieldEuler, MHD
weno-riemannWENO interpolation of the face states, a Riemann solver and a high-order correction (Chen, Tóth & Gombosi 2016)Euler (LLF, HLL, HLLC); MHD (LLF, HLL, HLLD)
hybrid-kep-wenoweno, with a 6th-order kinetic-energy- and pressure-equilibrium-preserving central flux at the faces away from shocks (turbulence)Euler

All operators store the face flux at the same place, so seams, AMR reflux and the flux difference are shared.

Grid, blocks and ghost cells ​

The domain is a forest of Cartesian blocks of ni × nj × nk cells, organised by an octree (or quadtree) with Morton ordering. Each block carries ngc ghost cells per side, filled before every residual evaluation from the neighbouring blocks (MPI exchange across ranks), from the physical boundary conditions, or by the coarse–fine interpolation at an AMR seam. A direction flagged null_x/y/z = .true. is inactive: its fluxes are not computed and the solution is constant along it (1-D and 2-D problems are 3-D runs with null directions). The ghost width must cover the stencil: ngc ≥ S for WENO of order 2S−1 (ngc = 3 for WENO5), and ngc ≥ 2 for weno-riemann.

WENO reconstruction ​

A WENO scheme of order 2S−1 ([weno] scheme = weno-u-{3,5,7,9}, S=2…5) combines S candidate polynomials pk, each on S points, with nonlinear weights

v^i+1/2=∑k=0S−1ωkpk,ωk=αk∑jαj,αk=dk(ε+βk)m,

with the optimal (linear) weights dk, the Jiang–Shu smoothness indicators βk, ε=10−6 and the exponent m=S (S−1 for S>4), the same on the host and on the device. The kernels are SETH's (seth_weno<2S-1>_js, one per width, compile-time coefficients; #139): on the CPU since S3a and on the GPU since S3b, each the same results as ADAM's former kernels bit for bit (no table crosses the device kernel boundary any more). On smooth data ωk→dk and the combination reaches order 2S−1; the stencils crossing a discontinuity get ωk→0. The centred schemes weno-c-* are refused by FLUME.

The absolute ε ties the weights to the units of the data: βk scales as the square of the field, so on a field of magnitude 10−4 the ratio βk/ε is 108 times smaller than on the same field at magnitude 1, the weights collapse to the linear ones and the scheme stops limiting (measured on Sod at an interstellar density, 10−21 kg/m³: the total variation of the density grows by 33%, and by 178% with weno-riemann, whose sensor reads the same weights; NV-6). Two cures: the reference layer, which hands the solver numbers of order 1, or [weno] weights = si, scale-invariant weights after Don, Li, Wang and Wang (2022):

αk=dk(ε+βk/μ2)m,

μ a magnitude of the reconstructed field with its units, so that βk/μ2 does not depend on them. The mean of |v| over the stencil (the descaler of Don et al.) fails on the characteristic fields: a field such as the shear wave ρ(v−vRoe), or one carrying only a small wave, is near zero by construction, εμ2→0, and the weights turn fully nonlinear on smooth data (the isentropic vortex falls from order 5.79 to 4.10, #49). FLUME takes instead the magnitude of the state that the field projects,

μk=⟨∑v|lkv|12(|fv|+αmaxq^v)⟩stencil

for the split fluxes (⟨∑v|lkv|q^v⟩ for the interpolated fields of weno-riemann), lk the left eigenvector (the identity for conservative variables), αmax the largest speed of the stencil (MHD: max(|un|+cf), never ch) and q^v≥|qv| a reference magnitude of each component: |ρ|, |E|, ∥ρu∥1+ρp for every momentum component, ∥B∥1+p for every field component, |ψ|+chq^B (GLM) or |ψ|+q^B (EGLM). With |qv| instead, a field built on vanishing or exponentially small components (the far field of the magnetised vortex, ∼10−21) gets a descaler of its own size, the weights treat round-off as data, and the vortex goes unstable at 256² (MV-7).

μk never vanishes on a physical state and at unit scale acts like the absolute ε (isentropic vortex: L1=7.22⋅10−8 at 256², order 4.97, against 8.38⋅10−8 with js). Every term scales exactly like the field, so multiplying the data by 2n multiplies the reconstruction by 2n bit for bit (unit tests test_flume_weno_weights, on SETH's kernels; the whole solver: the scaling oracle). μ is floored at the smallest normal number. Primitive variables have no projection, so si with weno-riemann on primitive variables is refused. A uniform field in a non-uniform state (the Bn of a 1-D MHD problem) is reconstructed with face values that differ in the last bits, because the si descaler varies from face to face (RJ2a: GLM equals the run without cleaning to 10−13, not bitwise).

The default js is the first formula, bitwise unchanged: the kernel receives 1/μ, which is exactly 1 for js, so the choice costs no branch in the kernels.

Round-off sensitivity of js on low-β MHD. On the flux-splitting scheme at low β (the Balsara–Spicer blast, β=2.5⋅10−4, characteristic variables) the js weights amplify a round-off difference in the data by about 3⋅104 within one step at the blast front; the si weights do not. Measured on two states that are equal in exact arithmetic, the identical z layers of an octree run with a null z axis (quadtree AMR, MV-15): with js they differ by 10−8 after 16 steps and by 1.9⋅10−3 (ψ) at t=0.006, with si by 3⋅10−12 and 5⋅10−8; on weno-riemann HLLD by 10−13 with js. The weights set this seed only: the splitting scheme's low-β grid-scale instability grows it by an e-fold about every 10 steps with either (the MHD blast symmetry study: si delays the loss of point symmetry by about 120 steps, 0.08 at t=0.01 against 0.18, and does not prevent it). js stays the default: switching would change every MHD golden, and the accuracy cost of si on MHD is not measured (#138 tracks it). Where the agreement of runs that are equal in exact arithmetic matters (backends, decompositions, symmetric setups), [weno] weights = si keeps it longer; weno-riemann with riemann_solver = hlld keeps it.

The WENO kernel takes its coefficient tables as arguments, so one kernel serves two purposes:

  • reconstruction (weno): from point values of a flux, the face value whose difference approximates the derivative;
  • interpolation (weno-riemann): from point values of the state, the state at the face. The interpolation tables (for WENO5: candidates exact to degree 2, combination (3,−20,90,60,−5)/128, linear weights 1/16,10/16,5/16) are generated with exact rational arithmetic by riemann-flux/weno_interpolation_tables.py.

scheme_space = weno: flux splitting ​

At each face i+1/2 of direction d, over the stencil of cells i−S+1…i+S:

  1. the eigenvectors are evaluated at the face (Euler: the Roe average of cells i, i+1; MHD: their arithmetic average);
  2. the state and the physical flux of every stencil cell are projected on the left eigenvectors, wk=lk⋅q, gk=lk⋅F (reconstruction_variables = characteristic), or kept component by component (conservative);
  3. each field is split with a local Lax–Friedrichs speed, gk±=12(gk±αkwk), where αk=maxstencil|λk| per characteristic field (conservative: one speed max(|un|+c), and with GLM at least ch);
  4. g+ is reconstructed from the left-biased stencil and g− from the right-biased one, and the face flux is projected back, F^=∑krk(g^k++g^k−).

For MHD the characteristic decomposition is block-diagonal: the 7×7 wave core plus the (Bn,ψ) pair with speeds ∓ch (without cleaning the Bn row has speed 0 and its face flux is exactly zero). The core is the Roe–Balsara set in the normalisation of Stone et al. (2008, appendix B), with αf2=(a2−cs2)/(cf2−cs2) and αs2=(cf2−a2)/(cf2−cs2). At high β with B near the face normal one of the two numerators is a difference of O(a2) speeds far smaller than them, so FLUME evaluates the smaller one without subtracting, 2a2ct2/((cf2−cs2)±(vA,n2+ct2−a2)) with ct2=Bt2/ρ, and the other as its complement. Subtracted directly, the normalisation carried an absolute error of ∼ε1/2 that the characteristic WENO turned into a 10−6 difference of B between compilers (#79).

scheme_space = weno-riemann: interpolation, Riemann flux and correction ​

The face flux of the hybrid scheme (Chen, Tóth & Gombosi 2016) is

F^i+1/2=FRS+s[c1FRS+c2(fi+fi+1)+c3(fi−1+fi+2)−FRS],

with FRS the Riemann flux of the two interpolated face states, fm the physical flux of cell m and s∈{0,1} a per-face sensor:

  1. Face states. The fields of the stencil are interpolated to the face from the left and from the right (reconstruction_variables: characteristic, the recommended default for Euler and MHD, with the eigenvectors of the face; or primitive, (ρ,u,v,w,p), plus B and ψ for MHD). A face state with non-positive density or pressure is replaced by the adjacent cell's state.

  2. Riemann flux (riemann_solver):

    • llf: FRS=12(fL+fR)−12α(qR−qL), α=max(|un|+a) of the two states;
    • hll (Harten, Lax & van Leer 1983) with the Einfeldt speeds SL=min(un,L−aL,u~n−a~), SR=max(un,R+aR,u~n+a~) (Roe averages): FRS=(SRfL−SLfR+SLSR(qR−qL))/(SR−SL) for SL<0<SR, the upwind physical flux otherwise;
    • hllc (Toro, Spruce & Speares 1994) with the same outer speeds and the contact speed of Batten et al. (1997), SM=pR−pL+ρLun,L(SL−un,L)−ρRun,R(SR−un,R)ρL(SL−un,L)−ρR(SR−un,R); it resolves an isolated contact exactly.
  3. Correction (flux_correction), coefficients derived with sympy so that the flux difference approximates the derivative of point values:

    flux_correctionc1c2c3Order of the flux difference
    6th64/45−13/601/1806 (the WENO5 interpolation limits the scheme to 5)
    4th4/3−1/604
    none1002
  4. Sensor (flux_correction_sensor): with weno, s=1 where every interpolated field keeps its nonlinear weights close to the linear ones, minkωk/dk≥0.2 on both sides of the face, and s=0 elsewhere: the correction, which amplifies jumps by 64/45, is switched off at discontinuities. none keeps it everywhere.

For MHD (riemann_solver = llf | hll | hlld) the solvers of adam_flume_mhd_riemann_library work in the frame of the direction, so the x, y and z runs of a rotated problem stay bitwise equal. HLLD (Miyoshi & Kusano 2005) handles its degenerate cases and falls back to HLL per face when a star state is not admissible or the wave speeds are out of order; the log counts the fallbacks per stage (HLLD fallbacks to HLL: N faces). With GLM the (Bn,ψ) subsystem is solved exactly at the face and both states take the resulting B~n; with EGLM the same in field units, the cleaning energy ψ2/2 kept out of the solver states and added to the energy flux (EGLM). Both interpolations agree on smooth waves; at discontinuities characteristic interpolation is more accurate (the recommended default), and primitive keeps the 7×7 eigenvector projection out of the face kernel.

Measured (WENO5, 6th-order correction, np 2, CPU and FNL identical to the printed digits; verification gallery):

CaseResult
Isentropic vortex, Euler HLLCorder 6.5 between 128² and 256², L1(ρ)=8.0⋅10−8 (splitting: 8.4⋅10−8)
Sod, Shu–Osher, Lax, Euler HLLCL1 9 % and 7 % below the splitting scheme's, 1.6 % above on Lax
Ryu–Jones 2a, 256 cellsHLLD L1=3.76⋅10−2 characteristic, 5.13⋅10−2 primitive (splitting 3.84⋅10−2; HLL 4.32, 5.98⋅10−2)
MHD linear waves, circularly polarised Alfvén waveorder 4.96–5.00
Brio–Wu, Ryu–Jones 4dno floor and no HLLD fallback needed
Orszag–Tangsymmetric, conserved to 10−16

Positivity limiter ​

[numerics] positivity_limiter = cell (#47; both space schemes) makes each stage keep the density and the pressure positive, so the floors are not needed on hard problems.

Backbone. Per cell, the backbone is the forward-Euler update with the first-order Lax–Friedrichs fluxes of the cell states: Rusanov for Euler; for MHD the Wu speed, which adds |BL−BR|/(ρL+ρR) to the fastest wave, and with EGLM at least ch. EGLM also takes the second-order nonconservative sources. With the Godunov–Powell (EGLM) sources the backbone is admissible under the CFL bound (Wu 2018, Wu & Shu 2018).

Cell factor. Each face carries the antidiffusive difference ±Δt/Δx(F−FLF) of the high-order flux F (EGLM also the difference of the high- and second-order sources). The cell factor Λ is the largest value in [0,1] for which every corner of the box [0,Λ]faces keeps ρ and the internal energy above their floors. Both are concave in the conservative state, so each corner has a closed-form factor (Zhang & Shu 2012), and 22D corners (16 in 2-D, 64 in 3-D) bound every combination.

Floors. The floor of a quantity is κ times its backbone value, κ=0.1, so a stage may not take a cell below a tenth of its first-order update. Positivity alone leaves a state admissible but not usable: on the planar Sedov blast with HLLC an absolute floor of 10−13 let one stage drain the centre cell to ρ=10−13 with its energy kept, and the next stage had no admissible backbone. The floor is relative only, because an absolute one makes the solution depend on the units of the input (#49). A smooth update differs from the backbone by O(Δx), so the relative floor does not act there.

Face blend. A face takes the smaller factor of its two cells, F←FLF+θ(F−FLF) (Xu 2014; Christlieb et al. 2015). The update is conservative and the forward-Euler step of the stage is admissible. An SSP Runge–Kutta stage is a convex combination of forward-Euler steps, which is why the limiter requires an SSP scheme (SELAH's SSP coefficient C>0). The step is the one the stage's residual actually takes in the scheme's Shu–Osher form, fkΔt with fk=maxiβik/αik (SELAH's stage_euler_fraction, maxkfk=1/C): a stage state plus fkΔt times its residual kept admissible keeps every later stage and the step admissible. fk=1 for every stage of SSP-11/22/33; SSP-54 has fk=0.392,0.663,0.663,0.663,0.584, so its stages are limited less than a step of the whole Δt would (#134 D4). A face whose two cells keep Λ=1 is not touched, so smooth runs are bitwise unchanged. The cell factors are exchanged like a field (intra-realm copies and MPI); a physical-boundary face takes the interior cell's factor.

Log. Per stage the log reports the limited faces and the cells whose backbone is inadmissible (zero in every verified case; they would fall back to the floors). A cell with a non-finite high-order face flux takes Λ=0 and its faces the backbone flux itself, since a NaN would pass every comparison of the corner factors and survive the blend. Such cells are logged on a line of their own; none occurs in the verified cases.

On the Balsara–Spicer blast (β = 2.5·10⁻⁴, EGLM) the splitting scheme fails at step 3 without the limiter and reaches t=0.01 with it (at most 4% of the faces limited per stage); weno-riemann HLLD passes with or without it.

At a 2:1 AMR seam the end-of-step reflux replaces the coarse face flux with the restricted fine one, a correction that no cell factor bounds: on the blast across a refined box it drives coarse cells beside the seam to ρe<0 (#50). A limited run therefore synchronises the seam flux at every stage, before the update. The fine seam faces take the backbone FLF(qC,qf), with the coarse cell qC as outer state. The coarse factor ΛC uses the means of the four fine backbone and high-order fluxes on the seam face; the coarse backbone update is then a convex combination of Lax–Friedrichs updates of qC, so it is admissible. Both sides blend with θs=min(ΛC,minΛf), so the coarse flux is exactly the mean of the fine ones, the stage is conservative, and the reflux only corrects round-off. The seam data travel over the ranks in seam skins (four reductions of seam size per stage); on the GPU the seam cells are gathered to the host, which recomputes their factors.

With self-gravity the register also carries the seam gravity work, so the end-of-step correction is not round-off: on a star whose surface a 2:1 seam cuts it drives a coarse atmosphere cell to ρe<0 (#88). A limited run gives each coarse cell the largest fraction θ∈[0,1] of its correction that keeps ρ and ρe at least κ times their values before it (reflux_positivity_theta, a bisection on the concave ρe(θ)). A cell whose full correction is admissible receives it exactly; a clipped cell gives up conservation by the part it did not receive, and the step logs reflux positivity: +N coarse cells limited. reflux_cadence = stage needs no such bound: its correction acts inside the stages, before the limiter.

Physics extensions ​

The equations of these extensions are on the models page; this section gives their discretisation.

Dual energy ​

The entropy ρs of euler-de (model) is a sixth characteristic field of eigenvalue un, carried by the acoustic and entropy waves of the Euler system, and is refluxed and prolonged like the other variables. The switch sync_dual_energy runs once per step, after the reflux and any regrid; CPU and FNL run the same rule (sync_dual_energy, sync_dual_energy_dev).

Passive scalars ​

Each scalar ρsk (model) rides the machinery of the dual-energy entropy: a characteristic field of eigenvalue un, its specific value averaged like the velocity, refluxed and prolonged like the other variables. The capacity is fixed: the kernels are compiled for four slots, the first N used and the others zero, so a scalar run pays the projection of the wider state. A scalar may vanish (a face state needs it non-negative, the entropy positive). WENO keeps it bounded only to its own accuracy: across a Sod contact a mass fraction moving from 1 to 0 over- and undershoots by 5⋅10−4.

Isothermal and barotropic equations of state ​

Each gas (model) is its own model, MODEL_EULER_ISO and MODEL_EULER_BARO, on one pointwise library body behind the interface of the Euler library, so the model-agnostic kernel bodies run it unchanged. The body takes the EOS from four hooks of the including module (the pressure, the temperature, the sound speed and the speed of the Roe average); the isothermal hooks are the closed forms, the barotropic ones read the realm's table. The kernels receive the EOS through one scalar (physics%eos_arg: γ, c02 or the table id). The tables live in a fixed-size registry (adam_flume_eos_tables_library): each realm registers its table at initialization, identical tables share an entry, and the FNL backend copies the registry to the device once. CPU and FNL instantiate the same kernel bodies on the same library.

Eigensystem. In direction n the acoustic eigenvectors are

r1,5=(1, u∓c0n, 0),l1,5=(±un±c02c0, ∓n2c0, 0),

the transverse ones r=(0,t,0), l=(−u⋅t,t,0). The Roe average of two isothermal states is the ρ-weighted velocity with the same c0. For the barotropic gas the Roe average keeps that velocity and takes the secant speed c~2=[P]/[ρ], the one for which the Roe matrix satisfies [F]=A~[U] for any P(ρ); P increases with ρ, so it is positive, also across breaks. Below a relative density jump of 10−6 the secant loses digits to cancellation (about ε over the jump) while c2 at the mean density errs by the jump squared, so there the mean is used.

Fluxes. weno splits on this eigensystem; weno-riemann interpolates the characteristic fields or the primitives (ρ,u), the inert slot in place of the pressure, and a face state is admissible when ρ>0. llf and hll (Einfeldt speeds) are the standard fluxes on the two acoustic speeds. The isothermal HLLC is HLL on the mass and the normal momentum, and the transverse momenta (and any advected scalar) are the HLL mass flux times the upwind specific value: the contact carries only the transverse velocity, so the star state needs no pressure. A Riemann flux always returns 0 in the inert slot. A null direction freezes its momentum (null_freeze), as for every Euler model.

Gravity. The residual of the energy slot is cleared after the sources (clear_inert_energy), the fourth-order energy correction of the constant gravity is not computed (nor its ngc >= 4 stencil required), and the AMR reflux carries no seam gravity work.

Positivity. The cell limiter is the density-only one: the models' admissible quantity is the density, so a stage and the end-of-step reflux keep every cell's density above POSITIVITY_LIMITER_KAPPA times its first-order backbone value, and an inadmissible seam ghost takes its interior cell. A corner whose density the chord takes to the floor would keep its momentum, so its velocity ρu/ρ would be extrapolated up to 1/κ times the backbone's. These gases therefore take a kinetic chord, the same closed form on the concave f=ρW−|m|2/(2ρ) with W=(4|ub|2+c2)/2 of the backbone (c2=dP/dρ at its density; the reflux limiter c02). f≥κfb bounds the corner's speed by about 4|ub|2+c2, twice the backbone's. The factor 4 matters for cold gas: with W=(|ub|2+c2)/2 a stage at Mach M that outruns its backbone by 0.45c/M is already clipped, and the sinks' cold accretion drifted its momentum by 13 % of the exchange, against 2.6 % with the factor (EO gravity).

Isothermal and barotropic MHD ​

The MHD gases (model) are MODEL_MHD_ISO, MODEL_MHD_BARO and their mixed-GLM twins MODEL_MHD_GLM_ISO, MODEL_MHD_GLM_BARO, on one library body (adam_flume_mhd_iso_library_body.INC) behind the EOS hooks. The normal field is a parameter of the 1-D core, as in the adiabatic library.

Eigensystem. The eigenvectors of Kim et al. (1999, ApJ 514, 506, eqs. 2-9 to 2-53) serve both gases with a2=c02 or the table's dP/dρ. Kim's fast normalisation αf=cf2−bn2/cf2−cs2 is the Ryu–Jones αf times cf/a. FLUME computes it from the cancellation-free pair of the adiabatic core (#79), with that core's degenerate values and the sign of Kim's eq. 2-53. The characteristic projection takes the eigenvectors of the arithmetic face average.

HLLD. The isothermal HLLD of Mignone (2007, section 3) has three states between the outer speeds SL,R and the rotational speeds SL,R∗=u∗∓|Bn|/ρ∗:

  • ρ∗, mn∗ and the first two flux components are the HLL averages, with u∗=Fρhll/ρhll;
  • the transverse components follow eqs. 30–37, and the flux eq. 38.

The outer speeds are those of the adiabatic library (Miyoshi & Kusano 2005, eq. 67). They bound Mignone's Davis estimates, whose eq. 39 is misprinted with SR a minimum: it must be the maximum. In the degenerate case, (S−SL∗)(S−SR∗)→0, the outer transverse state is kept. The flux falls back to HLL when ρ∗≤0 or when the speeds are out of order. They can be: u∗ is the advective velocity, which a strong density jump drives far off, and on Mignone's own tube 1 (ρL/ρR=10) the first face has SR∗=3.90>SR=3.37. LLF and HLL use each state's own Bn, so its jump is dissipated as in the adiabatic library; HLLD uses the average. With B=0 the HLLD flux is the isothermal HLLC's, and an isolated rotational discontinuity is resolved exactly.

src/tests/flume/verification/eos/mhd_oracle.py checks the two papers independently of the code (LR=I and RΛL=∂F/∂U at random and degenerate states, both gases; HLLD consistency, exactness and its hydrodynamic limit), and the Fortran library agrees with it to 2⋅10−15 on 525 cases.

Positivity. positivity_limiter = cell takes the density and the kinetic chord of the Euler gases, c2=dP/dρ of the backbone, and an inadmissible seam ghost takes its interior cell. It is refused with GLM, as for the ideal gas. The FNL kernels are the device twins of the CPU ones on the same library; the barotropic table is read from the device registry.

Radiative cooling ​

Cooling (model) is operator split: once per step, after the dual-energy sync, apply_cooling cools every cell isochorically over the step just advanced. The coupling with the dynamics is first order in Δt (Lie splitting, the field step first); the cooling itself is exact. SELAH owns the composition (additive_splitting, lie): the post-step flows, cooling and sinks, run over its flow substep, one of the whole Δt after the forest's field step.

Λ is a piecewise power law, so Townsend's exact integration (Townsend 2009) applies. Isochorically dT/dt=−(γ−1)ρΛ(T)/(m2R). With the temporal evolution function Y(T)=(ΛN/TN)∫TTNdT′/Λ(T′), closed form on each segment, dY/dt is the constant (γ−1)ρΛN/(m2RTN). One step adds Δt times it to Y(T) and inverts Y on the segment that holds the result: exact and unconditionally stable for any Δt/tcool. A cell whose Y passes Y(T1) stops exactly at T1. Near a segment exponent αk=1 both the closed form and its inverse are (1−xε)/ε with ε small; they are evaluated through expm1 and log1p (written as series below 10−2), so every exponent keeps full precision. A cell that does not cool keeps its bits.

On a uniform box the temperature follows the ODE solution to 4⋅10−14 relative, at the CFL step as with the limiter, on CPU and FNL alike (CO). The FNL device kernels (apply_cooling_dev, apply_cooling_entropy_dev) run the same library arithmetic, with tables of fixed size 64 nodes.

Sink particles ​

Replicated list. Every rank holds every sink (model) and updates it identically from MPI-reduced sums, so no sink is owned and none migrates; the replicated tree locates any sink's block on any rank.

Deposit and gather. Each sink's mass is spread over its cloud-in-cell stencil (the 8 cell centres of the level of its block around it) and added to the Poisson source through the packed path of both solvers. A sink feels the centred difference of Φ at those cells, interpolated with the same weights: the deposit-interpolation pair of Hockney & Eastwood (1988), free of self-force on a uniform grid. The gas feels Φ through its face gradients, so gas and sinks exchange momentum equal and opposite to truncation (4⋅10−5 relative on a uniform box). Near a point mass the gas's face gradients and the sink's CIC gather differ by about 1 %, so the gravity exchange during accretion is not exact. A sink at rest on a composite grid that is not symmetric about it feels its own potential through the 2:1 seams: a constant truncation force, 3⋅10−2 finest cells over t=0.5 on a refined box, against 1.4⋅10−4 on a uniform one (verification).

Time stepping. The gas step runs with the sinks at their positions xn in the Poisson source. Then, once per step on the committed state, kick-drift-kick: v+=Δt2a, x+=Δtv, the potential re-solved, a gathered at the new positions, v+=Δt2a. The kick-drift-kick is SELAH's Strang splitting of the velocities (the kick, residual a) and the positions (the drift, residual v), each an exact sub-flow: SELAH gives the fractions and the update, FLUME the accelerations, re-solved after the drift. This is second order for the sinks and first order in their coupling with the gas (the Lie composition above). Two time-step limits apply: a sink moves at most half a cell of its level per step, and gas a cell away from it, pulled by Gm/h2, at most half a cell from rest, Δt≤12h3/(Gm) (the acceleration limit of Federrath et al. 2010: a cold dense medium has a CFL step far longer than its fall onto a sink, and the self-gravity source is not limited by the CFL condition). Creation, accretion and mergers run once per step on the committed state, its ghost cells and its potential refreshed.

Backends. CPU and FNL run the same arithmetic, and their sink histories agree to round-off. The deposit and the gather are host work on both (FNL solves the Poisson equation on the host); the kick-drift-kick runs where SELAH's kernels run (the few sinks packed into a SELAH field, on the device in the FNL build). Accretion runs on the cells within the radii, which FNL gathers from the device and scatters back. Creation reads the whole committed state, which FNL copies to the host every step when creation is on: correct, not scalable.

Dissipative fluxes (Navier–Stokes) ​

The viscous, heat and Ohmic fluxes of the dissipative terms are one pure pointwise routine shared by both backends (adam_flume_dissipation_library). The Ohmic fluxes have their own kernels, with the same stencils on W=B, called only when the resistivity is on; the viscous and heat kernels serve the MHD models unchanged ((u,v,w,T) sit at the same auxiliary indexes). The psi equation and the EGLM sources are untouched.

Where it enters. The dissipative face fluxes are computed by their own kernels, after the inviscid face fluxes and before the seam accumulation and the flux difference, in both space schemes. Two consequences: the AMR reflux and the inter-realm flux register see the total flux, so conservation across seams needs no new machinery; and the WENO face kernels are untouched (their FNL register count does not change). A run without coefficients never calls the kernels and stays bitwise identical to the ideal solver. The kernels read (u,v,w,T) from the auxiliary variables, whose indexes are common to every model, and the host picks the kernel of the order ([numerics] dissipative_order), never a branch inside a loop.

Face derivatives. The scheme stores point values, so a face flux of order p does not by itself give a flux difference of order p: the conservative numerical flux is h=G−Δx224G″+O(Δx4) (Shu & Osher 1989). Face i+12 along d, cells m=−1…2 counted from the left one:

dissipative_order = 2dissipative_order = 4 (default)
face state(W0+W1)/2(9(W0+W1)−(W−1+W2))/16
normal derivative(W1−W0)/Δx(27(W1−W0)−(W2−W−1))/(24Δx)
tangential derivativemean of the 2nd-order central differences of cells 0 and 1the 4th-order central differences Dm of cells −1…2, interpolated as the state
fluxG(Wf,∇Wf)G(Wf,∇Wf)−(G2−G1−G0+G−1)/48

where Gm is the flux of cell m from 2nd-order central gradients, so the correction term is Δx2G″/24 to second order. The same form serves the linear and the nonlinear terms (uiτdi, μ(T)). Across a strong temperature jump the four-point face temperature undershoots, possibly below zero, where a power law (T/Tref)ω is NaN (a wall 300 times hotter than the gas); where it is not positive, the face takes the mean of its two cells for the laws, which a smooth positive T never triggers. For constant μ it is a 4th-order uxx on six points, not the compact five-point one; its Fourier symbol is non-positive at every wavenumber (−4.67ν/Δx2 at the grid Nyquist mode against −5.33 for the compact operator), so it damps every mode, and its error is O(θ6) in the wavenumber θ. The 4th-order fluxes read cells −2…3 along d and ±2 along the tangents, so they need [grid] ngc ≥3 (fatal otherwise); the tangential differences read the edge ghosts, whose fill is exact on every path (the ghost probe GP, verification). A null direction has a zero step, so its derivatives are zero exactly and its ghosts are never read.

Walls. wall-noslip and wall-isothermal (boundary conditions) are mirrors, second-order at the wall: a 4th-order interior with them converges at order 2 overall (VV-3).

Time step. The explicit unsplit integration adds the diffusive limit to the cell sum of the CFL bound,

Δt=CFLmaxcells[∑d|ud|+aΔxd+2ν∑d1Δxd2],ν=max(43μρ, γkρcp, η),

so under AMR the diffusive part tightens four times per level, against twice for the hyperbolic one. With a power law and an isothermal wall the laws in ν are evaluated at max(T,Tw,max2/T), the ghost temperature beside the hottest wall, since such a face has a coefficient above every cell's (a wall 330 times hotter than the gas blew up at CFL 0.5 without it). The first step logs both maxima, the minimum cell Reynolds number ∑d(|ud|+a)/Δxd/(ν∑dΔxd−2), and whether the run is hyperbolic- or diffusion-limited.

Limits. Explicit only: a diffusion-limited run pays Δt∝Δx2. The positivity limiter is refused with dissipative terms: its first-order backbone with a central dissipative flux is not admissible without the extension of Zhang (2017), which is not implemented. Immersed solids are refused too, since their walls are inviscid. A null direction freezes the momentum normal to it, so a shear layer or a Couette flow needs its velocity axis active, if thin.

Across seams. The dissipative fluxes enter the AMR reflux and the inter-realm register with the inviscid ones, so a 2:1 face conserves to round-off (VV-7). A 2:1 face is second order, for them as for the inviscid fluxes: the mean restriction of the coarse ghosts and the reflux of point-value fluxes each cap the order at 2 (#68); without the reflux the dissipative flux at the face is first order (VV-8).

Turbulence ​

The subgrid-scale models, the hybrid central/WENO scheme, the closed fluxes of no-slip walls, the wall models, the digital-filter inflow, the mass-flow forcing and the turbulence diagnostics are on the turbulence page.

Time integration ​

The library Runge–Kutta schemes ([runge_kutta] scheme, listed in the input reference) integrate the semi-discrete system: strong-stability-preserving (SSP) and low-storage schemes. On both backends the integrator is SELAH's, through the library adapter adam_stepper_object (#132; the FNL backend runs SELAH's OpenACC build on the device fields): the low-storage runge-kutta-1/2/3 are SELAH's two-register Shu–Osher forms of Euler, SSP(2,2) and SSP(3,3), every stage on the solution itself, and the runge-kutta-ssp-* schemes its Butcher forms, every stage on its own state register. The coefficients are ADAM's, bit for bit. SELAH sums the stages of the Butcher update in the FNL order (q + dt sum_s b_s R_s), so the CPU SSP runs moved at round-off from the former stage-by-stage sum (the FNL runs are bitwise the former ones, whose kernels summed in that order), and with immersed solids the step residual is 0 in the solid cells (#128 D4). Each stage refills the ghost cells, recomputes the auxiliary variables, applies the positivity floors (MHD) and evaluates the residual. The time step follows the CFL bound, with the diffusive part of the dissipative fluxes when they are on; [time] it_max and time_max stop the run.

The SSP Butcher tableaux have one source, SELAH's (every backend, PRISM's PIC particles and PML auxiliary fields included); they are the numbers of ADAM's former ssp_tableau, bit for bit (SELAH's selah_test_adam_parity). SSP(5,4) is the optimal five-stage fourth-order scheme of Spiteri & Ruuth (2002, SIAM J. Numer. Anal. 40, 469), SSP coefficient 1.508, stored in the Shu–Osher form printed with 15 digits by Isherwood, Grant & Gottlieb (2018, arXiv:1810.04800, §4). The order conditions then hold to 6⋅10−16, and a refinement in time keeps fourth order down to 10−13. SELAH's tests pin every SSP tableau (order conditions, SSP coefficients); ADAM's test_stepper_object the adapter (unit tests).

Adaptive mesh refinement ​

The block tree is refined at initialisation ([initial_conditions] amr_iterations passes) by the markers of the [amr] section: a geometric box, a variable gradient, or the surface of an immersed solid. Neighbouring blocks differ by at most one level (2:1 balance). With markers the tree is an octree (ratio = 8, and with a null axis nk ≥ 4) or a quadtree (ratio = 4, any nk, nk = 1 for a true 2-D run). A quadtree seam is 2:1 in x and y and 1:1 in z, and every seam operator below works per axis (#46, MV-15).

Coarse-fine ghosts ​

The ghost cells of the fine block are interpolated from the coarse one (the library seam ghost fill, tricubic by default), and the coarse ghosts are restricted from the fine cells. Two FLUME guards keep the fine ghosts admissible:

  • Clamp (#101). The interpolated density is clamped to the range of the coarse cells that bracket the ghost, widened by the curvature of the data (332 of the M4 minmod of the second differences, the largest over the bracketing lines; at the edge of the donor block, the widening of a quarter-cell extrapolation), in the manner of Suresh and Huynh. The velocity ρu/ρ is clamped the same way against the coarse cells' velocities, and the momentum is that density times that velocity. A ghost whose clamped density is still below a tenth of the coarse cell's (SEAM_DENSITY_GUARD) takes that cell's state in every variable. The other variables are interpolated unchanged. On smooth data the clamp moves nothing (the order across a 2:1 corner is unchanged, AO euler-l6). The velocity, not the density and the momenta apart, is what must be bounded: without it the tricubic overshoots at the corners of a refined region around a collapsing cloud make the corner cells run away.
  • Blend. The interpolant works variable by variable, so next to a strong shock it can return an inadmissible state: at low β the internal energy is a small residual of E−|B|2/2, and on the Balsara–Spicer blast across a 2:1 seam the fine ghosts reach ρe<0 (#50). After every ghost fill an inadmissible face ghost is blended toward the adjacent interior cell, g←qin+t(g−qin), with the largest t that keeps ρ and ρe above the limiter's floors of qin; a non-finite ghost takes qin, and so does any inadmissible ghost of the isothermal and barotropic gases. An admissible ghost is never touched; the log reports the ghosts blended, per rank.

For MHD, a cell-centred B cannot be kept divergence-free across a 2:1 face (Tóth & Roe 2002): the seams inject a truncation-level ∇⋅B that GLM transports and damps; the div(B) history reports it (seam_max_divb).

Reflux ​

Conservation is restored by the Berger–Colella reflux ([numerics] reflux = .true.): the fluxes of every Runge–Kutta stage through the seam are accumulated in a flux register, weighted by the stage's coefficient in the step, and at the end of the step the coarse cells next to the seam are corrected by the difference between the fine fluxes and their own. With reflux the volume integrals of a periodic box stay constant to round-off; without it they drift at 10−5 (conservation example).

  • Under GLM B and ψ are refluxed; under EGLM B is not, since the sources −u∇⋅B make it a non-conserved integral (verification).
  • reflux_cadence = stage corrects the coarse seam cells' residual at every stage from that stage's fluxes, so every stage advances them with the restricted fine fluxes. Both cadences conserve to round-off; stage keeps the order of the time integration where step leaves an O(Δt) inconsistency, e.g. in the E+W of self-gravity on AMR (SV-10). Intra-realm 2:1 faces only.
  • reflux_policy = troubled (#68) corrects only the seam face cells flagged in some stage of the step, by the positivity limiter (a blended seam face) or by the WENO-5 sensor (minkωk/dk<0.2 for density, normal velocity or pressure across the face). Elsewhere the coarse flux stays, so smooth regions keep the accuracy of the high-order seam operators at the cost of conservation there (Sod coarse-to-fine: mass drift 1.5⋅10−7, shock unchanged). It lets seam_restriction = lagrange6 with seam_ghost_fill = quintic keep sixth order across 2:1 seams (AO euler-tq), with a conservation drift of about 10−5 per period on the smooth vortex at N = 64. The default, always, conserves exactly.

Keep shocks off the 2:1 seams. A captured shock that crosses a 2:1 seam into finer cells leaves a defect behind it (about 2 % of the jump in density, with an entropy defect of the same size) that does not shrink with the resolution. No choice of seam operator removes it: restriction, coarse-to-fine fill and reflux move it by at most ±30 % (verification). The evidence points to the start-up error of a captured shock whose numerical structure is squeezed into finer cells. Refine ahead of the shocks instead: a gradient or Löhner marker on density or pressure with a buffer of a few cells and a regrid frequency short enough that a shock cannot outrun the refined region between two regrids (the standard AMR practice; the remedy itself is not measured).

Runtime regridding ​

With [amr] frequency = n > 0 (#74), after every n-th step and before its output, the realm regrids: up to iters sweeps, each one refreshing the ghost cells, combining the markers into one set of flags (a block is refined when any marker asks for it, coarsened only when all agree, never below the base level), and calling the library regrid (2:1 balance, prolongation, restriction, redistribution, maps). The distance function of the immersed solids is recomputed, the new state is checked (density and pressure positive, fatal otherwise), and the forest rebuilds the 2:1 flux register. The time step stays global (no subcycling). The FNL backend regrids by a host round trip that moves the blocks in use only: a kernel packs them, transposed to the host layout, into a scratch buffer that one contiguous copy moves (#75); its log line adds the wall time.

The Löhner marker (Löhner 1987, mode 4) is the scale-free second-derivative estimator

E=∑d(u+−2u+u−)2∑d(|u+−u|+|u−u−|+ϵ(|u+|+2|u|+|u−|)+δ)2∈[0,1],

in the dimension-sum form of FLASH and PLUTO (u± the neighbours along d): about 0 where the variable is smooth on the grid, about 1 at a jump. The epsilon term filters ripples small relative to the variable. On a variable that vanishes in quiet regions it filters nothing, and round-off noise reads E≈1; the absolute floor δ (default 0) makes the variations well below it noise. A block takes the largest E over its cells and buffer ghost layers; it is refined above refine_tol, coarsened below derefine_tol, kept between.

The Jeans marker (mode 5, #91) compares on every cell the Jeans length λJ=πcs2/(Gρ), cs2=γp/ρ (magnetic support not counted), with the block spacing h. A block is refined where some cell has λJ/h below jeans_cells (default 8; Truelove et al. 1997 ask for at least 4), coarsened where every cell is above jeans_cells_derefine (default twice that, the hysteresis band of Federrath et al. 2010), kept between. It reads no ghost cell, so it also shapes the initial grid (SV-16). It needs self-gravity.

The Kolmogorov marker (mode 7, #133) compares the spacing with the local Kolmogorov length, r=h/η, η=(ν3/ε)1/4, ε=2νSd:Sd (Sd the deviatoric strain rate, ν=μ(T)/ρ by the run's viscosity law, h the geometric mean of the spacings over the active axes): r2=h2|U′|/ν in a pure shear, r=h+ at a wall, h+/(κy+)1/4 in the log layer. A block is refined where some cell has r above refine_tol, coarsened where every cell is below derefine_tol (< refine_tol / 2: r halves across a level), kept between. The velocity gradient is the gradient marker's, so it also shapes the initial grid (refining only there). It needs a viscosity. The formula and its limits are in the library input reference.

Regridding transfers. A derefined parent takes the mean of its children. A refined block's children are filled by [amr] regrid_prolongation:

  • conservative (FLUME's default): the parent plus monotonized-central slopes (van Leer 1977) times a quarter of a cell, one per refined axis, scaled by the largest ϕ≤1 that keeps every child within the parent's and its face neighbours' range (Barth & Jespersen 1989). The children average to the parent, so a regrid changes no conserved integral, a refine followed by a derefine returns the state exactly, a positive variable stays positive, and linear data are reproduced.
  • linear (the library default): tensor interpolation, weights 1/4 and 3/4, second order but not conservative (RG).
  • conservative-state (#88): the children's mean stays on the parent, built from the tensor interpolation of whole coarse states, with one offset factor θ≤1 for the whole state, the largest that keeps every variable of every child within the range of the parent and its 3d neighbours. It keeps the runtime-AMR collapse of an under-resolved star admissible where the default drains a cell to a negative pressure (SV-15). It costs accuracy on smooth flow, since an extremum of any one variable flattens the children of every variable: the tracked vortex of AV misses its bound with it (L1 1.68 times the uniform fine run's, the bound 1.5).

All three read the parent's first ghost layer.

Immersed boundary (Euler) ​

Static rigid solids ([solids], [solid_N], e.g. definition = analytical_circle) are imposed as inviscid walls:

  1. a signed distance function ϕ marks the fluid and the solid cells;
  2. the fluid state is extended into the solid by n_eikonal sweeps of an eikonal extrapolation along the surface normal ∇ϕ (Jacobi sweeps: every increment is computed from the old state, so the result does not depend on the loop order or the thread count, and the CPU and FNL backends agree);
  3. the extended state is inverted into the mirror state of a slip wall (the normal velocity reversed);
  4. the fluid cells cut by the surface use the cut spacing in the flux difference, and the solid cells are masked in the Runge–Kutta stages. The cut spacing of a fluid cell c with a solid neighbour s is Δ/2−ϕcΔ/(ϕs−ϕc); the denominator is positive (ϕs>0>ϕc), so it carries no guard.

The solid surface can drive the AMR (the refined ring of the shock-over-a-cylinder example). mhd-ideal with solids is refused.

Multi-realm runs ​

A forest manifest glues several realms, each with its own input file, through inter-realm seams (mirror coupling of blocks of the same resolution). The seam ghosts are filled from the peer realm at every Runge–Kutta stage (stage_coincident) or once per step (end_of_step); the union of a split problem is bitwise equal to the single-realm run (verification multirealm/).

Output and diagnostics ​

Checkpoints are XH5F files (one HDF5 file per rank plus an XDMF description readable by ParaView), written every it_save steps, with optional slices, residual and conservation histories, and restart files. MHD adds the div(B) history <basename>-divb_history.dat (it time max_divb l1_divb seam_max_divb, plus the D_flux columns with [diagnostics] divb_flux) and the divb_tol monitor, on the normalised D_flux max h|D_flux| / max|B| (#68). D_flux is the divergence the cleaning acts on: that of the interface normal field Bn=Fψ/s read from the scheme's own ψ face fluxes (s=ch2 GLM, ch EGLM), the coarse 2:1 faces taking the fine fluxes, so its integral over a composite periodic domain is round-off. Each history row costs one residual evaluation of the committed state. The derived output fields are defined in the input reference.

References ​

  • Barth T. J., Jespersen D. C. (1989), The design and application of upwind schemes on unstructured meshes, AIAA paper 89-0366.
  • Batten P. et al. (1997), On the choice of wavespeeds for the HLLC Riemann solver, SIAM J. Sci. Comput. 18, 1553–1570.
  • Berger M. J., Colella P. (1989), Local adaptive mesh refinement for shock hydrodynamics, J. Comput. Phys. 82, 64–84.
  • Chen Y., Tóth G., Gombosi T. I. (2016), A fifth-order finite difference scheme for hyperbolic equations on block-adaptive curvilinear grids, J. Comput. Phys. 305, 604–621.
  • Christlieb A. J., Liu Y., Tang Q., Xu Z. (2015), Positivity-preserving finite difference weighted ENO schemes with constrained transport for ideal magnetohydrodynamic equations, SIAM J. Sci. Comput. 37, A1825–A1845, doi:10.1137/140971208.
  • Don W. S., Li R., Wang B.-S., Wang Y. H. (2022), A novel and robust scale-invariant WENO scheme for hyperbolic conservation laws, J. Comput. Phys. 448, 110724.
  • Einfeldt B. et al. (1991), On Godunov-type methods near low densities, J. Comput. Phys. 92, 273–295.
  • Federrath C., Banerjee R., Clark P. C., Klessen R. S. (2010), Modeling collapse and accretion in turbulent gas clouds: implementation and comparison of sink particles in AMR and SPH, ApJ 713, 269–290, doi:10.1088/0004-637X/713/1/269.
  • Hockney R. W., Eastwood J. W. (1988), Computer Simulation Using Particles, Adam Hilger, Bristol.
  • Jiang G.-S., Shu C.-W. (1996), Efficient implementation of weighted ENO schemes, J. Comput. Phys. 126, 202–228.
  • Löhner R. (1987), An adaptive finite element scheme for transient problems in CFD, Comput. Methods Appl. Mech. Engrg. 61, 323–338.
  • Miyoshi T., Kusano K. (2005), A multi-state HLL approximate Riemann solver for ideal MHD, J. Comput. Phys. 208, 315–344.
  • Shu C.-W., Osher S. (1989), Efficient implementation of essentially non-oscillatory shock-capturing schemes II, J. Comput. Phys. 83, 32–78.
  • Toro E. F., Spruce M., Speares W. (1994), Restoration of the contact surface in the HLL-Riemann solver, Shock Waves 4, 25–34.
  • Townsend R. H. D. (2009), An exact integration scheme for radiative cooling in hydrodynamical simulations, ApJS 181, 391–397, doi:10.1088/0067-0049/181/2/391.
  • Truelove J. K., Klein R. I., McKee C. F., Holliman J. H. II, Howell L. H., Greenough J. A. (1997), The Jeans condition: a new constraint on spatial resolution in simulations of isothermal self-gravitational hydrodynamics, ApJ 489, L179–L183, doi:10.1086/310975.
  • Tóth G., Roe P. L. (2002), Divergence- and curl-preserving prolongation and restriction formulas, J. Comput. Phys. 180, 736–750.
  • van Leer B. (1977), Towards the ultimate conservative difference scheme. IV. A new approach to numerical convection, J. Comput. Phys. 23, 276–299.
  • Wu K. (2018), doi:10.1137/18M1168017; Wu K., Shu C.-W. (2018), doi:10.1137/18M1168042: positivity of the first-order and high-order schemes for ideal MHD with the Godunov–Powell source.
  • Xu Z. (2014), Parametrized maximum principle preserving flux limiters for high order schemes solving hyperbolic conservation laws, Math. Comp. 83, 2213–2238, doi:10.1090/S0025-5718-2013-02788-3.
  • Zhang X. (2017), On positivity-preserving high order discontinuous Galerkin schemes for compressible Navier–Stokes equations, J. Comput. Phys. 328, 301–343.
  • Zhang X., Shu C.-W. (2012), Positivity-preserving high order finite difference WENO schemes for compressible Euler equations, J. Comput. Phys. 231, 2245–2258, doi:10.1016/j.jcp.2011.11.020.