Gyredocs
Depth Practice
API

Gyre/Mathematics & Numerical Methods

Two-point and interface fluxes

In one minuteThe volume terms use symmetric two-point fluxes that conserve entropy exactly; dissipation is added only at element interfaces through an upwind flux. A discrete entropy inequality is proven for the two interface fluxes built on the entropy-conservative flux (es_roe with matrix dissipation, llf with scalar dissipation); for the classical Roe flux, which is the default, and for HLLC entropy decay is measured, not proven.

Written at L2 Practice goes to L4 Theory 2215 words Markdown

A two-point flux F#(UL,UR;n)\mathbf F^{\#}(\mathbf U_L, \mathbf U_R; \mathbf n) is a function of two states and a direction. Gyre requires it to be consistent, F#(U,U;n)=F(U)⋅n\mathbf F^{\#}(\mathbf U,\mathbf U;\mathbf n) = \mathbf F(\mathbf U)\cdot\mathbf n, symmetric in its two states, and linear in n\mathbf n (so that metric-weighted directions can be passed directly).

name entropy conservative kinetic-energy preserving use
ranocha (default) yes yes, and pressure-equilibrium preserving production
chandrashekar yes yes alternative
kennedy_gruber no yes comparison
central no no the standard DGSEM on elements with constant metric terms; a metric-split variant of it on curved elements (details)

A two-point flux is entropy conservative when, for every pair of states and every direction,

(wR−wL)T F#(UL,UR;n)=(ψR−ψL)⋅n,ψ=ρ u,(\mathbf w_R - \mathbf w_L)^{\mathsf T}\, \mathbf F^{\#}(\mathbf U_L, \mathbf U_R; \mathbf n) = (\psi_R - \psi_L)\cdot\mathbf n, \qquad \boldsymbol\psi = \rho\,\mathbf u ,

with w\mathbf w the entropy variables. Inserted into the flux-differencing volume term this makes the element-wise entropy production telescope to its boundary (proof sketch). The property is tested pointwise for random admissible states in 2-D and 3-D (test_entropy_conservation_condition), and the non-conservative fluxes are tested to violate it, so the test cannot pass vacuously.

With arithmetic means { ⁣{a} ⁣}=12(aL+aR)\{\!\{a\}\!\} = \tfrac12(a_L + a_R) and logarithmic means aln⁡=(aL−aR)/(ln⁡aL−ln⁡aR)a^{\ln} = (a_L - a_R)/(\ln a_L - \ln a_R),

fρ=ρln⁡ { ⁣{un} ⁣},fρu=fρ { ⁣{u} ⁣}+{ ⁣{p} ⁣} n,fρE=fρ(12 uL ⁣⋅ ⁣uR+1(γ−1) (ρ/p)ln⁡)+12(pL un,R+pR un,L),\begin{aligned} f_\rho &= \rho^{\ln}\, \{\!\{u_n\}\!\}, \\ \mathbf f_{\rho\mathbf u} &= f_\rho\, \{\!\{\mathbf u\}\!\} + \{\!\{p\}\!\}\,\mathbf n, \\ f_{\rho E} &= f_\rho \left( \tfrac12\, \mathbf u_L\!\cdot\!\mathbf u_R + \frac{1}{(\gamma-1)\,(\rho/p)^{\ln}} \right) + \tfrac12\left( p_L\, u_{n,R} + p_R\, u_{n,L} \right), \end{aligned}

where un=u⋅nu_n = \mathbf u\cdot\mathbf n. Besides conserving entropy it preserves kinetic energy (the momentum flux is fρ{ ⁣{u} ⁣}f_\rho\{\!\{\mathbf u\}\!\} plus a pressure term) and keeps a moving contact with uniform pressure and velocity exactly in equilibrium, which suppresses a known source of spurious pressure oscillations in split-form schemes.

The logarithmic mean is 0/00/0 when its arguments coincide — which happens on the diagonal of every flux-differencing sum and wherever the flow is uniform. Gyre evaluates

aln⁡=a+b2+f2(23+f2(25+27f2))if f2<10−4,f2=a(a−2b)+b2a(a+2b)+b2,a^{\ln} = \frac{a + b}{2 + f^2\left(\tfrac23 + f^2\left(\tfrac25 + \tfrac27 f^2\right)\right)} \quad\text{if } f^2 < 10^{-4}, \qquad f^2 = \frac{a(a - 2b) + b^2}{a(a + 2b) + b^2},

and the closed form (b−a)/ln⁡(b/a)(b - a)/\ln(b/a) otherwise. Automatic differentiation adds a subtlety: jnp.where differentiates both branches, and the derivative of the unselected closed form is nan at a=ba = b, which would poison Jacobians and adjoints even though the value is correct. The implementation therefore feeds the unselected branch harmless substitute arguments (the “double-where” idiom). The unit test checks that forward- and reverse-mode derivatives are finite everywhere, equal 12\tfrac12 on the diagonal, and that the function is smooth across the branch switch.

Interface fluxes#

At element faces the two traces are genuinely different states and information must be upwinded. Gyre offers

  • roe (default): Roe’s approximate Riemann solver — the arithmetic mean of the two physical fluxes minus Roe’s matrix dissipation — with Harten’s entropy fix on the acoustic waves (which also makes ∣λ∣|\lambda| differentiable through sonic points). It does not use the two-point volume flux;
  • hllc: the classical three-wave HLLC solver. It does not use the two-point volume flux either;
  • es_roe: the two-point volume flux plus Roe-type matrix dissipation applied to the jump of the entropy variables, 12 R ∣Λ∣ T RT(wR−wL)\tfrac12\,\mathbf R\,|\boldsymbol\Lambda|\,\mathbf T\,\mathbf R\T (\mathbf w_R - \mathbf w_L): each wave is damped with its own speed, as in Roe’s solver, and the flux is entropy stable by construction;
  • llf: the two-point volume flux plus scalar dissipation 12λmax⁡(UR−UL)\tfrac12\lambda_{\max}(\mathbf U_R - \mathbf U_L): every wave is damped with the fastest speed;
  • ec: the bare two-point flux, used only to test entropy conservation.

The statement “the discrete entropy cannot grow” is a theorem only under conditions, and the default configuration does not meet all of them.

Interface flux Volume flux ranocha or chandrashekar Status
ec entropy conserved to round-off proven, and measured
llf entropy rate ≤0\le 0 for every admissible nodal state proven (entropy-conservative flux plus a dissipation that is non-negative in entropy variables), and measured
es_roe entropy rate ≤0\le 0 for every admissible nodal state proven (entropy-conservative flux plus a symmetric positive semi-definite matrix acting on the jump of the entropy variables), and measured
roe (default) entropy rate negative in the measured states measured only; no proof
hllc entropy rate negative in the measured states measured only; no proof

With the volume fluxes kennedy_gruber and central there is no entropy statement for any interface flux.

What the proof for llf and es_roe covers, and what no proof in Gyre covers:

  • It is semi-discrete (exact time integration), for the inviscid terms, on periodic or interior faces, and it assumes positive density and pressure at every node. Positivity is not enforced by the scheme; a state that leaves the admissible set ends the argument. (The steady solver’s line search rejects updates with non-positive density or pressure; a solve that finds no admissible update ends with the reason pseudo-time step collapsed.)
  • Wall and far-field boundary conditions are imposed through the interface flux with a constructed exterior state; they carry no discrete entropy proof.
  • The viscous terms (BR2 with gradients of velocity and temperature rather than of the entropy variables) and the shock-capturing viscosity carry no discrete entropy proof.
  • The steady solver is an implicit pseudo-time iteration; nothing above bounds its iterates.

So the default configuration (ranocha volume flux, roe interface flux) gives entropy-conservative volume terms — aliasing inside an element cannot produce entropy of the wrong sign — and an interface dissipation that removed entropy in every state of the verification study, but not a proven entropy inequality. Choose surface_flux: llf when the proven property matters more than the lower dissipation of Roe.

  • consistency: F∗(U,U;n)=F(U)⋅n\mathbf F^*(\mathbf U,\mathbf U;\mathbf n) = \mathbf F(\mathbf U)\cdot\mathbf n;
  • conservation: F∗(UL,UR;n)=−F∗(UR,UL;−n)\mathbf F^*(\mathbf U_L,\mathbf U_R;\mathbf n) = -\mathbf F^*(\mathbf U_R,\mathbf U_L;-\mathbf n), so what leaves one element enters its neighbour even though each face is evaluated from both sides;
  • full upwinding in supersonic flow, under a condition on the wave-speed estimates, not on the Mach numbers of the two traces. For flow from left to right, HLLC returns the left flux when its left wave speed min⁡(un,L−cL, u^n−c^)≥0\min(u_{n,L} - c_L,\ \hat u_n - \hat c) \ge 0, and Roe when the Roe-averaged normal Mach number u^n/c^≥1.1\hat u_n/\hat c \ge 1.1 (hats denote the Roe average). Between 11 and 1.11.1 the slow acoustic eigenvalue u^n−c^\hat u_n - \hat c lies inside the band ∣λ∣<0.1 c^|\lambda| < 0.1\,\hat c of Harten’s fix, where ∣λ∣|\lambda| is replaced by (λ2/δ+δ)/2(\lambda^2/\delta + \delta)/2, so the Roe flux differs slightly from the upstream flux there. For nearly equal traces the Roe average is the trace state and the condition is the trace Mach number. For very different traces it is not: the Roe-averaged sound speed contains the jump of the tangential velocity, so two traces that are each supersonic along the normal can have a subsonic Roe average, and then neither flux is the upstream flux. The unit test of this property runs at Mach 2.5 with nearby traces.

An evaluated example (γ=1.4\gamma = 1.4, normal along xx; executed by tests/test_docs_content.py): left trace ρ=1\rho = 1, u=1u = 1, v=3v = 3 at normal Mach number 2, right trace ρ=1.3\rho = 1.3, u=1.1u = 1.1, v=−3v = -3 at normal Mach number 1.5. The Roe-averaged normal Mach number is 0.711, and the largest component of the difference to the left flux is 6.7⋅10−26.7\cdot10^{-2} for roe and 5.4⋅10−25.4\cdot10^{-2} for hllc. With v=±1v = \pm 1 instead (Roe-averaged normal Mach number 1.36) both return the left flux to round-off.

Entropy dissipation is not in this list of properties. For llf and es_roe it follows from the construction; for roe and hllc it is an observation: in the study below the discrete entropy rate was negative for one perturbed periodic state in 2-D and one in 3-D, each on a warped mesh. That is evidence for those states, not a guarantee for every state.

Entropy rate and conservation defectEntropy conservation and stability
dimvolume fluxinterface fluxd/dt ∫ η|Σ Rw|
2-Dranochaec-5.9781e-154.4631e-14
2-Dchandrashekarec-8.0969e-154.8850e-14
2-Dkennedy_gruberec-5.9810e-044.2411e-14
2-Dcentralec-4.5667e-044.3077e-14
2-Dranochallf-0.05509534.6629e-14
2-Dranochaes_roe-0.01834934.4631e-14
2-Dchandrashekares_roe-0.01834934.7296e-14
2-Dranocharoe-0.01834874.1300e-14
2-Dranochahllc-0.01834484.0856e-14
3-Dranochaec-3.6880e-151.1970e-14
3-Dchandrashekarec-3.5232e-151.1685e-14
3-Dkennedy_gruberec-0.001197582.6854e-15
3-Dcentralec-0.007444481.8180e-15
3-Dranochallf-0.05431741.1796e-14
3-Dranochaes_roe-0.01777991.1602e-14
3-Dchandrashekares_roe-0.01777991.2261e-14
3-Dranocharoe-0.01783011.3600e-15
3-Dranochahllc-0.01781848.1879e-16

gyre 0.4.0 · 39979fcf90 · · cpu · quick suite · record (JSON)Same code as this build

The second table tests the interface fluxes alone. For a pair of states the entropy produced at a face is (wR−wL)TF∗−(ψR−ψL)⋅n(\mathbf w_R - \mathbf w_L)\T\mathbf F^* - (\psi_R - \psi_L)\cdot\mathbf n; an entropy-stable flux makes it non-positive for every pair, which is the property the proof rests on. The pairs are random and far apart (densities and pressures over a decade, Mach numbers up to about three), far outside what a resolved computation presents to a face.

Entropy production of the interface flux alone, random state pairs (Ranocha two-point flux)Entropy conservation and stability
diminterface fluxpairslargest productionpairs with production > 0 [%]
2-Dllf5000-0.05717050
2-Des_roe5000-0.03017790
2-Droe50001365.0618.5
2-Dhllc5000-0.01565710
3-Dllf5000-0.2281960
3-Des_roe5000-0.04117140
3-Droe5000812.67619.18
3-Dhllc5000-0.04019140

gyre 0.4.0 · 39979fcf90 · · cpu · quick suite · record (JSON)Same code as this build

Let A=∂(F⋅n)/∂U\mathbf A = \partial(\mathbf F\cdot\mathbf n)/\partial\mathbf U with eigenvalues Λ=diag⁡(un−a, un,…,un, un+a)\boldsymbol\Lambda = \operatorname{diag}(u_n - a,\ u_n,\dots,u_n,\ u_n + a) and right eigenvectors R\mathbf R. Roe’s solver subtracts 12R∣Λ∣R−1(UR−UL)\tfrac12\mathbf R|\boldsymbol\Lambda|\mathbf R^{-1}(\mathbf U_R - \mathbf U_L) from the mean of the two fluxes; nothing guarantees the sign of the entropy this produces. Barth’s observation is that the eigenvectors can be scaled so that R T RT=∂U/∂w\mathbf R\,\mathbf T\,\mathbf R\T = \partial\mathbf U/\partial\mathbf w with a positive diagonal T\mathbf T. Writing the jump in entropy variables then gives a dissipation

D=R ∣Λ∣ T RT (wR−wL),(wR−wL)TD=∑k∣λk∣ Tk (rkT(wR−wL))2 ≥ 0,\mathbf D = \mathbf R\,|\boldsymbol\Lambda|\,\mathbf T\,\mathbf R\T\,(\mathbf w_R - \mathbf w_L), \qquad (\mathbf w_R - \mathbf w_L)\T\mathbf D = \sum_k |\lambda_k|\,T_k\,\big(\mathbf r_k\T(\mathbf w_R - \mathbf w_L)\big)^2 \ \ge\ 0 ,

for any positive mean state at which R\mathbf R, Λ\boldsymbol\Lambda and T\mathbf T are evaluated. Subtracting 12D\tfrac12\mathbf D from an entropy-conservative flux therefore gives a flux whose entropy production at a face is non-positive: the same argument as for llf, with a matrix in place of the scalar λmax⁡\lambda_{\max}. For nearby states wR−wL≈(∂w/∂U)(UR−UL)\mathbf w_R - \mathbf w_L \approx (\partial\mathbf w/\partial\mathbf U)(\mathbf U_R - \mathbf U_L) and D\mathbf D tends to Roe’s ∣A∣(UR−UL)|\mathbf A|(\mathbf U_R - \mathbf U_L).

Gyre uses the mean state of Winters, Derigs, Gassner and Walch: logarithmic means ρln⁡\rho^{\ln} and βln⁡\beta^{\ln} of the density and of β=ρ/(2p)\beta = \rho/(2p), the arithmetic mean of the velocity, p^={ ⁣{ρ} ⁣}/(2{ ⁣{β} ⁣})\hat p = \{\!\{\rho\}\!\}/(2\{\!\{\beta\}\!\}), a^2=γp^/ρln⁡\hat a^2 = \gamma\hat p/\rho^{\ln}, u2‾=2∣{ ⁣{u} ⁣}∣2−{ ⁣{∣u∣2} ⁣}\overline{u^2} = 2\abs{\{\!\{\mathbf u\}\!\}}^2 - \{\!\{\abs{\mathbf u}^2\}\!\}, h^=γ/(2βln⁡(γ−1))+12u2‾\hat h = \gamma/\big(2\beta^{\ln}(\gamma - 1)\big) + \tfrac12\overline{u^2}, and

r±=(1{ ⁣{u} ⁣}±a^ nh^±a^ un),r0=(1{ ⁣{u} ⁣}12u2‾),rtk=(0tk{ ⁣{u} ⁣}⋅tk),T=diag⁡(ρln⁡2γ, (γ−1)ρln⁡γ, p^,…, ρln⁡2γ).\mathbf r_\pm = \begin{pmatrix} 1 \\ \{\!\{\mathbf u\}\!\} \pm \hat a\,\mathbf n \\ \hat h \pm \hat a\,u_n \end{pmatrix},\quad \mathbf r_0 = \begin{pmatrix} 1 \\ \{\!\{\mathbf u\}\!\} \\ \tfrac12\overline{u^2} \end{pmatrix},\quad \mathbf r_{t_k} = \begin{pmatrix} 0 \\ \mathbf t_k \\ \{\!\{\mathbf u\}\!\}\cdot\mathbf t_k \end{pmatrix}, \qquad \mathbf T = \operatorname{diag}\Big(\frac{\rho^{\ln}}{2\gamma},\ \frac{(\gamma-1)\rho^{\ln}}{\gamma},\ \hat p,\dots,\ \frac{\rho^{\ln}}{2\gamma}\Big).

The tangential waves are summed without constructing tangent vectors, using ∑ktktkT=I−nnT\sum_k \mathbf t_k\mathbf t_k\T = \mathbf I - \mathbf n\mathbf n\T, so one kernel serves two and three dimensions. The acoustic eigenvalues carry the same Harten fix as roe, which only increases ∣λ∣|\lambda| and so does not affect the inequality. With this mean state a contact discontinuity at rest is left exactly alone (no mass flux through it), where llf diffuses it with the speed of sound; unit tests check the inequality for random pairs, the limit ∣A∣|\mathbf A|, the symmetry of the operator and the stationary contact.

Inside an element the polynomial resolves the solution, and adding dissipation there would cost accuracy. Jumps at interfaces measure under-resolution: they are O(hp+1)\mathcal O(h^{p+1}) for resolved features and large only where the mesh cannot represent the solution. Interface dissipation proportional to the jump is therefore automatically high-order where the solution is smooth and stabilising where it is not, while the entropy-conservative volume term guarantees that the volume terms — where aliasing errors arise — neither produce nor destroy entropy (given positive density and pressure).

    ↑ ↓ moveEnter open[ ] change depthResults show section and depth level