A student guide · curated for engineering & physics students

From zero to your first CFD simulation with OpenFOAM.

OpenFOAM is the most widely used open-source computational fluid dynamics toolbox in research and industry. This guide walks a complete beginner — undergraduate or first-year graduate — from installation through a working lid-driven cavity simulation, covering the vocabulary, the case structure, the most useful solvers, and post-processing in ParaView along the way.

First release
2004
Open-sourced by OpenCFD
Solvers shipped
60+
Steady & transient, compressible & incompressible
Utilities
250+
Pre- and post-processing tools
License
GPL v3
Fully open, free for any use
student@uniud:~/cavity
bash

# 1. Copy the tutorial into your working directory

cp -r $FOAM_TUTORIALS/incompressible/icoFoam/cavity .

# 2. Build the mesh

blockMesh

# 3. Run the solver

icoFoam

# 4. Visualise the result

paraFoam

─────────────────────────────────────

Time = 0.5

Courant Number mean: 0.42 max: 0.91

✓ Solution converged in 500 steps

C++ core

GPL v3

FVM

A few solvers you will meet

  • › icoFoam → incompressible, laminar, transient
  • › simpleFoam → steady-state incompressible turbulent
  • › pisoFoam → transient incompressible turbulent
  • › rhoSimpleFoam → compressible steady
  • › interFoam → two-phase VOF
  • › reactingFoam → reactive flows
The toolbox

What is OpenFOAM, actually?

OpenFOAM stands for Open Field Operation And Manipulation. It is not a single program with a friendly window — it is a large collection of C++ libraries and command-line executables that together solve partial differential equations on unstructured meshes using the finite-volume method.

OpenFOAM was originally developed at Imperial College London by the group of Prof. Hrvoje Jasak, Dr. Henry Weller and collaborators during the 1990s. In 2004 the codebase was released under the GNU General Public License and the OpenFOAM Foundation was created to steward it. Today the codebase is actively maintained by two parallel organisations — OpenCFD / ESI Group, who publish theopenfoam.com line used in this guide, and the OpenFOAM Foundation, who publish theopenfoam.org line. Both are free and GPL; their releases differ slightly in packaging and timeline.

The toolbox is built around a top-level C++ class library that hides the unstructured-mesh bookkeeping behind a clean, almost mathematical syntax. A solver for, say, incompressible laminar flow can be written in roughly 100 lines and looks like the discretised form of the Navier–Stokes equations you would write on paper. This makes OpenFOAM uniquely attractive for teaching and research: every equation is visible, modifiable, and recompilable.

For a student the practical consequence is that OpenFOAM is a toolbox, not an application. There is no green "Run" button. You prepare an input directory (called a case), invoke a meshing utility, invoke a solver, and finally open the result in ParaView. Each step is a separate command-line program. Once you accept this decomposition, the whole workflow becomes logical and very scriptable.

Open source vs commercial

Why learn OpenFOAM instead of (or alongside) ANSYS Fluent or STAR-CCM+?

Commercial CFD packages are excellent, polished, and expensive. For a student the question is not which is «better» in industry, but which one teaches you the physics and the numerics. OpenFOAM, precisely because nothing is hidden, is the best teaching tool — and it also happens to be free.

The strongest argument for OpenFOAM in a university course is pedagogical. When you click "Run" in a commercial GUI, the solver is a black box. When you type icoFoam in OpenFOAM you can open the source fileicoFoam.C and read, line by line, how the pressure–velocity coupling is implemented through the PISO algorithm. You can modify it, recompile, and rerun in minutes. This loop — read the code, change it, observe the effect — is what makes engineers understand CFD rather than merely operate it.

The second argument is economic. A single seat of a commercial package costs more than a student workstation. OpenFOAM runs on any Linux laptop, scales to a cluster, and never asks for a licence token. You can install it at home over the weekend, on the lab machines, and on the HPC facility — all without paperwork.

The third argument is industrial relevance. OpenFOAM is no longer an academic toy: BMW Group, Volkswagen, Airbus, Siemens Energy, Engys and many others run it in production. A graduate who can demonstrate a working OpenFOAM case in their portfolio has a real, transferable skill — not just familiarity with one vendor's menus.

Feature
OpenFOAM
Commercial
License cost
Free (GPL v3)
€10k–€50k / seat / yr
Source code access
Full C++ source
Closed binary
Custom boundary conditions
Write your own in C++
UDF / UDF macros (limited)
Custom solvers
Fork & modify any solver
Not possible
Parallel scaling
MPI-native, hundreds of cores
MPI-native, similar
GUI
Text-driven (ParaView for viz)
Integrated GUI
Learning curve
Steep — Unix + physics + code
Gentler — menu-driven
Industry acceptance
Growing fast — BMW, VW, Airbus
Default in many firms

Truly open

GPL v3 — read, modify, redistribute. No lock-in.

Hackable

Every solver is plain C++ you can fork and recompile.

Huge community

cfd.direct, OpenFOAM Forum, LinkedIn groups, YouTube courses.

No licence server

Runs offline. No tokens, no dongles, no expirations.

Honest caveat. OpenFOAM is harder to learn than a commercial GUI. You will spend the first week fighting Linux paths, mesh dictionaries, and a cryptic segmentation fault or two. This is normal, expected, and exactly what this guide is designed to flatten. Persevere — the payoff is a transferable skill that outlives any single vendor.

The vocabulary

Core concepts you must internalise before touching a solver

OpenFOAM has its own dialect. If you understand six ideas — mesh, fields, boundary conditions, schemes, linear solvers and the pressure–velocity algorithm — every tutorial and every error message becomes readable. Skip this section and you will spend days guessing.

Mesh (FVM)

OpenFOAM discretises space into a collection of small polyhedral control volumes — the mesh. The finite-volume method integrates the governing equations over each volume, so fluxes in and out of every face cancel exactly. This guarantees local and global conservation, the property that makes FVM the standard for fluid flow.

Fields

A field is a value (scalar, vector, tensor) defined at every cell centre of the mesh. Pressure p, velocity U, temperature T are typical fields. Each field lives in a file inside the case directory and is read into memory by the solver as a C++ object — a volScalarField, volVectorField, etc.

Boundary conditions

Each field needs a value or constraint on every patch of the mesh boundary. OpenFOAM ships ~50 boundary-condition types, from fixedValue (Dirichlet) to zeroGradient (Neumann) to inletOutlet (switches between inflow and outflow). They live in the field files in the 0/ directory.

Discretisation schemes

The fvSchemes dictionary specifies how spatial and temporal derivatives are approximated — upwind vs central differencing, Euler vs Crank-Nicolson, limited linear schemes. These choices trade accuracy against stability and are the single biggest tuning knob after mesh quality.

Linear solvers

After discretisation every time step reduces to a large sparse linear system Ax = b. OpenFOAM ships iterative solvers (PCG, PBiCGStab, GAMG) and the preconditioners to go with them. The fvSolution dictionary declares which solver and tolerance to use for each field.

Algorithms: SIMPLE / PISO / PIMPLE

For incompressible flow pressure and velocity are coupled. SIMPLE is steady-state and pressure-velocity segregated. PISO is transient and corrects the pressure multiple times per step. PIMPLE blends the two and is the modern default for transient turbulent flow.

The mental model in one paragraph

OpenFOAM reads a case directory containing a mesh, initial/boundary fields, and dictionaries that control discretisation and linear algebra. The solver assembles a matrix equation for each field, solves it with the chosen linear solver, advances one time step (or one outer iteration for steady cases), and writes the new fields back to disk. The same machinery handles incompressible water, compressible air, combustion, particles, electromagnetic fields — what changes is which transport equations are assembled, controlled by which solver executable you launch.

Spatial discretisation

finite-volume · cell-centred

Mesh types supported

structured · unstructured · polyhedral

Parallel model

domain decomposition · MPI

Get it running

Installation — pick the path that matches your operating system

OpenFOAM is a Linux-native toolbox. On Linux it installs directly; on Windows the recommended route is WSL2 (Windows Subsystem for Linux); on macOS the only supported route is a Linux container. Pick the tab that matches your machine and follow the steps verbatim.

The OpenCFD (openfoam.com) line publishes an Ubuntu PPA. Add the repository and install with apt. This is the simplest possible path and the one recommended for students.

bash — Ubuntu 22.04 / 24.04
# 1. Add the OpenCFD signing key and apt source
sudo sh -c "wget -O - https://dl.openfoam.com/add-debian-repo.sh > /etc/apt/sources.list.d/openfoam.list"

# 2. Refresh package list
sudo apt update

# 3. Install the OpenFOAM v2412 default configuration
sudo apt install openfoam2412-default

# 4. Source the environment in your shell (do this in ~/.bashrc to persist)
source /usr/lib/openfoam/openfoam2412/etc/bashrc

# 5. Sanity-check the installation
simpleFoam -help | head -3
echo "OpenFOAM environment is: $WM_PROJECT_DIR"

After step 5 you should see the simpleFoam usage banner and a path like /usr/lib/openfoam/openfoam2412. If you do, the installation is complete.

Which version should I install?

The OpenCFD line uses a YYMM version label. v2412 (December 2024) is the current LTS-style release. The OpenFOAM Foundation line uses integer versions (v12, v13…). For a class, pick one line and stick with it — tutorial paths and dictionary syntax are 99% identical but not 100%.

Hardware requirements

For the tutorials in this guide any laptop with 8 GB RAM and 20 GB free disk is plenty. Real industrial cases need 32 GB+ RAM and ideally a multicore workstation or HPC cluster — OpenFOAM parallelises very well with MPI.

The case directory

The anatomy of an OpenFOAM case — three folders you will meet forever

Every OpenFOAM simulation lives in a directory with the same three sub-folders: 0/ for fields, constant/ for material properties and the mesh, and system/ for run-control dictionaries. Memorise this layout — it is the single most reusable piece of knowledge in the toolbox.

tree cavity
cavity/
├── 0/                 ← initial & boundary conditions (one file per field)
│   ├── U              ← velocity field (vector)
│   └── p              ← pressure field (scalar)
├── constant/
│   ├── transportProperties   ← fluid properties (ν, ρ)
│   └── polyMesh/             ← the mesh (points, faces, cells, boundary)
├── system/
│   ├── controlDict           ← time stepping, write interval, end time
│   ├── fvSchemes             ← discretisation schemes (grad, div, laplacian)
│   ├── fvSolution            ← linear solvers & tolerances
│   └── blockMeshDict         ← mesh description for blockMesh
└── Allclean, Allrun          ← convenience scripts

The three folders map cleanly to the three questions you must answer before running any simulation: What am I solving? (the fields in 0/), Where am I solving it? (the mesh in constant/polyMesh/), and How am I solving it? (the dictionaries in system/). Master this triplet and every tutorial on the planet becomes a variation on a theme.

0/Initial & boundary conditions

One plain-text file per field. Each file lists the internal field value and, for every boundary patch, the type of boundary condition and its parameters. At the end of a run, OpenFOAM writes new time-step folders (e.g. 0.5/, 1/) with the same field files containing the solution at that instant.

C/constant/

Material properties (kinematic viscosity, density, turbulence model constants) and the mesh itself under constant/polyMesh/. The mesh is regenerated by blockMesh or snappyHexMesh and never edited by hand — but it is plain text, so you can inspect it.

S/system/

Run-control dictionaries. controlDict sets the time step, end time and write interval. fvSchemes sets the discretisation schemes. fvSolution sets the linear solvers and tolerances. These three files are where you will spend 80% of your debugging time.

A real controlDict you can read

The lid-driven cavity tutorial ships with this control file. Notice the C++-like syntax and the FoamFile header that every OpenFOAM dictionary starts with.

cavity/system/controlDict
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    object      controlDict;
}

application     icoFoam;        // solver executable to launch

startFrom       startTime;      // begin from the time folder named in startTime
startTime       0;

stopAt          endTime;        // stop when endTime is reached
endTime         0.5;            // simulate 0.5 s of physical time

deltaT          0.005;          // time step (s) — keep Courant < 1

writeControl    timeStep;       // write every N steps
writeInterval   20;             // N = 20 -> write every 0.1 s

purgeWrite      0;              // keep all written time folders
writeFormat     ascii;          // human-readable output
writePrecision  6;              // 6 significant digits
writeCompression off;

timeFormat      general;
timePrecision   6;

runTimeModifiable true;

0/U

Velocity field — vector (Ux, Uy, Uz)

0/p

Pressure field — scalar (p)

constant/transportProperties

Kinematic viscosity ν

system/controlDict

Time stepping & output control

system/fvSchemes

Spatial & temporal discretisation

system/fvSolution

Linear solvers & tolerances

Your first simulation

Tutorial — the lid-driven cavity in 5 commands

The lid-driven cavity is the «Hello, World!» of CFD. A square box is filled with fluid; the top lid moves to the right at constant velocity, dragging the fluid with it and forming a large primary vortex and two small secondary vortices in the corners. It is small enough to run in 30 seconds on a laptop and rich enough to teach you the entire OpenFOAM workflow.

  1. 1
    Copy the tutorial
  2. 2
    Inspect the dictionaries
  3. 3
    Generate the mesh with blockMesh
  4. 4
    Run icoFoam
  5. 5
    Visualise in paraFoam

1 · Copy the tutorial case

Every OpenFOAM install ships with a tutorial tree at $FOAM_TUTORIALS. Copying a tutorial into your own directory is the cleanest way to start — you inherit a known-working setup and can modify from there.

bash
mkdir -p ~/openfoam-work && cd ~/openfoam-work
cp -r $FOAM_TUTORIALS/incompressible/icoFoam/cavity .
cd cavity
ls -R . | head -40

2 · Read the input dictionaries

Open system/controlDict, system/fvSchemes, system/fvSolution and constant/transportProperties in your editor. You should recognise them from the previous section. The lid velocity and the viscosity are the two numbers that define the physics of this case.

constant/transportProperties
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    object      transportProperties;
}

nu              [0 2 -1 0 0 0 0] 0.01;
//                 ↑ units: m^2/s      ↑ kinematic viscosity
// The lid speed is 1 m/s, so Re = U*L/nu = 1*0.1/0.01 = 10
0/U (velocity field — boundary patches)
FoamFile
{
    version     2.0;
    format      ascii;
    class       volVectorField;
    object      U;
}

dimensions      [0 1 -1 0 0 0 0];   // m/s

internalField   uniform (0 0 0);    // fluid initially at rest

boundaryField
{
    movingWall                    // top lid — drives the flow
    {
        type            fixedValue;
        value           uniform (1 0 0);   // 1 m/s to the right
    }
    fixedWalls                    // bottom + sides — no slip
    {
        type            noSlip;
    }
    frontAndBack                  // 2D empty direction
    {
        type            empty;
    }
}

3 · Generate the mesh

blockMesh reads system/blockMeshDict and writes a structured hexahedral mesh into constant/polyMesh/. The default cavity mesh is 20 × 20 × 1 cells — enough for a Reynolds number of 10.

bash
blockMesh
# Output (abbreviated):
#   Creating block mesh from
#       "/home/.../cavity/system/blockMeshDict"
#   Creating block offsets
#   Writing points (441), faces (840), cells (400) ...
#   Writing polyMesh files to constant/polyMesh

# Quick sanity-check — print mesh statistics
checkMesh | tail -20

4 · Run the solver

icoFoam solves the incompressible, laminar, transient Navier–Stokes equations using the PISO algorithm. The whole run takes a few seconds. Watch the Courant number — it must stay below 1 for stability.

bash
icoFoam
# Output (abbreviated):
#   Time = 0.005
#   Courant Number mean: 0.0423 max: 0.0847
#   ...
#   Time = 0.5
#   Courant Number mean: 0.419 max: 0.912
#   ExecutionTime = 0.42 s

ls                  # you now have 0/, 0.1/, 0.2/, ..., 0.5/

5 · Visualise the result

paraFoam is a thin wrapper that launches ParaView with the case already loaded. Inside ParaView: Apply the case, switch the representation to Surface With Edges, color by U magnitude, add a Stream Tracer filter — you will see the characteristic primary vortex.

bash
paraFoam
# ParaView opens with the cavity case loaded.
#   1. Click Apply in the Properties panel
#   2. Set Coloring -> U -> Magnitude
#   3. Filters -> Search -> "Stream Tracer" -> Apply
#   4. Use the time controls at the top to animate from 0 to 0.5 s

What you should see

A large clockwise primary vortex centred slightly above the geometric centre of the cavity. Two small counter-rotating vortices in the lower-left and lower-right corners (Moffatt eddies). The pressure field shows a low-pressure region in the vortex core. Increase the lid velocity or decrease nu in transportProperties to push to Re = 100 or Re = 1000 — the primary vortex moves towards the centre and the corner eddies grow.

Re = 10

Primary vortex in upper half; weak corner eddies.

Re = 100

Vortex moves toward centre; eddies grow.

Re = 1000

Vortex nearly centred; tertiary eddies appear.

Try this. Open system/blockMeshDict and change the blocks entry from (20 20 1) to (40 40 1) — a 4× finer mesh. Re-run blockMesh (delete the old time folders first with foamListTimes -rm) and then icoFoam. Compare the vortex centre with the coarse mesh result: this is your first mesh-sensitivity study.

Mesh generation

Meshing — the half-hour that decides the next half-day

A CFD result is only as trustworthy as the mesh under it. OpenFOAM ships two main meshers — blockMesh for structured blocks and snappyHexMesh for arbitrary STL geometry — and integrates cleanly with external meshers through conversion utilities. Pick the right one for the geometry, not the one you happen to know.

blockMesh

Mesher

When the geometry is a union of hexahedral blocks — channels, boxes, simple pipes.

Ships with OpenFOAM. Reads a single blockMeshDict file and writes a structured hex mesh. Excellent for tutorials, benchmark cases and anything parametric. Limited for curved or organic geometry.

snappyHexMesh

Mesher

When you have a CAD surface (STL/OBJ) and need a body-fitted mesh around it.

Three-stage mesher: castellate (snap hexes to the surface), snap (project to STL), and addLayers (inflate boundary layers). The de-facto standard for external aerodynamics and complex internal flow.

cfMesh / cartHex

Mesher

When snappyHexMesh struggles with small features or poor layer quality.

Third-party mesher by Franjo Juretic. Produces high-quality polyhedral meshes with robust boundary layers. Free for academic use. Often used for turbomachinery and marine applications.

Import from SALOME / GMSH / ANSYS Meshing

Mesher

When your group already has a meshing workflow in another tool.

OpenFOAM reads unstructured meshes through the conversion utilities gmshToFoam, fluentMeshToFoam, ansysToFoam, ccm26ToFoam. The converted mesh lives, as always, in constant/polyMesh/.

A minimal blockMeshDict

This is the dictionary behind the cavity mesh — a single hexahedral block from the origin to (0.1 0.1 0.1), split into 20 × 20 × 1 cells. The simpleGrading entry concentrates cells near the walls where gradients are steeper.

system/blockMeshDict (cavity)
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    object      blockMeshDict;
}

convertToMeters 0.1;          // all vertex coords below are scaled by this

vertices
(
    (0 0 0)        // 0
    (1 0 0)        // 1
    (1 1 0)        // 2
    (0 1 0)        // 3
    (0 0 0.1)      // 4
    (1 0 0.1)      // 5
    (1 1 0.1)      // 6
    (0 1 0.1)      // 7
);

blocks
(
    hex (0 1 2 3 4 5 6 7) (20 20 1) simpleGrading (1 1 1)
    //                  ↑ cells    ↑ expansion ratios (x y z)
);

boundary
(
    movingWall    { type wall;     faces ((3 7 6 2)); }
    fixedWalls    { type wall;     faces ((0 4 7 3) (2 6 5 1) (1 5 4 0) (0 3 2 1)); }
    frontAndBack  { type empty;    faces ((0 1 2 3) (4 5 6 7)); }
);

mergePatchPairs ( );

Mesh quality gate

Run checkMesh after every meshing step. Aim for "Mesh OK" in the report.

Cell types

OpenFOAM handles hex, tet, prism and polyhedral cells natively — polyhedra generally give the best accuracy per degree of freedom.

Near-wall resolution

For wall-functions: y+ ≈ 30–300. For low-Re models: y+ < 1. Use yPlusRAS to check post-run.

Reference

Solvers and boundary conditions — pick the right executable for the physics

OpenFOAM ships more than 60 solvers. As a student you will realistically use five or six. The table below is the cheat-sheet you can keep on your desk: it maps the physics you want to the executable you launch. The boundary-condition table that follows is the second half of the same cheat-sheet.

Solver quick reference

SolverFamilyPhysicsAlgorithmTypical use
icoFoamIncompressibleLaminar, transientPISOCavity, Stokes flow, validation benchmarks.
simpleFoamIncompressibleSteady, turbulentSIMPLEExternal aerodynamics at low Mach, internal steady flow.
pisoFoamIncompressibleTransient, turbulentPISOVortex shedding, transient HVAC.
pimpleFoamIncompressibleTransient, turbulentPIMPLEModern default for transient turbulent flow — large time steps.
rhoSimpleFoamCompressibleSteady, turbulentSIMPLECompressible external aero, nozzles.
rhoPimpleFoamCompressibleTransient, turbulentPIMPLECompressible transient — combustion prep, shock tubes.
sonicFoamCompressibleTransient, transonicPISOShock-capturing, transonic flow.
interFoamMultiphaseTwo-phase VOFPIMPLEFree-surface flows, dam break, wave impact.
reactingFoamReactingCombustion, multicomponentPIMPLEPremixed/non-premixed flames, chemical reactors.
laplacianFoamDiffusionPure diffusion—Heat conduction, verification of schemes.
potentialFoamPotentialInviscid, irrotational—Initial guess for other solvers, simple aero.
scalarTransportFoamPassive scalarAdvective–diffusive—Smoke, dye transport, mixing studies.

Boundary-condition quick reference

Each field needs a boundary condition on every patch. The ten types below cover ~95% of student cases. The math column shows the formal definition; the role column explains it in plain English.

TypeMathematical formRoleTypical use
fixedValueu = U₀Dirichlet — value prescribed.Inlet velocity, wall temperature.
fixedGradient∂u/∂n = g₀Neumann — gradient prescribed.Outlets, symmetry, known heat flux.
zeroGradient∂u/∂n = 0Neumann, zero — natural outflow.Default at pressure outlets.
noSlipu_wall = 0Wall — fluid velocity matches wall (zero here).Solid walls in viscous flow.
slipuₙ = 0, ∂uₜ/∂n = 0Wall — no normal flow, no tangential stress.Symmetry planes, inviscid walls.
inletOutletu = U₀ if inflow, ∂u/∂n = 0 if outflowSwitches BC by flow direction.Open boundaries, avoid backflow crashes.
pressureInletOutletVelocityp prescribed, ∂u/∂n = 0 outflowPressure-driven boundary.Free outlets with prescribed pressure.
wall functiony+ ≈ 30–300Bridges first cell to the log layer.High-Re turbulent wall-bounded flow.
movingWallVelocityu = u_wall(t)Wall that moves with a known trajectory.Pistons, rotating drums, sliding meshes.
cyclicu(x+L) = u(x)Periodic boundary — connects two patches.Fully-developed duct flow, DNS of turbulence.

How to discover a solver

Run icoFoam -help to see its options. Browse the source at $WM_PROJECT_DIR/applications/solvers/. Each solver folder contains a README and often a createFields.H that shows exactly which fields are read and which transport equations are solved.

Turbulence models

For RANS, set simulationType RAS in constant/turbulenceProperties and pick a model (kOmegaSST is a safe default). For LES, switch to LES and pick Smagorinsky or WALE. Always check the resulting y+ post-run.

See the result

Post-processing in ParaView — five filters that cover 90% of student work

OpenFOAM writes plain-text field files. Reading them visually is impossible past a few hundred cells — you need a viewer. ParaView is the standard companion: open-source, parallel, scriptable in Python, and the only tool you need for the first two years of your CFD career.

1

Load the case

Open the case directory with paraFoam or create an empty case.foam file ParaView can read.

2

Apply & color

Click Apply, then set Coloring to U (magnitude) or p. Switch representation to Surface With Edges to see the mesh.

3

Add filters

Slice, Contour, Stream Tracer, Glyph, Plot Over Line — these are the five filters you will use 90% of the time.

4

Export

Save screenshots (File → Save Screenshot), CSV data from plots, or animation (File → Save Animation).

The single most useful filter is Slice. For a 3D internal flow (a duct, an artery, a heat exchanger), slicing through the centreline and colouring by velocity immediately shows where the flow separates and where it accelerates. Add a second slice perpendicular to the first and you have a complete picture in two clicks.

The second most useful filter is Stream Tracer. It seeds massless particles at a regular grid and integrates their trajectories through the velocity field. The result is the streamline plot you have seen in every textbook — instantly readable by engineers and laypeople alike.

For quantitative data, use Plot Over Line — it draws a line through your domain and produces a 2D x–y plot of any field along it. This is how you extract a velocity profile at the channel centreline or a pressure distribution along a wall, and how you compare your simulation against an analytical or experimental reference.

bash — open a case in ParaView
# Option A: paraFoam wrapper (easiest)
cd ~/openfoam-work/cavity
paraFoam

# Option B: create an empty .foam file ParaView can open
touch cavity.foam
paraview cavity.foam &

# Option C: from inside ParaView, File -> Open -> cavity.foam
bash — extract data without ParaView
# Probe a field along a line — write CSV
postProcess -func "graphCellSet(U)" -time 0.5

# Sample fields on a plane — write VTK
sample -latestTime

# Compute y+ for a turbulent wall-bounded case
yPlusRAS -latestTime

Slice

Filters → Alphabetical → Slice

2D cross-section of a 3D field

Contour

Filters → Contour

Iso-surfaces of pressure, temperature, Q-criterion

Stream Tracer

Filters → Stream Tracer

Streamlines from a seeding grid

Glyph

Filters → Glyph

Vector arrows on a slice (velocity vectors)

Plot Over Line

Filters → Plot Over Line

x–y plot of a field along a line

Calculator

Filters → Calculator

Define new fields (e.g. Q-criterion)

Threshold

Filters → Threshold

Show only cells where a field is in a range

Streamline

Filters → Streamline (advanced)

More control than Stream Tracer

Lessons from the trenches

Common pitfalls, debugging recipes, and habits that will save you weeks

Every OpenFOAM beginner makes the same five mistakes and rediscovers the same eight good habits. This section collects them in one place so that you do not have to learn them the hard way at 2 a.m. before a deadline.

Courant number explodes

Symptom: Solver crashes at first time step with "Maximum number of iterations exceeded".

Fix: Halve deltaT in controlDict. Aim for max Co < 1 for PISO, < 5 for PIMPLE. Check with foamListTimes -rm and rerun.

FOAM_ABORT: cannot find patch

Symptom: BlockMeshDict patch name and 0/U patch name don't match exactly.

Fix: Patch names are case-sensitive and must appear in every field file in 0/. Run blockMesh and then foamListPatches to print the canonical names.

Negative volume cells

Symptom: checkMesh reports "cells with negative determinant".

Fix: The mesh is inverted — usually wrong vertex ordering in blockMeshDict or a bad STL normal in snappyHexMesh. Inspect with paraFoam and fix the topology.

Simulation never converges

Symptom: Residuals plateau at 1e-3 and never reach 1e-6.

Fix: Check schemes (try upwind instead of linear), relax the equations in fvSolution (0.3 for p, 0.7 for U), refine the mesh near separation, and verify the boundary conditions are physically consistent.

Disk fills up with time folders

Symptom: Simulation writes 50 GB of unwanted output.

Fix: In controlDict, increase writeInterval and set purgeWrite to keep only the last N time folders. Use writeCompression on; to halve disk usage.

Eight habits worth building now

  • 1Always start from a tutorial in $FOAM_TUTORIALS — never from a blank directory. You inherit a working setup and learn by modifying.
  • 2Run checkMesh on every mesh, every time. A failed mesh check invalidates every result you produce afterwards.
  • 3Keep deltaT conservative. A simulation that takes twice as long is better than one that crashes overnight.
  • 4Comment every change you make in a dictionary. Future-you will not remember why ν was set to 1e-6.
  • 5Use foamListTimes -rm to clean time folders between reruns. It is faster and safer than rm -rf.
  • 6Verify against an analytical solution or a published benchmark before trusting a new solver or a new mesh on a real problem.
  • 7Read the source. icoFoam.C is ~80 lines and reads like the PISO algorithm in a textbook. The day you understand it is the day you stop being an OpenFOAM user and become an OpenFOAM developer.
  • 8Use git on your case directory. Commit before every meaningful change. Diffs of dictionaries are the fastest way to find what broke.
“OpenFOAM rewards patience. The first week is brutal, the first month is satisfying, the first year is transforming. By the end you do not just know a piece of software — you understand fluid mechanics.”
— typical sentiment heard from graduate students after their first OpenFOAM project
Where to go next

Resources to continue the journey — curated by Prof. Miani, University of Udine

A beginner's guide is a starting point, not a destination. The eight resources below are the ones I recommend to my own students at the University of Udine when they are ready to go past the cavity and tackle real problems. Use them in order — they progress from documentation to community to advanced theory.

01

OpenFOAM.com — official site (ESI / OpenCFD line)

Documentation, releases, training courses and the OpenFOAM journal. The User Guide PDF linked here is the single most important reference for the openfoam.com line used in this guide.

https://www.openfoam.com

02

OpenFOAM.org — Foundation line

The OpenFOAM Foundation site, with the parallel openfoam.org line. The two lines are 99% compatible at the dictionary level. Worth bookmarking to compare release notes.

https://openfoam.org

03

OpenFOAM User Guide (PDF)

The 350-page official manual. Read chapters 2 (tutorial), 4 (mesh), 5 (fields and BCs) and 6 (solvers) at least once. It is dense but it is the ground truth.

https://www.openfoam.com/documentation/user-guide

04

Wolf Dynamics — OpenFOAM training notes

Free, university-grade course notes (hundreds of slides per course) on OpenFOAM fundamentals, meshing, post-processing and turbulence. Among the best free CFD teaching material on the web.

https://www.wolfdynamics.com/training.html

05

OpenFOAM Forum (cfd-online)

The de-facto community forum. Twenty years of Q&A; if you have an error message, somebody has already asked about it. Search before posting.

https://www.cfd-online.com/Forums/openfoam/

06

Jasak OpenFOAM lectures (YouTube)

Prof. Hrvoje Jasak's lecture series on finite-volume method and OpenFOAM implementation. Theoretical depth that turns menu-clickers into engineers.

https://www.youtube.com/results?search_query=openfoam+lecture

07

The Finite Volume Method in Computational Fluid Dynamics — Moukalled, Mangani, Darwish

An 800-page textbook that explains FVM with OpenFOAM examples. The bridge between a continuum-mechanics course and a working CFD engineer.

https://link.springer.com/book/10.1007/978-3-319-16874-6

08

Chalmers University OpenFOAM course

Hrvoje Jasak's course at Chalmers, with lecture notes, tutorial cases and exam problems freely available. A semester's worth of graduate-level material.

https://www.tfd.chalmers.se/~hani/kurser/OS_CFD/

Suggested learning path

  1. Week 1–2: Install, run the cavity, change Re, change mesh.
  2. Week 3–4: Run the OpenFOAM User Guide tutorials in order: cavity, backward-facing step, plate heat exchanger.
  3. Week 5–6: Mesh a real geometry with snappyHexMesh (aerofoil, bluff body).
  4. Week 7–8: Run a turbulent case with kOmegaSST, check y+, validate against experimental data.
  5. Week 9–10: Read icoFoam.C and simpleFoam.C. Modify one and recompile.
  6. Beyond: Pick a real engineering problem (your thesis, an industrial case) and apply everything.