Difference between revisions of "Installation/Linux/OpenFOAM-2.4.0/Ubuntu"

From OpenFOAMWiki
m (repaired links)
(Ubuntu 18.04: Corrected CGAL version...)
 
(12 intermediate revisions by the same user not shown)
Line 27: Line 27:
 
<ol>
 
<ol>
 
{{Installation/Linux/SwitchToRoot}}
 
{{Installation/Linux/SwitchToRoot}}
 
+
{{Installation/Linux/AptGetUpdate}}
 
<li>Install the necessary packages:
 
<li>Install the necessary packages:
 
<bash>apt-get install build-essential flex bison zlib1g-dev qt4-dev-tools libqt4-dev gnuplot libreadline-dev \
 
<bash>apt-get install build-essential flex bison zlib1g-dev qt4-dev-tools libqt4-dev gnuplot libreadline-dev \
Line 141: Line 141:
 
<li>{{Installation/Linux/CheckIfAllWentWell}}</li>
 
<li>{{Installation/Linux/CheckIfAllWentWell}}</li>
  
<li>Now you can go read the User Guide: [http://www.openfoam.org/docs/user/ official OpenFOAM User Guide]</li>
+
<li>{{Installation/ReadUserGuideEtAl_OpenFOAMFoundation}}</li>
 
</ol>
 
</ol>
  
Line 158: Line 158:
 
** Following the official instructions from here: [http://openfoam.org/download/2-4-0-source/ Download v2.4.0 | Source Pack]
 
** Following the official instructions from here: [http://openfoam.org/download/2-4-0-source/ Download v2.4.0 | Source Pack]
 
** Or by following the detailed step-by-step instructions below...
 
** Or by following the detailed step-by-step instructions below...
 +
  
 
'''Discussion thread where you can ask questions about these steps''': {{Installation/NoThreadAskForum}}
 
'''Discussion thread where you can ask questions about these steps''': {{Installation/NoThreadAskForum}}
Line 164: Line 165:
 
<ol>
 
<ol>
 
{{Installation/Linux/SwitchToRoot}}
 
{{Installation/Linux/SwitchToRoot}}
 
+
{{Installation/Linux/AptGetUpdate}}
 
<li>Install the necessary packages:
 
<li>Install the necessary packages:
 
<bash>apt-get install build-essential cmake flex bison zlib1g-dev qt4-dev-tools libqt4-dev libqtwebkit-dev gnuplot \
 
<bash>apt-get install build-essential cmake flex bison zlib1g-dev qt4-dev-tools libqt4-dev libqtwebkit-dev gnuplot \
Line 292: Line 293:
 
<li>{{Installation/Linux/CheckIfAllWentWell}}</li>
 
<li>{{Installation/Linux/CheckIfAllWentWell}}</li>
  
<li>Now you can go read the User Guide: [http://www.openfoam.org/docs/user/ official OpenFOAM User Guide]</li>
+
<li>{{Installation/ReadUserGuideEtAl_OpenFOAMFoundation}}</li>
 
</ol>
 
</ol>
  
Line 309: Line 310:
 
** Following the official instructions from here: [http://openfoam.org/download/2-4-0-source/ Download v2.4.0 | Source Pack]
 
** Following the official instructions from here: [http://openfoam.org/download/2-4-0-source/ Download v2.4.0 | Source Pack]
 
** Or by following the detailed step-by-step instructions below...
 
** Or by following the detailed step-by-step instructions below...
 +
  
 
'''Discussion thread where you can ask questions about these steps''': {{Installation/NoThreadAskForum}}
 
'''Discussion thread where you can ask questions about these steps''': {{Installation/NoThreadAskForum}}
Line 315: Line 317:
 
<ol>
 
<ol>
 
{{Installation/Linux/SwitchToRoot}}
 
{{Installation/Linux/SwitchToRoot}}
 
+
{{Installation/Linux/AptGetUpdate}}
 
<li>Install the necessary packages:
 
<li>Install the necessary packages:
 
<bash>apt-get install build-essential cmake flex bison zlib1g-dev qt4-dev-tools libqt4-dev libqtwebkit-dev gnuplot \
 
<bash>apt-get install build-essential cmake flex bison zlib1g-dev qt4-dev-tools libqt4-dev libqtwebkit-dev gnuplot \
Line 443: Line 445:
 
<li>{{Installation/Linux/CheckIfAllWentWell}}</li>
 
<li>{{Installation/Linux/CheckIfAllWentWell}}</li>
  
<li>Now you can go read the User Guide: [http://www.openfoam.org/docs/user/ official OpenFOAM User Guide]</li>
+
<li>{{Installation/ReadUserGuideEtAl_OpenFOAMFoundation}}</li>
 
</ol>
 
</ol>
  
Line 451: Line 453:
  
 
'''Discussion thread where you can ask questions about these steps''': {{Installation/NoThreadAskForum}}
 
'''Discussion thread where you can ask questions about these steps''': {{Installation/NoThreadAskForum}}
 
  
 
== Ubuntu 15.10 ==
 
== Ubuntu 15.10 ==
Line 457: Line 458:
  
 
== Ubuntu 16.04 ==
 
== Ubuntu 16.04 ==
 +
Here you have the following choices:
 +
* You can install from source, by either:
 +
** Following the official instructions from here: [http://openfoam.org/download/2-4-0-source/ Download v2.4.0 | Source Pack]
 +
** Or by following the detailed step-by-step instructions below...
 +
  
 
'''Discussion thread where you can ask questions about these steps''': [http://www.cfd-online.com/Forums/openfoam-installation/168746-problems-installing-openfoam-2-4-0-ubuntu-16-04-a.html Problems installing OpenFOAM 2.4.0 on Ubuntu 16.04]
 
'''Discussion thread where you can ask questions about these steps''': [http://www.cfd-online.com/Forums/openfoam-installation/168746-problems-installing-openfoam-2-4-0-ubuntu-16-04-a.html Problems installing OpenFOAM 2.4.0 on Ubuntu 16.04]
Line 463: Line 469:
 
<ol>
 
<ol>
 
{{Installation/Linux/SwitchToRoot}}
 
{{Installation/Linux/SwitchToRoot}}
 
+
{{Installation/Linux/AptGetUpdate}}
 
<li>Install the necessary packages:
 
<li>Install the necessary packages:
 
<bash>apt-get install build-essential binutils-dev cmake flex bison zlib1g-dev qt4-dev-tools libqt4-dev libqtwebkit-dev gnuplot \
 
<bash>apt-get install build-essential binutils-dev cmake flex bison zlib1g-dev qt4-dev-tools libqt4-dev libqtwebkit-dev gnuplot \
Line 597: Line 603:
 
<li>{{Installation/Linux/CheckIfAllWentWell}}</li>
 
<li>{{Installation/Linux/CheckIfAllWentWell}}</li>
  
<li>Now you can go read the User Guide: [http://www.openfoam.org/docs/user/ official OpenFOAM User Guide]</li>
+
<li>{{Installation/ReadUserGuideEtAl_OpenFOAMFoundation}}</li>
 
</ol>
 
</ol>
  
Line 605: Line 611:
  
 
'''Discussion thread where you can ask questions about these steps''': [http://www.cfd-online.com/Forums/openfoam-installation/168746-problems-installing-openfoam-2-4-0-ubuntu-16-04-a.html Problems installing OpenFOAM 2.4.0 on Ubuntu 16.04]
 
'''Discussion thread where you can ask questions about these steps''': [http://www.cfd-online.com/Forums/openfoam-installation/168746-problems-installing-openfoam-2-4-0-ubuntu-16-04-a.html Problems installing OpenFOAM 2.4.0 on Ubuntu 16.04]
 +
 +
 +
== Ubuntu 16.10 ==
 +
Here you have the following choices:
 +
* You can install from source, by either:
 +
** Following the official instructions from here: [http://openfoam.org/download/2-4-0-source/ Download v2.4.0 | Source Pack]
 +
** Or by following the detailed step-by-step instructions below...
 +
 +
 +
'''Discussion thread where you can ask questions about these steps''': [http://www.cfd-online.com/Forums/openfoam-installation/180040-openfoam-2-4-0-error-building-paraview-4-1-0-a.html <nowiki>[OpenFOAM][2.4.0] Error in the building of ParaView 4.1.0</nowiki>]
 +
 +
Steps:
 +
<ol>
 +
{{Installation/Linux/SwitchToRoot}}
 +
{{Installation/Linux/AptGetUpdate}}
 +
<li>Install the necessary packages:
 +
<bash>apt-get install build-essential binutils-dev cmake flex bison zlib1g-dev qt4-dev-tools libqt4-dev libqtwebkit-dev gnuplot \
 +
libreadline-dev libncurses-dev libxt-dev libopenmpi-dev openmpi-bin libboost-system-dev libboost-thread-dev libgmp-dev \
 +
libmpfr-dev python python-dev libcgal-dev gcc-4.7 g++-4.7
 +
</bash>
 +
'''Note''': It has been reported that the following should also be executed in some cases, so that ParaView and CGAL will build properly:
 +
<bash>apt-get install libglu1-mesa-dev libqt4-opengl-dev</bash>
 +
</li>
 +
 +
{{Installation/Linux/ExitRoot}}
 +
 +
<li>Download and unpack (here you can copy-paste all in single go):
 +
<bash>#OpenFOAM downloading and installation
 +
cd ~
 +
mkdir OpenFOAM
 +
cd OpenFOAM
 +
wget "http://downloads.sourceforge.net/foam/OpenFOAM-2.4.0.tgz?use_mirror=mesh" -O OpenFOAM-2.4.0.tgz
 +
wget "http://downloads.sourceforge.net/foam/ThirdParty-2.4.0.tgz?use_mirror=mesh" -O ThirdParty-2.4.0.tgz
 +
 +
tar -xzf OpenFOAM-2.4.0.tgz
 +
tar -xzf ThirdParty-2.4.0.tgz
 +
</bash></li>
 +
 +
<li>'''Optional''': Let's make a few symbolic links that should ensure that the correct global MPI installation is used by this OpenFOAM installation:
 +
<bash>ln -s /usr/bin/mpicc.openmpi OpenFOAM-2.4.0/bin/mpicc
 +
ln -s /usr/bin/mpirun.openmpi OpenFOAM-2.4.0/bin/mpirun</bash>
 +
This way we avoid having problems in case there is more than one MPI toolbox installed in your Ubuntu system, for example if MPICH2 is installed and is the default MPI toolbox.
 +
</li>
 +
 +
<li>Since we are going to use CGAL 4.8.1 and Boost 1.61 that comes with Ubuntu, we are going to configure accordingly by running:
 +
<bash>sed -i -e 's/^\(cgal_version=\).*/\1cgal-system/' OpenFOAM-2.4.0/etc/config/CGAL.sh
 +
sed -i -e 's=\(-lmpfr\)$=\1 -lboost_thread=' OpenFOAM-2.4.0/wmake/rules/General/CGAL</bash>
 +
</li>
 +
 +
<li>We will be using GCC 4.7, because 6.x is not compatible with OpenFOAM 2.4, as explained [http://www.cfd-online.com/Forums/openfoam-installation/180040-openfoam-2-4-0-error-building-paraview-4-1-0-a.html#post627619 here]. Therefore, we need to do a couple more changes, to ensure it works as intended:
 +
<bash>sed -i -e 's/gcc/gcc-4.7/' OpenFOAM-2.4.0/wmake/rules/linux64Gcc47/c
 +
sed -i -e 's/g++/g++-4.7/' OpenFOAM-2.4.0/wmake/rules/linux64Gcc47/c++
 +
echo "export WM_CC='gcc-4.7'" >> OpenFOAM-2.4.0/etc/bashrc
 +
echo "export WM_CXX='g++-4.7'" >> OpenFOAM-2.4.0/etc/bashrc
 +
</bash>
 +
</li>
 +
 +
<li>For building OpenFOAM itself, it depends on whether you have installed the i686 or x86_64 architecture of Ubuntu. To check this, run:
 +
<bash>uname -m</bash>
 +
Now, accordingly:
 +
<ul {{NoIndentStyle}}>
 +
<li>For i686:
 +
<bash>#here you can change 4 to the number of cores you've got
 +
source $HOME/OpenFOAM/OpenFOAM-2.4.0/etc/bashrc WM_NCOMPPROCS=4 WM_ARCH_OPTION=32 WM_COMPILER=Gcc47
 +
</bash></li>
 +
 +
<li>For x86_64:
 +
<bash>#here you can change 4 to the number of cores you've got
 +
source $HOME/OpenFOAM/OpenFOAM-2.4.0/etc/bashrc WM_NCOMPPROCS=4 WM_COMPILER=Gcc47
 +
</bash>
 +
</li>
 +
</ul>
 +
</li>
 +
 +
<li>Save an ''alias'' in the personal {{tt|.bashrc}} file, simply by running the following command:
 +
<bash>echo "alias of240='source \$HOME/OpenFOAM/OpenFOAM-2.4.0/etc/bashrc $FOAM_SETTINGS'" >> $HOME/.bashrc
 +
</bash>
 +
{{Installation/Linux/AliasNote|OpenFOAM 2.4.0|of240}}
 +
</li>
 +
 +
<li>Now, in order to build ParaView 4.1.0 that comes with OpenFOAM, including with the ability to use Python and MPI, several steps are needed:
 +
<ol>
 +
<li>First go into the 3rd party folder and make very certain that the correct Qt version is being used, by running this command:
 +
<bash>cd $WM_THIRD_PARTY_DIR
 +
 +
export QT_SELECT=qt4</bash>
 +
</li>
 +
<li>Then we need to do several fixes:
 +
<bash>sed -i -e 's=//#define GLX_GLXEXT_LEGACY=#define GLX_GLXEXT_LEGACY=' \
 +
  ParaView-4.1.0/VTK/Rendering/OpenGL/vtkXOpenGLRenderWindow.cxx
 +
 +
cd $WM_THIRD_PARTY_DIR/ParaView-4.1.0
 +
 +
wget http://www.paraview.org/pipermail/paraview/attachments/20140210/464496cc/attachment.bin -O Fix.patch
 +
patch -p1 < Fix.patch
 +
 +
cd VTK
 +
wget https://github.com/gladk/VTK/commit/ef22d3d69421581b33bc0cd94b647da73b61ba96.patch -O Fix2.patch
 +
patch -p1 < Fix2.patch
 +
 +
cd ../..
 +
</bash>
 +
</li>
 +
<li>For building ParaView with Python and MPI, it depends on whether you have installed the i686 or x86_64 architecture of Ubuntu. To check this, run:
 +
<bash>uname -m</bash>
 +
Now, accordingly:
 +
<ul {{NoIndentStyle}}>
 +
<li>For i686:
 +
<bash>#this will take a while... somewhere between 30 minutes to 2 hours or more
 +
./makeParaView4 -python -mpi -python-lib /usr/lib/i386-linux-gnu/libpython2.7.so.1.0 > log.makePV 2>&1</bash>
 +
</li>
 +
 +
<li>For x86_64:
 +
<bash>#this will take a while... somewhere between 30 minutes to 2 hours or more
 +
./makeParaView4 -python -mpi -python-lib /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0 > log.makePV 2>&1</bash>
 +
</li>
 +
</ul>
 +
</li>
 +
<li>Once the {{tt|makeParaView4}} script is finished running, make sure to check the contents of the file {{tt|log.makePV}} and check if there are any errors.
 +
</li>
 +
<li>Finally, update the shell environment:
 +
<bash>wmSET $FOAM_SETTINGS</bash>
 +
</li>
 +
</ol>
 +
</li>
 +
 +
<li>Now, before we can build OpenFOAM, we need to do a few fixes:
 +
<bash>#Go into OpenFOAM's main source folder
 +
cd $WM_PROJECT_DIR
 +
 +
#Change how the flex version is checked
 +
find src applications -name "*.L" -type f | xargs sed -i -e 's=\(YY\_FLEX\_SUBMINOR\_VERSION\)=YY_FLEX_MINOR_VERSION < 6 \&\& \1='
 +
</bash>
 +
</li>
 +
 +
<li>Now, let's simply create empty folders for the Boost and CGAL installation paths:
 +
<bash>mkdir -p $CGAL_ARCH_PATH
 +
mkdir -p $BOOST_ARCH_PATH</bash>
 +
</li>
 +
 +
<li>Now let's build OpenFOAM:<br>
 +
('''Warning''': this may take somewhere from 30 minutes to 6 hours, depending on your machine.)<br>
 +
<bash>#Go into OpenFOAM's main source folder
 +
cd $WM_PROJECT_DIR
 +
 +
#Still better be certain that the correct Qt version is being used
 +
export QT_SELECT=qt4
 +
 +
# This next command will take a while... somewhere between 30 minutes to 3-6 hours.
 +
./Allwmake > log.make 2>&1
 +
 +
#Run it a second time for getting a summary of the installation
 +
./Allwmake > log.make 2>&1
 +
</bash></li>
 +
 +
<li>{{Installation/Linux/CheckIfAllWentWell}}</li>
 +
 +
<li>{{Installation/ReadUserGuideEtAl_OpenFOAMFoundation}}</li>
 +
</ol>
 +
 +
 +
{{Installation/Linux/AliasReminder|OpenFOAM 2.4.0|of240}}
 +
 +
 +
'''Discussion thread where you can ask questions about these steps''': [http://www.cfd-online.com/Forums/openfoam-installation/180040-openfoam-2-4-0-error-building-paraview-4-1-0-a.html <nowiki>[OpenFOAM][2.4.0] Error in the building of ParaView 4.1.0</nowiki>]
 +
 +
 +
== Ubuntu 18.04 ==
 +
Here you have the following choices:
 +
* You can install from source, by either:
 +
** Following the official instructions from here: [http://openfoam.org/download/2-4-0-source/ Download v2.4.0 | Source Pack]
 +
** Or by following the detailed step-by-step instructions below...
 +
 +
 +
'''Discussion thread where you can ask questions about these steps''': [https://www.cfd-online.com/Forums/openfoam-installation/217507-install-openfoam-2-4-0-ubuntu-18-04-a.html Install OpenFOAM-2.4.0 in Ubuntu 18.04?]
 +
 +
Steps:
 +
<ol>
 +
{{Installation/Linux/SwitchToRoot}}
 +
{{Installation/Linux/AptGetUpdate}}
 +
<li>Install the necessary packages:
 +
<bash>apt-get install build-essential cmake flex bison zlib1g-dev qt4-dev-tools libqt4-dev libqtwebkit-dev gnuplot \
 +
libreadline-dev libncurses5-dev libxt-dev libopenmpi-dev openmpi-bin libboost-system-dev libboost-thread-dev libgmp-dev \
 +
libmpfr-dev python python-dev libcgal-dev gcc-5 g++-5
 +
</bash>
 +
'''Note''': It has been reported that the following should also be executed in some cases, so that ParaView and CGAL will build properly:
 +
<bash>apt-get install libglu1-mesa-dev libqt4-opengl-dev</bash>
 +
</li>
 +
 +
{{Installation/Linux/ExitRoot}}
 +
 +
<li>Download and unpack (here you can copy-paste all in single go):
 +
<bash>#OpenFOAM downloading and installation
 +
cd ~
 +
mkdir OpenFOAM
 +
cd OpenFOAM
 +
wget "http://downloads.sourceforge.net/foam/OpenFOAM-2.4.0.tgz?use_mirror=mesh" -O OpenFOAM-2.4.0.tgz
 +
wget "http://downloads.sourceforge.net/foam/ThirdParty-2.4.0.tgz?use_mirror=mesh" -O ThirdParty-2.4.0.tgz
 +
 +
tar -xzf OpenFOAM-2.4.0.tgz
 +
tar -xzf ThirdParty-2.4.0.tgz
 +
</bash></li>
 +
 +
<li>'''Optional''': Let's make a few symbolic links that should ensure that the correct global MPI installation is used by this OpenFOAM installation:
 +
<bash>ln -s /usr/bin/mpicc.openmpi OpenFOAM-2.4.0/bin/mpicc
 +
ln -s /usr/bin/mpirun.openmpi OpenFOAM-2.4.0/bin/mpirun</bash>
 +
This way we avoid having problems in case there is more than one MPI toolbox installed in your Ubuntu system, for example if MPICH2 is installed and is the default MPI toolbox.
 +
</li>
 +
 +
<li>A few details need to be fixed, before proceeding, which will change the default Boost and CGAL versions, to then use the ones provided by Ubuntu, along with a few GCC version changes:
 +
<bash>sed -i -e 's/\(cgal_version=\)CGAL-4.6/\1cgal-system/' OpenFOAM-2.4.0/etc/config/CGAL.sh
 +
sed -i -e 's=\-lmpfr=-lmpfr -lboost_thread=' OpenFOAM-2.4.0/wmake/rules/General/CGAL
 +
 +
sed -i -e 's/gcc/\$(WM_CC)/' OpenFOAM-2.4.0/wmake/rules/linux*Gcc/c
 +
sed -i -e 's/g++/\$(WM_CXX)/' OpenFOAM-2.4.0/wmake/rules/linux*Gcc/c++
 +
</bash>
 +
</li>
 +
 +
<li>For building OpenFOAM itself, it depends on whether you have installed the i686 or x86_64 architecture of Ubuntu. To check this, run:
 +
<bash>uname -m</bash>
 +
Now, accordingly:
 +
<ul {{NoIndentStyle}}>
 +
<li>For i686:
 +
<bash>#here you can change 4 to the number of cores you've got
 +
source $HOME/OpenFOAM/OpenFOAM-2.4.0/etc/bashrc WM_NCOMPPROCS=4 WM_MPLIB=SYSTEMOPENMPI WM_ARCH_OPTION=32
 +
export WM_CC='gcc-5'
 +
export WM_CXX='g++-5'
 +
</bash></li>
 +
 +
<li>For x86_64:
 +
<bash>#here you can change 4 to the number of cores you've got
 +
source $HOME/OpenFOAM/OpenFOAM-2.4.0/etc/bashrc WM_NCOMPPROCS=4 WM_MPLIB=SYSTEMOPENMPI
 +
export WM_CC='gcc-5'
 +
export WM_CXX='g++-5'
 +
</bash>
 +
</li>
 +
</ul>
 +
</li>
 +
 +
<li>Save an ''alias'' in the personal {{tt|.bashrc}} file, simply by running the following command:
 +
<bash>echo "alias of240='source \$HOME/OpenFOAM/OpenFOAM-2.4.0/etc/bashrc $FOAM_SETTINGS; export WM_CC=gcc-5; export WM_CXX=g++-5'" >> $HOME/.bashrc
 +
</bash>
 +
{{Installation/Linux/AliasNote|OpenFOAM 2.4.0|of240}}
 +
<ul  {{NoIndentStyle}}><li>Just in case, also ''source'' that file, so that you can use {{tt|of240}} in this terminal if necessary, by running:
 +
<bash>source $HOME/.bashrc</bash>
 +
</li></ul>
 +
</li>
 +
 +
<li>Now let's build the {{tt|ThirdParty}} folder, because we need the shell environment to be updated afterwards, for CGAL to be properly picked up for building OpenFOAM:
 +
<bash>cd $WM_THIRD_PARTY_DIR
 +
 +
#make very certain that the correct Qt version is being used, by running this command:
 +
export QT_SELECT=qt4
 +
 +
# Fix issue regarding not wanting to build CGAL
 +
sed -i -e 's|\(^if.*CGAL_ARCH_PATH.*\)]|\1 -a "${CGAL_ARCH_PATH##*/}" != "cgal-system" ]|' Allwmake
 +
 +
# This next command will take a while... somewhere between 5 minutes to 30 minutes.
 +
./Allwmake > log.make 2>&1
 +
 +
#update the shell environment
 +
of240
 +
</bash>
 +
</li>
 +
 +
<li>Now, in order to build ParaView 4.1.0 that comes with OpenFOAM, including with the ability to use Python and MPI, several steps are needed:
 +
<ol>
 +
<li>First make very certain that the correct Qt version is being used, by running this command:
 +
<bash>export QT_SELECT=qt4</bash>
 +
</li>
 +
<li>Need to do several fixes:
 +
<bash>cd $WM_THIRD_PARTY_DIR
 +
 +
sed -i -e 's=MPI_ARCH_PATH/include=MPI_ARCH_PATH/include;$MPI_INCLUDE=' etc/tools/ParaView4Functions
 +
 +
sed -i -e 's=//#define GLX_GLXEXT_LEGACY=#define GLX_GLXEXT_LEGACY=' \
 +
  ParaView-4.1.0/VTK/Rendering/OpenGL/vtkXOpenGLRenderWindow.cxx
 +
 +
cd $WM_THIRD_PARTY_DIR/ParaView-4.1.0
 +
 +
wget http://www.paraview.org/pipermail/paraview/attachments/20140210/464496cc/attachment.bin -O Fix.patch
 +
patch -p1 < Fix.patch
 +
 +
cd VTK
 +
wget https://github.com/gladk/VTK/commit/ef22d3d69421581b33bc0cd94b647da73b61ba96.patch -O Fix2.patch
 +
patch -p1 < Fix2.patch
 +
 +
cd ../..
 +
</bash>
 +
</li>
 +
<li>For building ParaView with Python and MPI, it depends on whether you have installed the i686 or x86_64 architecture of Ubuntu. To check this, run:
 +
<bash>uname -m</bash>
 +
Now, accordingly:
 +
<ul {{NoIndentStyle}}>
 +
<li>For i686:
 +
<bash>#this will take a while... somewhere between 30 minutes to 2 hours or more
 +
./makeParaView4 -python -mpi -python-lib /usr/lib/i386-linux-gnu/libpython2.7.so.1.0 > log.makePV 2>&1</bash>
 +
</li>
 +
 +
<li>For x86_64:
 +
<bash>#this will take a while... somewhere between 30 minutes to 2 hours or more
 +
./makeParaView4 -python -mpi -python-lib /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0 > log.makePV 2>&1</bash>
 +
</li>
 +
</ul>
 +
</li>
 +
<li>Once the {{tt|makeParaView4}} script is finished running, make sure to check the contents of the file {{tt|log.makePV}} and check if there are any errors.
 +
</li>
 +
<li>Finally, update the shell environment:
 +
<bash>of240</bash>
 +
</li>
 +
</ol>
 +
</li>
 +
 +
<li>Now, before we can build OpenFOAM, we need to do a few fixes:
 +
<bash>#Go into OpenFOAM's main source folder
 +
cd $WM_PROJECT_DIR
 +
 +
#Change how the flex version is checked
 +
find src applications -name "*.L" -type f | xargs sed -i -e 's=\(YY\_FLEX\_SUBMINOR\_VERSION\)=YY_FLEX_MINOR_VERSION < 6 \&\& \1='
 +
</bash>
 +
</li>
 +
 +
<li>Now let's build OpenFOAM:<br>
 +
('''Warning''': this may take somewhere from 30 minutes to 6 hours, depending on your machine.)<br>
 +
<bash>#Go into OpenFOAM's main source folder
 +
cd $WM_PROJECT_DIR
 +
 +
#Still better be certain that the correct Qt version is being used
 +
export QT_SELECT=qt4
 +
 +
# This next command will take a while... somewhere between 30 minutes to 3-6 hours.
 +
./Allwmake > log.make 2>&1
 +
 +
#Run it a second time for getting a summary of the installation
 +
./Allwmake > log.make 2>&1
 +
</bash></li>
 +
 +
<li>{{Installation/Linux/CheckIfAllWentWell}}</li>
 +
 +
<li>{{Installation/ReadUserGuideEtAl_OpenFOAMFoundation}}</li>
 +
</ol>
 +
 +
 +
{{Installation/Linux/AliasReminder|OpenFOAM 2.4.0|of240}}
 +
 +
 +
'''Discussion thread where you can ask questions about these steps''': [https://www.cfd-online.com/Forums/openfoam-installation/217507-install-openfoam-2-4-0-ubuntu-18-04-a.html Install OpenFOAM-2.4.0 in Ubuntu 18.04?]
 +
 +
<br>
  
  
 
[[Category:Installing OpenFOAM on Linux]] [[Category:Installing OpenFOAM on Ubuntu]]
 
[[Category:Installing OpenFOAM on Linux]] [[Category:Installing OpenFOAM on Ubuntu]]

Latest revision as of 17:01, 18 May 2019

1 Introduction

This page is dedicated to explaining how to install OpenFOAM OF Version 240.png in Ubuntu.

If you do not yet feel comfortable using Linux, then perhaps you better first read the page Working with the Shell and train a bit with the shell/terminal environments, so you can have a better perception of the steps shown below.


2 Copy-Paste steps

A few notes before you start copy-pasting:

  1. Lines that start with # don't have to be copy-pasted. They are just comments to let you know what's going on.
  2. One wrong character is enough for breaking this guide, so make sure you can read the characters properly or that the installed language system does not break the copied characters!

2.1 Ubuntu 12.04

Here you have at least two choices:

  • You can install from source, by either:


Discussion thread where you can ask questions about these steps: No thread available. Please a create a new thread in the forum.

Steps:

  1. Switch to root mode (administrator), to install the necessary packages:
    sudo -s
    • If the 'sudo' command tells you're not in the sudoers list, then run:
      su -
  2. Update the apt-get cache by running:
    apt-get update
  3. Install the necessary packages:
    apt-get install build-essential flex bison zlib1g-dev qt4-dev-tools libqt4-dev gnuplot libreadline-dev \
    libncurses-dev libxt-dev libopenmpi-dev openmpi-bin libboost-system-dev libboost-thread-dev libgmp-dev libmpfr-dev \
    python python-dev

    Note: It has been reported that the following should also be executed in some cases, so that ParaView and CGAL will build properly:

    apt-get install libglu1-mesa-dev libqt4-opengl-dev
  4. Now exit from the root mode:
    exit
  5. Download and unpack (here you can copy-paste all in single go):
    #OpenFOAM downloading and installation
    cd ~
    mkdir OpenFOAM
    cd OpenFOAM
    wget "http://downloads.sourceforge.net/foam/OpenFOAM-2.4.0.tgz?use_mirror=mesh" -O OpenFOAM-2.4.0.tgz
    wget "http://downloads.sourceforge.net/foam/ThirdParty-2.4.0.tgz?use_mirror=mesh" -O ThirdParty-2.4.0.tgz
     
    tar -xzf OpenFOAM-2.4.0.tgz 
    tar -xzf ThirdParty-2.4.0.tgz
  6. Optional: Let's make a few symbolic links that should ensure that the correct global MPI installation is used by this OpenFOAM installation:
    ln -s /usr/bin/mpicc.openmpi OpenFOAM-2.4.0/bin/mpicc
    ln -s /usr/bin/mpirun.openmpi OpenFOAM-2.4.0/bin/mpirun

    This way we avoid having problems in case there is more than one MPI toolbox installed in your Ubuntu system, for example if MPICH2 is installed and is the default MPI toolbox.

  7. For building OpenFOAM itself, it depends on whether you have installed the i686 or x86_64 architecture of Ubuntu. To check this, run:
    uname -m

    Now, accordingly:

    • For i686:
      #here you can change 4 to the number of cores you've got
      source $HOME/OpenFOAM/OpenFOAM-2.4.0/etc/bashrc WM_NCOMPPROCS=4 WM_ARCH_OPTION=32
    • For x86_64:
      #here you can change 4 to the number of cores you've got
      source $HOME/OpenFOAM/OpenFOAM-2.4.0/etc/bashrc WM_NCOMPPROCS=4
  8. Save an alias in the personal .bashrc file, simply by running the following command:
    echo "alias of240='source \$HOME/OpenFOAM/OpenFOAM-2.4.0/etc/bashrc $FOAM_SETTINGS'" >> $HOME/.bashrc
    Note: This last line means that whenever you start a new terminal window or tab, you should run the alias command associated to the OpenFOAM 2.4.0 shell environment. In other words, whenever you start a new terminal, you should run:
    of240
    
    For more information on this topic, read section Using aliases to help manage multiple OpenFOAM versions in the page Installation/Working with the Shell.
  9. Ubuntu 12.04 comes with CMake 2.8.7, but ParaView 4.1.0 needs CMake 2.8.8 or newer series; CGAL also needs CMake. Therefore, we'll need to do a custom build:
    cd $WM_THIRD_PARTY_DIR
    ./makeCmake > log.makeCM 2>&1
    wmSET $FOAM_SETTINGS
  10. Now let's build the ThirdParty folder, because we need the shell environment to be updated afterwards, for CGAL to be properly picked up for building OpenFOAM:
    cd $WM_THIRD_PARTY_DIR
     
    # This next command will take a while... somewhere between 5 minutes to 30 minutes.
    ./Allwmake > log.make 2>&1
     
    #update the shell environment
    wmSET $FOAM_SETTINGS
  11. Now, in order to build ParaView 4.1.0 that comes with OpenFOAM, including with the ability to use Python and MPI, several steps are needed:
    1. Need to do several fixes:
      sed -i -e 's=//#define GLX_GLXEXT_LEGACY=#define GLX_GLXEXT_LEGACY=' \
        ParaView-4.1.0/VTK/Rendering/OpenGL/vtkXOpenGLRenderWindow.cxx
       
      cd $WM_THIRD_PARTY_DIR/ParaView-4.1.0
       
      wget http://www.paraview.org/pipermail/paraview/attachments/20140210/464496cc/attachment.bin -O Fix.patch
      patch -p1 < Fix.patch
       
      cd VTK
      wget https://github.com/gladk/VTK/commit/ef22d3d69421581b33bc0cd94b647da73b61ba96.patch -O Fix2.patch
      patch -p1 < Fix2.patch
       
      cd ../..
    2. For building ParaView with Python and MPI, run:
      #this will take a while... somewhere between 30 minutes to 2 hours or more
      ./makeParaView4 -python -mpi -python-lib /usr/lib/libpython2.7.so.1.0 > log.makePV 2>&1
    3. Once the makeParaView4 script is finished running, make sure to check the contents of the file log.makePV and check if there are any errors.
    4. Finally, update the shell environment:
      wmSET $FOAM_SETTINGS
  12. Now let's build OpenFOAM:
    (Warning: this may take somewhere from 30 minutes to 6 hours, depending on your machine.)
    #Go into OpenFOAM's main source folder
    cd $WM_PROJECT_DIR
     
    # This next command will take a while... somewhere between 30 minutes to 3-6 hours.
    ./Allwmake > log.make 2>&1
     
    #Run it a second time for getting a summary of the installation
    ./Allwmake > log.make 2>&1
  13. To check if everything went well:
    1. Check if icoFoam is working, by running this command:
      icoFoam -help

      which should tell you something like this:

      Usage: icoFoam [OPTIONS]
      options:
        -case <dir>       specify alternate case directory, default is the cwd
        -noFunctionObjects
                          do not execute functionObjects
        -parallel         run in parallel
        -roots <(dir1 .. dirN)>
                          slave root directories for distributed running
        -srcDoc           display source code in browser
        -doc              display application documentation in browser
        -help             print the usage

      Note: And keep in mind that you need to be careful with the letter case of the command. It's icoFoam, not icoFOAM.

    2. If the previous command failed to work properly, then edit the file log.make and check if there are any error messages. A few examples on how you can edit this file:
      • By using kwrite:
        kwrite log.make
      • By using gedit:
        gedit log.make
      • By using nano:
        nano log.make

        You can then exit by using the key combination Ctrl+X and following any instructions it gives you.

      Note: It's the first error message that matters.

    3. If you don't understand the output, then please compress the log-file log.make and attach the compressed file to a post in the designated thread.
      If you do not know how to create a compressed file, then try one of the following examples:
      • You can compress the file with gzip by running this command:
        gzip < log.make > log.make.gz

        Then attach the resulting package file named log.make.gz to a post in the designated thread.

      • Or you can compress one or more log-files into a tarball package file, by running this command:
        tar -czf logs.tar.gz log.*

        Then attach the resulting package file named logs.tar.gz to a post in the designated thread.

    4. Instructions on how to further diagnose the issue yourself, have a look at the section Common errors when building OpenFOAM from source code in the page FAQ/Installation and Running.
  14. Now you can go read the User Guide, where you may have more than one choice:
    1. Which you can find a local copy of the User Guide by running the following command:
      ls -A1 $WM_PROJECT_DIR/doc/Guides*/*UserGuide*.pdf
      • You should see two available formats: A4 and US-Letter.
      • But if it instead tells you that there is No such file or directory, then the OpenFOAM environment is possibly not properly activated.
    2. You can also find the more recent OpenFOAM Foundation User Guides online at the following page: official OpenFOAM User Guide - but be careful if you use the version that is too much ahead of the version you are currently using, given that some features have changed overtime.


Reminder: Whenever you start a new terminal window or tab, you should run the alias command associated to the OpenFOAM 2.4.0 shell environment. In other words, run the following command whenever you start a new terminal:
of240
For more information on this topic, read section Using aliases to help manage multiple OpenFOAM versions in the page Installation/Working with the Shell.


Discussion thread where you can ask questions about these steps: No thread available. Please a create a new thread in the forum.

2.2 Ubuntu 14.04

Here you have the following choices:


Discussion thread where you can ask questions about these steps: No thread available. Please a create a new thread in the forum.

Steps:

  1. Switch to root mode (administrator), to install the necessary packages:
    sudo -s
    • If the 'sudo' command tells you're not in the sudoers list, then run:
      su -
  2. Update the apt-get cache by running:
    apt-get update
  3. Install the necessary packages:
    apt-get install build-essential cmake flex bison zlib1g-dev qt4-dev-tools libqt4-dev libqtwebkit-dev gnuplot \
    libreadline-dev libncurses-dev libxt-dev libopenmpi-dev openmpi-bin libboost-system-dev libboost-thread-dev libgmp-dev \
    libmpfr-dev python python-dev

    Note: It has been reported that the following should also be executed in some cases, so that ParaView and CGAL will build properly:

    apt-get install libglu1-mesa-dev libqt4-opengl-dev
  4. Now exit from the root mode:
    exit
  5. Download and unpack (here you can copy-paste all in single go):
    #OpenFOAM downloading and installation
    cd ~
    mkdir OpenFOAM
    cd OpenFOAM
    wget "http://downloads.sourceforge.net/foam/OpenFOAM-2.4.0.tgz?use_mirror=mesh" -O OpenFOAM-2.4.0.tgz
    wget "http://downloads.sourceforge.net/foam/ThirdParty-2.4.0.tgz?use_mirror=mesh" -O ThirdParty-2.4.0.tgz
     
    tar -xzf OpenFOAM-2.4.0.tgz 
    tar -xzf ThirdParty-2.4.0.tgz
  6. Optional: Let's make a few symbolic links that should ensure that the correct global MPI installation is used by this OpenFOAM installation:
    ln -s /usr/bin/mpicc.openmpi OpenFOAM-2.4.0/bin/mpicc
    ln -s /usr/bin/mpirun.openmpi OpenFOAM-2.4.0/bin/mpirun

    This way we avoid having problems in case there is more than one MPI toolbox installed in your Ubuntu system, for example if MPICH2 is installed and is the default MPI toolbox.

  7. For building OpenFOAM itself, it depends on whether you have installed the i686 or x86_64 architecture of Ubuntu. To check this, run:
    uname -m

    Now, accordingly:

    • For i686:
      #here you can change 4 to the number of cores you've got
      source $HOME/OpenFOAM/OpenFOAM-2.4.0/etc/bashrc WM_NCOMPPROCS=4 WM_ARCH_OPTION=32
    • For x86_64:
      #here you can change 4 to the number of cores you've got
      source $HOME/OpenFOAM/OpenFOAM-2.4.0/etc/bashrc WM_NCOMPPROCS=4
  8. Save an alias in the personal .bashrc file, simply by running the following command:
    echo "alias of240='source \$HOME/OpenFOAM/OpenFOAM-2.4.0/etc/bashrc $FOAM_SETTINGS'" >> $HOME/.bashrc
    Note: This last line means that whenever you start a new terminal window or tab, you should run the alias command associated to the OpenFOAM 2.4.0 shell environment. In other words, whenever you start a new terminal, you should run:
    of240
    
    For more information on this topic, read section Using aliases to help manage multiple OpenFOAM versions in the page Installation/Working with the Shell.
  9. Now let's build the ThirdParty folder, because we need the shell environment to be updated afterwards, for CGAL to be properly picked up for building OpenFOAM:
    cd $WM_THIRD_PARTY_DIR
     
    #make very certain that the correct Qt version is being used, by running this command:
    export QT_SELECT=qt4
     
    # This next command will take a while... somewhere between 5 minutes to 30 minutes.
    ./Allwmake > log.make 2>&1
     
    #update the shell environment
    wmSET $FOAM_SETTINGS
  10. Now, in order to build ParaView 4.1.0 that comes with OpenFOAM, including with the ability to use Python and MPI, several steps are needed:
    1. First make very certain that the correct Qt version is being used, by running this command:
      export QT_SELECT=qt4
    2. Need to do several fixes:
      sed -i -e 's=//#define GLX_GLXEXT_LEGACY=#define GLX_GLXEXT_LEGACY=' \
        ParaView-4.1.0/VTK/Rendering/OpenGL/vtkXOpenGLRenderWindow.cxx
       
      cd $WM_THIRD_PARTY_DIR/ParaView-4.1.0
       
      wget http://www.paraview.org/pipermail/paraview/attachments/20140210/464496cc/attachment.bin -O Fix.patch
      patch -p1 < Fix.patch
       
      cd VTK
      wget https://github.com/gladk/VTK/commit/ef22d3d69421581b33bc0cd94b647da73b61ba96.patch -O Fix2.patch
      patch -p1 < Fix2.patch
       
      cd ../..
    3. For building ParaView with Python and MPI, it depends on whether you have installed the i686 or x86_64 architecture of Ubuntu. To check this, run:
      uname -m

      Now, accordingly:

      • For i686:
        #this will take a while... somewhere between 30 minutes to 2 hours or more
        ./makeParaView4 -python -mpi -python-lib /usr/lib/i386-linux-gnu/libpython2.7.so.1.0 > log.makePV 2>&1
      • For x86_64:
        #this will take a while... somewhere between 30 minutes to 2 hours or more
        ./makeParaView4 -python -mpi -python-lib /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0 > log.makePV 2>&1
    4. Once the makeParaView4 script is finished running, make sure to check the contents of the file log.makePV and check if there are any errors.
    5. Finally, update the shell environment:
      wmSET $FOAM_SETTINGS
  11. Now let's build OpenFOAM:
    (Warning: this may take somewhere from 30 minutes to 6 hours, depending on your machine.)
    #Go into OpenFOAM's main source folder
    cd $WM_PROJECT_DIR
     
    #Still better be certain that the correct Qt version is being used
    export QT_SELECT=qt4
     
    # This next command will take a while... somewhere between 30 minutes to 3-6 hours.
    ./Allwmake > log.make 2>&1
     
    #Run it a second time for getting a summary of the installation
    ./Allwmake > log.make 2>&1
  12. To check if everything went well:
    1. Check if icoFoam is working, by running this command:
      icoFoam -help

      which should tell you something like this:

      Usage: icoFoam [OPTIONS]
      options:
        -case <dir>       specify alternate case directory, default is the cwd
        -noFunctionObjects
                          do not execute functionObjects
        -parallel         run in parallel
        -roots <(dir1 .. dirN)>
                          slave root directories for distributed running
        -srcDoc           display source code in browser
        -doc              display application documentation in browser
        -help             print the usage

      Note: And keep in mind that you need to be careful with the letter case of the command. It's icoFoam, not icoFOAM.

    2. If the previous command failed to work properly, then edit the file log.make and check if there are any error messages. A few examples on how you can edit this file:
      • By using kwrite:
        kwrite log.make
      • By using gedit:
        gedit log.make
      • By using nano:
        nano log.make

        You can then exit by using the key combination Ctrl+X and following any instructions it gives you.

      Note: It's the first error message that matters.

    3. If you don't understand the output, then please compress the log-file log.make and attach the compressed file to a post in the designated thread.
      If you do not know how to create a compressed file, then try one of the following examples:
      • You can compress the file with gzip by running this command:
        gzip < log.make > log.make.gz

        Then attach the resulting package file named log.make.gz to a post in the designated thread.

      • Or you can compress one or more log-files into a tarball package file, by running this command:
        tar -czf logs.tar.gz log.*

        Then attach the resulting package file named logs.tar.gz to a post in the designated thread.

    4. Instructions on how to further diagnose the issue yourself, have a look at the section Common errors when building OpenFOAM from source code in the page FAQ/Installation and Running.
  13. Now you can go read the User Guide, where you may have more than one choice:
    1. Which you can find a local copy of the User Guide by running the following command:
      ls -A1 $WM_PROJECT_DIR/doc/Guides*/*UserGuide*.pdf
      • You should see two available formats: A4 and US-Letter.
      • But if it instead tells you that there is No such file or directory, then the OpenFOAM environment is possibly not properly activated.
    2. You can also find the more recent OpenFOAM Foundation User Guides online at the following page: official OpenFOAM User Guide - but be careful if you use the version that is too much ahead of the version you are currently using, given that some features have changed overtime.


Reminder: Whenever you start a new terminal window or tab, you should run the alias command associated to the OpenFOAM 2.4.0 shell environment. In other words, run the following command whenever you start a new terminal:
of240
For more information on this topic, read section Using aliases to help manage multiple OpenFOAM versions in the page Installation/Working with the Shell.


Discussion thread where you can ask questions about these steps: No thread available. Please a create a new thread in the forum.

2.3 Ubuntu 15.04

Here you have the following choices:


Discussion thread where you can ask questions about these steps: No thread available. Please a create a new thread in the forum.

Steps:

  1. Switch to root mode (administrator), to install the necessary packages:
    sudo -s
    • If the 'sudo' command tells you're not in the sudoers list, then run:
      su -
  2. Update the apt-get cache by running:
    apt-get update
  3. Install the necessary packages:
    apt-get install build-essential cmake flex bison zlib1g-dev qt4-dev-tools libqt4-dev libqtwebkit-dev gnuplot \
    libreadline-dev libncurses5-dev libxt-dev libopenmpi-dev openmpi-bin libboost-system-dev libboost-thread-dev libgmp-dev \
    libmpfr-dev python python-dev

    Note: It has been reported that the following should also be executed in some cases, so that ParaView and CGAL will build properly:

    apt-get install libglu1-mesa-dev libqt4-opengl-dev
  4. Now exit from the root mode:
    exit
  5. Download and unpack (here you can copy-paste all in single go):
    #OpenFOAM downloading and installation
    cd ~
    mkdir OpenFOAM
    cd OpenFOAM
    wget "http://downloads.sourceforge.net/foam/OpenFOAM-2.4.0.tgz?use_mirror=mesh" -O OpenFOAM-2.4.0.tgz
    wget "http://downloads.sourceforge.net/foam/ThirdParty-2.4.0.tgz?use_mirror=mesh" -O ThirdParty-2.4.0.tgz
     
    tar -xzf OpenFOAM-2.4.0.tgz 
    tar -xzf ThirdParty-2.4.0.tgz
  6. Optional: Let's make a few symbolic links that should ensure that the correct global MPI installation is used by this OpenFOAM installation:
    ln -s /usr/bin/mpicc.openmpi OpenFOAM-2.4.0/bin/mpicc
    ln -s /usr/bin/mpirun.openmpi OpenFOAM-2.4.0/bin/mpirun

    This way we avoid having problems in case there is more than one MPI toolbox installed in your Ubuntu system, for example if MPICH2 is installed and is the default MPI toolbox.

  7. For building OpenFOAM itself, it depends on whether you have installed the i686 or x86_64 architecture of Ubuntu. To check this, run:
    uname -m

    Now, accordingly:

    • For i686:
      #here you can change 4 to the number of cores you've got
      source $HOME/OpenFOAM/OpenFOAM-2.4.0/etc/bashrc WM_NCOMPPROCS=4 WM_ARCH_OPTION=32
    • For x86_64:
      #here you can change 4 to the number of cores you've got
      source $HOME/OpenFOAM/OpenFOAM-2.4.0/etc/bashrc WM_NCOMPPROCS=4
  8. Save an alias in the personal .bashrc file, simply by running the following command:
    echo "alias of240='source \$HOME/OpenFOAM/OpenFOAM-2.4.0/etc/bashrc $FOAM_SETTINGS'" >> $HOME/.bashrc
    Note: This last line means that whenever you start a new terminal window or tab, you should run the alias command associated to the OpenFOAM 2.4.0 shell environment. In other words, whenever you start a new terminal, you should run:
    of240
    
    For more information on this topic, read section Using aliases to help manage multiple OpenFOAM versions in the page Installation/Working with the Shell.
  9. Now let's build the ThirdParty folder, because we need the shell environment to be updated afterwards, for CGAL to be properly picked up for building OpenFOAM:
    cd $WM_THIRD_PARTY_DIR
     
    #make very certain that the correct Qt version is being used, by running this command:
    export QT_SELECT=qt4
     
    # This next command will take a while... somewhere between 5 minutes to 30 minutes.
    ./Allwmake > log.make 2>&1
     
    #update the shell environment
    wmSET $FOAM_SETTINGS
  10. Now, in order to build ParaView 4.1.0 that comes with OpenFOAM, including with the ability to use Python and MPI, several steps are needed:
    1. First make very certain that the correct Qt version is being used, by running this command:
      export QT_SELECT=qt4
    2. Need to do several fixes:
      sed -i -e 's=//#define GLX_GLXEXT_LEGACY=#define GLX_GLXEXT_LEGACY=' \
        ParaView-4.1.0/VTK/Rendering/OpenGL/vtkXOpenGLRenderWindow.cxx
       
      cd $WM_THIRD_PARTY_DIR/ParaView-4.1.0
       
      wget http://www.paraview.org/pipermail/paraview/attachments/20140210/464496cc/attachment.bin -O Fix.patch
      patch -p1 < Fix.patch
       
      cd VTK
      wget https://github.com/gladk/VTK/commit/ef22d3d69421581b33bc0cd94b647da73b61ba96.patch -O Fix2.patch
      patch -p1 < Fix2.patch
       
      cd ../..
    3. For building ParaView with Python and MPI, it depends on whether you have installed the i686 or x86_64 architecture of Ubuntu. To check this, run:
      uname -m

      Now, accordingly:

      • For i686:
        #this will take a while... somewhere between 30 minutes to 2 hours or more
        ./makeParaView4 -python -mpi -python-lib /usr/lib/i386-linux-gnu/libpython2.7.so.1.0 > log.makePV 2>&1
      • For x86_64:
        #this will take a while... somewhere between 30 minutes to 2 hours or more
        ./makeParaView4 -python -mpi -python-lib /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0 > log.makePV 2>&1
    4. Once the makeParaView4 script is finished running, make sure to check the contents of the file log.makePV and check if there are any errors.
    5. Finally, update the shell environment:
      wmSET $FOAM_SETTINGS
  11. Now let's build OpenFOAM:
    (Warning: this may take somewhere from 30 minutes to 6 hours, depending on your machine.)
    #Go into OpenFOAM's main source folder
    cd $WM_PROJECT_DIR
     
    #Still better be certain that the correct Qt version is being used
    export QT_SELECT=qt4
     
    # This next command will take a while... somewhere between 30 minutes to 3-6 hours.
    ./Allwmake > log.make 2>&1
     
    #Run it a second time for getting a summary of the installation
    ./Allwmake > log.make 2>&1
  12. To check if everything went well:
    1. Check if icoFoam is working, by running this command:
      icoFoam -help

      which should tell you something like this:

      Usage: icoFoam [OPTIONS]
      options:
        -case <dir>       specify alternate case directory, default is the cwd
        -noFunctionObjects
                          do not execute functionObjects
        -parallel         run in parallel
        -roots <(dir1 .. dirN)>
                          slave root directories for distributed running
        -srcDoc           display source code in browser
        -doc              display application documentation in browser
        -help             print the usage

      Note: And keep in mind that you need to be careful with the letter case of the command. It's icoFoam, not icoFOAM.

    2. If the previous command failed to work properly, then edit the file log.make and check if there are any error messages. A few examples on how you can edit this file:
      • By using kwrite:
        kwrite log.make
      • By using gedit:
        gedit log.make
      • By using nano:
        nano log.make

        You can then exit by using the key combination Ctrl+X and following any instructions it gives you.

      Note: It's the first error message that matters.

    3. If you don't understand the output, then please compress the log-file log.make and attach the compressed file to a post in the designated thread.
      If you do not know how to create a compressed file, then try one of the following examples:
      • You can compress the file with gzip by running this command:
        gzip < log.make > log.make.gz

        Then attach the resulting package file named log.make.gz to a post in the designated thread.

      • Or you can compress one or more log-files into a tarball package file, by running this command:
        tar -czf logs.tar.gz log.*

        Then attach the resulting package file named logs.tar.gz to a post in the designated thread.

    4. Instructions on how to further diagnose the issue yourself, have a look at the section Common errors when building OpenFOAM from source code in the page FAQ/Installation and Running.
  13. Now you can go read the User Guide, where you may have more than one choice:
    1. Which you can find a local copy of the User Guide by running the following command:
      ls -A1 $WM_PROJECT_DIR/doc/Guides*/*UserGuide*.pdf
      • You should see two available formats: A4 and US-Letter.
      • But if it instead tells you that there is No such file or directory, then the OpenFOAM environment is possibly not properly activated.
    2. You can also find the more recent OpenFOAM Foundation User Guides online at the following page: official OpenFOAM User Guide - but be careful if you use the version that is too much ahead of the version you are currently using, given that some features have changed overtime.


Reminder: Whenever you start a new terminal window or tab, you should run the alias command associated to the OpenFOAM 2.4.0 shell environment. In other words, run the following command whenever you start a new terminal:
of240
For more information on this topic, read section Using aliases to help manage multiple OpenFOAM versions in the page Installation/Working with the Shell.


Discussion thread where you can ask questions about these steps: No thread available. Please a create a new thread in the forum.

2.4 Ubuntu 15.10

The instructions written for Ubuntu 15.04 also work in 15.10.

2.5 Ubuntu 16.04

Here you have the following choices:

  • You can install from source, by either:


Discussion thread where you can ask questions about these steps: Problems installing OpenFOAM 2.4.0 on Ubuntu 16.04

Steps:

  1. Switch to root mode (administrator), to install the necessary packages:
    sudo -s
    • If the 'sudo' command tells you're not in the sudoers list, then run:
      su -
  2. Update the apt-get cache by running:
    apt-get update
  3. Install the necessary packages:
    apt-get install build-essential binutils-dev cmake flex bison zlib1g-dev qt4-dev-tools libqt4-dev libqtwebkit-dev gnuplot \
    libreadline-dev libncurses-dev libxt-dev libopenmpi-dev openmpi-bin libboost-system-dev libboost-thread-dev libgmp-dev \
    libmpfr-dev python python-dev libcgal-dev

    Note: It has been reported that the following should also be executed in some cases, so that ParaView and CGAL will build properly:

    apt-get install libglu1-mesa-dev libqt4-opengl-dev
  4. Now exit from the root mode:
    exit
  5. Download and unpack (here you can copy-paste all in single go):
    #OpenFOAM downloading and installation
    cd ~
    mkdir OpenFOAM
    cd OpenFOAM
    wget "http://downloads.sourceforge.net/foam/OpenFOAM-2.4.0.tgz?use_mirror=mesh" -O OpenFOAM-2.4.0.tgz
    wget "http://downloads.sourceforge.net/foam/ThirdParty-2.4.0.tgz?use_mirror=mesh" -O ThirdParty-2.4.0.tgz
     
    tar -xzf OpenFOAM-2.4.0.tgz 
    tar -xzf ThirdParty-2.4.0.tgz
  6. Optional: Let's make a few symbolic links that should ensure that the correct global MPI installation is used by this OpenFOAM installation:
    ln -s /usr/bin/mpicc.openmpi OpenFOAM-2.4.0/bin/mpicc
    ln -s /usr/bin/mpirun.openmpi OpenFOAM-2.4.0/bin/mpirun

    This way we avoid having problems in case there is more than one MPI toolbox installed in your Ubuntu system, for example if MPICH2 is installed and is the default MPI toolbox.

  7. Since we are going to use CGAL 4.7 that comes with Ubuntu, we are going to configure accordingly by running:
    sed -i -e 's/^\(cgal_version=\).*/\1cgal-system/' OpenFOAM-2.4.0/etc/config/CGAL.sh
  8. For building OpenFOAM itself, it depends on whether you have installed the i686 or x86_64 architecture of Ubuntu. To check this, run:
    uname -m

    Now, accordingly:

    • For i686:
      #here you can change 4 to the number of cores you've got
      source $HOME/OpenFOAM/OpenFOAM-2.4.0/etc/bashrc WM_NCOMPPROCS=4 WM_ARCH_OPTION=32
    • For x86_64:
      #here you can change 4 to the number of cores you've got
      source $HOME/OpenFOAM/OpenFOAM-2.4.0/etc/bashrc WM_NCOMPPROCS=4
  9. Save an alias in the personal .bashrc file, simply by running the following command:
    echo "alias of240='source \$HOME/OpenFOAM/OpenFOAM-2.4.0/etc/bashrc $FOAM_SETTINGS'" >> $HOME/.bashrc
    Note: This last line means that whenever you start a new terminal window or tab, you should run the alias command associated to the OpenFOAM 2.4.0 shell environment. In other words, whenever you start a new terminal, you should run:
    of240
    
    For more information on this topic, read section Using aliases to help manage multiple OpenFOAM versions in the page Installation/Working with the Shell.
  10. Now, in order to build ParaView 4.1.0 that comes with OpenFOAM, including with the ability to use Python and MPI, several steps are needed:
    1. First go into the 3rd party folder and make very certain that the correct Qt version is being used, by running this command:
      cd $WM_THIRD_PARTY_DIR
       
      export QT_SELECT=qt4
    2. Then we need to do several fixes:
      sed -i -e 's=//#define GLX_GLXEXT_LEGACY=#define GLX_GLXEXT_LEGACY=' \
        ParaView-4.1.0/VTK/Rendering/OpenGL/vtkXOpenGLRenderWindow.cxx
       
      cd $WM_THIRD_PARTY_DIR/ParaView-4.1.0
       
      wget http://www.paraview.org/pipermail/paraview/attachments/20140210/464496cc/attachment.bin -O Fix.patch
      patch -p1 < Fix.patch
       
      cd VTK
      wget https://github.com/gladk/VTK/commit/ef22d3d69421581b33bc0cd94b647da73b61ba96.patch -O Fix2.patch
      patch -p1 < Fix2.patch
       
      cd ../..
    3. For building ParaView with Python and MPI, it depends on whether you have installed the i686 or x86_64 architecture of Ubuntu. To check this, run:
      uname -m

      Now, accordingly:

      • For i686:
        #this will take a while... somewhere between 30 minutes to 2 hours or more
        ./makeParaView4 -python -mpi -python-lib /usr/lib/i386-linux-gnu/libpython2.7.so.1.0 > log.makePV 2>&1
      • For x86_64:
        #this will take a while... somewhere between 30 minutes to 2 hours or more
        ./makeParaView4 -python -mpi -python-lib /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0 > log.makePV 2>&1
    4. Once the makeParaView4 script is finished running, make sure to check the contents of the file log.makePV and check if there are any errors.
    5. Finally, update the shell environment:
      wmSET $FOAM_SETTINGS
  11. Now, before we can build OpenFOAM, we need to do a few fixes:
    #Go into OpenFOAM's main source folder
    cd $WM_PROJECT_DIR
     
    #Change how the flex version is checked
    find src applications -name "*.L" -type f | xargs sed -i -e 's=\(YY\_FLEX\_SUBMINOR\_VERSION\)=YY_FLEX_MINOR_VERSION < 6 \&\& \1='
  12. Now, let's simply create empty folders for the Boost and CGAL installation paths:
    mkdir -p $CGAL_ARCH_PATH
    mkdir -p $BOOST_ARCH_PATH
  13. Now let's build OpenFOAM:
    (Warning: this may take somewhere from 30 minutes to 6 hours, depending on your machine.)
    #Go into OpenFOAM's main source folder
    cd $WM_PROJECT_DIR
     
    #Still better be certain that the correct Qt version is being used
    export QT_SELECT=qt4
     
    # This next command will take a while... somewhere between 30 minutes to 3-6 hours.
    ./Allwmake > log.make 2>&1
     
    #Run it a second time for getting a summary of the installation
    ./Allwmake > log.make 2>&1
  14. To check if everything went well:
    1. Check if icoFoam is working, by running this command:
      icoFoam -help

      which should tell you something like this:

      Usage: icoFoam [OPTIONS]
      options:
        -case <dir>       specify alternate case directory, default is the cwd
        -noFunctionObjects
                          do not execute functionObjects
        -parallel         run in parallel
        -roots <(dir1 .. dirN)>
                          slave root directories for distributed running
        -srcDoc           display source code in browser
        -doc              display application documentation in browser
        -help             print the usage

      Note: And keep in mind that you need to be careful with the letter case of the command. It's icoFoam, not icoFOAM.

    2. If the previous command failed to work properly, then edit the file log.make and check if there are any error messages. A few examples on how you can edit this file:
      • By using kwrite:
        kwrite log.make
      • By using gedit:
        gedit log.make
      • By using nano:
        nano log.make

        You can then exit by using the key combination Ctrl+X and following any instructions it gives you.

      Note: It's the first error message that matters.

    3. If you don't understand the output, then please compress the log-file log.make and attach the compressed file to a post in the designated thread.
      If you do not know how to create a compressed file, then try one of the following examples:
      • You can compress the file with gzip by running this command:
        gzip < log.make > log.make.gz

        Then attach the resulting package file named log.make.gz to a post in the designated thread.

      • Or you can compress one or more log-files into a tarball package file, by running this command:
        tar -czf logs.tar.gz log.*

        Then attach the resulting package file named logs.tar.gz to a post in the designated thread.

    4. Instructions on how to further diagnose the issue yourself, have a look at the section Common errors when building OpenFOAM from source code in the page FAQ/Installation and Running.
  15. Now you can go read the User Guide, where you may have more than one choice:
    1. Which you can find a local copy of the User Guide by running the following command:
      ls -A1 $WM_PROJECT_DIR/doc/Guides*/*UserGuide*.pdf
      • You should see two available formats: A4 and US-Letter.
      • But if it instead tells you that there is No such file or directory, then the OpenFOAM environment is possibly not properly activated.
    2. You can also find the more recent OpenFOAM Foundation User Guides online at the following page: official OpenFOAM User Guide - but be careful if you use the version that is too much ahead of the version you are currently using, given that some features have changed overtime.


Reminder: Whenever you start a new terminal window or tab, you should run the alias command associated to the OpenFOAM 2.4.0 shell environment. In other words, run the following command whenever you start a new terminal:
of240
For more information on this topic, read section Using aliases to help manage multiple OpenFOAM versions in the page Installation/Working with the Shell.


Discussion thread where you can ask questions about these steps: Problems installing OpenFOAM 2.4.0 on Ubuntu 16.04


2.6 Ubuntu 16.10

Here you have the following choices:

  • You can install from source, by either:


Discussion thread where you can ask questions about these steps: [OpenFOAM][2.4.0] Error in the building of ParaView 4.1.0

Steps:

  1. Switch to root mode (administrator), to install the necessary packages:
    sudo -s
    • If the 'sudo' command tells you're not in the sudoers list, then run:
      su -
  2. Update the apt-get cache by running:
    apt-get update
  3. Install the necessary packages:
    apt-get install build-essential binutils-dev cmake flex bison zlib1g-dev qt4-dev-tools libqt4-dev libqtwebkit-dev gnuplot \
    libreadline-dev libncurses-dev libxt-dev libopenmpi-dev openmpi-bin libboost-system-dev libboost-thread-dev libgmp-dev \
    libmpfr-dev python python-dev libcgal-dev gcc-4.7 g++-4.7

    Note: It has been reported that the following should also be executed in some cases, so that ParaView and CGAL will build properly:

    apt-get install libglu1-mesa-dev libqt4-opengl-dev
  4. Now exit from the root mode:
    exit
  5. Download and unpack (here you can copy-paste all in single go):
    #OpenFOAM downloading and installation
    cd ~
    mkdir OpenFOAM
    cd OpenFOAM
    wget "http://downloads.sourceforge.net/foam/OpenFOAM-2.4.0.tgz?use_mirror=mesh" -O OpenFOAM-2.4.0.tgz
    wget "http://downloads.sourceforge.net/foam/ThirdParty-2.4.0.tgz?use_mirror=mesh" -O ThirdParty-2.4.0.tgz
     
    tar -xzf OpenFOAM-2.4.0.tgz 
    tar -xzf ThirdParty-2.4.0.tgz
  6. Optional: Let's make a few symbolic links that should ensure that the correct global MPI installation is used by this OpenFOAM installation:
    ln -s /usr/bin/mpicc.openmpi OpenFOAM-2.4.0/bin/mpicc
    ln -s /usr/bin/mpirun.openmpi OpenFOAM-2.4.0/bin/mpirun

    This way we avoid having problems in case there is more than one MPI toolbox installed in your Ubuntu system, for example if MPICH2 is installed and is the default MPI toolbox.

  7. Since we are going to use CGAL 4.8.1 and Boost 1.61 that comes with Ubuntu, we are going to configure accordingly by running:
    sed -i -e 's/^\(cgal_version=\).*/\1cgal-system/' OpenFOAM-2.4.0/etc/config/CGAL.sh
    sed -i -e 's=\(-lmpfr\)$=\1 -lboost_thread=' OpenFOAM-2.4.0/wmake/rules/General/CGAL
  8. We will be using GCC 4.7, because 6.x is not compatible with OpenFOAM 2.4, as explained here. Therefore, we need to do a couple more changes, to ensure it works as intended:
    sed -i -e 's/gcc/gcc-4.7/' OpenFOAM-2.4.0/wmake/rules/linux64Gcc47/c
    sed -i -e 's/g++/g++-4.7/' OpenFOAM-2.4.0/wmake/rules/linux64Gcc47/c++
    echo "export WM_CC='gcc-4.7'" >> OpenFOAM-2.4.0/etc/bashrc
    echo "export WM_CXX='g++-4.7'" >> OpenFOAM-2.4.0/etc/bashrc
  9. For building OpenFOAM itself, it depends on whether you have installed the i686 or x86_64 architecture of Ubuntu. To check this, run:
    uname -m

    Now, accordingly:

    • For i686:
      #here you can change 4 to the number of cores you've got
      source $HOME/OpenFOAM/OpenFOAM-2.4.0/etc/bashrc WM_NCOMPPROCS=4 WM_ARCH_OPTION=32 WM_COMPILER=Gcc47
    • For x86_64:
      #here you can change 4 to the number of cores you've got
      source $HOME/OpenFOAM/OpenFOAM-2.4.0/etc/bashrc WM_NCOMPPROCS=4 WM_COMPILER=Gcc47
  10. Save an alias in the personal .bashrc file, simply by running the following command:
    echo "alias of240='source \$HOME/OpenFOAM/OpenFOAM-2.4.0/etc/bashrc $FOAM_SETTINGS'" >> $HOME/.bashrc
    Note: This last line means that whenever you start a new terminal window or tab, you should run the alias command associated to the OpenFOAM 2.4.0 shell environment. In other words, whenever you start a new terminal, you should run:
    of240
    
    For more information on this topic, read section Using aliases to help manage multiple OpenFOAM versions in the page Installation/Working with the Shell.
  11. Now, in order to build ParaView 4.1.0 that comes with OpenFOAM, including with the ability to use Python and MPI, several steps are needed:
    1. First go into the 3rd party folder and make very certain that the correct Qt version is being used, by running this command:
      cd $WM_THIRD_PARTY_DIR
       
      export QT_SELECT=qt4
    2. Then we need to do several fixes:
      sed -i -e 's=//#define GLX_GLXEXT_LEGACY=#define GLX_GLXEXT_LEGACY=' \
        ParaView-4.1.0/VTK/Rendering/OpenGL/vtkXOpenGLRenderWindow.cxx
       
      cd $WM_THIRD_PARTY_DIR/ParaView-4.1.0
       
      wget http://www.paraview.org/pipermail/paraview/attachments/20140210/464496cc/attachment.bin -O Fix.patch
      patch -p1 < Fix.patch
       
      cd VTK
      wget https://github.com/gladk/VTK/commit/ef22d3d69421581b33bc0cd94b647da73b61ba96.patch -O Fix2.patch
      patch -p1 < Fix2.patch
       
      cd ../..
    3. For building ParaView with Python and MPI, it depends on whether you have installed the i686 or x86_64 architecture of Ubuntu. To check this, run:
      uname -m

      Now, accordingly:

      • For i686:
        #this will take a while... somewhere between 30 minutes to 2 hours or more
        ./makeParaView4 -python -mpi -python-lib /usr/lib/i386-linux-gnu/libpython2.7.so.1.0 > log.makePV 2>&1
      • For x86_64:
        #this will take a while... somewhere between 30 minutes to 2 hours or more
        ./makeParaView4 -python -mpi -python-lib /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0 > log.makePV 2>&1
    4. Once the makeParaView4 script is finished running, make sure to check the contents of the file log.makePV and check if there are any errors.
    5. Finally, update the shell environment:
      wmSET $FOAM_SETTINGS
  12. Now, before we can build OpenFOAM, we need to do a few fixes:
    #Go into OpenFOAM's main source folder
    cd $WM_PROJECT_DIR
     
    #Change how the flex version is checked
    find src applications -name "*.L" -type f | xargs sed -i -e 's=\(YY\_FLEX\_SUBMINOR\_VERSION\)=YY_FLEX_MINOR_VERSION < 6 \&\& \1='
  13. Now, let's simply create empty folders for the Boost and CGAL installation paths:
    mkdir -p $CGAL_ARCH_PATH
    mkdir -p $BOOST_ARCH_PATH
  14. Now let's build OpenFOAM:
    (Warning: this may take somewhere from 30 minutes to 6 hours, depending on your machine.)
    #Go into OpenFOAM's main source folder
    cd $WM_PROJECT_DIR
     
    #Still better be certain that the correct Qt version is being used
    export QT_SELECT=qt4
     
    # This next command will take a while... somewhere between 30 minutes to 3-6 hours.
    ./Allwmake > log.make 2>&1
     
    #Run it a second time for getting a summary of the installation
    ./Allwmake > log.make 2>&1
  15. To check if everything went well:
    1. Check if icoFoam is working, by running this command:
      icoFoam -help

      which should tell you something like this:

      Usage: icoFoam [OPTIONS]
      options:
        -case <dir>       specify alternate case directory, default is the cwd
        -noFunctionObjects
                          do not execute functionObjects
        -parallel         run in parallel
        -roots <(dir1 .. dirN)>
                          slave root directories for distributed running
        -srcDoc           display source code in browser
        -doc              display application documentation in browser
        -help             print the usage

      Note: And keep in mind that you need to be careful with the letter case of the command. It's icoFoam, not icoFOAM.

    2. If the previous command failed to work properly, then edit the file log.make and check if there are any error messages. A few examples on how you can edit this file:
      • By using kwrite:
        kwrite log.make
      • By using gedit:
        gedit log.make
      • By using nano:
        nano log.make

        You can then exit by using the key combination Ctrl+X and following any instructions it gives you.

      Note: It's the first error message that matters.

    3. If you don't understand the output, then please compress the log-file log.make and attach the compressed file to a post in the designated thread.
      If you do not know how to create a compressed file, then try one of the following examples:
      • You can compress the file with gzip by running this command:
        gzip < log.make > log.make.gz

        Then attach the resulting package file named log.make.gz to a post in the designated thread.

      • Or you can compress one or more log-files into a tarball package file, by running this command:
        tar -czf logs.tar.gz log.*

        Then attach the resulting package file named logs.tar.gz to a post in the designated thread.

    4. Instructions on how to further diagnose the issue yourself, have a look at the section Common errors when building OpenFOAM from source code in the page FAQ/Installation and Running.
  16. Now you can go read the User Guide, where you may have more than one choice:
    1. Which you can find a local copy of the User Guide by running the following command:
      ls -A1 $WM_PROJECT_DIR/doc/Guides*/*UserGuide*.pdf
      • You should see two available formats: A4 and US-Letter.
      • But if it instead tells you that there is No such file or directory, then the OpenFOAM environment is possibly not properly activated.
    2. You can also find the more recent OpenFOAM Foundation User Guides online at the following page: official OpenFOAM User Guide - but be careful if you use the version that is too much ahead of the version you are currently using, given that some features have changed overtime.


Reminder: Whenever you start a new terminal window or tab, you should run the alias command associated to the OpenFOAM 2.4.0 shell environment. In other words, run the following command whenever you start a new terminal:
of240
For more information on this topic, read section Using aliases to help manage multiple OpenFOAM versions in the page Installation/Working with the Shell.


Discussion thread where you can ask questions about these steps: [OpenFOAM][2.4.0] Error in the building of ParaView 4.1.0


2.7 Ubuntu 18.04

Here you have the following choices:

  • You can install from source, by either:


Discussion thread where you can ask questions about these steps: Install OpenFOAM-2.4.0 in Ubuntu 18.04?

Steps:

  1. Switch to root mode (administrator), to install the necessary packages:
    sudo -s
    • If the 'sudo' command tells you're not in the sudoers list, then run:
      su -
  2. Update the apt-get cache by running:
    apt-get update
  3. Install the necessary packages:
    apt-get install build-essential cmake flex bison zlib1g-dev qt4-dev-tools libqt4-dev libqtwebkit-dev gnuplot \
    libreadline-dev libncurses5-dev libxt-dev libopenmpi-dev openmpi-bin libboost-system-dev libboost-thread-dev libgmp-dev \
    libmpfr-dev python python-dev libcgal-dev gcc-5 g++-5

    Note: It has been reported that the following should also be executed in some cases, so that ParaView and CGAL will build properly:

    apt-get install libglu1-mesa-dev libqt4-opengl-dev
  4. Now exit from the root mode:
    exit
  5. Download and unpack (here you can copy-paste all in single go):
    #OpenFOAM downloading and installation
    cd ~
    mkdir OpenFOAM
    cd OpenFOAM
    wget "http://downloads.sourceforge.net/foam/OpenFOAM-2.4.0.tgz?use_mirror=mesh" -O OpenFOAM-2.4.0.tgz
    wget "http://downloads.sourceforge.net/foam/ThirdParty-2.4.0.tgz?use_mirror=mesh" -O ThirdParty-2.4.0.tgz
     
    tar -xzf OpenFOAM-2.4.0.tgz 
    tar -xzf ThirdParty-2.4.0.tgz
  6. Optional: Let's make a few symbolic links that should ensure that the correct global MPI installation is used by this OpenFOAM installation:
    ln -s /usr/bin/mpicc.openmpi OpenFOAM-2.4.0/bin/mpicc
    ln -s /usr/bin/mpirun.openmpi OpenFOAM-2.4.0/bin/mpirun

    This way we avoid having problems in case there is more than one MPI toolbox installed in your Ubuntu system, for example if MPICH2 is installed and is the default MPI toolbox.

  7. A few details need to be fixed, before proceeding, which will change the default Boost and CGAL versions, to then use the ones provided by Ubuntu, along with a few GCC version changes:
    sed -i -e 's/\(cgal_version=\)CGAL-4.6/\1cgal-system/' OpenFOAM-2.4.0/etc/config/CGAL.sh
    sed -i -e 's=\-lmpfr=-lmpfr -lboost_thread=' OpenFOAM-2.4.0/wmake/rules/General/CGAL
     
    sed -i -e 's/gcc/\$(WM_CC)/' OpenFOAM-2.4.0/wmake/rules/linux*Gcc/c
    sed -i -e 's/g++/\$(WM_CXX)/' OpenFOAM-2.4.0/wmake/rules/linux*Gcc/c++
  8. For building OpenFOAM itself, it depends on whether you have installed the i686 or x86_64 architecture of Ubuntu. To check this, run:
    uname -m

    Now, accordingly:

    • For i686:
      #here you can change 4 to the number of cores you've got
      source $HOME/OpenFOAM/OpenFOAM-2.4.0/etc/bashrc WM_NCOMPPROCS=4 WM_MPLIB=SYSTEMOPENMPI WM_ARCH_OPTION=32
      export WM_CC='gcc-5'
      export WM_CXX='g++-5'
    • For x86_64:
      #here you can change 4 to the number of cores you've got
      source $HOME/OpenFOAM/OpenFOAM-2.4.0/etc/bashrc WM_NCOMPPROCS=4 WM_MPLIB=SYSTEMOPENMPI
      export WM_CC='gcc-5'
      export WM_CXX='g++-5'
  9. Save an alias in the personal .bashrc file, simply by running the following command:
    echo "alias of240='source \$HOME/OpenFOAM/OpenFOAM-2.4.0/etc/bashrc $FOAM_SETTINGS; export WM_CC=gcc-5; export WM_CXX=g++-5'" >> $HOME/.bashrc
    Note: This last line means that whenever you start a new terminal window or tab, you should run the alias command associated to the OpenFOAM 2.4.0 shell environment. In other words, whenever you start a new terminal, you should run:
    of240
    
    For more information on this topic, read section Using aliases to help manage multiple OpenFOAM versions in the page Installation/Working with the Shell.
    • Just in case, also source that file, so that you can use of240 in this terminal if necessary, by running:
      source $HOME/.bashrc
  10. Now let's build the ThirdParty folder, because we need the shell environment to be updated afterwards, for CGAL to be properly picked up for building OpenFOAM:
    cd $WM_THIRD_PARTY_DIR
     
    #make very certain that the correct Qt version is being used, by running this command:
    export QT_SELECT=qt4
     
    # Fix issue regarding not wanting to build CGAL
    sed -i -e 's|\(^if.*CGAL_ARCH_PATH.*\)]|\1 -a "${CGAL_ARCH_PATH##*/}" != "cgal-system" ]|' Allwmake
     
    # This next command will take a while... somewhere between 5 minutes to 30 minutes.
    ./Allwmake > log.make 2>&1
     
    #update the shell environment
    of240
  11. Now, in order to build ParaView 4.1.0 that comes with OpenFOAM, including with the ability to use Python and MPI, several steps are needed:
    1. First make very certain that the correct Qt version is being used, by running this command:
      export QT_SELECT=qt4
    2. Need to do several fixes:
      cd $WM_THIRD_PARTY_DIR
       
      sed -i -e 's=MPI_ARCH_PATH/include=MPI_ARCH_PATH/include;$MPI_INCLUDE=' etc/tools/ParaView4Functions
       
      sed -i -e 's=//#define GLX_GLXEXT_LEGACY=#define GLX_GLXEXT_LEGACY=' \
        ParaView-4.1.0/VTK/Rendering/OpenGL/vtkXOpenGLRenderWindow.cxx
       
      cd $WM_THIRD_PARTY_DIR/ParaView-4.1.0
       
      wget http://www.paraview.org/pipermail/paraview/attachments/20140210/464496cc/attachment.bin -O Fix.patch
      patch -p1 < Fix.patch
       
      cd VTK
      wget https://github.com/gladk/VTK/commit/ef22d3d69421581b33bc0cd94b647da73b61ba96.patch -O Fix2.patch
      patch -p1 < Fix2.patch
       
      cd ../..
    3. For building ParaView with Python and MPI, it depends on whether you have installed the i686 or x86_64 architecture of Ubuntu. To check this, run:
      uname -m

      Now, accordingly:

      • For i686:
        #this will take a while... somewhere between 30 minutes to 2 hours or more
        ./makeParaView4 -python -mpi -python-lib /usr/lib/i386-linux-gnu/libpython2.7.so.1.0 > log.makePV 2>&1
      • For x86_64:
        #this will take a while... somewhere between 30 minutes to 2 hours or more
        ./makeParaView4 -python -mpi -python-lib /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0 > log.makePV 2>&1
    4. Once the makeParaView4 script is finished running, make sure to check the contents of the file log.makePV and check if there are any errors.
    5. Finally, update the shell environment:
      of240
  12. Now, before we can build OpenFOAM, we need to do a few fixes:
    #Go into OpenFOAM's main source folder
    cd $WM_PROJECT_DIR
     
    #Change how the flex version is checked
    find src applications -name "*.L" -type f | xargs sed -i -e 's=\(YY\_FLEX\_SUBMINOR\_VERSION\)=YY_FLEX_MINOR_VERSION < 6 \&\& \1='
  13. Now let's build OpenFOAM:
    (Warning: this may take somewhere from 30 minutes to 6 hours, depending on your machine.)
    #Go into OpenFOAM's main source folder
    cd $WM_PROJECT_DIR
     
    #Still better be certain that the correct Qt version is being used
    export QT_SELECT=qt4
     
    # This next command will take a while... somewhere between 30 minutes to 3-6 hours.
    ./Allwmake > log.make 2>&1
     
    #Run it a second time for getting a summary of the installation
    ./Allwmake > log.make 2>&1
  14. To check if everything went well:
    1. Check if icoFoam is working, by running this command:
      icoFoam -help

      which should tell you something like this:

      Usage: icoFoam [OPTIONS]
      options:
        -case <dir>       specify alternate case directory, default is the cwd
        -noFunctionObjects
                          do not execute functionObjects
        -parallel         run in parallel
        -roots <(dir1 .. dirN)>
                          slave root directories for distributed running
        -srcDoc           display source code in browser
        -doc              display application documentation in browser
        -help             print the usage

      Note: And keep in mind that you need to be careful with the letter case of the command. It's icoFoam, not icoFOAM.

    2. If the previous command failed to work properly, then edit the file log.make and check if there are any error messages. A few examples on how you can edit this file:
      • By using kwrite:
        kwrite log.make
      • By using gedit:
        gedit log.make
      • By using nano:
        nano log.make

        You can then exit by using the key combination Ctrl+X and following any instructions it gives you.

      Note: It's the first error message that matters.

    3. If you don't understand the output, then please compress the log-file log.make and attach the compressed file to a post in the designated thread.
      If you do not know how to create a compressed file, then try one of the following examples:
      • You can compress the file with gzip by running this command:
        gzip < log.make > log.make.gz

        Then attach the resulting package file named log.make.gz to a post in the designated thread.

      • Or you can compress one or more log-files into a tarball package file, by running this command:
        tar -czf logs.tar.gz log.*

        Then attach the resulting package file named logs.tar.gz to a post in the designated thread.

    4. Instructions on how to further diagnose the issue yourself, have a look at the section Common errors when building OpenFOAM from source code in the page FAQ/Installation and Running.
  15. Now you can go read the User Guide, where you may have more than one choice:
    1. Which you can find a local copy of the User Guide by running the following command:
      ls -A1 $WM_PROJECT_DIR/doc/Guides*/*UserGuide*.pdf
      • You should see two available formats: A4 and US-Letter.
      • But if it instead tells you that there is No such file or directory, then the OpenFOAM environment is possibly not properly activated.
    2. You can also find the more recent OpenFOAM Foundation User Guides online at the following page: official OpenFOAM User Guide - but be careful if you use the version that is too much ahead of the version you are currently using, given that some features have changed overtime.


Reminder: Whenever you start a new terminal window or tab, you should run the alias command associated to the OpenFOAM 2.4.0 shell environment. In other words, run the following command whenever you start a new terminal:
of240
For more information on this topic, read section Using aliases to help manage multiple OpenFOAM versions in the page Installation/Working with the Shell.


Discussion thread where you can ask questions about these steps: Install OpenFOAM-2.4.0 in Ubuntu 18.04?