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.com, 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 the update is complete, navigate to your preferred directory, then download and unpack the two compressed files:
cd ~/download/fem
mkdir openFOAM
cd openFAOAM
wget https://dl.openfoam.com/source/v2512/OpenFOAM-v2606.tgz
wget https://dl.openfoam.com/source/v2606/ThirdParty-v2606.tgz
tar -zxvf OpenFOAM-v2606.tgz
tar -zxvf ThirdParty-v2606.tgz
cd elmerfemThese two foders will be created:
OpenFOAM-v2606 ThirdParty-v2606/If you plan to have multiple OpenFOAM users on your Linux system, we strongly raccomend to compile it in the /opt system directory.
If so, become the root superuser and execute the following command:
cd /opt
mkdir openFOAM
mv /home/user/downloads/fem/openFOAM/OpenFOAM-v2606 openFOAM
mv /home/user/downloads/fem/openFOAM/ThirdParty-v2606 openFOAM
source OpenFOAM-v2606/etc/bashrcNow that the environment is properly loaded, simply select the number of processors and launch the two compilation processes in this exact order: ThirdParty first, and then OpenFOAM:
cd ThirdParty-v2606
./Allwmake -j 6
cd ../OpenFOAM-v2606
./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 blockMesh
which simpleFoam
which icoFoam
If the compilation process finishes without any errors, you should see the following output:
OpenFOAM-v2606
/opt/openFOAM/OpenFOAM-v2606/platforms/linux64GccDPInt32Opt/lib
/opt/openFOAM/OpenFOAM-v2606/platforms/linux64GccDPInt32Opt/bin/blockMesh
/opt/openFOAM/OpenFOAM-v2606/platforms/linux64GccDPInt32Opt/bin/simpleFoam
/opt/openFOAM/OpenFOAM-v2606/platforms/linux64GccDPInt32Opt/bin/icoFoamThats'all!
Following this straightforward guide, you should now be able to run your first CFD simulation using openFOAM.com.
Back to Quick start section