Module 13: Higher-Order Convection Schemes and Flux Limiters
Understand numerical diffusion, reconstruct face values, derive slope limiters, and implement a conservative higher-resolution advection scheme in C++.
1. Introduction
In Module 12, we implemented central-difference and first-order upwind schemes for the steady convection–diffusion equation. We learned that the choice of face interpolation directly affects the accuracy, stability, and boundedness of a numerical solution.
First-order upwind is robust, but it can smear sharp gradients. Central differencing is more accurate for smooth fields, but it can generate nonphysical oscillations when convection dominates diffusion.
This module introduces a family of methods designed to balance these competing requirements: higher-order convection schemes with slope limiters.
The central idea is straightforward:
- Use information from neighbouring cells to reconstruct a more accurate face value.
- Detect where the solution is smooth and where it contains steep gradients or extrema.
- Reduce the reconstruction slope where necessary to prevent nonphysical oscillations.
- Calculate fluxes consistently so that the finite-volume method remains conservative.
These ideas are used in many modern CFD methods, including MUSCL-type reconstruction, total variation diminishing schemes, and flux-limiter methods.
By the end of this module, you should be able to:
- Explain numerical diffusion and spurious oscillations.
- Understand why higher-order reconstruction improves accuracy.
- Calculate a limited gradient from neighbouring cell values.
- Derive a conservative higher-resolution flux.
- Implement first-order upwind and a monotonized central (MC) limiter in C++.
- Compare numerical results using mass conservation, boundedness, and total variation.
- Understand the limitations of higher-order schemes and how they fit into a larger CFD framework.
2. Why do we need higher-order convection schemes?
Consider the one-dimensional linear advection equation:
Here:
- is a transported scalar.
- is a constant velocity.
- is the spatial coordinate.
- is time.
Assume that , so information travels from left to right.
The analytical solution is
where is the initial distribution.
The profile translates at velocity without changing shape. If the initial condition contains a sharp front, that front should remain sharp in the exact solution.
Numerical methods do not always reproduce this behaviour perfectly.
2.1 Numerical diffusion
First-order upwind uses the upstream cell value to calculate the convective flux. This is robust, but it introduces artificial smoothing.
For example, consider an initial scalar distribution with a sharp transition:
As this profile moves through the numerical mesh, a first-order upwind solution tends to spread the sharp transitions across multiple cells.
This is called numerical diffusion or artificial diffusion.
It is caused by the discretization rather than by the physical diffusion coefficient in the governing equation.
Numerical diffusion can be particularly harmful when modelling:
- Thin shear layers.
- Species concentration fronts.
- Thermal interfaces.
- Contact discontinuities.
- Material interfaces.
- Sharp changes in transported quantities.
A mesh-refinement study can reduce this error, but increasing the mesh resolution may be computationally expensive.
A higher-order convection scheme attempts to obtain better accuracy on a given mesh.
2.2 Nonphysical oscillations
A different problem occurs when a numerical scheme uses a high-order approximation without adequately controlling the solution near steep gradients.
The computed solution may develop overshoots and undershoots:
- An overshoot occurs when the numerical value exceeds the local physical range.
- An undershoot occurs when the numerical value falls below that range.
For example, if a scalar is initially between zero and one, an oscillatory scheme may produce values greater than one or less than zero.
These values may be physically meaningless, depending on the transported quantity.
The challenge is therefore not simply to maximize formal accuracy. A useful CFD scheme must also behave appropriately near steep gradients and discontinuities.
3. A hierarchy of convection schemes
The following hierarchy illustrates the development from a simple robust scheme to more advanced reconstruction methods.
3.1 First-order upwind
The face value is taken directly from the upstream cell:
For positive velocity,
This method is simple and robust, but it is generally first-order accurate in space and can introduce substantial numerical diffusion.
3.2 Central differencing
The face value is interpolated from the two adjacent cell centres:
On a uniform mesh, this approximation is second-order accurate for smooth fields.
However, central differencing does not automatically respect local bounds when convection dominates diffusion.
3.3 Higher-order reconstruction
A higher-order method estimates how the scalar varies inside each cell.
For example, a linear reconstruction inside cell can be written as
where:
- is the cell-centred value.
- is the cell-centre coordinate.
- is the reconstructed spatial slope.
At the east face of a uniform cell,
The slope allows the scheme to account for variation within the cell rather than assuming that the scalar is constant throughout it.
But an unrestricted slope can produce nonphysical oscillations near extrema or discontinuities.
This motivates slope limiting.
4. Understanding slope reconstruction
4.1 The unlimited gradient
For a uniform one-dimensional mesh, define the backward and forward differences:
An unlimited centred slope is
Equivalently,
This is second-order accurate for smooth fields on a uniform grid.
However, consider a local maximum. The scalar increases on one side and decreases on the other. The backward and forward differences have opposite signs.
An unrestricted linear reconstruction may extend beyond the local maximum and generate an overshoot.
The problem is not that the gradient formula is incorrect in smooth regions. The problem is applying an unrestricted reconstruction where the local solution is not adequately represented by a smooth linear profile.
4.2 Introducing a limited slope
A slope limiter modifies the reconstructed gradient according to the neighbouring values.
A general limiter can be expressed as
The limited slope is designed to retain useful gradient information in smooth regions while reducing it near extrema or steep changes.
If the neighbouring values indicate a local extremum, a typical monotone limiter reduces the slope to zero.
If the solution varies smoothly and monotonically, the limiter can retain a nonzero slope.
The resulting reconstruction is less aggressive near problematic regions than an unrestricted higher-order reconstruction.
5. The minmod limiter
One of the simplest slope limiters is the minmod limiter.
Define the function
For a uniform one-dimensional mesh, the minmod-limited slope is
If both differences have the same sign, the limiter selects the smaller magnitude. If their signs differ, it sets the slope to zero.
5.1 Physical interpretation
Suppose the scalar values are
Then
and
Both differences are positive and equal. The limiter retains the slope.
Now consider
Then
and
The differences have opposite signs, indicating a local maximum. The limiter sets the slope to zero.
5.2 Advantages and limitations
The minmod limiter is simple and effective at suppressing oscillations.
Its main limitation is that it can be overly diffusive. Even smooth gradients may be reduced more than necessary, especially on coarse meshes.
Other limiters attempt to retain more gradient information while maintaining desirable boundedness properties.
6. The monotonized central limiter
This module will implement the monotonized central (MC) limiter.
The MC-limited slope on a uniform mesh is
The three arguments represent different estimates of the local gradient:
- Twice the backward difference.
- The centred difference.
- Twice the forward difference.
The limiter selects a suitably restricted slope that does not exceed the bounds implied by these estimates.
6.1 Why use three estimates?
The centred estimate is accurate in smooth regions, but it may be too aggressive near steep gradients.
The one-sided estimates provide local bounds on the slope.
Combining them helps preserve more accuracy than a restrictive limiter in smooth regions while still reducing slopes near extrema.
The MC limiter is generally less diffusive than minmod, although its behaviour depends on the solution and the mesh.
6.2 Limiting the slope, not the physical equation
The limiter does not change the governing transport equation.
The physical equation remains
for constant velocity.
The limiter changes how the face flux is approximated from the available cell values.
This distinction is fundamental: the limiter is part of the numerical discretization, not an additional physical term.
7. From reconstruction to a higher-resolution face flux
We now derive the numerical flux used in the C++ solver.
Consider positive constant velocity and a uniform mesh.
Define the Courant number:
The Courant number measures how far information travels during one time step relative to the cell width.
For the explicit method used in this module, we require
The time step is chosen to satisfy this condition.
7.1 First-order upwind flux
For positive velocity, the upwind face value is the value from the cell immediately upstream:
The convective flux is
Here, denotes the physical convective flux per unit area for this scalar equation, not the mass flow rate used in Module 12.
7.2 Limited higher-resolution flux
Using the MC-limited slope, a reconstructed face value can be written as
The factor accounts for the time discretization in this particular flux-limited method. It is not a universal factor for every higher-order reconstruction method.
Substituting the face value into the convective flux gives
When the limiter sets , the flux reduces to first-order upwind.
When the solution is smooth and the limiter retains its slope, the flux uses higher-order information.
At , the correction vanishes. For this constant-velocity periodic advection problem, the upwind update then translates the solution by one cell per time step.
7.3 Conservative update
The finite-volume balance for cell is
Using an explicit Euler time update,
This update is conservative because it uses the difference between the flux leaving the cell and the flux entering the cell.
The same face flux must be used by both neighbouring cells. If one cell uses a different value for the shared face, conservation can be lost.
8. Total variation and boundedness
Higher-resolution methods are often discussed in terms of total variation diminishing (TVD) behaviour.
For a discrete one-dimensional periodic scalar field, define the total variation as
with periodic indexing, so that the first cell is adjacent to the last.
Total variation measures the overall magnitude of changes between neighbouring values.
For a scalar advection problem, a TVD update satisfies
under the assumptions for which the method is TVD.
This condition helps prevent the creation of new oscillations, although it is not a complete measure of physical correctness or accuracy.
8.1 What a limiter aims to achieve
A well-designed limiter aims to:
- Preserve higher-order accuracy in smooth regions.
- Reduce the slope near extrema and discontinuities.
- Avoid introducing spurious oscillations.
- Maintain conservative face-flux updates.
The precise properties depend on the limiter, flux formula, time integrator, and time-step restriction.
The implementation in this module uses a standard MC-limited flux for one-dimensional linear advection with positive constant velocity, a uniform mesh, periodic boundaries, and an explicit Euler update with .
Do not assume that a limiter automatically makes every multidimensional CFD scheme TVD or bounded. The complete discretization and its stability restrictions still matter.
9. Building a C++ advection solver
We will implement two schemes:
- First-order upwind.
- MC-limited higher-resolution flux.
The problem is one-dimensional linear advection on a periodic domain. The periodic boundary condition makes the implementation straightforward and allows us to focus on the face fluxes and limiter.
9.1 Governing equation
We solve
with
and periodic boundary conditions:
For periodic advection, the scalar leaving the right side of the domain re-enters at the left side.
The initial condition is a top-hat profile:
The exact solution is the initial profile shifted by and wrapped periodically around the domain.
This problem is useful because it tests the transport of sharp fronts. It also lets us monitor conservation and the creation of new extrema.
9.2 Numerical setup
The default parameters are:
| Parameter | Value |
|---|---|
| Domain length | |
| Number of cells | |
| Velocity | |
| Courant number | |
| Final time | |
| Boundary condition | Periodic |
| Schemes | Upwind and MC |
The time step is calculated from
For these settings, the final time is reached exactly by an integer number of time steps.
9.3 Complete C++ implementation
Save the following code as advection_limiter.cpp.
#include <algorithm>
#include <cmath>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <stdexcept>
#include <string>
#include <vector>
enum class Scheme
{
Upwind,
MC
};
struct Parameters
{
int cells = 200;
double length = 1.0;
double velocity = 1.0;
double courant = 0.5;
double finalTime = 0.5;
};
double minmod3(double a, double b, double c)
{
// Return zero if the arguments do not all
// have the same strict sign.
if (a > 0.0 && b > 0.0 && c > 0.0)
{
return std::min({a, b, c});
}
if (a < 0.0 && b < 0.0 && c < 0.0)
{
return std::max({a, b, c});
}
return 0.0;
}
double limitedSlope(
const std::vector<double>& phi,
int i,
Scheme scheme)
{
const int N = static_cast<int>(phi.size());
const int im = (i - 1 + N) % N;
const int ip = (i + 1) % N;
const double dm = phi[i] - phi[im];
const double dp = phi[ip] - phi[i];
if (scheme == Scheme::Upwind)
{
return 0.0;
}
// MC-limited difference across the cell.
//
// This quantity approximates:
// dx * d(phi)/dx
//
// The physical slope is obtained by dividing
// by dx, but the flux formula below uses
// this difference directly.
return minmod3(
2.0 * dm,
0.5 * (dm + dp),
2.0 * dp);
}
std::vector<double> calculateFaceValues(
const std::vector<double>& phi,
double courant,
Scheme scheme)
{
const int N = static_cast<int>(phi.size());
std::vector<double> faceValue(N, 0.0);
// faceValue[i] is the scalar value at the
// east face of cell i.
for (int i = 0; i < N; ++i)
{
const double slope =
limitedSlope(phi, i, scheme);
faceValue[i] =
phi[i] +
0.5 * (1.0 - courant) * slope;
}
return faceValue;
}
void advanceOneStep(
std::vector<double>& phi,
double courant,
Scheme scheme)
{
const int N = static_cast<int>(phi.size());
const std::vector<double> faceValue =
calculateFaceValues(phi, courant, scheme);
std::vector<double> next(N, 0.0);
// Positive velocity and periodic boundaries:
//
// phi_i^(n+1) =
// phi_i^n
// - C * (phi_(i+1/2) - phi_(i-1/2))
//
// faceValue[i] = east face of cell i
// faceValue[im] = west face of cell i
for (int i = 0; i < N; ++i)
{
const int im = (i - 1 + N) % N;
next[i] =
phi[i] -
courant * (faceValue[i] - faceValue[im]);
}
phi.swap(next);
}
double initialCondition(double x, double length)
{
const double normalizedX = x / length;
if (normalizedX >= 0.2 &&
normalizedX < 0.4)
{
return 1.0;
}
return 0.0;
}
double periodicCoordinate(double x, double length)
{
double wrapped = std::fmod(x, length);
if (wrapped < 0.0)
{
wrapped += length;
}
return wrapped;
}
double exactSolution(
double x,
double time,
const Parameters& p)
{
// The exact solution is the initial profile
// evaluated at the departure point x - u*t.
const double departure =
periodicCoordinate(
x - p.velocity * time,
p.length);
return initialCondition(departure, p.length);
}
double meanValue(
const std::vector<double>& phi)
{
double sum = 0.0;
for (double value : phi)
{
sum += value;
}
return sum / phi.size();
}
double minimumValue(
const std::vector<double>& phi)
{
return *std::min_element(
phi.begin(), phi.end());
}
double maximumValue(
const std::vector<double>& phi)
{
return *std::max_element(
phi.begin(), phi.end());
}
double totalVariation(
const std::vector<double>& phi)
{
const int N = static_cast<int>(phi.size());
double tv = 0.0;
for (int i = 0; i < N; ++i)
{
const int im = (i - 1 + N) % N;
tv += std::abs(phi[i] - phi[im]);
}
return tv;
}
void writeCSV(
const Parameters& p,
const std::vector<double>& initial,
const std::vector<double>& final,
Scheme scheme)
{
const std::string filename =
scheme == Scheme::Upwind
? "advection_upwind.csv"
: "advection_mc.csv";
std::ofstream file(filename);
if (!file)
{
throw std::runtime_error(
"Could not open output file: " + filename);
}
file << "x,initial,numerical,exact\n";
file << std::setprecision(12);
const double dx = p.length / p.cells;
for (int i = 0; i < p.cells; ++i)
{
const double x = (i + 0.5) * dx;
file << x << ','
<< initial[i] << ','
<< final[i] << ','
<< exactSolution(x, p.finalTime, p)
<< '\n';
}
}
void runSimulation(
const Parameters& p,
Scheme scheme)
{
if (p.cells < 3)
{
throw std::invalid_argument(
"At least three cells are required.");
}
if (!(p.length > 0.0) ||
!(p.velocity > 0.0) ||
!(p.courant > 0.0) ||
!(p.courant <= 1.0) ||
!(p.finalTime >= 0.0))
{
throw std::invalid_argument(
"Require positive length and velocity, "
"0 < Courant <= 1, and non-negative final time.");
}
const double dx = p.length / p.cells;
const double dt = p.courant * dx / p.velocity;
const int steps = static_cast<int>(
std::llround(p.finalTime / dt));
const double actualFinalTime = steps * dt;
const double timeTolerance =
1.0e-10 * std::max(1.0, p.finalTime);
if (std::abs(actualFinalTime - p.finalTime) >
timeTolerance)
{
throw std::invalid_argument(
"The final time must be an integer multiple "
"of the calculated time step. Adjust the "
"Courant number, cell count, or final time.");
}
std::vector<double> phi(p.cells, 0.0);
for (int i = 0; i < p.cells; ++i)
{
const double x = (i + 0.5) * dx;
phi[i] = initialCondition(x, p.length);
}
const std::vector<double> initial = phi;
const double initialMean = meanValue(phi);
const double initialTV = totalVariation(phi);
for (int step = 0; step < steps; ++step)
{
advanceOneStep(phi, p.courant, scheme);
}
const double finalMean = meanValue(phi);
const double finalTV = totalVariation(phi);
const double minPhi = minimumValue(phi);
const double maxPhi = maximumValue(phi);
const double massDifference =
std::abs(finalMean - initialMean);
writeCSV(p, initial, phi, scheme);
std::cout << std::setprecision(10);
std::cout << "\nScheme: "
<< (scheme == Scheme::Upwind
? "First-order upwind"
: "MC-limited higher-resolution")
<< '\n';
std::cout << "Cells: " << p.cells << '\n';
std::cout << "Time steps: " << steps << '\n';
std::cout << "dx: " << dx << '\n';
std::cout << "dt: " << dt << '\n';
std::cout << "Courant number: " << p.courant << '\n';
std::cout << "Initial mean: "
<< initialMean << '\n';
std::cout << "Final mean: "
<< finalMean << '\n';
std::cout << "Absolute mean difference: "
<< massDifference << '\n';
std::cout << "Initial total variation: "
<< initialTV << '\n';
std::cout << "Final total variation: "
<< finalTV << '\n';
std::cout << "Minimum final value: "
<< minPhi << '\n';
std::cout << "Maximum final value: "
<< maxPhi << '\n';
std::cout << "CSV written for this scheme.\n";
}
int main(int argc, char* argv[])
{
try
{
Parameters p;
// Usage:
// ./advection_limiter [cells] [Courant] [upwind|mc]
//
// Examples:
// ./advection_limiter 200 0.5 upwind
// ./advection_limiter 200 0.5 mc
if (argc >= 2)
{
p.cells = std::stoi(argv[1]);
}
if (argc >= 3)
{
p.courant = std::stod(argv[2]);
}
Scheme scheme = Scheme::MC;
if (argc >= 4)
{
const std::string schemeName = argv[3];
if (schemeName == "upwind")
{
scheme = Scheme::Upwind;
}
else if (schemeName == "mc")
{
scheme = Scheme::MC;
}
else
{
throw std::invalid_argument(
"Scheme must be 'upwind' or 'mc'.");
}
}
runSimulation(p, scheme);
return 0;
}
catch (const std::exception& e)
{
std::cerr << "Error: " << e.what() << '\n';
return 1;
}
}
9.4 Compile and run
Compile using a C++17-compatible compiler:
g++ -std=c++17 -O2 -Wall -Wextra -pedantic \
advection_limiter.cpp \
-o advection_limiter
Run the first-order upwind scheme:
./advection_limiter 200 0.5 upwind
Run the MC-limited scheme:
./advection_limiter 200 0.5 mc
The program writes separate CSV files:
advection_upwind.csvadvection_mc.csv
Each file contains the cell-centre coordinate, initial scalar value, numerical solution, and exact translated profile.
The program also reports the initial and final mean, total variation, minimum value, and maximum value.
These quantities allow you to compare conservation and solution behaviour without relying solely on a visual plot.
10. Interpreting the numerical results
10.1 Compare the solution profiles
Plot the numerical and exact fields from each CSV file.
The expected qualitative behaviour is:
- First-order upwind tends to smear the sharp fronts.
- The MC-limited scheme should generally preserve sharper transitions.
- A properly behaving limiter should avoid the pronounced nonphysical oscillations associated with an unrestricted high-order reconstruction.
The exact degree of improvement depends on the mesh, time step, limiter, and initial condition.
Do not assume that the MC solution must be more accurate at every individual cell. Compare the overall profile and perform a mesh-refinement study.
10.2 Check conservation
For periodic advection, the domain contains no net boundary inflow or outflow. The mean scalar value should therefore remain constant:
The reported mean difference should be small, with the remaining discrepancy generally associated with floating-point round-off.
This is a useful test of the conservative flux update.
10.3 Check minimum and maximum values
The initial condition lies between zero and one.
Inspect the final minimum and maximum. Values substantially below zero or above one indicate potential nonphysical oscillations or an implementation problem.
For the scalar linear advection setup used here, the MC-limited update is intended to maintain non-oscillatory behaviour under the stated assumptions and Courant restriction. Small floating-point deviations should not be confused with meaningful physical overshoots.
10.4 Check total variation
Compare
with
The first-order upwind solution typically reduces total variation because it smooths the discontinuities.
A higher-resolution limiter aims to preserve more of the original variation without creating new oscillations.
For the intended TVD update, total variation should not increase beyond numerical tolerance. This is a useful diagnostic, but it does not replace a mesh-refinement study or comparison against the exact solution.
11. Visualizing the results with Python
You can plot both numerical solutions using the following Python script.
Save it as plot_advection.py in the same directory as the CSV files.
import pandas as pd
import matplotlib.pyplot as plt
upwind = pd.read_csv("advection_upwind.csv")
mc = pd.read_csv("advection_mc.csv")
plt.figure()
plt.plot(
upwind["x"],
upwind["numerical"],
label="First-order upwind"
)
plt.plot(
mc["x"],
mc["numerical"],
label="MC limiter"
)
plt.plot(
mc["x"],
mc["exact"],
"--",
label="Exact solution"
)
plt.xlabel("x")
plt.ylabel("Scalar field")
plt.title("Periodic advection: convection scheme comparison")
plt.legend()
plt.grid(True)
plt.tight_layout()
plt.savefig("advection_comparison.png", dpi=200)
plt.show()
Run:
python plot_advection.py
If necessary, install the dependencies:
python -m pip install pandas matplotlib
The plot should help you identify how much each scheme spreads the front and how closely the numerical solution follows the translated initial profile.
Because the initial condition is discontinuous, pointwise errors near the front are sensitive to the exact placement of the front relative to the cell centres. Use mesh refinement and integral error measures when comparing convergence quantitatively.
12. Important limitations of this implementation
The solver is deliberately small so that the numerical method can be understood in isolation.
It is not yet a general-purpose CFD solver.
12.1 One-dimensional transport
The implementation uses a one-dimensional mesh. In two or three dimensions, reconstruction must account for gradients in multiple coordinate directions and the orientation of each face.
12.2 Constant positive velocity
The implementation assumes a constant positive velocity. For negative velocity, the upwind direction and face reconstruction must be reversed.
For spatially varying velocity, the scheme must use the local face velocity and apply the correct upwind direction at every face.
12.3 Uniform mesh
The limiter uses differences defined for a uniform grid.
On a nonuniform mesh, the slope estimates must account for unequal cell-centre distances. Simply applying the same formula to nonuniform spacing can reduce accuracy or violate the intended limiter properties.
12.4 Scalar linear advection
The solver handles a single scalar with a linear advection equation. Compressible flow, nonlinear conservation laws, and multiphase transport introduce additional challenges, including nonlinear wave speeds, coupled variables, and more complex boundary conditions.
12.5 Explicit time integration
The method uses forward Euler time integration. The time step must satisfy the stability and limiter restrictions of the complete scheme.
A stable time step does not guarantee accurate results. Smaller time steps may still be required to resolve time-dependent features accurately.
12.6 Discontinuities and formal accuracy
Higher-order schemes are designed to achieve better accuracy in smooth regions. Near discontinuities, limiters intentionally reduce the reconstruction order to control oscillations.
Consequently, a scheme may exhibit second-order behaviour in smooth regions but only first-order convergence near a discontinuity.
This is an important distinction when interpreting verification results.
13. How higher-order schemes fit into a CFD framework
The main purpose of this module is not just to implement one limiter. It is to establish a software architecture that allows numerical schemes to be compared without changing the entire solver.
A practical finite-volume framework should separate:
- Mesh geometry.
- Field storage.
- Gradient calculation.
- Reconstruction schemes.
- Flux evaluation.
- Boundary conditions.
- Time integration.
- Linear-system assembly, when an implicit formulation is used.
- Verification and post-processing.
For example, the reconstruction interface could conceptually expose a function:
double reconstructEastFace(
const ScalarField& field,
int cell,
const Mesh& mesh
);
Different implementations could provide:
- First-order upwind reconstruction.
- Unlimited linear reconstruction.
- Minmod reconstruction.
- MC-limited reconstruction.
- Van Leer-limited reconstruction.
The face-flux calculation could then use the selected reconstruction without depending on the internal details of the limiter.
This separation makes numerical experiments easier and reduces the risk of introducing unrelated errors when adding a new scheme.
In an implicit solver, the implementation becomes more involved because higher-resolution fluxes may depend on reconstructed values from several cells. The resulting discretization may require additional matrix coefficients, deferred corrections, or nonlinear iterations, depending on the scheme.
14. Connection to professional CFD software
Modern CFD packages provide many convection discretization schemes because no single method is ideal for every problem.
The numerical choices can affect:
- The sharpness of transported interfaces.
- The resolution of shear layers.
- The prediction of scalar mixing.
- The representation of shocks in compressible flow.
- The convergence behaviour of nonlinear equations.
- The computational cost required to achieve a target accuracy.
In OpenFOAM, the divSchemes section of fvSchemes controls the discretization of divergence terms. Scheme availability and exact names depend on the field, solver, and OpenFOAM version.
A simplified illustrative entry is:
divSchemes
{
default none;
div(phi,U) Gauss linearUpwind grad(U);
}
This is an example of a higher-resolution convection discretization for a velocity field. It is not the same implementation as the MC limiter developed in this module, and it should not be assumed to be a drop-in equivalent.
The important conceptual link is that professional CFD software separates the transport equation from the selected numerical approximation used to evaluate its convective fluxes.
Understanding reconstruction and limiting makes these scheme choices much easier to interpret.
15. Exercises
Exercise 1: Compare upwind and MC
Run both schemes using 200 cells and a Courant number of 0.5.
Compare the solution profiles, minimum and maximum values, and total variation.
Explain the difference in numerical diffusion.
Exercise 2: Change the Courant number
Repeat the simulations using Courant numbers of 0.2, 0.5, and 0.8.
Keep the mesh and final time unchanged.
Explain how the time step affects the numerical solution. Distinguish changes caused by time discretization from those caused by the spatial reconstruction.
Exercise 3: Refine the mesh
Run the MC scheme with 50, 100, 200, and 400 cells.
Plot the results against the exact translated profile.
Describe how the numerical front changes with mesh refinement.
Exercise 4: Implement minmod
Add a Minmod option to the scheme enumeration.
Implement the minmod-limited difference:
Compare its results with the MC limiter.
Explain why the minmod limiter is generally more restrictive.
Exercise 5: Use a smooth initial condition
Replace the top-hat initial condition with a smooth periodic profile, for example:
The exact solution is
Compare the numerical solution with the exact profile.
A smooth initial condition helps investigate accuracy in regions where the solution is differentiable.
Exercise 6: Measure error norms
Add the following metrics:
Compare these errors across mesh resolutions.
For finite-volume cell averages, use an exact cell-average reference when possible rather than only evaluating the exact solution at the cell centre. This avoids mixing cell-average and point-value comparisons.
Exercise 7: Extend to a nonuniform mesh
Modify the gradient calculation to account for unequal distances between cell centres.
Explain why a limiter developed for a uniform grid cannot always be applied unchanged to a nonuniform grid.
Exercise 8: Design a reconstruction interface
Refactor the solver so that the reconstruction scheme is independent of the time-update function.
Your objective is to add a new limiter without modifying the conservative update or output routines.
16. Key takeaways
Higher-order convection schemes improve the representation of transported fields by using more information from neighbouring cells. However, higher-order reconstruction must be controlled near extrema and discontinuities to avoid nonphysical oscillations.
The main lessons are:
- First-order upwind is robust but diffusive. It often smears sharp fronts on coarse meshes.
- Higher-order reconstruction uses local variation. A reconstructed slope estimates how the scalar changes inside a cell.
- Slope limiters control reconstruction. They retain useful gradients in smooth regions and reduce slopes where necessary.
- The MC limiter balances accuracy and robustness. It is generally less restrictive than minmod while still controlling nonphysical oscillations under its intended assumptions.
- Conservative fluxes are essential. The same face flux must be used by both neighbouring cells.
- The time step matters. Stability and TVD properties depend on the complete discretization, not just the limiter formula.
- Verification requires more than a plot. Check conservation, boundedness, total variation, exact solutions, and mesh refinement.
- Numerical schemes should be modular. Separating reconstruction, flux evaluation, and time integration makes a solver easier to test and extend.
17. What’s next?
Module 14 can move from one-dimensional scalar transport to multidimensional finite-volume discretization.
The next step is to understand how face normals, vector gradients, mesh geometry, and face fluxes interact on two-dimensional meshes. This provides the foundation for multidimensional diffusion and convection operators, non-orthogonal mesh corrections, and eventually the momentum and pressure equations used in incompressible CFD.