Visualize Airflow Over a Wing with OpenFOAM

Run a real computational fluid dynamics simulation and watch the airflow come alive.

High School Aerodynamics 3–5 weeks
Last reviewed: March 2026

Overview

Computational Fluid Dynamics (CFD) is how aerospace engineers "see" airflow without a wind tunnel. Modern airliners, Formula 1 cars, and wind turbines are designed using CFD simulations that model the physics of air moving around complex shapes—solving millions of equations at thousands of points in space. OpenFOAM is the world's most widely used open-source CFD platform, and it is the same solver used in academic research and small-to-medium aerospace companies worldwide.

In this project you will simulate steady incompressible flow over a NACA 0012 airfoil at 5° angle of attack—one of the most iconic benchmark problems in aerodynamics. You will generate a structured mesh around the airfoil, configure the simpleFoam solver, run the calculation on your laptop, and use the free ParaView tool to visualize pressure coefficient distribution, velocity magnitude contours, and streamlines around the wing. The colorful flow-field images you produce are the same type engineers use to explain aerodynamic behavior to design teams and clients.

OpenFOAM runs on Linux; if you use Windows you will work inside Windows Subsystem for Linux (WSL2), which is straightforward to install. This is itself a valuable skill—most scientific computing infrastructure runs on Linux, and learning to navigate it confidently is an asset in any STEM career.

What You'll Learn

  • Explain what CFD is and identify the three stages of any simulation: meshing, solving, and post-processing.
  • Set up a 2D airfoil case in OpenFOAM including boundary conditions and solver settings.
  • Generate and inspect a structured C-mesh around an airfoil using blockMesh.
  • Run simpleFoam and monitor convergence using residual plots.
  • Visualize velocity, pressure, and streamlines in ParaView and extract the pressure coefficient distribution.

Step-by-Step Guide

1

Install OpenFOAM and ParaView

On Ubuntu (or WSL2), add the OpenFOAM repository and install with sudo apt install openfoam11 (check the official site for the current version). Source the OpenFOAM environment: source /opt/openfoam11/etc/bashrc. Add this line to your ~/.bashrc so it loads automatically. Install ParaView with sudo apt install paraview. Verify everything works by running foamVersion—you should see the version number printed. Copy the built-in airfoil tutorial to your working directory: cp -r $FOAM_TUTORIALS/incompressible/simpleFoam/airFoil2D ~/airfoil_project.

2

Explore the case structure

Navigate into ~/airfoil_project and list its contents. Every OpenFOAM case has three directories: 0/ (initial and boundary conditions), constant/ (physical properties and mesh), and system/ (solver and numerical settings). Open 0/U to see how velocity boundary conditions are specified—the inlet velocity direction encodes the angle of attack. Open constant/transportProperties to see kinematic viscosity. Open system/blockMeshDict to see the mesh definition. Read through each file and write a one-sentence description of what it controls.

3

Generate the mesh and check quality

Run blockMesh from inside the case directory to generate the computational mesh. This takes about 30 seconds. Run checkMesh to verify mesh quality—look for the line "Mesh OK" at the bottom of the output. If you see warnings about high non-orthogonality, they are typically acceptable for this benchmark. Open ParaView and load the mesh by clicking File → Open and selecting airfoil_project.foam (an empty file you create with touch airfoil_project.foam). Color the mesh by region to see the C-shaped mesh wrapped around the airfoil.

4

Configure the solver and run the simulation

Open system/fvSolution and system/fvSchemes to review numerical settings—the tutorial defaults are already appropriate. Run the solver: simpleFoam > log.simpleFoam 2>&1 &. The solver runs in the background and writes results every 50 iterations. In another terminal, monitor convergence by running foamMonitor -l postProcessing/residuals/0/residuals.dat or by tailing the log file. The simulation is converged when Ux, Uy, and p residuals fall below 1e-4, which typically takes 300–500 iterations.

5

Visualize velocity and pressure fields

Open your completed case in ParaView. Apply the foam reader, then click the eye icon to display the mesh. Use the Slice filter to create a 2D cross-section if needed. Color the field by "p" (pressure) and set the color map to a diverging blue-red scale. Switch to "U" (velocity) and enable streamline visualization using the Stream Tracer filter with seeds near the inlet. Note the separation region on the upper surface near the trailing edge, the stagnation point on the leading edge, and the acceleration of flow over the upper surface.

6

Extract and plot the pressure coefficient

Use the Plot Over Line filter in ParaView to sample pressure along the airfoil surface chord. Export to CSV. In Python, load the CSV, compute Cp = (p − p_inf)/(0.5 × ρ × V²) where p_inf is freestream pressure, ρ = 1.225 kg/m³, and V is freestream speed. Plot Cp vs. chord position (x/c from 0 to 1) with upper surface in blue and lower surface in red. Compare your plot to published NACA 0012 experimental data from NASA Technical Report TM-85927. Document where CFD agrees well and where there are discrepancies, and hypothesize reasons (turbulence model, mesh resolution).

Go Further

  • Run the simulation at multiple angles of attack (0°, 5°, 10°, 15°) and plot CL and CD vs. alpha to generate the full aerodynamic polar, then compare to XFOIL predictions.
  • Refine the mesh by doubling the number of cells and check how the Cp distribution changes—this is a mesh independence study, required in any published CFD work.
  • Switch from a NACA 0012 (symmetric) to a NACA 2412 (cambered) airfoil by modifying the blockMeshDict and observe how the pressure distribution changes at 0° angle of attack.
  • Run the compressible rhoCentralFoam solver at Mach 0.5 and compare the pressure field to your incompressible result—note the appearance of compressibility effects.