Introduction to OpenFOAM

Category: Open-Source CAE | Revised 2026-10-02
CAE visualization for openfoam intro theory - technical simulation diagram
Introduction to OpenFOAM

Theory: case structure, time step and mesh choices

Overview

🙋

I want to start OpenFOAM but hear there's no GUI. Where should I begin?

🎓

By running one official tutorial unchanged. OpenFOAM represents an analysis as a folder called a case containing three folders: 0/ holds initial values and boundary conditions for each variable (velocity U, pressure p); constant/ holds properties (such as viscosity) and the mesh; system/ holds run time and output (controlDict), discretisation (fvSchemes), linear solvers (fvSolution) and mesh generation (blockMeshDict). Start by copying the cavity case (a square box whose lid alone moves), build the mesh with blockMesh, solve with icoFoam and view in ParaView. Once that runs, change one setting at a time and watch the results. Without a GUI, every setting stays as text, which makes comparison and automation easy.

Reynolds number, Courant number and cost

$$ Re = \frac{U L}{\nu},\qquad Co = \frac{U\,\Delta t}{\Delta x} \le 1,\qquad \text{cost} \propto N^2 \times N = N^3\ \ (\text{2D}) $$

U is the reference speed (lid speed), L the reference length (cavity side), ν kinematic viscosity, Δt time step, Δx cell size and N divisions per side. icoFoam is a transient incompressible laminar solver that couples pressure and velocity with the PISO algorithm.

Coffee Break Trivia

From a London lab to the world

OpenFOAM's forerunner FOAM was developed at Imperial College London in the 1990s as a C++ library for writing partial differential equations much as they look on paper. After its open-source release in 2004, use spread rapidly through industry and academia. Solver code that reads almost like the governing equations is why researchers find it easy to add their own models.

Worked examples

Example 1: viscosity and Reynolds number (1 m/s lid, 0.1 m side)

Viscosity νReynolds numberViscous diffusion time L²/ν
0.01 m²/s101 s
0.001 m²/s10010 s
0.0001 m²/s1,000100 s

The tutorial uses ν = 0.01 (Re = 10) with an end time of 0.5 s.

Example 2: mesh density and cost (Co = 1, to 0.5 s)

MeshCell sizeTime stepStepsCellsCost (20×20 = 1)
20×200.0050 m0.0050 s1004001
40×400.0025 m0.0025 s2001,6008
80×800.00125 m0.00125 s4006,40064
🙋

To get Re = 1000, can I just change viscosity to 0.0001?

🎓

Not enough on its own. Higher Re brings small corner eddies and steep near-wall gradients that 20×20 cannot capture; refine to at least about 80×80 and shrink the time step to keep the Courant number below 1. The flow also takes longer to settle: the rough time for viscosity to spread momentum across the box, L²/ν, is 1 s at Re = 10 but 100 s at Re = 1000, so stopping at 0.5 s shows only a transient state. Extend endTime and use results only after the centreline velocity profile stops changing. At Re = 1000 always check mesh convergence too. The cavity has detailed reference data (the tables of Ghia et al.), the ideal first verification.

Getting started

  1. Copy the tutorial cavity case to a working folder.
  2. Build the mesh with blockMesh and check quality with checkMesh.
  3. Solve with icoFoam and check residuals and Courant number in the log.
  4. View velocity and pressure in ParaView (paraFoam or foamToVTK).
  5. Change one setting at a time and verify against reference data.
Coffee Break Trivia

“A first modification that diverged at once”

A common next step after the tutorial runs is to refine the mesh and run again. One student went to 40×40 and the run diverged immediately; the log showed a Courant number near 2, because the cell size had halved while the time step stayed at 0.005 s. Halving the time step to 0.0025 s fixed it. OpenFOAM can also adjust the time step automatically via adjustTimeStep and a maximum Courant number in controlDict.

Common mistakes

Mistakes and fixes

MistakeEffectFix
Refining mesh onlyDivergence from high Courant numberReduce time step too
Higher Re, same end timeViewing a transientConfirm steady state
Mismatched patch namesError at start-upMatch names in 0/ and mesh
Skipping checkMeshDivergence from bad cellsCheck quality
No reference comparisonErrors unnoticedVerify on benchmarks
🙋

I'd like to learn related topics.

Related Simulators

Experience the theory firsthand with the interactive simulator for this field

All Simulators

Related fields

Structural AnalysisFluid Analysis (CFD)Thermal Analysis
Rate this article
Thank you for your feedback!
Helpful
More details
Report error
Helpful
0
More details
0
Report error
0