Appearance
Numerical methods
FLUME discretises the conservation laws with high-order finite differences on point values: the state
integrated in time by an explicit Runge–Kutta scheme. The numerical flux [numerics] scheme_space:
scheme_space | Face flux | Models |
|---|---|---|
weno | WENO reconstruction of the Lax–Friedrichs-split fluxes, per characteristic field | Euler, MHD |
weno-riemann | WENO 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) |
Both 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 ngc = 3 for WENO5), and ngc ≥ 2 for weno-riemann.
WENO reconstruction
A WENO scheme of order [weno] scheme = weno-u-{3,5,7,9},
with the optimal (linear) weights weno-c-* are refused by FLUME.
The absolute 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):
for the split fluxes (weno-riemann), js). Every term scales exactly like the field (test_flume_weno_weights on the host, test_flume_weno_interpolation_fnl on the device; the whole solver: the scaling oracle). si with weno-riemann on primitive variables is refused. One property of js is lost at round-off: the smoothness indicator of a uniform field is a quadratic form, round-off rather than zero, and the si descaler varies from face to face, so a uniform field in a non-uniform state (the
The default js is the first formula, bitwise unchanged: the kernel receives js, so the choice costs no branch in the kernels.
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, linear weights ) are generated with exact rational arithmetic by riemann-flux/weno_interpolation_tables.py.
scheme_space = weno: flux splitting
At each face
- the eigenvectors are evaluated at the face (Euler: the Roe average of cells
, ; MHD: their arithmetic average); - the state and the physical flux of every stencil cell are projected on the left eigenvectors,
, ( reconstruction_variables = characteristic), or kept component by component (conservative); - each field is split with a local Lax–Friedrichs speed,
, where per characteristic field ( conservative: one speed, and with GLM at least ); is reconstructed from the left-biased stencil and from the right-biased one, and the face flux is projected back, .
For MHD the characteristic decomposition is block-diagonal: the 7×7 wave core plus the
scheme_space = weno-riemann: interpolation, Riemann flux and correction
The face flux of the hybrid scheme (Chen, Tóth & Gombosi 2016) is
with
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; orprimitive,, plus and for MHD). A face state with non-positive density or pressure is replaced by the adjacent cell's state. Riemann flux (
riemann_solver):llf:, of the two states; hll(Harten, Lax & van Leer 1983) with the Einfeldt speeds, (Roe averages): for , the upwind physical flux otherwise; hllc(Toro, Spruce & Speares 1994) with the same outer speeds and the contact speed of Batten et al. (1997),; it resolves an isolated contact exactly.
Correction (
flux_correction), coefficients derived with sympy so that the flux difference approximates the derivative of point values:flux_correctionOrder of the flux difference 6th6 (the WENO5 interpolation limits the scheme to 5) 4th4 none2 Sensor (
flux_correction_sensor): withweno,where every interpolated field keeps its nonlinear weights close to the linear ones, on both sides of the face, and elsewhere: the correction, which amplifies jumps by , is switched off at discontinuities. nonekeeps 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: LLF, HLL, and HLLD (Miyoshi & Kusano 2005) with its degenerate cases and a per-face fallback to HLL when a star state is not admissible or the wave speeds are out of order; the fallbacks are counted and logged per stage (HLLD fallbacks to HLL: N faces). With GLM the weno-riemann through the --numerics option of its scripts (issue #47, M3-P3c): the linear waves and the circularly polarised Alfvén wave converge at order 4.96–5.00, Brio–Wu and Ryu–Jones 4d need no floor and no HLLD fallback, Orszag–Tang keeps its symmetry and conserves to
Measured (np 2, WENO5, 6th-order correction, CPU and FNL identical to the printed digits; details in the verification gallery): on the isentropic vortex the HLLC variant reaches order 6.5 between 128² and 256² with
Positivity limiter
[numerics] positivity_limiter = cell (issue #47, D-9; both space schemes) makes each stage keep the density and the pressure positive, so the floors are no longer needed on hard problems. Per cell, the backbone is the forward-Euler update with the first-order Lax–Friedrichs fluxes of the cell states (Euler: Rusanov; MHD: the Wu speed, which adds
On the Balsara–Spicer blast (β = 2.5·10⁻⁴, EGLM) the splitting scheme fails at step 3 without the limiter and reaches weno-riemann HLLD passes with or without it.
At a 2:1 AMR seam the end-of-step reflux (below) would replace 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
- the fine seam faces take the backbone
, with the coarse cell as outer state; - the coarse cell's factor
uses, on the seam face, the means of the four fine backbone and high-order fluxes; the coarse backbone update with the mean of is a convex combination of Lax–Friedrichs updates of , so it is admissible; - both sides blend with
, so each cell stays in its corner box and the coarse flux is exactly the mean of the fine ones. The stage is conservative, and the reflux only corrects round-off.
With self-gravity the register also carries the seam gravity work (#81 P5b), so the end-of-step correction is not round-off: on a star whose surface a 2:1 seam cuts, in a reflux_positivity_theta; reflux positivity: +N coarse cells limited. On that star one cell was limited on five steps, and the run reached its end. reflux_cadence = stage needs no such bound: its correction acts inside the stages, before the limiter.
The coarse states, the fine means and the factors 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 and returns them with the seam face fluxes.
Dissipative fluxes (Navier–Stokes)
With a viscosity or a conductivity in [physics] (input), Euler becomes the compressible Navier–Stokes system (issue #65, P2), and so does each MHD model (P3), which also takes an Ohmic resistivity. Each term is the divergence of a flux, added to the inviscid one in direction
with no bulk viscosity (Stokes hypothesis), adam_flume_dissipation_library).
Ohmic resistivity (MHD). With the magnetic diffusivity
with
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 [numerics] dissipative_order), never a branch inside a loop.
Face derivatives. The scheme stores point values, so a face flux of order
dissipative_order = 2 | dissipative_order = 4 (default) | |
|---|---|---|
| face state | ||
| normal derivative | ||
| tangential derivative | mean of the 2nd-order central differences of cells 0 and 1 | the 4th-order central differences |
| flux |
where [grid] ngc
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,
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
Limits. Explicit only: a diffusion-limited run pays
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 (issue #68 F1); without the reflux the dissipative flux at the face is first order (VV-8).
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. 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.
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). At a coarse–fine face:
- the ghost cells of the fine block are interpolated from the coarse one (the library seam ghost fill), and the coarse ghosts are restricted from the fine cells. The interpolant (tricubic by default) 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
, and on the Balsara–Spicer blast across a 2:1 seam the fine ghosts reach , which makes the high-order flux non-finite (issue #50). After every ghost fill, an inadmissible face ghost is therefore blended toward the adjacent interior cell, , with the largest that keeps and above the limiter's floors of (a non-finite ghost takes ). An admissible ghost is never touched, so the blend changes nothing else and costs one scan of the face ghosts; the log reports the ghosts blended, per rank; - conservation is restored by the Berger–Colella reflux: 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 (
[numerics] reflux = .true.; withreflux_cadence = stagethe correction is applied at every stage instead). Under GLMand are refluxed; under EGLM is not, since the sources make it a non-conserved integral (G3b). With reflux the volume integrals of a periodic box stay constant to round-off, without it they drift at (conservation example).
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 the ghost restriction, the coarse-fine interpolation, the reflux and the limiter's seam synchronisation work per axis (issue #46, verified by MV-15). For MHD, a cell-centred seam_max_divb).
Runtime regridding (#74). With [amr] frequency = n > 0, after every 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 on the new grid, the new state is checked (density and pressure positive, fatal otherwise, with the cell), and the forest rebuilds the 2:1 flux register, so the reflux follows seams that appear and disappear. The time step stays global (no subcycling). The FNL backend regrids by a host round trip: each sweep refreshes the ghosts on the device, copies the state to the host, marks and regrids there with the same code, and copies the state, the block coordinates, the maps and the distance function back (a map the new grid no longer has is freed on the device); its log line adds the wall time. The state and distance-function copies move the blocks in use only: the device array leads with the block index, so a kernel packs those blocks, transposed to the host layout, into a scratch buffer that one contiguous copy moves (#75; copying the whole capacity cost about 2.5 s per regrid on the development box, two ranks of 17195 blocks, whatever the grid, against 0.02 s now on a 52-block grid). The Löhner marker (Löhner 1987, mode 4) is the scale-free second-derivative estimator
in the dimension-sum form of FLASH and PLUTO (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 floor buffer ghost layers; it is refined above refine_tol, coarsened below derefine_tol, kept between.
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 and that no choice of seam operator removes: restriction, coarse-to-fine fill and reflux move it by at most ±30 % (A3, E0). 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, so shocks stay inside the finest level and never cross a seam (the standard AMR practice; E0 measured the defect, not this remedy).
Regridding transfers. When a block is derefined, the parent takes the mean of its children. When one is refined, [amr] regrid_prolongation chooses how the children are filled. FLUME's default is conservative: each child is the parent plus monotonized-central slopes (van Leer 1977) times a quarter of a cell, one per refined axis, scaled by the largest linear prolongation (tensor interpolation, weights 1/4 and 3/4) is second order too but not conservative (RG). Both 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:
- a signed distance function
marks the fluid and the solid cells; - the fluid state is extended into the solid by
n_eikonalsweeps 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); - the extended state is inverted into the mirror state of a slip wall (the normal velocity reversed);
- 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
with a solid neighbour is ; the denominator is positive ( ), so it carries no guard (the absolute inherited from CHASE was a length, removed with issue #49).
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 G1).
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.
- Einfeldt B. et al. (1991), On Godunov-type methods near low densities, J. Comput. Phys. 92, 273–295.
- 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.
- Jiang G.-S., Shu C.-W. (1996), Efficient implementation of weighted ENO schemes, J. Comput. Phys. 126, 202–228.
- Becker R. (1922), Stoßwelle und Detonation, Z. Phys. 8, 321–362.
- 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.
- 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., 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.