Module 7: Convection, Transport, and Numerical Stability
Understand convection-dominated transport, derive central and upwind discretizations, analyze the cell Peclet number, numerical diffusion, boundedness, and implement a one-dimensional convection-diffusion solver.
Introduction
Many CFD problems involve the transport of physical quantities by a moving fluid. Temperature is carried by the flow, pollutants are transported through the atmosphere, and momentum is transferred between neighboring regions.
This transport process is called convection, or advection when referring specifically to transport by the velocity field. It is different from diffusion, which redistributes a quantity because of spatial gradients.
A numerical method must represent both processes accurately. If convection is dominant, some discretization schemes can produce nonphysical oscillations or inaccurate gradients. If diffusion is dominant, a different balance of numerical properties may be acceptable.
In this module, we examine why the choice of spatial discretization matters and how numerical methods influence a CFD solution.
Learning objectives
By the end of this module, you should be able to:
- Distinguish convection from diffusion.
- Interpret the convection-diffusion equation physically.
- Derive central-difference and first-order upwind approximations.
- Understand the cell Peclet number and its role in scheme behavior.
- Explain numerical diffusion and nonphysical oscillations.
- Understand boundedness and monotonicity.
- Implement a one-dimensional steady convection-diffusion solver.
- Relate discretization choices to practical CFD software.
1. Convection and diffusion: two different physical processes
Consider a scalar field, denoted by . It could represent temperature, concentration, or another transported quantity.
Two important mechanisms can change its distribution.
1.1 Convection
Convection transports a quantity with the fluid velocity.
For example, when warm air enters a room, it carries thermal energy from one location to another. The resulting temperature distribution depends on both the velocity field and the temperature field.
For a constant velocity in one dimension, the convective transport term is
The velocity determines the transport direction, while the spatial gradient describes how the transported quantity varies.
Convection does not necessarily smooth a profile. In the ideal constant-velocity advection equation, the profile moves without changing shape.
1.2 Diffusion
Diffusion transports a quantity down its gradient.
Heat conducts from hotter regions toward colder regions. A dissolved substance diffuses from regions of high concentration toward regions of low concentration.
The one-dimensional diffusion term is
where is a diffusivity.
Diffusion tends to smooth spatial variations. Its effect depends on the curvature of the field, represented by the second derivative.
1.3 Physical comparison
| Property | Convection | Diffusion |
|---|---|---|
| Main mechanism | Transport by fluid motion | Transport caused by gradients |
| Characteristic quantity | Velocity, | Diffusivity, |
| Typical effect | Moves a profile | Smooths spatial variations |
| Direction | Determined by the flow | Down the scalar gradient |
| Numerical challenge | Capturing transport without oscillations | Representing gradients and fluxes accurately |
Real CFD problems often contain both mechanisms. The numerical method must handle their relative importance.
2. The convection-diffusion equation
Consider one-dimensional transport with constant velocity and constant diffusivity .
A simplified steady convection-diffusion equation is
The left-hand side represents convection, and the right-hand side represents diffusion.
For a time-dependent problem, the equation becomes
This equation is useful for understanding the numerical treatment of transport in more complex CFD models.
The equation assumes constant velocity and diffusivity, no source term, and one-dimensional transport. General CFD equations may have variable properties, multidimensional velocity fields, source terms, and additional physical processes.
2.1 Conservative form
The steady equation can also be written as
for constant and .
The total flux is
where:
- is the convective flux.
- is the diffusive flux.
The conservative form states that the total flux is constant in a source-free, steady, one-dimensional problem.
This is especially important for the finite volume method. Rather than approximating every derivative independently, the method balances the fluxes entering and leaving each control volume.
3. Why spatial discretization becomes challenging
A numerical solver cannot store the exact continuous field at every point. It represents the solution using discrete values at cell centers, nodes, or other locations.
Consider a one-dimensional mesh with cell-center values
The numerical method needs to estimate the field at cell faces or approximate derivatives using these discrete values.
For diffusion, central approximations are often natural because they represent gradients using values on both sides of a location.
For convection, the direction of the flow matters. Information is transported from upstream toward downstream. A scheme that ignores this direction can behave poorly when convection dominates.
We will examine two classical approaches:
- Central differencing.
- First-order upwind differencing.
These schemes illustrate the trade-off between formal accuracy, boundedness, and numerical diffusion.
4. Central differencing
Suppose is the value at a cell center , and and are the values at the neighboring east and west cell centers.
For a uniform grid, the central approximation to the first derivative is
The approximation is second-order accurate in space for a sufficiently smooth field.
For a face halfway between two neighboring cell centers, linear interpolation gives
where is the estimated value at the east face.
Central interpolation treats both neighboring values symmetrically. It can represent smooth profiles accurately, but it does not inherently respect the direction of convective transport.
4.1 Central differencing for convection
For the one-dimensional convection term,
central differencing gives
This is a second-order spatial approximation when the field is sufficiently smooth.
However, the accuracy of a derivative approximation does not guarantee that the complete discretized convection-diffusion equation will produce a bounded solution.
When convection is strong relative to diffusion, central differencing may generate oscillations near steep gradients.
4.2 Why oscillations occur
Consider a scalar field that changes sharply from a low value to a high value. A physically meaningful solution might remain between the imposed boundary values.
A numerical scheme can nevertheless produce values above the maximum or below the minimum. These overshoots and undershoots are nonphysical oscillations.
Such behavior can occur because central differencing allows a strong convective influence without sufficient numerical damping or directional bias.
The problem is not that central differencing is universally inaccurate. It is that its behavior depends on the equation, mesh, boundary conditions, and relative strengths of convection and diffusion.
5. Upwind differencing
The upwind method uses the flow direction to determine which neighboring value should represent the transported quantity.
For positive velocity, information moves from west to east. The upstream value is therefore used at the east face.
For negative velocity, information moves from east to west. The upstream value at the east face is the value in the eastern cell.
The first-order upwind face value can be written as
Here, is the velocity normal to the east face, with positive direction pointing east.
In practical code, the zero-velocity case contributes no convective flux, so the choice of face value when does not affect that flux.
5.1 First-order upwind derivative
For positive velocity, the upstream approximation at cell is
For negative velocity, the downstream direction reverses, and the corresponding approximation is
These are one-sided differences selected according to the direction of transport.
5.2 Why upwind often behaves better
Upwind differencing respects the directional nature of convection. For standard scalar advection problems, first-order upwind is generally more robust and avoids many of the oscillations associated with central differencing.
Its main disadvantage is numerical diffusion. The computed solution can become smoother than the physical solution, particularly on coarse meshes.
This means a sharp front may spread across several cells instead of remaining sharp.
5.3 Accuracy versus robustness
| Property | Central differencing | First-order upwind |
|---|---|---|
| Formal spatial accuracy for smooth fields | Second order | First order |
| Uses flow direction explicitly | No | Yes |
| Numerical diffusion | Often lower | Often higher |
| Risk of oscillations in convection-dominated problems | Can be significant | Usually lower for standard scalar transport |
| Behavior on coarse meshes | May oscillate | May smear gradients |
Neither scheme is best for every problem. The appropriate choice depends on the physics, desired accuracy, mesh resolution, and acceptable numerical behavior.
6. The cell Peclet number
The Peclet number compares the strength of convection with diffusion.
A characteristic physical Peclet number is
where is a characteristic velocity, is a characteristic length, and is a diffusivity.
- Small : diffusion is relatively important.
- Large : convection is relatively important.
For discretization, a local or cell Peclet number is often more informative.
For a uniform one-dimensional grid, define
This signed form retains the direction of the flow. When discussing relative magnitudes, use
The cell Peclet number compares convective transport across one cell with diffusive transport across that cell.
6.1 Interpreting the cell Peclet number
If the cell Peclet number is small, diffusion acts strongly over the cell scale. Central differencing is often effective in this regime.
If the cell Peclet number is large, convection dominates at the cell scale. The discretization must handle directional transport carefully.
For the standard one-dimensional steady convection-diffusion equation with constant positive velocity and diffusivity, a uniform mesh, and the conventional central-difference finite volume discretization, bounded coefficients require
This is a scheme-specific result, not a universal Peclet limit for all central schemes, meshes, or equations.
First-order upwind is commonly used when stronger convection makes central differencing unsuitable, although it may introduce substantial numerical diffusion.
6.2 Worked calculation
Suppose the velocity is
the cell width is
and the diffusivity is
Then
The cell Peclet number is large. Convection dominates diffusion at this cell scale.
A first-order upwind scheme may produce a stable, bounded profile, but it can smear steep gradients. To improve the representation of those gradients, one may refine the mesh or use a suitable higher-resolution convection scheme.
7. Numerical diffusion
Numerical diffusion is artificial smoothing introduced by the discretization rather than by the physical diffusion coefficient.
It is especially important in convection-dominated flows, where the physical solution may contain steep gradients, thin shear layers, or transported fronts.
7.1 How it appears
Imagine transporting a sharp temperature front through a domain.
The physical model may predict that the front remains relatively sharp. A numerical method with excessive numerical diffusion spreads the transition over a wider region.
This can affect:
- Temperature gradients.
- Concentration fronts.
- Shear layers.
- Vortex structures.
- Mixing predictions.
- Heat and mass transfer rates.
Numerical diffusion can therefore influence engineering quantities of interest, not just the appearance of a contour plot.
7.2 Why first-order upwind is diffusive
For constant positive velocity and a smooth solution, a Taylor expansion of the backward difference gives
The leading error term is proportional to .
When this derivative is used in a linear advection equation, the leading error can be interpreted as an additional diffusion-like contribution. For constant positive velocity, the modified equation of first-order upwind advection with forward Euler time integration is approximately
where
and
This leading-order estimate applies to the specified constant-velocity, positive-flow, first-order upwind and forward-Euler scheme in its usual stable range. It is not a universal expression for numerical diffusion in all discretizations.
It shows an important trend: for this scheme, numerical diffusion depends on the mesh spacing and time step. Refining the mesh reduces the leading spatial contribution, while the Courant number also influences the effective diffusion.
7.3 Numerical and physical diffusion are different
Physical diffusion is part of the governing model. Numerical diffusion is an error associated with its discrete approximation.
If the physical diffusivity is , the numerical solution may behave as though additional diffusion were present. In a simplified interpretation, the effective smoothing can resemble the combination of physical and numerical diffusion.
However, the exact modified equation depends on the scheme, so this interpretation should not be used as a universal correction formula.
The practical objective is to control numerical diffusion through appropriate discretization, mesh resolution, and verification.
8. Boundedness and monotonicity
A numerical solution is bounded when its values remain within physically or mathematically acceptable limits under the relevant assumptions.
For a scalar transport problem with boundary values between zero and one, an unphysical solution might contain values such as
or
Such overshoots may indicate that the discretization is not preserving the expected bounds.
8.1 Why boundedness matters
Nonphysical values can cause more than cosmetic problems.
For example:
- A negative concentration may be physically meaningless.
- A volume fraction outside its admissible range can break a multiphase model.
- Temperature oscillations can distort heat-transfer predictions.
- Nonphysical oscillations can destabilize nonlinear solution procedures.
Boundedness requirements depend on the physical quantity and mathematical model. Not every variable has a simple fixed interval, and not every overshoot automatically means the complete simulation is invalid. The behavior must be assessed in context.
8.2 Monotonicity
For many scalar transport problems, a monotone scheme avoids introducing new local maxima or minima when the exact solution should remain monotone.
First-order upwind has useful boundedness properties for standard scalar advection problems under appropriate conditions. Central differencing can fail to preserve monotonicity in convection-dominated cases.
Higher-order schemes aim to reduce numerical diffusion while avoiding spurious oscillations. This is challenging because high-order linear schemes generally cannot maintain all desirable monotonicity properties for arbitrary data without additional restrictions.
9. Higher-resolution convection schemes
First-order upwind is robust but often too diffusive for demanding CFD applications. Central differencing is more accurate for smooth fields but can oscillate in convection-dominated regions.
Higher-resolution methods seek a compromise.
Common approaches include:
- Second-order upwind.
- QUICK.
- Total variation diminishing (TVD) schemes.
- Flux-limited schemes.
- Monotonic upstream-centered schemes for conservation laws (MUSCL).
The details differ, but many higher-resolution schemes reconstruct a face value using additional information about local gradients.
9.1 Gradient reconstruction
A simple linear reconstruction in one dimension can be written as
The gradient can be estimated from neighboring cell values. The reconstructed face value is then used to evaluate the convective flux.
Higher-order reconstruction can improve accuracy on smooth solutions. However, near discontinuities or sharp gradients, unrestricted reconstruction can produce overshoots and undershoots.
9.2 Flux limiters
A flux limiter modifies the high-order correction based on the local solution behavior.
In smooth regions, the limiter may allow a higher-order reconstruction. Near sharp gradients, it reduces the correction to help avoid nonphysical oscillations.
A generic reconstruction can be expressed schematically as
Here, is a limiter function and is a measure of the local gradient ratio. The exact definition depends on the chosen scheme.
This expression illustrates the concept rather than specifying a particular limiter implementation.
The goal is to retain high-order accuracy where the solution is smooth while improving boundedness near steep gradients.
10. Finite volume interpretation of convection
The finite volume method represents convection through fluxes across control-volume faces.
For a one-dimensional steady scalar transport equation, define the total flux as
For a source-free problem, conservation over a cell gives
where and are the total fluxes at the east and west faces.
Split the flux into convective and diffusive parts:
For a uniform one-dimensional grid with constant properties,
is the convective flux per unit cross-sectional area, while
is the diffusive conductance per unit cross-sectional area.
The exact definitions of flux and conductance change if density, area, or other properties vary. Here, the simplified forms are used to illustrate the discretization.
10.1 Why face fluxes matter
Suppose two neighboring cells share one face. The flux leaving the first cell should be the same flux entering the second cell, with opposite signs in their respective balances.
Using a consistent face flux makes the finite volume method locally conservative.
This is one of the central advantages of FVM. Conservation is built into the structure of the discrete equations, provided the same face flux is used consistently by adjacent cells.
11. A simple steady convection-diffusion problem
Consider a one-dimensional domain with constant positive velocity , constant diffusivity , no source term, and fixed boundary values.
The governing equation is
The boundary conditions are
and
11.1 Analytical solution
For nonzero constant velocity, the differential equation can be solved analytically.
Rearrange it as
The solution is
Applying the boundary conditions gives
where
is the domain Peclet number.
For , the equation reduces to pure diffusion, and the solution is linear:
The analytical solution provides a reference for checking a numerical implementation.
11.2 Interpretation
When the domain Peclet number is small, diffusion has a strong influence over the domain and the solution is close to linear.
When the domain Peclet number is large and the velocity is positive, the solution changes predominantly near the downstream boundary to satisfy the prescribed right boundary value. A numerical method must resolve this potentially steep gradient.
A coarse grid with a diffusive scheme may smear the gradient. A central scheme may produce nonphysical oscillations if its discrete coefficients are unsuitable for the local Peclet number.
12. Implementing a one-dimensional finite volume solver in C++
The following example solves the steady one-dimensional convection-diffusion equation using a cell-centered finite volume method with first-order upwind convection and central differencing for diffusion.
Assumptions:
- Constant positive velocity.
- Constant diffusivity.
- Uniform mesh.
- Unit cross-sectional area.
- No source term.
- Fixed scalar values at both domain boundaries.
The discretization uses the convective flux
and diffusive conductance
For each interior cell, the resulting equation is
This schematic expression combines terms without separating the two neighbor coefficients clearly, so the implementation below instead uses the conventional coefficient form:
with
for positive flow and an interior cell.
At the boundaries, the code uses half-cell diffusion conductance and the prescribed boundary values. The resulting tridiagonal system is solved with the Thomas algorithm.
Save the following code as convection_diffusion.cpp.
#include <cmath>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <stdexcept>
#include <vector>
int main()
{
// Physical parameters
const double L = 1.0;
const double u = 1.0;
const double alpha = 0.01;
const double phi_left = 1.0;
const double phi_right = 0.0;
// Numerical parameters
const int cells = 100;
if (cells < 2)
{
throw std::runtime_error(
"At least two cells are required."
);
}
if (L <= 0.0 || alpha <= 0.0)
{
throw std::runtime_error(
"Domain length and diffusivity must be positive."
);
}
const double dx = L / cells;
const double F = u;
const double D = alpha / dx;
const double Pe_cell = u * dx / alpha;
std::vector<double> lower(cells, 0.0);
std::vector<double> diag(cells, 0.0);
std::vector<double> upper(cells, 0.0);
std::vector<double> rhs(cells, 0.0);
std::vector<double> phi(cells, 0.0);
// Assemble the finite volume system.
for (int i = 0; i < cells; ++i)
{
if (i == 0)
{
// West boundary: prescribed phi_left.
// The boundary face is half a cell from the
// first cell center.
const double D_boundary = 2.0 * D;
diag[i] = F + D + D_boundary;
upper[i] = -D;
rhs[i] = (F + D_boundary) * phi_left;
}
else if (i == cells - 1)
{
// East boundary: prescribed phi_right.
const double D_boundary = 2.0 * D;
lower[i] = -(F + D);
diag[i] = D + F + D_boundary;
rhs[i] = D_boundary * phi_right;
}
else
{
// Interior cell, positive flow, first-order upwind.
lower[i] = -(D + F);
diag[i] = F + 2.0 * D;
upper[i] = -D;
}
}
// Thomas algorithm: forward elimination.
for (int i = 1; i < cells; ++i)
{
if (std::abs(diag[i - 1]) < 1.0e-14)
{
throw std::runtime_error(
"Zero or near-zero pivot in Thomas algorithm."
);
}
const double factor = lower[i] / diag[i - 1];
diag[i] -= factor * upper[i - 1];
rhs[i] -= factor * rhs[i - 1];
}
if (std::abs(diag.back()) < 1.0e-14)
{
throw std::runtime_error(
"Zero or near-zero final pivot."
);
}
// Back substitution.
phi.back() = rhs.back() / diag.back();
for (int i = cells - 2; i >= 0; --i)
{
phi[i] =
(rhs[i] - upper[i] * phi[i + 1]) / diag[i];
}
// Write cell-center values.
std::ofstream output("convection_diffusion.csv");
if (!output)
{
throw std::runtime_error(
"Could not open convection_diffusion.csv."
);
}
output << "x_m,phi\n";
output << std::setprecision(12);
for (int i = 0; i < cells; ++i)
{
const double x = (i + 0.5) * dx;
output << x << "," << phi[i] << "\n";
}
std::cout << std::fixed << std::setprecision(6);
std::cout << "Steady convection-diffusion solve completed.\n";
std::cout << "Cells: " << cells << "\n";
std::cout << "Domain Peclet number: "
<< u * L / alpha << "\n";
std::cout << "Cell Peclet number: "
<< Pe_cell << "\n";
std::cout << "Minimum phi: "
<< *std::min_element(phi.begin(), phi.end()) << "\n";
std::cout << "Maximum phi: "
<< *std::max_element(phi.begin(), phi.end()) << "\n";
std::cout << "Output: convection_diffusion.csv\n";
return 0;
}
12.1 Required header correction
The code uses std::min_element and std::max_element. Add the following header to the includes before compiling:
#include <algorithm>
12.2 Compile and run
g++ -std=c++20 -O2 -Wall -Wextra -pedantic \
convection_diffusion.cpp -o convection_diffusion
./convection_diffusion
The program writes convection_diffusion.csv in the current working directory.
12.3 What to examine
Plot the cell-center values from the CSV file.
Check whether:
- The solution remains between the boundary values.
- The profile changes more sharply as the Peclet number increases.
- Refining the mesh changes the numerical profile.
- The numerical solution approaches the analytical solution as the mesh is refined.
For a rigorous verification study, compare numerical and analytical values at the same locations, account for the cell-centered representation, and report an error measure such as the error.
One common discrete error measure is
This gives a single measure of the difference between numerical and analytical values. A mesh-refinement study can then reveal whether the error decreases at the expected rate.
13. Connecting the concepts to practical CFD
In a real CFD solver, the convection term is part of a larger discretized transport equation. The selected scheme affects accuracy, robustness, and computational behavior.
For example, in OpenFOAM, convection schemes are configured in the divSchemes section of system/fvSchemes.
A schematic configuration might contain:
divSchemes
{
div(phi,U) Gauss upwind;
}
The exact field names and supported schemes depend on the solver and the case. This example illustrates the general form of a convection-scheme entry rather than a complete case configuration.
The scheme Gauss upwind represents a first-order upwind-style treatment in the finite volume framework.
Higher-resolution options are also available in many CFD software packages. Before selecting one, consider:
- The type of transported quantity.
- Whether the solution contains sharp gradients.
- The mesh quality and resolution.
- Whether the scheme preserves appropriate bounds.
- The computational cost and nonlinear convergence behavior.
- Whether verification results support the chosen discretization.
A scheme that works well for a smooth temperature field may behave differently for a volume fraction, turbulent variable, or sharply varying concentration field.
14. Practical workflow for choosing a convection scheme
A useful approach is to begin with the physics and the required engineering accuracy.
- Identify the transport regime. Estimate the characteristic Peclet number and determine whether convection or diffusion dominates.
- Start with a robust scheme. First-order upwind is often useful for debugging and establishing a stable baseline.
- Check boundedness. Inspect minimum and maximum values and look for nonphysical oscillations.
- Inspect gradients. Determine whether the scheme is smearing important fronts, shear layers, or thermal gradients.
- Refine the mesh. Test whether the solution becomes less sensitive to numerical diffusion as spatial resolution improves.
- Test a higher-resolution scheme. Compare against the baseline while monitoring convergence and physical quantities.
- Verify the result. Use analytical solutions, benchmark cases, conservation checks, and systematic refinement where possible.
Do not select a scheme based only on how smooth the contours look. A smooth solution can be excessively diffusive, while a more detailed-looking solution can contain numerical oscillations.
15. Common mistakes
Mistake 1: Assuming second-order accuracy always gives a better answer
Formal accuracy describes how the error behaves under appropriate conditions. It does not guarantee boundedness or robustness on every mesh and for every transport regime.
Mistake 2: Treating numerical diffusion as physical diffusion
Artificial smoothing can change predicted gradients, mixing rates, and heat-transfer quantities. It should not be interpreted as a real physical property of the fluid.
Mistake 3: Ignoring the flow direction
Upwind face values depend on the sign of the face-normal velocity. Using the wrong upstream cell reverses the intended transport direction.
Mistake 4: Using the domain Peclet number as a universal scheme criterion
The domain Peclet number characterizes the overall physical regime. Scheme behavior often depends on the local cell Peclet number, grid arrangement, boundary conditions, and the particular discretization.
Mistake 5: Assuming a bounded solution is necessarily accurate
A bounded numerical field can still be heavily smeared and quantitatively wrong. Boundedness and accuracy must be assessed separately.
Mistake 6: Comparing solutions at different resolutions without matching conditions
A meaningful comparison should use consistent physical parameters, boundary conditions, and quantities of interest. For transient problems, compare at the same physical time.
16. Key takeaways
- Convection transports a quantity with fluid motion, while diffusion redistributes it down gradients.
- The convection-diffusion equation combines both processes.
- Central differencing is second-order accurate for smooth fields but can produce oscillations in convection-dominated cases.
- First-order upwind uses the flow direction and is generally robust for standard scalar transport, but it introduces numerical diffusion.
- The cell Peclet number compares convective and diffusive effects over a cell width.
- Boundedness, stability, and accuracy are different numerical properties.
- Higher-resolution schemes attempt to reduce numerical diffusion while controlling nonphysical oscillations.
- Finite volume methods represent transport through face fluxes and preserve conservation when shared fluxes are assembled consistently.
- Scheme selection should be supported by verification, mesh refinement, and analysis of quantities of interest.
What’s next?
In Module 8: Fluid-Flow Solvers and Pressure-Velocity Coupling, we will examine how the continuity and momentum equations are solved together, why pressure plays a special role in incompressible flow, and how algorithms such as SIMPLE and PISO connect the governing equations to practical CFD solvers.