Originally developed as the commercial software FOAM by Nabla Ltd, OpenFOAM was released as an open-source C++ toolbox for computational fluid dynamics (CFD) under the GNU General Public License in December 2004. The name OpenFOAM stay for: Open Field Operation and Manipulation.
Over the years, its codebase branched into three main actively maintained variants:
- the OpenFOAM Foundation version openfoam.org
- the ESI-OpenCFD version openfoam.com
- the community-driven fork foam-extend.
At foamBuilder, we started using it since version 1.2 in 2005, so it was only natural to discuss it on this website.
In this simple and straightforward guide, we will explain the main steps for compiling the OpenFOAM Foundation version openfoam.org, on Linux or in the same way in WSL (the Windows Subsistem Linux) for Windows.
Before starting, it is best practice to update and upgrade your Linux system using the following commands. Furthermore, you will need to install the following essential dependancies:
sudo apt update
sudo apt upgrade
sudo apt install -y
build-essential
flex
bison
cmake
zlib1g-dev
libgmp-dev
libmpfr-dev
libboost-system-dev
libboost-thread-dev
libreadline-dev
libncurses-dev
libxt-dev
libfftw3-dev
libopenmpi-dev
openmpi-bin
git
Once updated, navigate to your preferred download directory and clone the repository:
cd ~/download/fem
mkdir openFOAM
cd openFAOAM
wget -O - http://dl.openfoam.org/source/14 | tar xvz
wget -O - http://dl.openfoam.org/third-party/14 | tar xvz
cd openFOAMThese two foders will be downloaded:
OpenFOAM-14-version-14 ThirdParty-14-version-14/Since compiling script expects folder paths without the "-version-14" suffix, rename the existing directories to OpenFOAM-14 and ThirdParty-14 respectively:
mv OpenFOAM-14-version-14 OpenFOAM-14
mv ThirdParty-14-version-14 ThirdParty-14Next, create the .OpenFOAM/14 directory and place an empty prefs.sh file inside it:
mkdir -p ~/.OpenFOAM/14
touch -p ~/.OpenFOAM/14/prefs.shand edit it with the following content:
export WM_COMPILER_TYPE=system
export WM_COMPILER=Gcc
export WM_MPLIB=SYSTEMOPENMPI
Now you are ready to start the compiling process. Just load the environment and select the number of processor:
cd OpenFOAM-14
source etc/bashrc
./Allwmake -j 6Depending on the number of selected cores, the compilation process may take anywhere from half an hour to several hours.
Once the compilation process is complete, you can verify the installation with the following commands:
foamVersion
echo $FOAM_LIBBIN
ls -lh $FOAM_LIBBIN
which foamRun
which blockMesh
which simpleFoam
which icoFoam
If the compilation process finishes without any errors, you should see the following output:
OpenFOAM-14
/home/user/downloads/fem/openFOAM/OpenFOAM-14/platforms/linux64GccDPInt32Opt/lib
/home/user/downloads/fem/openFOAM/OpenFOAM-14/platforms/linux64GccDPInt32Opt/bin/foamRun
/home/user/downloads/fem/openFOAM/OpenFOAM-14/platforms/linux64GccDPInt32Opt/bin/blockMesh
/home/user/downloads/fem/openFOAM/OpenFOAM-14/platforms/linux64GccDPInt32Opt/bin/simpleFoam
/home/user/downloads/fem/openFOAM/OpenFOAM-14/platforms/linux64GccDPInt32Opt/bin/icoFoamThats'all!
Following this straightforward guide, you should now be able to run your first CFD simulation using openFOAM.org.
Back to Quick start section