OpenFOAM Installation ‐ Windows - openfoam-ICL-UC/openfoam_intro_EN GitHub Wiki


The most flexible and powerful way to install OpenFOAM on Windows is to install it directly within a Linux distribution inside the "Windows Subsystem for Linux" virtual machine. Additionally, we will install the Windows Terminal graphical interface to facilitate interaction with the Unix command line in Linux.

Installing Windows Subsystem for Linux (WSL)

Windows Subsystem for Linux (WSL) allows you to install Linux distributions within Windows as a development environment. The following page is the official Microsoft tutorial for installing Windows Subsystem for Linux. These instructions install the default distribution, Ubuntu, which is suitable for subsequently installing OpenFOAM.

Installing Linux on Windows with WSL

If you have never used the Linux command line or want to ensure that you configure your WSL correctly, we recommend the following tutorial (30 minutes):

Training: Introduction to Windows Subsystem for Linux

If you haven't done so already, the first time you open Ubuntu in Windows Subsystem for Linux, you will need to create a user and password. If you encounter any issues, visit the following page: Setting up Ubuntu on WSL

Installing Visual Studio Code with the WSL Extension

Visual Studio Code is a development environment that can be used for multiple languages. It is highly optimized and has become the standard in scientific programming. The capabilities of the editor can be enhanced with extensions, the most important of which is "WSL" which allows connecting the Windows editor graphical interface with the Windows Subsystem for Linux.

Follow the instructions on the following Microsoft Learn page to install Visual Studio Code with the WSL extension: Visual Studio Code with WSL Extension

Installing Windows Terminal

In addition to Visual Studio Code, Windows Terminal is an invaluable tool for managing your Windows Subsystem for Linux distribution. To install it, follow the instructions in the optional subsection "Windows Terminal Installation (optional)

Installing OpenFOAM in WSL

Now that we have WSL, we can use the easiest and most robust way to install OpenFOAM in Linux, which is to use the package manager apt-get to install a precompiled version of OpenFOAM.

  1. Use Windows Terminal to open the WSL terminal.

  2. Update the certificates of your Ubuntu distribution:

sudo apt-get install ca-certificates

sudo apt-get update

  1. Add the OpenFOAM repository using the command:

curl | sudo bash

  1. Update the repository information once more:

sudo apt-get update

  1. Install the latest version of OpenFOAM. For this workshop:

sudo apt-get install openfoam2406-default

Installing ParaView

ParaView is a visualization software for computational mechanics simulation results. This software is not installed by default in OpenFOAM, and it is necessary to visualize and analyze the results.

Compatibility of Graphical Interfaces in WSL

To run graphical interfaces from WSL, you need to update the drivers for your video card. In the following section of the official Microsoft documentation for WSL, you will find links to download the appropriate drivers for your video card (Intel, NVIDIA, or AMD):

Installation of GUI Application Support

Direct Installation of ParaView Using the apt Package Manager

ParaView installation is done directly by typing the following line in the WSL Windows Terminal:

sudo apt install paraview

Using OpenFOAM and Testing the Installation of OpenFOAM + ParaView

  1. To access the functionalities of OpenFOAM from the terminal, you need to start the OpenFOAM shell. This must be done each time you open a terminal:


If you are able to run this command, you will see a message that says "OpenFOAM shell session - use 'exit' to quit."

  1. From the OpenFOAM shell, navigate to your home directory, make a copy of the pitzDaily tutorial folder from pimpleFoam, and then enter the pitzDaily directory:


cp -r $FOAM_TUTORIALS/incompressible/pimpleFoam/RAS/pitzDaily/ .

cd pitzDaily

This tutorial, or case, involves the simulation of steady-state turbulent flow over a backward-facing step.

  1. Generate the computational grid:


  1. Run the pimpleFoam solver for incompressible, unsteady flow:


You will see many numbers appearing in the terminal, representing information from each iteration of the algorithm. Wait between 30 seconds and 2 minutes until the algorithm finishes. You will notice the message "End." If you type the command:


A list of files in the directory will be shown, and you will notice a series of folders from 0.01 to 0.3. These folders contain the simulation results, which include pressure and velocity as a function of space for each saved time step. To visualize these results, use ParaView.

  1. First, create an empty file that will allow ParaView to connect with the folders containing the case solution:

touch foam.foam

Then, open the case in ParaView using the foam.foam file:

paraview foam.foam

  1. In ParaView, a window will open, but initially, nothing will be displayed.

View of ParaView upon opening

  1. To display the solution, click the 'Apply' button. If the simulation has been executed correctly, you will be able to view the following pressure profile on a 2-D mesh. This profile represents the pressure after 0.01 seconds since the simulation started.

Pressure profile after 0.1 seconds of simulation for the pitzDaily case.

Congratulations! You have successfully completed your OpenFOAM installation.