In this post you will learn how to install OpenFOAM v2006 from source pack. The operating system is Ubuntu 18.04 LTS. It is assumed that you are installing OpenFOAM v2006 on a fresh operating system. These steps were also followed for installing OpenFOAM v2006 on Ubuntu 20.04 LTS.
Note: If you previously installed the older version of OpenFOAM from source pack, you may not need to install some of the prerequisite packages on your computer and skip them.
You can find instructions to install older versions of OpenFOAM:
- Installing OpenFOAM-v1912
- Installing OpenFOAM-7
A) Download and Initial Checks
1) Downloading source code: go to official website of OpenFOAM v2006 and download the source pack of the latest version (at the moment it is OpenFOAM v2006). Or simply follow these links to download the compressed files by clicking on them:
2) Creating installation folder in the home folder: move the downloaded compressed files to the directory in which you want to install (compile) OpenFOAM v2006. Here we keep everything on the home folder of the computer. Create a new folder with name “OpenFOAM” (if you already do not have it) on the home folder and move the compressed files into this folder.
3) Unpacking the files: open a new terminal in this folder and decompress these two files:
tar -xzf OpenFOAM-v2006.tgz tar -xzf ThirdParty-v2006.tgz
Two folders with names “OpenFOAM-v2006” and “ThirdParty-v2006” are created under ~/OpenFOAM folder.
4) Compiler version: check the compiler version. You need gcc version 4.8.5 or higher.
gcc --version
if you do not have gcc installed on your computer or gcc version is lower than 4.8.5, execute the following commands:
sudo apt-get update sudo apt-get install gcc
B) Installing prerequisites on your Computer
5) Installing prerequisites: you need to install other packages to be able to compile and run OpenFoam and Paraview. These packages are FLEX, cmake , boost, Git distributed version control, and OpenMPI and etc. To install these packages on Ubuntu 18.04, execute the following commands in the terminal (for compiling and running OpenFOAM):
sudo apt-get update sudo apt-get install build-essential autoconf autotools-dev cmake gawk gnuplot sudo apt-get install flex libfl-dev libreadline-dev zlib1g-dev openmpi-bin libopenmpi-dev mpi-default-bin mpi-default-dev sudo apt-get install libgmp-dev libmpfr-dev libmpc-dev sudo apt-get install libscotch-dev libptscotch-dev libfftw3-dev libboost-system-dev libboost-thread-dev libcgal-dev
In any stage of package installation, if you get error “unable to fetch some archives”, try the following command:
sudo apt-get update --fix-missing
and restart installing packages.
6) Setting environmental variables: in this step, you need to set environmental variables. The method allows you to install multiple versions of OpenFOAM v2006 on your computer at the same time. So, open ~/.bashrc file using this command:
gedit ~/.bashrc
and add the following line at the end of this file, save and close the file (assuming that you installed OpenFOAM v2006 in the $HOME/OpenFOAM directory).
alias of2006="source $HOME/OpenFOAM/OpenFOAM-v2006/etc/bashrc"
then enter this commands in the current terminal window:
source ~/.bashrc
the bashrc file of OpenFoam which contains the environmental setting is not configured in the current terminal window. To load these settings into the current terminal window (or any new terminal window that you open) you need to enter the following command:
of2006
C) Compiling and running
7) Installing Third-party packages: change the current directory to $HOME/OpenFOAM/ThirdParty-v2006 in the terminal (you already entered of2006 command in this terminal) and then enter this command to install third party packages:
./Allwmake
Note: If you performed step 6 successfully, most of the third-party packages are already installed on your computer. OpenFOAM, by default, uses these packages that are installed on your system (from apt repository or other official repositories). So building packages from Third-party folder is not mandatory. However, if in any circumstance you fail to install any package on your computer from apt repository, you can install/build that package from Third-party folder.
8) Compiling OpenFOAM: change the current directory to $HOME/OpenFOAM/OpenFOAM-v2006 in the terminal (you already entered of2006 command in this terminal) and then enter this command to compile OpenFOAM:
./Allwmake -j
this may take several minutes to hours to finish.
Note: The above command builds OpenFOAM using all the available processors on your computer. If you do not have enough RAM and/or Swap space, compilation may fail due to shortage of memory. In this case, just remove -j flag from above command.
9) using OpenFOAM: you will find some tutorials on using OpenFOAM v2009 on this website (for intermediate users) and cfd.at (for beginners) .
I have been trying for 3 days to install (from the source files) OFv2006 on Ubuntu 18.04 with no success. All my packages versions are above the requirements and all the versions that should be avoided are avoided. However, some folders and files cannot be made during Allwmake and I end up getting the following error when I run “foamInstallationTest”:
Do you have any idea what the problem might be?
Cheers,
==================================================
Executing foamInstallationTest
Basic setup :
——————————————————————————-
OpenFOAM: OpenFOAM-v2006
ThirdParty: ThirdParty-v2006
Shell: bash
Host: air-X10DAi
OS: Linux version 5.4.0-42-generic
——————————————————————————-
Main OpenFOAM env variables :
——————————————————————————-
Environment FileOrDirectory Valid Crit
——————————————————————————-
$WM_PROJECT_USER_DIR /home/cfdwork/OpenFOAM/cfdwork-v2006 no no
$WM_THIRD_PARTY_DIR /home/cfdwork/OpenFOAM/ThirdParty-v2006 yes maybe
$WM_PROJECT_SITE [env variable unset] no
——————————————————————————-
OpenFOAM env variables in PATH :
——————————————————————————-
Environment FileOrDirectory Valid Path Crit
——————————————————————————-
$WM_PROJECT_DIR /home/cfdwork/OpenFOAM/OpenFOAM-v2006 yes yes yes
$FOAM_APPBIN …06/platforms/linux64GccDPInt32Opt/bin yes yes yes
$FOAM_SITE_APPBIN …06/platforms/linux64GccDPInt32Opt/bin no no
$FOAM_USER_APPBIN …06/platforms/linux64GccDPInt32Opt/bin no no
$WM_DIR …cfdwork/OpenFOAM/OpenFOAM-v2006/wmake yes yes often
——————————————————————————-
OpenFOAM env variables in LD_LIBRARY_PATH :
——————————————————————————-
Environment FileOrDirectory Valid Path Crit
——————————————————————————-
$FOAM_LIBBIN …06/platforms/linux64GccDPInt32Opt/lib no yes
$FOAM_SITE_LIBBIN …06/platforms/linux64GccDPInt32Opt/lib no no
$FOAM_USER_LIBBIN …06/platforms/linux64GccDPInt32Opt/lib no no
$FOAM_EXT_LIBBIN …v2006/platforms/linux64GccDPInt32/lib yes yes maybe
$MPI_ARCH_PATH /home/cfdwork/openmpi yes yes yes
——————————————————————————-
Software Components
——————————————————————————-
Software Version Location
——————————————————————————-
flex 2.6.4 /usr/bin/flex
wmake 2006 /home/cfdwork/OpenFOAM/OpenFOAM-v2006/wmake/wmake
gcc 7.5.0 /usr/bin/gcc
g++ 7.5.0 /usr/bin/g++
——————————————————————————-
icoFoam *** not installed ***
CRITICAL ERROR
Summary
——————————————————————————-
Base configuration ok.
The foam installation contains 1 critical error(s).
Review the output for warning messages and consult
the installation guide for troubleshooting.
Done
Did you test the method recommended in this post?
If no, just undo everything and follow the steps explained here. Just remember that if you fail to install any package, try installing them from third-party folder, since most of them are provided for portability.
Personal experience: always use LTS version of ubuntu.
This is what I got from my recent installation.
Executing foamInstallationTest
Basic setup :
——————————————————————————-
OpenFOAM: OpenFOAM-v2006
ThirdParty: ThirdParty-v2006
Shell: bash
Host: ubuntu
OS: Linux version 4.15.0-20-generic
——————————————————————————-
Main OpenFOAM env variables :
——————————————————————————-
Environment FileOrDirectory Valid Crit
——————————————————————————-
$WM_PROJECT_USER_DIR /home/hrn/OpenFOAM/hrn-v2006 no no
$WM_THIRD_PARTY_DIR /home/hrn/OpenFOAM/ThirdParty-v2006 yes maybe
$WM_PROJECT_SITE [env variable unset] no
——————————————————————————-
OpenFOAM env variables in PATH :
——————————————————————————-
Environment FileOrDirectory Valid Path Crit
——————————————————————————-
$WM_PROJECT_DIR /home/hrn/OpenFOAM/OpenFOAM-v2006 yes yes yes
$FOAM_APPBIN …06/platforms/linux64GccDPInt32Opt/bin yes yes yes
$FOAM_SITE_APPBIN …06/platforms/linux64GccDPInt32Opt/bin no no
$FOAM_USER_APPBIN …06/platforms/linux64GccDPInt32Opt/bin no no
$WM_DIR /home/hrn/OpenFOAM/OpenFOAM-v2006/wmake yes yes often
——————————————————————————-
OpenFOAM env variables in LD_LIBRARY_PATH :
——————————————————————————-
Environment FileOrDirectory Valid Path Crit
——————————————————————————-
$FOAM_LIBBIN …06/platforms/linux64GccDPInt32Opt/lib yes yes yes
$FOAM_SITE_LIBBIN …06/platforms/linux64GccDPInt32Opt/lib no no
$FOAM_USER_LIBBIN …06/platforms/linux64GccDPInt32Opt/lib no no
$FOAM_EXT_LIBBIN …v2006/platforms/linux64GccDPInt32/lib yes yes maybe
$MPI_ARCH_PATH /usr/lib/x86_64-linux-gnu/openmpi yes yes yes
——————————————————————————-
Software Components
——————————————————————————-
Software Version Location
——————————————————————————-
flex 2.6.4 /usr/bin/flex
wmake 2006 /home/hrn/OpenFOAM/OpenFOAM-v2006/wmake/wmake
gcc 7.5.0 /usr/bin/gcc
g++ 7.5.0 /usr/bin/g++
——————————————————————————-
icoFoam exists …OAM-v2006/platforms/linux64GccDPInt32Opt/bin/icoFoam
Summary
——————————————————————————-
Base configuration ok.
Critical systems ok.