From Zero → CFD: Installing OpenFOAM 12 on Windows (WSL) & Visualising with ParaView

Running CFD on Windows used to mean dual-booting or juggling virtual machines. Thanks to Windows Subsystem for Linux (WSL), you can now get a near-native Ubuntu environment, install the latest community release of OpenFOAM, and post-process in the powerhouse visualiser ParaView—all without leaving Windows. Links to the software used in this tutorial:

Below is a step-by-step guide that walks you through the entire journey I recently recorded for YouTube. Feel free to copy–paste the commands straight into your terminal.

Table of contents

  1. Enable WSL
  2. Install Windows Terminal (optional—but do it)
  3. Install Ubuntu in WSL
  4. Update & upgrade Ubuntu packages
  5. Fix dpkg/apt problems (if they appear)
  6. Quick tour of your new Linux
  7. Install OpenFOAM 12
  8. Create a handy alias
  9. Run the bubbleColumn tutorial
  10. Install ParaView on Windows
  11. Create the .foam stub & open the case
  12. Wrap-up & next steps

1 Enable the Windows Subsystem for Linux (WSL)

WSL boots a lightweight utility VM that runs a real Linux kernel side-by-side with Windows, giving you native‐speed file-system access and networking without a heavyweight hyper-visor. New Linux distributions installed with wsl --install are WSL by default. Check hardware prerequisite:

  • BIOS/UEFI: make sure Virtualization (Intel VT-x/AMD-V) is enabled.
  • Windows edition: Home, Pro, Enterprise, and Education all support WSL 2.
  • Platform updates: run Windows Update first—WSL piggybacks on recent kernel and package changes

Enable WSL & the VM platform (two ways): Settings → Apps → Optional Features → More Windows Features. Tick Windows Subsystem for Linux and Virtual Machine Platform, click OK, reboot.

2 Install Windows Terminal (optional—but highly recommended)

The classic Console Host still works, but Windows Terminal gives you:

  • Tabbed sessions for PowerShell, Cmd, Ubuntu (and any other distro).
  • JSON-based profiles you can colour-code and font-tweak.
  • GPU-accelerated text rendering—smooth scrolling even when OpenFOAM prints thousands of iteration lines.

How-to install “Windows Terminal”

  1. Open Microsoft Store → search “Windows Terminal”.
  2. Click InstallLaunch.
  3. Pin it to the task-bar (Right-click → Pin to taskbar) for one-click access.

3 Install Ubuntu inside WSL

Open an Administrator Windows Terminal tab and run:

wsl --install -d Ubuntu

Windows downloads the latest LTS image, extracts it, and launches it automatically on first boot. You’ll be prompted for:

  • UNIX username – anything you like, case-sensitive.
  • Password – characters won’t echo (normal for *nix).

Verify the install with:

wsl -l -v      # should list Ubuntu with VERSION 2

If you have multiple distros and want Ubuntu as default:

wsl --set-default Ubuntu

4 Update & upgrade Ubuntu packages

New images can be several weeks behind the upstream repositories. Refresh everything before adding software:

sudo apt update          # refresh package lists
sudo apt full-upgrade -y # kernel + security + feature upgrades
sudo apt autoremove -y   # purge old dependencies

full-upgrade (a.k.a. dist-upgrade) handles kernel transitions and renamed packages more gracefully than plain upgrade.

Tip: WSL reboots are instant—just close and reopen the Ubuntu tab to pick up a new kernel. you can now go back to “Windows Terminal” if any other environment has been popped up.

5 Fix dpkg/apt problems (only if they appear)

Package-database corruption is rare but can happen if an install is interrupted. Symptoms include “dpkg: error processing archive …” or “sub-process /usr/bin/dpkg returned error code 1”. Quick checks:

sudo lsof /var/lib/dpkg/lock-frontend
sudo dpkg –configure -a
sudo apt -f install

If the lock file isn’t held and dpkg --configure -a still fails, proceed with the nuclear rebuild. Rebuild the info directory:

sudo mv /var/lib/dpkg/info /var/lib/dpkg/info_bak
sudo mkdir /var/lib/dpkg/info
sudo apt update
sudo apt -f install
sudo mv /var/lib/dpkg/info/* /var/lib/dpkg/info_bak
sudo rm -rf /var/lib/dpkg/info
sudo mv /var/lib/dpkg/info_bak /var/lib/dpkg/info
sudo apt update
sudo apt full-upgrade -y

This sequence recreates the info tree, forces any half-configured packages to finish, then restores metadata—a proven recipe shared by the Ubuntu community.

6 Quick tour of your new Linux

CommandPurposeTypical output/how to use
pwd“Where am I?”/home/alex
ls -lList files long-format-rw-r–r– 1 alex alex 4096 notes.txt
cd <dir>Change directory
cd ..Go up one level
cp Copy folder/filecp -r input output
nanoa simple text editornano fileName

All fixed drives are mounted under /mnt via DrvFs.
For example, Windows C:\Users\Alex\Desktop appear. Where Windows lives inside WSL:

cd /mnt/c/Users/Alex/Desktop

Microsoft’s own docs confirm this mapping.

Keep CFD projects inside your Linux home (e.g. /home/alex/OpenFOAM/…). Reading/writing meshes through /mnt/c is convenient but much slower because every syscall crosses the Windows ↔ Linux boundary.

7 Install OpenFOAM 12 (Ubuntu package)

OpenFOAM 12 was released on 9 July 2024 and is the current LTS from the Foundation.

sudo sh -c "wget -O - https://dl.openfoam.org/gpg.key > /etc/apt/trusted.gpg.d/openfoam.asc"
sudo add-apt-repository http://dl.openfoam.org/ubuntu
sudo apt update

Install OpenFOAM 12 which also installs paraview (or paraviewopenfoam510 on Ubuntu 20.04) as a dependency if it is not already installed.

sudo apt -y install openfoam12

Behind the scenes this script sets dozens of variables (FOAM_ETC, FOAM_TUTORIALS, WM_PROJECT_USER_DIR, …) and updates PATH, LD_LIBRARY_PATH, and MANPATH.

Why source manually? Because you might install multiple OpenFOAM versions side-by-side; sourcing lets you pick on demand.

8 Create a one-word alias

Typing that long source line in every terminal gets old fast. Append an alias to ~/.bashrc:

cd
nano ~/.bashrc

scroll to bottom of file and add below line:

alias of12='source /opt/openfoam12/etc/bashrc'

Reload once:

source ~/.bashrc

Now a fresh Ubuntu tab only needs:

of12       # instantaneous OpenFOAM 12 activation

9 Run the bubble column tutorial

The bubble column models air sparging into a quiescent water column using the twoPhaseEulerFoam solver (Euler-Euler approach). Copy and run the tutorial:

cd  # just in case
cp -r /opt/openfoam12/tutorials/multiphaseEuler/bubbleColumn buubleColumn
cd buubleColumn
blockMesh
foamRun

10 Install ParaView on Windows

ParaView can be installed inside Linux, but the WSL route needs an X-server and you lose hardware-accelerated graphics. The signed MS-installer runs directly on Windows, sees your GPU out-of-the-box, and happily reads files sitting in the WSL file-system.

Open a browser and go to paraview.org/download.
Under Latest Stable, grab ParaView-….-Win64.msi (plain or MPI build—either works).
Run the wizard with defaults (≈ 500 MB on disk).
Launch once and pin it to the task-bar.

11 Create the .foam stub & open the bubble column case

Back in your Ubuntu tab—still inside bubbleColumn:

touch bubbleColumn.foam
pwd

Either filename is understood by ParaView’s internal reader.

  1. Open Paraview software.
  1. Navigate to the working directory and open bubbleColumn.foam.
  2. In the Properties panel click Apply to load the mesh.
  3. Hit Play—you should see rising gas pockets breaking through the liquid free surface.

A quick styling pass

  • Color byalpha.air to visualise the gas volume fraction.
  • Add an Iso-Volume filter at alpha.air = 0.5 to get a crisp bubble outline.
  • Use the Plot Over Time filter on voidfraction to watch global gas holdup.

ParaView’s full manual (HTML & PDF) ships with the installer; new users should skim Sections 1-5 of the Self-directed Tutorial. docs.paraview.org

🎉 Mission Accomplished — Now Go Break Things (Safely)

If you followed along, congratulations—you just turned a perfectly innocent Windows laptop into a full-blown CFD workstation and made bubble bath art in ParaView. Your reward? A hard drive that smells faintly of Linux and bragging rights at the next office coffee break:

“Oh, you still dual-boot? Cute. I CFD inside WSL.”

Remember:

  • 💾 Save early, mesh often.
  • 🧹 When disk usage balloons, shrink that WSL VHD before it starts demanding its own climate-controlled server rack.
  • 🐛 If something explodes, it’s almost always a missing of12 or a typo in phaseProperties—double-check before rage-quitting.

Got questions, epic success GIFs, or tales of numerical carnage? Drop them in the comments—or ping me on the socials. If this guide saved you hours of googling, consider buying me a virtual coffee ☕ (I’ll spend it on more cores).

Now shut the lid, step outside, and admire a real bubble column: a pint of your favorite beverage. Cheers, and happy simulating!

Leave a Comment

Your email address will not be published. Required fields are marked *