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 at a point, each number is the average of 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.
Transcript
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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 and integrate over the cell of width . The integral of is the rate of change of the cell content, and the integral of 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):
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 . The scheme supplies a numerical flux from the neighbouring averages, and forward Euler in time gives
Conservation. The face appears twice: subtracted from cell , added to cell . Summed over all cells the interior fluxes cancel in pairs (the sum telescopes):
Whatever formula is used for , the total changes only through the ends: periodic ends give an exactly constant total, a solid wall sets there, an inflow boundary prescribes . The one requirement is that the two cells sharing a face use the same number . Boundary conditions become flux conditions, a more natural place for them than a ghost value.
Cell averages are not point values
Expand about the cell centre , , and average over . The odd term vanishes and :
The difference is small, and it is second order in , 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 error into the initial data. The lab therefore starts from exact cell averages. For the average is , and for the biggest gap between average and point value of is .
At a jump the average is in between: a cell that is half in the square pulse holds . 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 takes the averages on the two sides of a face. It must be consistent, , so a uniform state moves at the right rate. The face is where information crosses, so for with the sensible choice is the upwind flux . Two more, with the CFL number of 10.3 Von Neumann Stability Analysis:
- Central: , unstable with forward Euler.
- Lax-Wendroff: , 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 the upwind flux difference 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 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 carried by a prescribed speed on a periodic domain, . The mass flux is . Expand the product and the same equation reads , the advective form, which looks as consistent as any other. Start from . The lab compares, on cells at :
- Conservative upwind, : the mass is at and at , to round-off.
- Advective form : the mass is at and at . It created of the fluid from nothing.
The exact answer follows from being constant along the paths : with the foot of the path. The errors at are for conservative upwind and 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, on the left and on the right, which is a Riemann problem, exactly the one of 9.11 Nonlinear Waves: Burgers' Equation & Shocks. Its solution depends only on , so at the face it takes one value . The Godunov flux is . Then the exact solution is averaged back onto cells. (The picture of averaging exact solutions needs waves from neighbouring faces not to meet: , from memory. For scalar schemes the flux update itself is stable to .)
For advection with , and Godunov is upwind. For Burgers it is the flux of 9.11 Nonlinear Waves: Burgers' Equation & Shocks: if the shock moves right or the fan lies in , for the left, and 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 and pressure , density and bulk modulus , reads
Let and . The combinations and satisfy : is carried right at speed , left. Geometrically, there are two special directions in the plane that are not mixed by the dynamics, and these are the eigenvectors. Their eigenvalues are the wave speeds.
At a face, the information about comes from the left cell and from the right. Hence the upwind flux:
Example. , (so ), a pressure step: left , right . Then , , so , and : 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, , whose average is still for any , since it is centred. The face states are (left of the face) and (right). Feed them to the upwind flux. The slope is chosen by the minmod limiter,
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 (from memory).
The lab
All runs: cells, (Burgers: CFL ), pulse on , one lap (to ) unless noted. Every run conserves mass to except where stated.
- Square pulse. Upwind: max , min , total variation (start ), error . Lax-Wendroff: max , min , TV , error . MUSCL with Heun: max , min , TV , error .
- Time stepper. MUSCL with forward Euler gives and at (error , a coincidence of the half-cell step that I have not analysed) but at the maximum is . Heun at : max , error , worse than upwind’s there: near upwind is almost exact.
- Smooth hump, order. errors at : upwind , , , (orders , , ); Lax-Wendroff , , , (order ); MUSCL , , , (orders , , , shaved at the extrema).
- Burgers sine to (exact shock height ): Godunov peak , error ; MUSCL peak , error . Richtmyer (Lax-Wendroff for Burgers): max , error . It does not just ring, it grows after the shock forms, though mass stays . I verified the growth with a separate script but have not analysed its cause; the shock here is stationary at a sonic point , a hard case for an unlimited scheme.
- Duct: conservative upwind, Lax-Wendroff and MUSCL give errors , , with mass ; the advective form gives mass and error .
Cells without grid lines
In 2D on a Cartesian grid with fluxes and across vertical and horizontal faces,
With and the face velocities this is the divergence of 10.11 2D Grids, Boundary Conditions & Staggered (MAC) Grids. On an arbitrary polygonal cell with faces of length and outward unit normals :
where is a one-dimensional numerical flux in the direction , 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 , so a uniform state creates no change on any mesh.
Computing it
Concept checks
Problems
For on the cell (), find and compare with at the centre and with .
Show worked solution
. The centre is , . The gap is , and : for a quadratic the formula is exact.
Take , , forward Euler, with cell averages and zero outside. Compute the minmod slopes , the face fluxes for , and the new values of cells to . Check the mass, and compare with upwind.
Show worked solution
Slopes: ; ; ; ; . Fluxes: , , , , . Update : cell : ; cell : ; cell : ; cell : . Mass: before , after ; flux in at the left, , minus flux out at the right, , times is . Upwind gives for the same cells, so the limited scheme keeps cell higher ( against ) and drains cell faster ( against ): a steeper front.
With , take left state and right state , two gas columns colliding. Find the star state and the flux through the face, and check that and agree with the correct side.
Show worked solution
. and . Then and . The flux is . Check: and . The pressure rises from and to , the collision compresses the gas.
A triangular cell with vertices , , lies in the uniform velocity , carrying a conserved with . Across the bottom edge the neighbour has , across the hypotenuse , across the left edge . Use the upwind flux and find . Then show that if all neighbours also have the rate is zero.
Show worked solution
Outward normals and lengths: bottom , ; hypotenuse , ; left , . Then . Negative means inflow, so the neighbour’s value is used: bottom ; hypotenuse (outflow, own value) ; left . The sum is , the area is , so . With all values the sum is : 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: and on a pulse of height , and a runaway growth for Burgers. The limiter removed it at the price of clipping smooth extrema, giving order to instead of . 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 , 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 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 in every lab run) whatever the flux, step, or order.
- A cell average is , not ; initial data must be averaged. A shock is a cell holding an in-between value.
- Written in advective form the duct problem gained of its mass by and by ; the conservative scheme kept .
- 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 .
- Reconstruction with a minmod slope and a Heun step gave a square pulse in (Lax-Wendroff: ), and order about on smooth data; Richtmyer on Burgers grew without bound.
- The same update works on any polygon: , with uniform states preserved because . 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.