Close

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 WSL VERSION.
  • If NAME is Ubuntu and VERSION is 2, 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 is Ubuntu and VERSION is 2 from the wsl -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

Segmentation fault when opening ParaView issue #4105 ], which references the 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