Flow Lab

Syllabus / Module 10: Numerical Methods for PDEs

Lesson 10.10

The Finite Volume Method

Cell averages and fluxes; conservative discretization; Godunov's method and Riemann problems; finite volumes on unstructured meshes.

Written byClaude Sonnet

🌊
Why this matters for simulation: OpenFOAM, ANSYS Fluent and most industrial CFD codes are finite-volume codes.

By the end of this lesson you can…

  • Derive the finite volume update from the integral conservation law on one cell, and show why the total is conserved to round-off.
  • Explain why a cell average differs from a point value by $h^2 u''/24$, and why initial data must be averaged.
  • Write upwind, Lax-Wendroff and a MUSCL minmod scheme as choices of face flux, and compare them on a square pulse and a smooth hump.
  • Build an upwind flux for a linear system (acoustics) by splitting into left- and right-going waves.
  • Show on a variable-speed example that the non-conservative form loses mass.
  • Implement a limited second-order step and check mass, extrema and order.
On this page
·
  1. From the integral law to a cell update
  2. Cell averages are not point values
  3. What makes a numerical flux
  4. Why the flux form matters: a duct of varying speed
  5. Godunov’s method and the Riemann problem
  6. Systems: upwind means splitting into waves
  7. Second order without wiggles: reconstruction
  8. The lab
  9. Cells without grid lines
  10. Computing it
  11. Concept checks
  12. Problems
  13. What comes next
  14. Key Takeaways

9.11 Nonlinear Waves: Burgers' Equation & Shocks ended on a fact it used without proof: each cell changes only by what crosses its faces. That fact is the whole method. 10.6 Advection Schemes: Upwind, Lax–Wendroff & Beyond built upwind, Lax-Wendroff and limiters as formulas for grid values. This lesson changes what the numbers mean. Instead of the value of uu at a point, each number is the average of uu over a cell, and the scheme is bookkeeping for the cell’s contents: what flowed in, minus what flowed out. This is the finite volume method, the design behind most industrial flow solvers (from memory: OpenFOAM and Fluent are finite volume codes). It also carries over, with no new idea, to 2D, to systems such as the Euler equations, and to meshes with no grid lines at all.

▶ Video One cell and its two faces, telescoping fluxes, a cell average against a point value, a square pulse through upwind, Lax-Wendroff and a limited scheme, and a duct where the advective form loses masscaptions only
Transcript
  1. Take a conservation law, u t plus f of u x equals zero, and integrate it over one cell of width h. The cell's content changes by the flux in at one face minus the flux out at the other. That is exact: no Taylor series, no smoothness. The only unknown is the flux at a face, because the scheme stores averages, not point values. So the scheme supplies a numerical flux, and forward Euler gives the update: new average equals old average minus delta t over h times right flux minus left flux.
  2. Why does that matter? Every face appears twice: subtracted from the cell on its left, added to the cell on its right. Add up all the cells and the interior fluxes cancel in pairs. The sum telescopes, and only the two ends survive. A wall sets the flux to zero; a periodic domain keeps its total exactly. All it needs is that neighbours share one number. Any fluxes, any step, any order: conserved to round-off.
  3. What makes a good numerical flux? It must be consistent: with the same state on both sides, return f of u. For a speed a above zero, the upwind flux is a times the left average, because information crosses from the left. The central flux is unstable with forward Euler. Lax-Wendroff adds a correction to upwind. For constant speed these are the finite difference schemes you know. The views split apart for variable coefficients, shocks, boundaries and unstructured cells.
  4. For second order without wiggles, reconstruct inside each cell: a line through the average, with slope s. The face states are the average plus or minus half a slope, and they feed the upwind flux. The minmod limiter picks the smaller of the two one-sided differences, or zero if their signs differ. So the slope vanishes at extrema and jumps, and no new maximum can form. Take averages 0, 1, 3, 2, 2, 0: only the second cell is tilted.
  5. Push a square pulse once around a periodic grid of 100 cells, c equals 0.5, to time 1. Upwind stays between 0 and 0.8418: no wiggles, but smeared, L1 error 0.1031. Lax-Wendroff is sharper but rings: it rises to 1.2129 and dips to minus 0.2074, a negative amount of a positive quantity. Error 0.0675. MUSCL with Heun stays inside 0 and 0.9637, with the smallest error, 0.0557.
  6. On a smooth hump, halve h and watch the L1 error. Upwind's orders are 0.93, 0.97, 0.98: first order. Lax-Wendroff is 2.00, from 0.0039 at 50 cells to 0.00006 at 400. MUSCL lands at 1.80, 1.87, 1.88, shaved because minmod flattens the top of the hump. That is the limiter's price: no wiggles at jumps, slightly less than second order at smooth extrema.
  7. Now Burgers, the sine wave run to time 2, exact shock height 0.9477. Godunov's flux, the exact Riemann solution at each face, peaks at 0.9304 with L1 error 0.0357. MUSCL gets 0.9490 and 0.0023. Richtmyer, Lax-Wendroff for Burgers, does worse than ring: its maximum grows to 12.4703 and its error to 6.034, though mass is still conserved to round-off. Conservation is necessary, not sufficient.
  8. Now why the flux form matters. A density rho is carried by a varying speed a of x, 1 plus a half sine 2 pi x. The conservative flux is a rho. Expanded, rho t plus a rho x equals minus a prime rho looks equally consistent. Start from rho equal to 1. Conservative upwind keeps the mass at 1.000000 at time 1 and time 3. The advective form gains mass: 1.029766, then 1.084005. That is 8.4% of the fluid created from nothing, yet the L1 errors, 0.0693 against 0.0777, look similar.
  9. One more subtlety: a cell average is not a point value. Expand about the centre and the odd term vanishes, leaving u plus h squared over 24 times u double prime. That is second order, the same size as a second order scheme's error, so the lab starts from exact cell averages. At a jump the average sits in between: a cell half inside the pulse holds 1/2. A shock is not between two cells but inside one.
  10. To recap. Integrate over a cell and the update is exact, apart from the face fluxes. One flux per face makes the total telescope. Upwind smears, Lax-Wendroff rings, and limited reconstruction does neither. The conservative form saves the duct from drifting mass. One loose end: the schemes that tried to be sharp rang at a jump. Next, convergence and the Gibbs phenomenon: what a Fourier partial sum does at a jump, and how to tame it.

From the integral law to a cell update

Take ut+f(u)x=0u_t + f(u)_x = 0 and integrate over the cell [xj−1/2,xj+1/2][x_{j-1/2}, x_{j+1/2}] of width hh. The integral of utu_t is the rate of change of the cell content, and the integral of f(u)xf(u)_x is the difference of the flux at the two ends (the fundamental theorem of calculus, the 1D case of 2.10 Green, Stokes & the Divergence Theorem):

ddt uˉj=−1h(f(u(xj+1/2,t))−f(u(xj−1/2,t))),uˉj(t)=1h∫xj−1/2xj+1/2u dx.\frac{d}{dt}\,\bar u_j = -\frac{1}{h}\Big(f\big(u(x_{j+1/2},t)\big) - f\big(u(x_{j-1/2},t)\big)\Big), \qquad \bar u_j(t) = \frac1h\int_{x_{j-1/2}}^{x_{j+1/2}} u\,dx .

This is exact: no Taylor series, no smoothness. The only unknown is the flux at a face, since the scheme stores averages and not the point values u(xj+1/2)u(x_{j+1/2}). The scheme supplies a numerical flux Fj+1/2F_{j+1/2} from the neighbouring averages, and forward Euler in time gives

uˉj n+1=uˉj n−Δth(Fj+1/2−Fj−1/2).\bar u_j^{\,n+1} = \bar u_j^{\,n} - \frac{\Delta t}{h}\left(F_{j+1/2} - F_{j-1/2}\right).

Conservation. The face j+1/2j+1/2 appears twice: subtracted from cell jj, added to cell j+1j+1. Summed over all cells the interior fluxes cancel in pairs (the sum telescopes):

∑jh uˉj n+1=∑jh uˉj n−Δt (Fright end−Fleft end).\sum_j h\,\bar u_j^{\,n+1} = \sum_j h\,\bar u_j^{\,n} - \Delta t\,\big(F_{\text{right end}} - F_{\text{left end}}\big).

Whatever formula is used for FF, the total changes only through the ends: periodic ends give an exactly constant total, a solid wall sets F=0F = 0 there, an inflow boundary prescribes FF. The one requirement is that the two cells sharing a face use the same number Fj+1/2F_{j+1/2}. Boundary conditions become flux conditions, a more natural place for them than a ghost value.

Cell averages are not point values

Expand uu about the cell centre xjx_j, u(xj+s)=u+s u′+12s2u′′+⋯u(x_j + s) = u + s\,u' + \tfrac12 s^2 u'' + \cdots, and average over −h/2≤s≤h/2-h/2 \le s \le h/2. The odd term vanishes and 1h∫s2 ds=h2/12\frac1h\int s^2\,ds = h^2/12:

uˉj=u(xj)+h224 u′′(xj)+O(h4).\bar u_j = u(x_j) + \frac{h^2}{24}\,u''(x_j) + O(h^4).

The difference is small, and it is second order in hh, the same order as a second-order scheme’s error, so it cannot be ignored: starting a second-order scheme from point values puts a spurious O(h2)O(h^2) error into the initial data. The lab therefore starts from exact cell averages. For u=sin⁡2πxu = \sin 2\pi x the average is sin⁡(2πxj) sin⁡(πh)/(πh)\sin(2\pi x_j)\,\sin(\pi h)/(\pi h), and for h=0.01h = 0.01 the biggest gap between average and point value of (1−cos⁡2πx)/2(1 - \cos 2\pi x)/2 is 8.22×10−58.22\times10^{-5}.

At a jump the average is in between: a cell that is half in the square pulse holds 1/21/2. A shock is not “between two cells” but inside one, and a finite volume scheme holds that fact as an intermediate number.

What makes a numerical flux

A numerical flux F(a,b)F(a, b) takes the averages on the two sides of a face. It must be consistent, F(u,u)=f(u)F(u,u) = f(u), so a uniform state moves at the right rate. The face is where information crosses, so for ut+aux=0u_t + a u_x = 0 with a>0a \gt 0 the sensible choice is the upwind flux Fj+1/2=a uˉjF_{j+1/2} = a\,\bar u_j. Two more, with c=aΔt/hc = a\Delta t/h the CFL number of 10.3 Von Neumann Stability Analysis:

  • Central: Fj+1/2=a2(uˉj+uˉj+1)F_{j+1/2} = \tfrac a2(\bar u_j + \bar u_{j+1}), unstable with forward Euler.
  • Lax-Wendroff: Fj+1/2=auˉj+12a(1−c)(uˉj+1−uˉj)F_{j+1/2} = a\bar u_j + \tfrac12 a(1-c)(\bar u_{j+1} - \bar u_j), upwind plus a correction.

These are the schemes of 10.6 Advection Schemes: Upwind, Lax–Wendroff & Beyond, rewritten as fluxes.

Versus finite differences. For constant aa the upwind flux difference a(uˉj−uˉj−1)/ha(\bar u_j - \bar u_{j-1})/h is the same finite difference as before, so on a uniform grid with constant coefficients the two views produce the same formulas. They split apart where the equation does not allow differentiating freely: variable coefficients, shocks, boundaries and curved or unstructured cells. A finite difference scheme approximates uxu_x and cannot know that a flux is conserved. The finite volume scheme builds that knowledge in.

Why the flux form matters: a duct of varying speed

Take a conserved density ρ\rho carried by a prescribed speed a(x)=1+12sin⁡2πxa(x) = 1 + \tfrac12\sin 2\pi x on a periodic domain, ρt+(aρ)x=0\rho_t + (a\rho)_x = 0. The mass flux is aρa\rho. Expand the product and the same equation reads ρt+aρx=−a′ρ\rho_t + a\rho_x = -a'\rho, the advective form, which looks as consistent as any other. Start from ρ=1\rho = 1. The lab compares, on 100100 cells at c=0.5c = 0.5:

  • Conservative upwind, Fj+1/2=aj+1/2 ρˉjF_{j+1/2} = a_{j+1/2}\,\bar\rho_j: the mass is 1.0000001.000000 at t=1t = 1 and at t=3t = 3, to round-off.
  • Advective form ρj−Δt [aj(ρj−ρj−1)/h+aj′ρj]\rho_j - \Delta t\,[a_j(\rho_j - \rho_{j-1})/h + a'_j\rho_j]: the mass is 1.0297661.029766 at t=1t = 1 and 1.0840051.084005 at t=3t = 3. It created 8.4%8.4\% of the fluid from nothing.

The exact answer follows from ρa\rho a being constant along the paths dx/dt=adx/dt = a: ρ(x,t)=a(x0)/a(x)\rho(x,t) = a(x_0)/a(x) with x0x_0 the foot of the path. The L1L^1 errors at t=1t = 1 are 0.06930.0693 for conservative upwind and 0.07770.0777 for the advective form, which is not so different, and that is the trap: the pointwise error looks acceptable while the total is silently drifting.

Godunov’s method and the Riemann problem

Which flux for a nonlinear law? Godunov (1959, from memory) answered it by treating each cell average as a piecewise constant state. At each face two constant states meet, uˉj\bar u_j on the left and uˉj+1\bar u_{j+1} on the right, which is a Riemann problem, exactly the one of 9.11 Nonlinear Waves: Burgers' Equation & Shocks. Its solution depends only on x/tx/t, so at the face x/t=0x/t = 0 it takes one value u∗u^*. The Godunov flux is Fj+1/2=f(u∗)F_{j+1/2} = f(u^*). Then the exact solution is averaged back onto cells. (The picture of averaging exact solutions needs waves from neighbouring faces not to meet: max⁡∣λ∣ Δt/h≤12\max\lvert\lambda\rvert\,\Delta t/h \le \tfrac12, from memory. For scalar schemes the flux update itself is stable to 11.)

For advection with a>0a \gt 0, u∗=uˉju^* = \bar u_j and Godunov is upwind. For Burgers it is the flux of 9.11 Nonlinear Waves: Burgers' Equation & Shocks: f(a)f(a) if the shock moves right or the fan lies in u>0u \gt 0, f(b)f(b) for the left, and 00 at a sonic point.

Systems: upwind means splitting into waves

Systems are the reason the method matters for fluids. The linearised 1D acoustics of a gas, with velocity vv and pressure pp, density ρ\rho and bulk modulus KK, reads

vt+1ρ px=0,pt+K vx=0.v_t + \tfrac1\rho\,p_x = 0, \qquad p_t + K\,v_x = 0 .

Let c=K/ρc = \sqrt{K/\rho} and Z=ρcZ = \rho c. The combinations w+=p+Zvw^+ = p + Zv and w−=p−Zvw^- = p - Zv satisfy wt±=∓c wx±w^\pm_t = \mp c\,w^\pm_x: w+w^+ is carried right at speed cc, w−w^- left. Geometrically, there are two special directions in the (v,p)(v, p) plane that are not mixed by the dynamics, and these are the eigenvectors. Their eigenvalues ±c\pm c are the wave speeds.

At a face, the information about w+w^+ comes from the left cell and w−w^- from the right. Hence the upwind flux:

p∗=12(wL++wR−),v∗=wL+−wR−2Z,F=(p∗ρ, K v∗).p^* = \tfrac12\big(w^+_L + w^-_R\big), \qquad v^* = \frac{w^+_L - w^-_R}{2Z}, \qquad F = \Big(\frac{p^*}{\rho},\ K\,v^*\Big).

Example. ρ=1\rho = 1, K=4K = 4 (so c=Z=2c = Z = 2), a pressure step: left (v,p)=(0,1)(v,p) = (0,1), right (0,0)(0,0). Then wL+=1w^+_L = 1, wR−=0w^-_R = 0, so p∗=0.5p^* = 0.5, v∗=0.25v^* = 0.25 and F=(0.5, 1.0)F = (0.5,\ 1.0): the high-pressure side pushes the gas right. The nonlinear Euler equations use the same recipe with approximate Riemann solvers (Roe, HLL, from memory), the subject of 11.3 Momentum: Pressure & the Euler Equations and 11.12 Compressible Flow & Shocks.

Second order without wiggles: reconstruction

Upwind is conservative and smears; Lax-Wendroff is conservative and rings. Finite volume gives a second way to think about the fix: reconstruct the profile inside each cell, not only the flux. Replace the constant by a line through the average, u(x)=uˉj+sj(x−xj)/hu(x) = \bar u_j + s_j (x - x_j)/h, whose average is still uˉj\bar u_j for any sjs_j, since it is centred. The face states are uˉj+sj/2\bar u_j + s_j/2 (left of the face) and uˉj+1−sj+1/2\bar u_{j+1} - s_{j+1}/2 (right). Feed them to the upwind flux. The slope is chosen by the minmod limiter,

sj=minmod⁡(uˉj−uˉj−1, uˉj+1−uˉj),minmod⁡(a,b)={0ab≤0a or b, whichever is smaller in sizeotherwise.s_j = \operatorname{minmod}\big(\bar u_j - \bar u_{j-1},\ \bar u_{j+1} - \bar u_j\big), \qquad \operatorname{minmod}(a,b) = \begin{cases} 0 & ab \le 0 \\ a \text{ or } b,\ \text{whichever is smaller in size} & \text{otherwise.} \end{cases}

It is zero at extrema and at jumps, so no new maximum can form, and on smooth monotone data it picks the smaller of the two one-sided differences. This is MUSCL (van Leer, 1979, from memory). 10.6 Advection Schemes: Upwind, Lax–Wendroff & Beyond limited the flux; here the data are limited, and the results are of the same family. The time stepper matters: Heun’s method (second order, strong-stability-preserving, from memory) keeps the scheme bounded, which forward Euler does only for c≤1/2c \le 1/2 (from memory).

The lab

◆ Interactive Finite volume lab: four problems, five schemes, exact cell averages dashed, face fluxes below

Loading simulation…

All runs: 100100 cells, c=0.5c = 0.5 (Burgers: CFL 0.50.5), pulse on [0.125,0.325)[0.125, 0.325), one lap (to t=1t = 1) unless noted. Every run conserves mass to 10−1510^{-15} except where stated.

  1. Square pulse. Upwind: max 0.84180.8418, min 0.00000.0000, total variation 1.68371.6837 (start 22), L1L^1 error 0.10310.1031. Lax-Wendroff: max 1.21291.2129, min −0.2074-0.2074, TV 3.28573.2857, error 0.06750.0675. MUSCL with Heun: max 0.96370.9637, min 0.00000.0000, TV 1.92741.9274, error 0.05570.0557.
  2. Time stepper. MUSCL with forward Euler gives 1.00001.0000 and 0.00000.0000 at c=0.5c = 0.5 (error 0.00410.0041, a coincidence of the half-cell step that I have not analysed) but at c=0.9c = 0.9 the maximum is 39.601739.6017. Heun at c=0.9c = 0.9: max 0.88110.8811, error 0.09300.0930, worse than upwind’s 0.04190.0419 there: near c=1c = 1 upwind is almost exact.
  3. Smooth hump, order. L1L^1 errors at N=50,100,200,400N = 50, 100, 200, 400: upwind 0.05690.0569, 0.02990.0299, 0.01530.0153, 0.00780.0078 (orders 0.930.93, 0.970.97, 0.980.98); Lax-Wendroff 0.00390.0039, 0.000990.00099, 0.000250.00025, 0.000060.00006 (order 2.002.00); MUSCL 0.01630.0163, 0.00470.0047, 0.00130.0013, 0.000350.00035 (orders 1.801.80, 1.871.87, 1.881.88, shaved at the extrema).
  4. Burgers sine to t=2t = 2 (exact shock height 0.94770.9477): Godunov peak 0.93040.9304, error 0.03570.0357; MUSCL peak 0.94900.9490, error 0.00230.0023. Richtmyer (Lax-Wendroff for Burgers): max 12.470312.4703, error 6.0346.034. It does not just ring, it grows after the shock forms, though mass stays 10−1610^{-16}. I verified the growth with a separate script but have not analysed its cause; the shock here is stationary at a sonic point u=0u = 0, a hard case for an unlimited scheme.
  5. Duct: conservative upwind, Lax-Wendroff and MUSCL give errors 0.06930.0693, 0.00470.0047, 0.00590.0059 with mass 1.0000001.000000; the advective form gives mass 1.0297661.029766 and error 0.07770.0777.

Cells without grid lines

In 2D on a Cartesian grid with fluxes FF and GG across vertical and horizontal faces,

uˉij n+1=uˉij n−Δth(Fi+1/2,j−Fi−1/2,j+Gi,j+1/2−Gi,j−1/2).\bar u_{ij}^{\,n+1} = \bar u_{ij}^{\,n} - \frac{\Delta t}{h}\Big(F_{i+1/2,j} - F_{i-1/2,j} + G_{i,j+1/2} - G_{i,j-1/2}\Big).

With FF and GG the face velocities this is the divergence of 10.11 2D Grids, Boundary Conditions & Staggered (MAC) Grids. On an arbitrary polygonal cell ViV_i with faces ff of length ∣f∣\lvert f\rvert and outward unit normals nf\mathbf n_f:

uˉi n+1=uˉi n−Δt∣Vi∣∑fFf ∣f∣,\bar u_i^{\,n+1} = \bar u_i^{\,n} - \frac{\Delta t}{\lvert V_i\rvert}\sum_f F_f\,\lvert f\rvert,

where FfF_f is a one-dimensional numerical flux in the direction nf\mathbf n_f, the same Riemann problem along the normal. Nothing in the derivation needed a grid, only the divergence theorem on the cell. This is why finite volume codes handle wings and engine cavities with unstructured meshes. Conservation still telescopes, since the neighbour sees the same face with the normal flipped. One more check is free-stream preservation: a closed polygon has ∑fnf∣f∣=0\sum_f \mathbf n_f\lvert f\rvert = \mathbf 0, so a uniform state creates no change on any mesh.

Computing it

🐍 PythonLab: averages against point values, an acoustic face flux, and telescoping
⌘/Ctrl + Enter
🧪 Coding exerciseExercise: a MUSCL-minmod finite volume step
⌘/Ctrl + Enter

Concept checks

✅ Concept check

A cell has $\bar u = 2$, width $h = 0.5$, and the step is $\Delta t = 0.1$. The flux in through its left face is $3$ and the flux out through its right face is $1$. What is the new average?

✅ Concept check

Why must the cells on both sides of a face use the same number $F_{j+1/2}$?

✅ Concept check

Which statement about the duct example is true?

✅ Concept check

At the top of a smooth hump the differences $\bar u_j - \bar u_{j-1}$ and $\bar u_{j+1} - \bar u_j$ have opposite signs. What does minmod do there, and what is the price?

Problems

✏️ Pen & paperAverage against point value●○○

For u=x2u = x^2 on the cell [0.2,0.4][0.2, 0.4] (h=0.2h = 0.2), find uˉ\bar u and compare with uu at the centre and with h2u′′/24h^2u''/24.

Show worked solution

uˉ=10.2∫0.20.4x2 dx=0.43−0.233⋅0.2=0.0560.6=0.09333\bar u = \dfrac{1}{0.2}\displaystyle\int_{0.2}^{0.4} x^2\,dx = \dfrac{0.4^3 - 0.2^3}{3\cdot0.2} = \dfrac{0.056}{0.6} = 0.09333. The centre is x=0.3x = 0.3, u=0.09u = 0.09. The gap is 0.0033330.003333, and h2u′′/24=0.04⋅2/24=0.003333h^2u''/24 = 0.04\cdot2/24 = 0.003333: for a quadratic the formula is exact.

✏️ Pen & paperOne limited step by hand●●○

Take a=1a = 1, c=Δt/h⋅a=0.5c = \Delta t/h\cdot a = 0.5, forward Euler, with cell averages (uˉ0,…,uˉ5)=(0,1,3,2,2,0)(\bar u_0,\dots,\bar u_5) = (0, 1, 3, 2, 2, 0) and zero outside. Compute the minmod slopes s1,…,s4s_1,\dots,s_4, the face fluxes Fj+1/2=uˉj+sj/2F_{j+1/2} = \bar u_j + s_j/2 for j=0,…,4j = 0,\dots,4, and the new values of cells 11 to 44. Check the mass, and compare with upwind.

Show worked solution

Slopes: s1=minmod⁡(1,2)=1s_1 = \operatorname{minmod}(1, 2) = 1; s2=minmod⁡(2,−1)=0s_2 = \operatorname{minmod}(2, -1) = 0; s3=minmod⁡(−1,0)=0s_3 = \operatorname{minmod}(-1, 0) = 0; s4=minmod⁡(0,−2)=0s_4 = \operatorname{minmod}(0, -2) = 0; s0=0s_0 = 0. Fluxes: F1/2=0F_{1/2} = 0, F3/2=1.5F_{3/2} = 1.5, F5/2=3F_{5/2} = 3, F7/2=2F_{7/2} = 2, F9/2=2F_{9/2} = 2. Update uˉj−0.5 (Fj+1/2−Fj−1/2)\bar u_j - 0.5\,(F_{j+1/2} - F_{j-1/2}): cell 11: 1−0.75=0.251 - 0.75 = 0.25; cell 22: 3−0.75=2.253 - 0.75 = 2.25; cell 33: 2+0.5=2.52 + 0.5 = 2.5; cell 44: 22. Mass: before 88, after 77; flux in at the left, F1/2=0F_{1/2} = 0, minus flux out at the right, F9/2=2F_{9/2} = 2, times 0.50.5 is −1-1. Upwind gives (0.5,2,2.5,2)(0.5, 2, 2.5, 2) for the same cells, so the limited scheme keeps cell 22 higher (2.252.25 against 22) and drains cell 11 faster (0.250.25 against 0.50.5): a steeper front.

✏️ Pen & paperAn acoustic Riemann problem●●○

With ρ=1\rho = 1, K=4K = 4 take left state (v,p)=(1,3)(v, p) = (1, 3) and right state (−1,1)(-1, 1), two gas columns colliding. Find the star state and the flux through the face, and check that w+w^+ and w−w^- agree with the correct side.

Show worked solution

c=Z=2c = Z = 2. wL+=3+2=5w^+_L = 3 + 2 = 5 and wR−=1−2(−1)=3w^-_R = 1 - 2(-1) = 3. Then p∗=(5+3)/2=4p^* = (5 + 3)/2 = 4 and v∗=(5−3)/4=0.5v^* = (5 - 3)/4 = 0.5. The flux is (p∗/ρ, Kv∗)=(4,2)(p^*/\rho,\ K v^*) = (4, 2). Check: p∗+Zv∗=5=wL+p^* + Zv^* = 5 = w^+_L and p∗−Zv∗=3=wR−p^* - Zv^* = 3 = w^-_R. The pressure rises from 11 and 33 to 44, the collision compresses the gas.

✏️ Pen & paperA triangle with neighbours●●●

A triangular cell with vertices (0,0)(0,0), (1,0)(1,0), (0,1)(0,1) lies in the uniform velocity a=(1,2)\mathbf a = (1, 2), carrying a conserved ρ\rho with ρi=1\rho_i = 1. Across the bottom edge the neighbour has ρ=0.5\rho = 0.5, across the hypotenuse 22, across the left edge 33. Use the upwind flux Ff=(a⋅nf)ρupwindF_f = (\mathbf a\cdot\mathbf n_f)\rho_{\text{upwind}} and find dρi/dtd\rho_i/dt. Then show that if all neighbours also have ρ=1\rho = 1 the rate is zero.

Show worked solution

Outward normals and lengths: bottom (0,−1)(0,-1), 11; hypotenuse (1,1)/2(1,1)/\sqrt2, 2\sqrt2; left (−1,0)(-1,0), 11. Then a⋅n=−2, 3/2, −1\mathbf a\cdot\mathbf n = -2,\ 3/\sqrt2,\ -1. Negative means inflow, so the neighbour’s value is used: bottom −2⋅0.5⋅1=−1-2\cdot0.5\cdot1 = -1; hypotenuse (outflow, own value) (3/2)(1)(2)=3(3/\sqrt2)(1)(\sqrt2) = 3; left −1⋅3⋅1=−3-1\cdot3\cdot1 = -3. The sum is −1-1, the area is 1/21/2, so dρi/dt=−(1/0.5)(−1)=+2d\rho_i/dt = -(1/0.5)(-1) = +2. With all values 11 the sum is a⋅∑fnf∣f∣=a⋅[(0,−1)+(1,1)+(−1,0)]=0\mathbf a\cdot\sum_f \mathbf n_f\lvert f\rvert = \mathbf a\cdot[(0,-1) + (1,1) + (-1,0)] = 0: free-stream preservation.

What comes next

One loose end. Every scheme here that tried to be sharp and second order, Lax-Wendroff and Richtmyer, rang at a jump: 1.21291.2129 and −0.2074-0.2074 on a pulse of height 11, and a runaway growth for Burgers. The limiter removed it at the price of clipping smooth extrema, giving order 1.81.8 to 1.91.9 instead of 22. That is a symptom you will meet again in a different place. The next lesson, 8.5 Convergence & the Gibbs Phenomenon, goes back to Fourier series (module 8) and asks what a partial sum does at a jump. It overshoots by a fixed fraction of the jump (about 9%9\%, from memory), however many terms are kept: the Gibbs phenomenon. I do not claim it is the same mechanism as the ringing above. It is the same kind of symptom, a smooth high-order approximation of a discontinuity, so the lesson will ask when it converges, how fast the coefficients decay and how to filter it, with the discrete and fast Fourier transforms needed later for spectral methods.

Key Takeaways

  • The finite volume update uˉj n+1=uˉj n−(Δt/h)(Fj+1/2−Fj−1/2)\bar u_j^{\,n+1} = \bar u_j^{\,n} - (\Delta t/h)(F_{j+1/2} - F_{j-1/2}) is the exact integral law on a cell, with one approximation: the flux at the face.
  • One flux per face makes the sum telescope, so the total changes only at the boundary: mass is conserved to round-off (about 10−1610^{-16} in every lab run) whatever the flux, step, or order.
  • A cell average is u+h2u′′/24u + h^2u''/24, not uu; initial data must be averaged. A shock is a cell holding an in-between value.
  • Written in advective form the duct problem gained 2.98%2.98\% of its mass by t=1t = 1 and 8.4%8.4\% by t=3t = 3; the conservative scheme kept 1.0000001.000000.
  • Godunov’s flux is the exact Riemann solution on the face; for systems, upwind means taking each wave from its upwind side, shown by the acoustic example F=(0.5,1.0)F = (0.5, 1.0).
  • Reconstruction with a minmod slope and a Heun step gave a square pulse in [0,0.9637][0, 0.9637] (Lax-Wendroff: [−0.2074,1.2129][-0.2074, 1.2129]), and order about 1.81.8 on smooth data; Richtmyer on Burgers grew without bound.
  • The same update works on any polygon: −(Δt/∣V∣)∑fFf∣f∣-(\Delta t/\lvert V\rvert)\sum_f F_f\lvert f\rvert, with uniform states preserved because ∑fnf∣f∣=0\sum_f \mathbf n_f\lvert f\rvert = 0. This is the basis of unstructured-mesh CFD.
  • Next: 8.5 Convergence & the Gibbs Phenomenon studies the Gibbs overshoot of Fourier series at a jump.
Finished this lesson?

Mark it complete to track your progress (saved in this browser). Reading every section does this for you.

Where this leads

These later lessons build directly on this one: