To get the best experience with OpenFOAM installation on windows, you need to have windows 10 (build 19041 and higher) or higher versions of Windows like windows 11. So, you can install/activate WSL2 on your computer. WSL, stands for windows subsystem for Linux, is a new technology of Microsoft and is a managed virtual machine that implements the full Linux kernel. So, to install OpenFOAM on your windows OS, you need to first install WSL2 on your computer.
Step 1: Installing WSL2 on your windows OS
Open windows PowerShell in administrator mode by right-clicking and selecting “Run as administrator” and enter the following command
wsl --install
for older versions of windows-10 OS (Windows 10 with build lower than 19041), you may need to follow instructions provided by Microsoft to install it manually.
After installation, you can check the WSL version installed on your computer in the PowerShell:
wsl -v
and you may get the following output:
WSL version: 2.1.5.0 Kernel version: 5.15.146.1-2 WSLg version: 1.0.60 MSRDC version: 1.2.5105 Direct3D version: 1.611.1-81528511 DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp Windows version: 10.0.19045.4412
The first and the last lines show that the WSL version is 2.1.5.0 and windows version is 10 and it is build 19045).
Step 2: Installing Ubuntu on WSL2
To get the available list of Linux distributions for installation, you have two options: using Microsoft store and search for the name of your desired Linux distribution or using PowerShell and install it with one command. Here, the second method is explained. To get the list of available distributions, just enter this command in the PowerShell:
wsl --list --online
you may get the following output:
The following is a list of valid distributions that can be installed. Install using 'wsl.exe --install <Distro>'. wsl --list --online NAME FRIENDLY NAME Ubuntu Ubuntu Debian Debian GNU/Linux kali-linux Kali Linux Rolling Ubuntu-18.04 Ubuntu 18.04 LTS Ubuntu-20.04 Ubuntu 20.04 LTS Ubuntu-22.04 Ubuntu 22.04 LTS Ubuntu-24.04 Ubuntu 24.04 LTS OracleLinux_7_9 Oracle Linux 7.9 OracleLinux_8_7 Oracle Linux 8.7 OracleLinux_9_1 Oracle Linux 9.1 openSUSE-Leap-15.5 openSUSE Leap 15.5 SUSE-Linux-Enterprise-Server-15-SP4 SUSE Linux Enterprise Server 15 SP4 SUSE-Linux-Enterprise-15-SP5 SUSE Linux Enterprise 15 SP5 openSUSE-Tumbleweed openSUSE Tumbleweed
Suppose you are going to install Ubuntu-24.04 on the computer, enter the following command in the PowerShell:
wsl --install -d Ubuntu-24.04
you can replace “Ubuntu-24.04” with any distribution name from the above list. The Ubuntu-24.04 will be installed without GUI on your computer. Now, you can install OpenFOAM on it.
Step 3 (optional): Installing Windows Terminal and Other Apps
To have a better experience with working with WSL, I highly recommend you install Windows Terminal. Go to the Microsoft store and search for Windows Terminal and install it if it is not already installed on your computer. It is also recommended to install notepad++ and sublime text editors on your Windows, so that you can modify and work with text files easily.
Step 4: Running Ubuntu and some tips
Open Windows Terminal and enter the following command. The installed Linux distribution will start.
wsl cd
You will be asked for a password, and you need to enter the password that you set during Linux installation. Whenever you want to have access to files outside the terminal, enter the following command:
explorer.ext .
You can also start Ubuntu from the list of installed applications on your computer in the start menu. Upon start, you need to enter the password that you set during installation of Linux.
Step 5: Installing OpenFOAM on your WSL machine
The installation is like what you do when installing OpenFOAM on a computer with normal installation of Ubuntu. So, you are referred to recent posts for installing OpenFOAM. There, you will have two options: installing from source pack and installing from pre-built files: