OpenFOAM for Windows
The packaged distributions of OpenFOAM for Ubuntu can be installed directly on Microsoft Windows 10 and 11 using Windows Subsystem for Linux (WSL). WSL provides a full compatibility layer for running Linux applications on Windows by performing real-time translation of Linux system calls into Windows OS system calls. The system can support graphical Linux applications such as ParaView that can access the reader modules within OpenFOAM (to load OpenFOAM cases).
Note: If graphical applications fail on WSL, report it to Microsoft’s WSL project on GitHub. In particular, if ParaView fails, do not report the issue to its producer Kitware, as they do not officially support ParaView on WSL. For any problems with the instructions below, go to the OpenFOAM Issue Tracking system.
Running OpenFOAM in WSL
Microsoft provides a guide to Install WSL which provides detailed information about the process. The steps to get OpenFOAM running on WSL are described below. The installation is specifically for WSL version 2 (not v1) with the Ubuntu 22.04 LTS Linux Distribution.
Step 1: Open Windows Command Prompt
- Open the Start menu, type “cmd” in the Search until the “Command Prompt” appears.
- Click with right mouse button to open a menu where you can then click
Run as Administrator
. - When prompted “Do you want to allow this app to make changes to your device”, select
Yes
.
Step 2: Check if WSL is installed
- Check if WSL is already installed by pasting the following command at the command prompt:
wsl -l -v
- If there is no WSL installed in your machine, you will see a similar response to the following:
Windows subsystem for Linux has no installed distributions
- Otherwise, if WSL is installed, it will print a table including the distribution
NAME
and WSLVERSION
. - If
NAME
isUbuntu
andVERSION
is2
, WSL is installed correctly; otherwise install WSL according to Step 3.
Step 3: Install WSL with Ubuntu 22.04
- Install WSL with Ubuntu 22.04 by typing the following command at the command prompt:
wsl --install -d Ubuntu-22.04
- When prompted during the installation, enter a username and password of your choice.
- After installation, confirm
NAME
isUbuntu
andVERSION
is2
from thewsl -l -v
command above.
Step 4: Starting WSL
- To start WSL: Either open the Start menu, search for “Ubuntu” and, when the Ubuntu WSL appears, click
Open
. - Or, from the command prompt, type:
wsl
- A Linux terminal will open on the screen, running the Bash shell.
Installing OpenFOAM
The packaged distributions of OpenFOAM on Ubuntu Linux can be installed from within the Linux terminal. Packages are provided by the OpenFOAM download repository (dl.openfoam.org
). Instructions for the following versions of OpenFOAM, packaged for Ubuntu, are available including “User Configuration” and “Getting Started”.
Known Issues with Fixes
Qt
library (e.g. libQt5Core.so.5
) used by ParaView. The segmentation fault may be avoided by using software rendering in the MESA 3D Graphics Library (GL) to process the graphics. Software rendering is enabled by setting the LIBGL_ALWAYS_SOFTWARE
environment variable to true
(or “1
”), typically by adding the following entry at the end of the user’s ~/.bashrc
file (see User Configuration for editing .bashrc
):export LIBGL_ALWAYS_SOFTWARE=1
QStandardPaths: wrong permissions on runtime directory /run/user/1000/, 0755 instead of 0700
This is an open issue in WSL [ WSL issue #10896 ]. The issue has not been resolved but can be remedied by adding the following at the end of the user’s ~/.bashrc
file:
chmod 0700 /run/user/1000