Compiling OpenFOAM on more popular Linux distros has become a trivial task due to the abundance of the references and guides published on the internet. However, for the first time that I tried compiling OpenFOAM on CentOS Stream, I realized that there is a lack of A-to-Z guide for more recent RHEL-based linux distros. This first post here is to fill the gap.
The main steps for the compilation are exactly the same as those published in the official OpenFOAM page: Compiling OpenFOAM from Source Code
However, the first step (installing Software for Compilation) is different here. Unfortunately, the old guide on the OpenFOAM page (Upgrading RHEL 6 Packages for OpenFOAM) would neither be useful for more recent RHEL-based OSs. The following steps are tested on CentOS Stream 9.
Installing the main tools
Before starting, it is easier to gain superuser privileges:
sudo -s
Installing
EPEL RPM (the release version should match your OS, 9 in my case):
yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm
It is now easy to install the compilation and development prerequisites
yum groupinstall 'Development Tools'
yum install openmpi openmpi-devel
yum install CGAL-devel
Now, we want to add a link to the boost library
ln -s /usr/lib64/libboost_thread-mt.so /usr/lib64/libboost_thread.so
And adding the OpenMPI binaries to system path
export PATH=/usr/lib64/openmpi/bin/:$PATH
export LD_LIBRARY_PATH=/usr/lib64/openmpi/lib/:$LD_LIBRARY_PATH
Installing QT tools for compiling ParaView
yum install qt5
yum install qt5-qtbase-devel
Adding a link to qmake-qt5 (to be able to call it just as qmake)
ln -s /usr/bin/qmake-qt5 /usr/bin/qmake
yum install qt5-qtwebkit-devel
yum install qt5-qttools-devel
yum install qt5-qtsvg-devel
yum install qt5-qtxmlpatterns-devel
Now, we can end the superuser privilidges
exitSupposing that the OpenFOAM source has already been
downloaded, the necessary paths can be set for bashrc
source $HOME/OpenFOAM/OpenFOAM-dev/etc/bashrcCompiling thirdparty applications
From within the ThirdParty-dev directory run the commands
./Allwmake
./makeParaView
wmRefresh
Compiling OpenFOAM
From within the OpenFOAM-dev directory run the command
./Allwmake -j [no. of processors]
Finalizing the installation
The final step is to check if OpenFOAM is working. To this end, change the directory to
cd /$HOME/OpenFOAM/OpenFOAM-dev/tutorials/incompressible/icoFoam/cavity/cavity
and run OpenFOAM mesher and solver, and post-process the result
blockMesh
icoFoam
paraFoam
If you are able to see the result, everything went well.