LAST SEEN ONLINE:
NOV 22, 2026 11:36 UTC
LOCAL_TIME_SYNC:
--:--:-- | -- _
← Digital notebook
CFD 9 min read First-Principles CFD / Module 1

Module 1: Mathematical Foundations for CFD

The mathematical language behind computational fluid dynamics. Understanding fields, vector calculus, derivatives, and the Taylor series before deriving the governing equations.

Before we can write a single line of CFD solver code, we need to understand the mathematical language that describes fluid motion. Computational Fluid Dynamics (CFD) is not simply about solving equations on a computer—it’s about converting continuous physical phenomena into numerical algorithms.

Whether we’re simulating airflow around an aircraft, cooling inside a data centre, or flow through a packed-bed reactor, the underlying mathematics is remarkably similar. Every CFD solver, from OpenFOAM to ANSYS Fluent, begins with the same building blocks: fields, vector calculus, derivatives, and approximations.

This module establishes those foundations before we derive the governing equations of fluid flow.


Learning Objectives

By the end of this module, you should be able to:

  • Understand the continuum assumption.
  • Distinguish scalar and vector fields.
  • Interpret the Gradient, Divergence, Curl, and Laplacian physically.
  • Understand partial derivatives and material derivatives.
  • Use the Taylor Series to approximate neighbouring values.
  • See how calculus eventually becomes numerical code.

Why Mathematics Matters in CFD

River analogy — Measure the temperature, velocity, pressure, and density beside a river, then move a few metres downstream: every value changes. Rather than memorizing millions of measurements, we describe them as continuous mathematical functions.

For example, T(x,y,z,t)T(x,y,z,t) means that temperature exists at every point in space and every instant in time. The computer’s job is to approximate these continuous functions using a finite number of values. That journey—from continuous mathematics to discrete computation—is the essence of CFD.


1. The Continuum Assumption

Real fluids consist of molecules, and a cubic millimetre of air contains trillions of them. Tracking every molecule individually would be impossible for engineering-scale problems, so we assume the fluid behaves as a continuous medium.

Fluid→Continuum→Mathematical Fields\text{Fluid} \rightarrow \text{Continuum} \rightarrow \text{Mathematical Fields}

Instead of following molecules, we describe smoothly varying quantities like:

  • Pressure
  • Velocity
  • Temperature
  • Density

This assumption is valid whenever the molecular scale is much smaller than the engineering scale. For example:

ProblemCharacteristic Length
Airfoil1 m
Pipe0.1 m
Human hair70 μm
Air mean free path~65 nm

Since engineering dimensions are vastly larger than molecular distances, treating the fluid as continuous is usually justified.


2. Scalar and Vector Fields

Everything in CFD begins with fields. A field assigns a value to every location in space.

Weather-map analogy — Every city has a temperature, pressure, and wind speed; each quantity is a field defined across locations.

Scalar Fields

A scalar has magnitude only. Examples include:

  • Pressure
  • Temperature
  • Density
  • Energy

Mathematically, pressure is represented as

p=p(x,y,z,t)p=p(x,y,z,t)

Pressure changes from one location to another.

Mountain analogy — Height is a scalar field: each location has one height, just as each point in a fluid has one pressure.

Vector Fields

A vector has magnitude and direction. Velocity is the most important vector field in CFD:

u=ui^+vj^+wk^\mathbf{u}=u\hat{i}+v\hat{j}+w\hat{k}

where uu, vv, and ww are the velocity components in the x-, y-, and z-directions, respectively. Instead of one value, every point stores three components.

River analogy — Each floating leaf moves in a direction and at a speed; together, those motions form a velocity field.


3. Coordinate Systems

CFD problems exist in three-dimensional space, and we usually begin with Cartesian coordinates:

(x,y,z)(x,y,z)

where x is horizontal, y is vertical, and z is depth. Many engineering problems later use cylindrical or spherical coordinates. For example:

GeometryPreferred Coordinates
PipeCylindrical
Rocket nozzleCylindrical
Planet atmosphereSpherical
Cube cavityCartesian

We’ll begin entirely in Cartesian coordinates before exploring others.


4. Derivatives: Measuring Change

Derivatives describe how quickly something changes. Suppose temperature varies along a rod; its first derivative is

dTdx\frac{dT}{dx}

This tells us how rapidly temperature changes as we move.

Mountain analogy — Walking uphill, a steep slope means a large derivative, flat ground means zero, and downhill means a negative derivative. The same mathematics applies to temperature.


5. Partial Derivatives

In CFD, variables depend on multiple coordinates. For temperature,

T(x,y,z,t)T(x,y,z,t)

we can ask how it changes in one coordinate while holding the others fixed:

Change only in x

∂T∂x\frac{\partial T}{\partial x}

Change only in y

∂T∂y\frac{\partial T}{\partial y}

Change only in time

∂T∂t\frac{\partial T}{\partial t}

Each derivative isolates one direction while holding the others fixed, which is essential for three-dimensional simulations.


6. The Nabla Operator

The symbol ∇\nabla (pronounced nabla or del) is the most important operator in CFD. It combines spatial derivatives into one compact symbol:

∇=i^∂∂x+j^∂∂y+k^∂∂z\nabla=\hat{i}\frac{\partial}{\partial x}+\hat{j}\frac{\partial}{\partial y}+\hat{k}\frac{\partial}{\partial z}

Rather than writing three derivatives repeatedly, we use one operator. Depending on how we apply it, it produces entirely different physical meanings.


7. Gradient

The Gradient, ∇ϕ\nabla\phi, where ϕ\phi is a scalar, is a vector pointing toward the greatest increase. For temperature and pressure:

∇T∇p\nabla T \qquad \nabla p

Hill analogy — The gradient points in the direction of the fastest climb; the longer the vector, the steeper the climb.

Why pressure gradients matter

Pressure differences drive fluid motion. The force term inside the Navier-Stokes equations is

−∇p-\nabla p

Notice the minus sign: fluids accelerate toward lower pressure.


8. Divergence

Divergence measures whether something is spreading out or converging. Mathematically,

∇⋅u\nabla\cdot\mathbf{u}

Expanding,

∂u∂x+∂v∂y+∂w∂z\frac{\partial u}{\partial x}+\frac{\partial v}{\partial y}+\frac{\partial w}{\partial z}

Balloon analogy — As a balloon inflates, air spreads outward and divergence is positive; when it is compressed, air converges inward and divergence is negative.

Incompressible flow

For constant-density fluids,

∇⋅u=0\nabla\cdot\mathbf{u}=0

What enters must leave. This equation becomes one of the most important constraints in CFD.


9. Curl

Curl measures rotation. Mathematically,

∇×u\nabla\times\mathbf{u}

Whirlpool analogy — A leaf dropped into a whirlpool spins; that spinning motion is described by curl.

Curl becomes important for:

  • vortices
  • turbulence
  • rotating flows

Later, we’ll connect this to vorticity.


10. Laplacian

The Laplacian combines second derivatives:

∇2ϕ=∂2ϕ∂x2+∂2ϕ∂y2+∂2ϕ∂z2\nabla^2\phi=\frac{\partial^2\phi}{\partial x^2}+\frac{\partial^2\phi}{\partial y^2}+\frac{\partial^2\phi}{\partial z^2}

Physical meaning

The Laplacian measures curvature.

Rubber-sheet analogy — A flat sheet has zero curvature, while a dent has curvature; diffusion tries to smooth the dent.

This is why the Laplacian appears in:

  • heat conduction
  • momentum diffusion
  • species diffusion

It mathematically represents the tendency of nature to smooth differences.


11. Material Derivative

This is one of the biggest conceptual shifts in fluid mechanics.

Two-observer analogy — An observer standing on a bridge measures temperature change at one location, ∂T∂t\frac{\partial T}{\partial t}; an observer floating with the water follows the fluid and experiences DTDt\frac{DT}{Dt}.

The latter is called the Material (or Substantial) Derivative:

DϕDt=∂ϕ∂t+u⋅∇ϕ\frac{D\phi}{Dt}=\frac{\partial\phi}{\partial t}+\mathbf{u}\cdot\nabla\phi

It has two contributions:

  • local change
  • transport by motion

This becomes the foundation of the Navier-Stokes equations.


12. The Taylor Series

This is arguably the most important mathematical tool in numerical methods. A computer cannot calculate infinitesimal derivatives, so it estimates nearby values. The Taylor Series says

f(x+Δx)=f(x)+f′(x)Δx+f′′(x)2!(Δx)2+f′′′(x)3!(Δx)3+⋯f(x+\Delta x)=f(x)+f'(x)\Delta x+\frac{f''(x)}{2!}(\Delta x)^2+\frac{f'''(x)}{3!}(\Delta x)^3+\cdots

This infinite expansion lets us derive finite-difference equations.

Why it matters

Nearby-point analogy — If we know the current temperature, its slope, and its curvature, we can estimate the temperature at a nearby point. Numerical solvers repeat this process.


13. Deriving the First Finite Difference

Using the first-order Taylor approximation

f(x+Δx)=f(x)+f′(x)Δx+O(Δx2)f(x+\Delta x)=f(x)+f'(x)\Delta x+O(\Delta x^2)

and rearranging the forward and backward expansions gives:

f′(x)≈f(x+Δx)−f(x)ΔxForwardf′(x)≈f(x)−f(x−Δx)ΔxBackwardf′(x)≈f(x+Δx)−f(x−Δx)2ΔxCentral\begin{aligned} f'(x)&\approx\frac{f(x+\Delta x)-f(x)}{\Delta x} && \text{Forward}\\ f'(x)&\approx\frac{f(x)-f(x-\Delta x)}{\Delta x} && \text{Backward}\\ f'(x)&\approx\frac{f(x+\Delta x)-f(x-\Delta x)}{2\Delta x} && \text{Central} \end{aligned}

The central difference generally has higher accuracy for smooth functions on uniform grids.


14. Deriving the Second Derivative

Add the forward and backward Taylor expansions; the first-derivative terms cancel. The result becomes

f′′(x)≈f(x+Δx)−2f(x)+f(x−Δx)Δx2f''(x)\approx\frac{f(x+\Delta x)-2f(x)+f(x-\Delta x)}{\Delta x^2}

This equation becomes the backbone of:

  • heat conduction
  • diffusion equations
  • Poisson equations

and many numerical operators we’ll implement later.


15. Truncation Error

The Taylor Series never truly ends. When we stop after a few terms, we introduce truncation error. For the central difference, O(Δx2)O(\Delta x^2) means the leading neglected term scales with the square of the grid spacing.

Smaller cells generally reduce this approximation error, although other sources of numerical error still exist. This idea eventually leads to:

  • mesh refinement
  • convergence studies
  • verification

which become essential parts of CFD development.


16. From Mathematics to Code

Everything we’ve learned maps directly into software:

Mathematical ConceptFuture C++ Component
Scalar FieldScalarField class
Vector FieldVectorField class
CoordinatesGrid class
GradientDifferential operator
DivergenceContinuity operator
LaplacianDiffusion operator
Taylor SeriesNumerical stencil
Partial derivativesDiscrete operators
Material derivativeTransport calculations

Nothing here is abstract mathematics for its own sake. Every symbol eventually becomes a class, function, or numerical algorithm inside our solver.


Key Takeaways

  • CFD treats fluids as continuous fields rather than collections of molecules.
  • Scalar fields store magnitude; vector fields store magnitude and direction.
  • The Gradient points toward the greatest increase.
  • Divergence measures net outflow.
  • Curl measures local rotation.
  • The Laplacian represents diffusion through curvature.
  • The Material Derivative follows a moving fluid particle.
  • The Taylor Series provides the mathematical bridge from continuous equations to numerical approximations.
  • These concepts become the building blocks of every CFD solver we’ll develop in this series.

What’s Next

In Module 2, we’ll leave pure mathematics behind and begin deriving the physical laws that govern fluids. We’ll start from first principles and derive:

  • Conservation of Mass (Continuity Equation)
  • Conservation of Momentum (Newton’s Second Law)
  • Conservation of Energy

These equations eventually combine to form the Navier-Stokes equations—the mathematical heart of Computational Fluid Dynamics.