Manuscript Offprint

arXiv:2609.06199

Gradient Reconstruction in Lattice Boltzmann Methods for Systems of Conservation Laws

Adrian Kummerländer, Fedor Bukreev, Mathias J. Krause

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

ADRIAN KUMMERLÄNDER*,†, FEDOR BUKREEV*,‡, AND MATHIAS J. KRAUSE*,†,‡

Abstract. The automatic derivation of [22] turns a declared system of conservation laws into a lattice Boltzmann scheme, giving each conserved physical quantity a set of qq populations whose linear equilibrium embeds the physical flux in their first moment. When the flux depends on gradients of the conserved state, those gradients are supplied by tracking them as additional transported fields. Since lattice Boltzmann is commonly memory-bound, these additional degrees of freedom reduce the achievable throughput. To reclaim it, we reconstruct the gradients from the moment structure of the equilibrium instead of transporting them. To leading order, the first moment of a conserved quantity's non-equilibrium part carries its gradient. Because the reconstructed flux enters its own equilibrium reference, that moment is the image of the gradient under a linear operator built from the diffusive-flux Jacobian. The reconstruction is that operator's algebraic inverse, generic across gradient-form constitutive closures and generated automatically from each declared flux. The resulting scheme carries the conserved quantities alone, reconstructing the required gradients from the populations and forming the fluxes locally. It converges at second order in double precision across advection–diffusion–reaction, Allen–Cahn, Navier–Stokes, resistive magnetohydrodynamics and homogenized compressible Navier–Stokes–Fourier systems, matching the accuracy of gradient tracking at equal resolution. On an NVIDIA RTX A5000 it is up to 3.7 times faster in single precision, the memory-bound kernels reaching up to 97% of peak memory bandwidth.

Key words. Lattice Boltzmann methods, gradient reconstruction, non-equilibrium moment, method of manufactured solutions, high-performance computing

MSC codes. 76M28, 65M12, 68W30, 65Y05, 35L65

  1. Introduction. The derivation in [22] produces a lattice Boltzmann scheme from a declared system of conservation laws, targeting OpenLB [19, 23]. It assigns an independent set of populations to each conserved field and embeds the physical flux in the first moment of a linear equilibrium, the vector-kinetic and relaxation route to systems of conservation laws [1, 2, 5, 6, 9, 12, 14, 16, 25, 28]. Wherever a constitutive closure is a first gradient of the conserved state, as for the Newtonian stress and the Fourier flux, the scheme needs that gradient. It has so far been provided by transport, in one of two forms [7, 8, 22]: Gradient tracking carries the gradient itself. The relaxed-flux form carries the diffusive flux itself: the viscous stress and the heat flux. Both append an auxiliary field, advanced by relaxation alongside the conserved ones, and differ only in what that field represents. Since lattice Boltzmann is commonly bound by memory bandwidth rather than floating-point performance [3, 4, 13, 15, 20, 31], the additional degree of freedom carried by the auxiliary field directly reduces the achievable throughput. Yet the field is redundant: while carried as an independent degree of freedom, it holds no information the conserved state does not already determine, because the closure ties the flux to a gradient of that state.

The present work recognizes these independent degrees of freedom as unnecessary and removes them. This route was noted in [22] but not pursued. To leading order, the first moment of a conserved field's non-equilibrium part carries that field's gradient, by the Chapman–Enskog relation that recovers strain rate and heat flux from the non-equilibrium populations [10, 17, 18, 20, 24, 26, 30]. As such, the gradients a

*All authors are with the Lattice Boltzmann Research Group (LBRG), Karlsruhe Institute of Technology (KIT), 76131 Karlsruhe, Germany (kummerlaender@kit.edu, corresponding author). †Institute for Applied and Numerical Mathematics (IANM), KIT, Englerstraße 2. ‡Institute of Mechanical Process Engineering and Mechanics (MVM), KIT, Straße am Forum 8.

A. KUMMERLÄNDER, F. BUKREEV, AND M. J. KRAUSE

Figure

FIG. 1. The compiler pipeline with the gradient reconstruction in place of the gradient-tracking cascade of [22]. A declared conservation law keeps its conserved state Q\mathbf{Q}. The reconstruction operator R\mathbf{R} recovers the gradient ∇Q\nabla \mathbf{Q} inside the collision (Sections 2.1–2.2), so the relaxation and lattice stages act on Q\mathbf{Q} alone rather than on an augmented state Q+=(Q,∇Q)\mathbf{Q}^+ = (\mathbf{Q}, \nabla \mathbf{Q}).

closure needs can be reconstructed inside the collision from the conserved fields alone. The reconstruction is a single declaration, generated from the declared flux, trading transport for local computation.

Unlike the transport forms, where the gradient is read from its own transported field, the reconstructed gradient feeds back into its own measurement. The diffusive flux built from it is injected into the equilibrium first moment, the reference against which the next non-equilibrium moment is taken. The moment therefore returns not the gradient but its image under a linear operator built from the diffusive-flux Jacobian. Taken directly as the gradient, it carries an error that does not vanish under refinement.

The operator is linear, so the reconstruction is its algebraic inverse. Its coefficient is already assembled symbolically by the compiler of [22] with the SymPy computer algebra system [27], so the inverse can be generated in closed form from each declared flux. We verify the scheme by manufactured solutions across the five gradient-tracking systems of [22] and by a throughput study on an NVIDIA RTX A5000 GPU.

The remainder of this paper is organized as follows: Section 2 presents the method: Section 2.1 states the gradient reconstruction, Section 2.2 derives the reconstruction operator and Section 2.3 describes its generation by the compiler. Section 3 verifies the scheme by the method of manufactured solutions, and Section 4 benchmarks its throughput against the gradient-tracking scheme and hardware roofline.

  1. Methodology. Figure 1 shows the overall pipeline: a declared system of conservation laws is compiled to a lattice Boltzmann scheme, with the constitutive gradients reconstructed inside the collision rather than tracked as auxiliary fields.

2.1. Gradient Reconstruction. The method of [22] takes a system of conservation laws as its entry point,

(2.1)

∂tQ+∇⋅Φ=S,\partial_{t}\mathbf{Q}+\nabla\cdot\mathbf{\Phi}=\mathbf{S},

with Q\mathbf{Q} the conserved state, Φ\mathbf{\Phi} the physical flux and S\mathbf{S} a local source. Each conserved field kk with moment QkQ_k and flux Φk\mathbf{\Phi}_k is assigned an independent set of populations fk,if_{k,i} on a discrete-velocity stencil. The flux is embedded in the first moment of a linear equilibrium, the field is recovered from the zeroth moment, and the scheme iterates by a BGK collide-and-stream update with the source projected onto the lattice weights.

The equilibrium fk,ieqf_{k,i}^{\mathrm{eq}} of [22] is linear in the state and reproduces the conserved moment, the physical flux and an isotropic second moment,

(2.2)

∑ifk,ieq=Qk,∑ifk,ieqξi=Φk,∑ifk,ieqξi⊗ξi=cs2QkI,\sum_{i}f_{k,i}^{\mathrm{e q}}=Q_{k},\qquad\sum_{i}f_{k,i}^{\mathrm{e q}}\boldsymbol{\xi}_{i}=\boldsymbol{\Phi}_{k},\qquad\sum_{i}f_{k,i}^{\mathrm{e q}}\boldsymbol{\xi}_{i}\otimes\boldsymbol{\xi}_{i}=c_{s}^{2}Q_{k}\mathbf{I},

with ξi=ci\boldsymbol{\xi}_i = \mathbf{c}_i the lattice velocities and csc_s the lattice speed of sound. The Chapman–Enskog expansion fk,i=fk,ieq+Δtfk,i(1)+O(Δt2)f_{k,i} = f_{k,i}^{\mathrm{eq}} + \Delta t f_{k,i}^{(1)} + \mathcal{O}(\Delta t^2), ∑ifk,i(1)=0\sum_i f_{k,i}^{(1)} = 0 relates the non-equilibrium part, with τLB,k\tau_{\mathrm{LB},k} the relaxation time of field kk, to the derivative of the equilibrium along the discrete velocity ξi\boldsymbol{\xi}_i,

(2.3)

fk,i(1)=−τLB,k(∂t+ξi⋅∇)fk,ieq+O(Δt).f_{k,i}^{(1)}=-\tau_{\mathrm{L B},k}\left(\partial_{t}+\boldsymbol{\xi}_{i}\cdot\nabla\right)f_{k,i}^{\mathrm{e q}}+\mathcal{O}(\Delta t).

Its first moment, evaluated with the equilibrium moments (2.2), is the non-equilibrium deviation flux

(2.4)

Πk(1)=∑ifk,i(1)ξi=−τLB,k(∂tΦk+∇⋅(cs2QkI))=−τLB,k(∂tΦk+cs2∇Qk).\begin{aligned}\boldsymbol{\Pi}_{k}^{(1)}&=\sum_{i}f_{k,i}^{(1)}\boldsymbol{\xi}_{i}\\&=-\tau_{\mathrm{LB},k}\left(\partial_{t}\boldsymbol{\Phi}_{k}+\nabla\cdot\left(c_{s}^{2}Q_{k}\mathbf{I}\right)\right)\\&=-\tau_{\mathrm{LB},k}\left(\partial_{t}\boldsymbol{\Phi}_{k}+c_{s}^{2}\nabla Q_{k}\right).\\ \end{aligned}

In [22] this relation supplies the relaxation diffusion. The flux time derivative is closed by the chain rule

(2.5)

∂tΦk=Ak∂tQ=Ak(S−∇⋅Φ),Ak=∂Φk∂Q,\partial_{t}\mathbf{\Phi}_{k}=\mathbf{A}_{k}\partial_{t}\mathbf{Q}=\mathbf{A}_{k}\left(\mathbf{S}-\nabla\cdot\mathbf{\Phi}\right),\qquad\mathbf{A}_{k}=\frac{\partial\mathbf{\Phi}_{k}}{\partial\mathbf{Q}},

where the second equality uses ∂tQ=S−∇⋅Φ\partial_t \mathbf{Q} = \mathbf{S} - \nabla \cdot \mathbf{\Phi} from (2.1). This closure is algebraic and transports no field. A constitutive gradient is different: where the flux depends on ∇V\nabla V for a primitive VV, the augmented construction appends an auxiliary field G≈∇V\mathbf{G} \approx \nabla V and relaxes it alongside the conserved state. We instead set ∂tΦk=0\partial_t \mathbf{\Phi}_k = 0. This ties the gradient to the non-equilibrium moment and leaves no independent degree of freedom to transport.

Equation (2.4) then reads Πk(1)=−cs2τLB,k∇Qk\mathbf{\Pi}_k^{(1)} = -c_s^2 \tau_{\mathrm{LB},k} \nabla Q_k, so the gradient would follow as ∇Qk=−Πk(1)/(cs2τLB,k)\nabla Q_k = -\mathbf{\Pi}_k^{(1)} / (c_s^2 \tau_{\mathrm{LB},k}). This non-equilibrium moment Πk(1)=∑ifk,iξi−Φk\mathbf{\Pi}_k^{(1)} = \sum_i f_{k,i} \boldsymbol{\xi}_i - \boldsymbol{\Phi}_k, in lattice units where Δt=1\Delta t = 1, subtracts the full equilibrium flux, but Φk\boldsymbol{\Phi}_k carries the gradient in its diffusive part and cannot be formed in-collide. Subtracting only its advective part Φkadv=Φk∣∇Q=0\boldsymbol{\Phi}_k^{\mathrm{adv}} = \boldsymbol{\Phi}_k |_{\nabla \mathbf{Q} = 0}, a function of the conserved state Qk=∑ifk,iQ_k = \sum_i f_{k,i} alone, gives the direct reconstruction

(2.6)

∇Q~k=−1cs2τLB,k(∑ifk,iξi−Φkadv).\nabla\widetilde{Q}_{k}=-\frac{1}{c_{s}^{2}\tau_{\mathrm{L B},k}}\left(\sum_{i}f_{k,i}\boldsymbol{\xi}_{i}-\boldsymbol{\Phi}_{k}^{\mathrm{a d v}}\right).

Both terms are known during the collision, so ∇Q~k\nabla\tilde{Q}_k is available in-collide for every conserved field. The diffusive flux it still leaves in the moment is what Section 2.2 accounts for.

Recovering the gradient from the non-equilibrium moment while neglecting the flux time derivative is the local strain-rate and heat-flux evaluation of regularized and non-equilibrium lattice Boltzmann methods [10,24,26]. The neglected term is higher order under the diffusive and acoustic scalings, and the second-order convergence of Section 3 confirms it across the present systems.

A. KUMMERLÄNDER, F. BUKREEV, AND M. J. KRAUSE

The reconstructed gradients are the inputs the constitutive closures require, evaluated in Section 3 across the declared systems, most extensively for the resistive Magnetohydrodynamics (MHD) system, which couples a Newtonian stress, a Fourier flux and a resistive term through the reconstructed velocity, temperature and magnetic-field gradients.

2.2. The Reconstruction Operator. The diffusive flux left in the direct reconstruction (2.6) is the remainder of the physical flux after its advective part, Φdiff=Φ−Φadv\Phi^{\mathrm{diff}} = \Phi - \Phi^{\mathrm{adv}}. Because the constitutive closures are first gradients of the state, it is linear in the gradient,

(2.7)

Φdiff=M∇Q,M=∂Φdiff∂(∇Q),\mathbf{\Phi}^{\mathrm{d i f f}}=\mathbf{M}\nabla\mathbf{Q},\qquad\mathbf{M}=\frac{\partial\mathbf{\Phi}^{\mathrm{d i f f}}}{\partial(\nabla\mathbf{Q})},

with M\mathbf{M} the diffusive-flux Jacobian. The equilibrium first moment (2.2) carries M∇Q\mathbf{M}\nabla\mathbf{Q}, so with ωk=1/τLB,k\omega_k = 1/\tau_{\mathrm{LB},k} the relaxation frequency of field kk, the direct reconstruction is

(2.8)

∇Q~=(I−cs−2diag(ωk)M)∇Q\nabla\widetilde{\mathbf{Q}}=\left(\mathbf{I}-c_{s}^{-2}\mathrm{d i a g}(\omega_{k})\mathbf{M}\right)\nabla\mathbf{Q}

rather than ∇Q\nabla Q itself. The true gradient is the inverse,

(2.9)

∇Q=R∇Q~,R=(I−cs−2diag(ωk)M)−1,\nabla\mathbf{Q}=\mathbf{R}\nabla\widetilde{\mathbf{Q}},\qquad\mathbf{R}=\left(\mathbf{I}-c_{s}^{-2}\mathrm{d i a g}(\omega_{k})\mathbf{M}\right)^{-1},

the reconstruction operator R\mathbf{R}, assembled from the diffusive-flux Jacobian M\mathbf{M} and the field relaxation frequencies. The form R\mathbf{R} takes follows from the closure, and separates the systems into two cases. For a scalar diffusive closure, flux −D∇c-D\nabla c, the Jacobian (2.7) is the constant M=−DI\mathbf{M} = -D\mathbf{I}, and R\mathbf{R} reduces to a single scaling factor

(2.10)

R=11+βI,β=cs−2ωDlat,Dlat=DΔtΔx2,\mathbf{R}=\frac{1}{1+\beta}\mathbf{I},\qquad\beta=c_{s}^{-2}\omega D_{\mathrm{l a t}},\qquad D_{\mathrm{l a t}}=D\frac{\Delta t}{\Delta x^{2}},

with DlatD_{\mathrm{lat}} the diffusivity in lattice units. The coefficient is constant, so this R\mathbf{R} is formed once at compile time. The second, state-dependent case is a Newtonian stress τ=μ(∇u+∇uT−23(∇⋅u)I)\boldsymbol{\tau}=\mu(\nabla\mathbf{u}+\nabla\mathbf{u}^{\mathrm{T}}-\frac{2}{3}(\nabla\cdot\mathbf{u})\mathbf{I}). By the chain rule ∇u=(∇(ρu)−u⊗∇ρ)/ρ\nabla\mathbf{u}=(\nabla(\rho\mathbf{u})-\mathbf{u}\otimes\nabla\rho)/\rho, its Jacobian is M=−(μ/ρ)S\mathbf{M}=-(\mu/\rho)\mathbf{S}, with S\mathbf{S} the symmetric-deviatoric map S∇u=∇u+∇uT−23(∇⋅u)I\mathbf{S}\nabla\mathbf{u}=\nabla\mathbf{u}+\nabla\mathbf{u}^{\mathrm{T}}-\frac{2}{3}(\nabla\cdot\mathbf{u})\mathbf{I}, which acts as the factor two on each shear pair. The shear block therefore keeps the scalar form 1/(1+β)1/(1+\beta), but its coefficient is now set by the local density through ν=μ/ρ\nu=\mu/\rho, and by the local temperature where μ=μ(T)\mu=\mu(T). There R\mathbf{R} is not a single constant but is evaluated per cell inside the collision (Section 2.3). The advection-diffusion-reaction and Allen-Cahn systems fall in the first case, the Navier-Stokes, magnetohydrodynamics and Homogenized Compressible Navier-Stokes-Fourier (HCNSF) systems in the second.

In both cases the correction is significant. At the diffusive working points, with cs2=1/3c_s^2 = 1/3 and relaxation near the stability limit ω→2\omega \to 2, β≈2.9\beta \approx 2.9 for advection-diffusion-reaction ( Dlat=0.48D_{\text{lat}} = 0.48), 3.8 for Allen-Cahn, and 2.9 for the Navier-Stokes shear (there β=2νlatω/cs2\beta = 2\nu_{\text{lat}} \omega/c_s^2 with the lattice kinematic viscosity νlat=νΔt/Δx2\nu_{\text{lat}} = \nu \Delta t / \Delta x^2, ν=μ/ρ\nu = \mu / \rho, quoted at the reference density ρ0\rho_0 that eliminates the mass dimension), a scaling factor 1/(1+β)≈0.261/(1 + \beta) \approx 0.26 (0.21 for Allen-Cahn). Under acoustic scaling νlat=νfN\nu_{\text{lat}} = \nu f N grows with the resolution NN ( f=Δt/Δxf = \Delta t / \Delta x fixed), so β≈1.5\beta \approx 1.5 for magnetohydrodynamics and 2.0 for the HCNSF system at the finest grids, factors 0.40 and 0.33. Because M does not decay in lattice units under refinement, this correction never vanishes: read directly as the gradient, the moment overshoots it several-fold and does not converge to the declared solution.

Algorithm 2.1 Gradient reconstruction compiler pass.

Require: flux Φ(Q,∇Q)\Phi(\mathbf{Q}, \nabla \mathbf{Q}), discrete velocities ci\mathbf{c}_i, relaxation freq. ωk=1/τLB,k\omega_k = 1/\tau_{\mathrm{LB},k}

Ensure: in-collide reconstruction of ∇Q\nabla \mathbf{Q}, no auxiliary state carried

Split (symbolic) Φ→(Φadv,Φdiff)\Phi \to (\Phi^{\mathrm{adv}}, \Phi^{\mathrm{diff}})

1: Φadv←Φ∣∇Q=0\Phi^{\mathrm{adv}} \leftarrow \Phi|_{\nabla \mathbf{Q}=0}, a function of Q\mathbf{Q} alone

2: Φdiff←Φ−Φadv\Phi^{\mathrm{diff}} \leftarrow \Phi - \Phi^{\mathrm{adv}}

Form (symbolic) diffusive-flux Jacobian

3: M←∂Φdiff/∂(∇Q)\mathbf{M} \leftarrow \partial \Phi^{\mathrm{diff}} / \partial(\nabla \mathbf{Q}) by CAS differentiation [27]

Assemble (symbolic) reconstruction operator

4: R←(I−cs−2diag(ωk)M)−1\mathbf{R} \leftarrow (\mathbf{I} - c_s^{-2} \mathrm{diag}(\omega_k) \mathbf{M})^{-1} in closed form

5: if M\mathbf{M} is constant then

6: R\mathbf{R} is a compile-time constant

7: else

8: R\mathbf{R} is emitted as per-cell block solves

9: end if

Reconstruct (per cell, in-collide) fk,i→∇Qf_{k,i} \to \nabla \mathbf{Q}

10: for each conserved field kk do

11: ∇Q~k←−(∑ifk,iξi−Φkadv)/(cs2τLB,k)\nabla \widetilde{Q}_k \leftarrow -(\sum_i f_{k,i} \xi_i - \Phi_k^{\mathrm{adv}})/(c_s^2 \tau_{\mathrm{LB},k})

12: end for

13: ∇Q←R∇Q~\nabla \mathbf{Q} \leftarrow \mathbf{R} \nabla \widetilde{\mathbf{Q}}

14: evaluate the constitutive closures from ∇Q\nabla \mathbf{Q}

2.3. Compilation. In the compiler the reconstruction is generated for any declared flux rather than hand-written per system. The call reconstruct_gradients takes the quantities V1,…,VnV_1, \ldots, V_n whose gradients the constitutive closures need and recovers each from the non-equilibrium moment rather than from an auxiliary field, dropping that field. Each argument must reduce to a function of the conserved state, so that its gradient can be reconstructed from the conserved populations, and a quantity that does not is rejected at compile time. The pass takes the place of the gradient-tracking cascade of [22]: the conserved state is not augmented, and the required gradients are recovered locally instead (Algorithm 2.1, Figure 1).

The gradients the closures require are those of the declared primitives VV, not of the conserved state Q\mathbf{Q} directly. The compiler reconstructs the conserved-field gradients ∇Q\nabla \mathbf{Q} from the non-equilibrium moment (Section 2.1) and forms each requested gradient by the chain rule

(2.11)

∇V=∂V∂Q∇Q,\nabla V = \frac{\partial V}{\partial \mathbf{Q}} \nabla \mathbf{Q},

with ∂V/∂Q\partial V/\partial \mathbf{Q} the Jacobian of the primitive in the conserved state, as in the Newtonian velocity gradient of Section 2.2. Because the physical flux Φ\Phi is already held symbolically, the compiler forms this Jacobian together with the diffusive-flux Jacobian M\mathbf{M} and the reconstruction operator R\mathbf{R} of (2.9) in closed form in SymPy [27], the same way for every declared flux with a diffusive part. Listing 1 declares the resistive magnetohydrodynamics system of Section 3 in this form, its Newtonian stress, Fourier flux and resistive term written directly as first gradients and closed by the single call reconstruct_gradients([u, Temp, B]).

Where M\mathbf{M} is state-dependent, R\mathbf{R} is solved per cell. This per-cell solve is computationally affordable because M\mathbf{M} is a block-sparse matrix: a few small strongly coupled

A. KUMMERLÄNDER, F. BUKREEV, AND M. J. KRAUSE

LISTING 1

DSL formulation of resistive MHD with gradient reconstruction. B is the Alfvén-scaled magnetic field and s−rhous_{-rhou}, sEs_E, sBs_B are the Powell ∇⋅B\nabla \cdot B-cleaning sources [29].

from pde2lbm import * eqs = ConservationLaws(dim=2)

References (30)