OpenFOAM® Installation on Windows 10

OpenFOAM®  Installation on Windows 10

From OpenFOAM-v1706, users can now run OpenFOAM using Bash on Ubuntu on Windows. This utility, referred to as the Windows Subsystem for Linux (WSL), uses the genuine Ubuntu image provided by Canonical, the group behind Ubuntu Linux. Bash on Ubuntu on Windows does not support graphics directly. For GUI-based processing users are recommended to download and use the ParaView Windows native build.

Preliminaries

Activate Ubuntu Bash and create a user account. Note: this will require a computer reboot. Additional guidance can be found in

https://msdn.microsoft.com/en-us/commandline/wsl/install_guide

To run OpenFOAM in the Windows10, User should have latest Ubuntu bash 16.04 or above. User can check their version by running command

lsb_release -a
in bash terminal on Windows10. User can upgrade to latest bash .

Install OpenFOAM

  1. Click on the link OpenFOAM-v1706-windows10.tgz to download OpenFOAM-v1706.
  2. Start Bash on Ubuntu by typing bash in search toolbar, and click on the Desktop app Bash on Ubuntu on Windows

    [Picture]

  3. In the bash-terminal, copy OpenFOAM-v1706-Windows10.tgz from the Download folder to the local bash-environment by typing command

    cp -ar /mnt/c/Users/<USER>/Downloads/OpenFOAM-v1706-Windows10.tgz .

    [Picture]

    Note

    • Replace the <USER> string with your own user name when copying the file, e.g. here shown by the user pgh
    • The final dot (.) is required to specify the current location
  4. Untar the OpenFOAM installation by running the following command

    sudo tar -xvzf  OpenFOAM-v1706-Windows10.tgz -C /opt/
    sudo chown -R $USER /opt/OpenFOAM

    [Picture]

    Enter your linux password to allow the process to start.
    Note

    • it may take some minutes to complete the process
    • if tar is not installed, please install it using the command

      sudo apt install tar
  5. Install the additional dependencies

    sudo apt install bison flex m4

Configure the bash-shell to run OpenFOAM

  1. Run the following command to set the OpenFOAM working environment (once only)

    echo "source /opt/OpenFOAM/OpenFOAM-v1706/etc/bashrc" >> ~/.bashrc
    source $HOME/.bashrc

Check everything is OK

The installation can be verified by running your first OpenFOAM tutorial.

mkdir -p /c/mnt/Users/<USER>/tutorial
cd /c/mnt/Users/pgh/tutorial
cp -ar $FOAM_TUTORIALS/incompressible/icoFoam/cavity/cavity .
cd cavity
blockMesh
icoFoam
touch cavity.foam
The case can then be visually checked using ParaView.