By following the instructions below, you should be able to install Ubuntu 14.04 LTS, OpenFOAM-2.3.x (one optimal and one debug version), foam-extend-3.1, PyFoam, Python packages, Gnuplot etc. You will pull the git source and compile from scratch, since you will then get access to updates and bug fixes. OpenFOAM-2.3.0 can also be installed as a package, which is much faster, but gives less control in my opinion (http://openfoam.com/download/ubuntu.php). Feel free to try it out if you like – you can have both that version and the git versions installed at the same time!
The Linux commands below are written for bash shell. It may be beneficial to copy-paste single lines rather than multiple lines, and check that all went well for each line. Some lines will require you to press a key at some point, such as the “sudo apt-get” lines. Let me know if you run into problems, and I’ll help you.
Table of contents:
This section takes about 1.5 hour to complete.
Download Ubuntu 14.04 LTS (note that you can get it for free by setting your contribution to zero): http://www.ubuntu.com/download, get Ubuntu Desktop (in my case 64 bit), save iso-file (Optional: burn iso to CD - if you do, make sure to burn it as iso, to make the CD bootable!)
You can use VirtualBox to install Linux and OpenFOAM in your current OS. It has been recommended to use the official version downloadable from the Sun web page, https://www.virtualbox.org/wiki/Downloads, and not the pre-packed open source version, because it supports all options in an easy way (e.g. the USB controllers). See also: http://openfoam.com/resources/windows.php
After installing VirtualBox, start it and create new virtual disk:
Click on New
Name: Ubuntu 14.04 LTS
Operating System: Linux
Version: Ubuntu
Base memory: 2048MB (25% of total on the machine in my case, minimum 2GB required for 64-bit operating system)
Create new virtual disk
VDI
Fixed size, 30GB (2GB is enough to just test one OpenFOAM installation)
Settings can be changed later, using "settings"
Click on Create
Install Ubuntu on the virtual disk:
Double-click on the virtual disk you just created
Choose installation media by browsing to the downloaded Ubuntu iso-file
Click on Install Ubuntu and choose your specific settings
I recommend that you tick: Download updates while installing, and Install this third-party software
When it asks you if it should erase the whole disk, it refers to the virtual disk you have just created in VirtualBox, and not your Windows disk. You should be able to see that the reported disk size is the one you requested for your virtual disk, to verify that this is correct.
Restart when asked
At the top of your Ubuntu window, there might be an icon which sais ‘Install drivers’ when you click on it. It might be good to do so, and activate virtual box drivers. I think that the scroll wheel on my mouse required this to be done.
To the left of your Ubuntu window, there should be an icon which sais ‘Update Manager’ when you move the pointer over it. Use it to update the system, and restart Ubuntu.
I had some problems that the desktop did not resize. This was solved by clicking on “Devices/Insert Guest Addition CD image”, and restarting the virtual machine.
Occasionally, the Guest Addition may not be possible to mount and you get a pop-up window asking you if you want to force unmounts. This may not work. In Ubuntu, Open the Disks utility (click on “Search your computer and online sources”, in the left bar of Ubuntu, and enter “disks”), Under CD/DVD: mount the Guest Addition and then eject it. After that it should be possible to Insert it again, as explained above.
This section takes about 7 hours to complete
(Straight-forward according to http://www.openfoam.org/download/git.php (for 2.3.x, later in http://www.openfoam.org/archive/2.3.0/download/). See also: http://openfoamwiki.net/index.php/Installation/Linux/OpenFOAM-2.3.0/Ubuntu)
Open a terminal window (CTRL-ALT-T) and type (copy-paste, line-by-line):
mkdir $HOME/OpenFOAM
cd $HOME/OpenFOAM
sudo su - #Makes you root user, so that you can run apt-get directly and without entering password
apt-get install git-core
apt-get install build-essential flex bison cmake zlib1g-dev qt4-dev-tools libqt4-dev gnuplot libreadline-dev libncurses-dev libxt-dev
apt-get install libscotch-dev libopenmpi-dev libcgal-dev
exit #Stop being root user
git clone git://github.com/OpenFOAM/OpenFOAM-2.3.x.git
wget http://downloads.sourceforge.net/project/foam/foam/2.3.0/ThirdParty-2.3.0.tgz
You may have to press Enter here, to get the prompt back.
tar xzf ThirdParty-2.3.0.tgz
rm ThirdParty-2.3.0.tgz
mv ThirdParty-2.3.0 ThirdParty-2.3.x
echo "alias OF23x='. $HOME/OpenFOAM/OpenFOAM-2.3.x/etc/bashrc'" >> $HOME/.bashrc
Some checks, before proceeding:
gcc --version #Gives 4.8.2. Required: 4.5.0. Ok!
flex --version #Gives 2.5.35. Seems to have worked ok!
Close the terminal window, open a new one (CTRL-ALT-T) and continue:
OF23x
foam
The following line takes about 4h. You can do CTRL-C and continue later, by starting again from where you opened a new terminal window above
./Allwmake
./Allwmake>& log_Allwmake #Second time is fast, just to easier check the log file for possible errors - in my case none.
Compile ParaView-4.1.0 (takes 2.5h):
qmake --version #Gives Qt version 4.8.6. Required: 4.7.2 or newer. Ok!
cmake --version #Gives 2.8.12.2. Required: 2.8.8 or newer. Ok!
cd $WM_THIRD_PARTY_DIR
./makeParaView4 #This is what takes 2.5h
cd $FOAM_UTILITIES/postProcessing/graphics/PV4Readers
wmSET
./Allwclean
./Allwmake
Test the installation (first open a new terminal window - CTRL-ALT_T):
OF23x
mkdir -p $FOAM_RUN
run
cp -r $FOAM_TUTORIALS/incompressible/icoFoam/cavity .
cd cavity
blockMesh
icoFoam
paraFoam
This section takes about 4h to complete.
Compile Debug version, without recompiling ThirdParty:
echo "alias OF23xDebug='. $HOME/OpenFOAM/OpenFOAM-2.3.x/etc/bashrc WM_COMPILE_OPTION=Debug'" >> $HOME/.bashrc
Open new terminal window (CTRL-ALT-T)
OF23xDebug
cd $WM_THIRD_PARTY_DIR/platforms
ln -s linux64GccDPOpt linux64GccDPDebug
foam
./Allwmake #This takes 4 hours
./Allwmake>& log_Allwmake #Second time is fast, just to easier check the log file for possible errors - in my case none.
cd $FOAM_UTILITIES/postProcessing/graphics/PV4Readers
Don’t do wmSET since it will not pick Debug version – see alias wmSET! Instead:
OF23xDebug
./Allwclean
./Allwmake
Test the installation in a new terminal window (CTRL-ALT-T):
OF23xDebug
mkdir -p $FOAM_RUN
run
cp -r $FOAM_TUTORIALS/incompressible/icoFoam/cavity .
cd cavity
blockMesh
icoFoam
paraFoam
This takes 10min to complete.
You can do debugging with gdb and Emacs. Emacs in that case needs to be installed:
sudo apt-get install emacs24
You can also try ddd for debugging (not available at Chalmers):
sudo apt-get install ddd
Python-related packages:
sudo apt-get install python python-dev python-matplotlib python-numpy python-scipy
Gnuplot:
sudo apt-get install gnuplot
xmgrace:
sudo apt-get install grace
For OpenFOAM-2.3.x, the PyFoam package is not included (which it is for foam-extend). We will follow the installation instructions for PyFoam at http://openfoamwiki.net/index.php/Contrib_PyFoam.
Condensed installation instructions:
mkdir $HOME/OpenFOAM/linuxSrc
cd $HOME/OpenFOAM/linuxSrc
wget http://openfoamwiki.net/images/8/89/PyFoam-0.6.2.tar.gz
tar xzf PyFoam-0.6.2.tar.gz
rm PyFoam-0.6.2.tar.gz
cd PyFoam-0.6.2
Install as regular user (recommended):
python setup.py install --prefix=$HOME/OpenFOAM/PyFoam-0.6.2
echo "alias PF062='export PYTHONPATH=\$HOME/OpenFOAM/PyFoam-0.6.2/lib/python2.7/site-packages:\$PYTHONPATH; export PATH=\$HOME/OpenFOAM/PyFoam-0.6.2/bin:\$PATH'" >> $HOME/.bashrc
Open a new window and type (<TAB> refers to the tab key):
PF062
pyFoam<TAB><TAB>
You will see numerous pyFoam commands that can be used to help you use OpenFOAM efficiently.
The foam-extend (foam-extend.org) fork has some features that are not in OpenFOAM-x.x.x, such as the GGI interface. If you do not need those features, you do not have to follow this section.
This section takes about 5h or more – leave the computer over-night (where this message is repeated).
For other installation instructions, see also:
http://openfoamwiki.net/index.php/Installation/Linux/foam-extend-3.1
And later the file $WM_PROJECT_DIR/doc/buildInstructions/Ubuntu/Ubuntu_14.04, also located here: https://sourceforge.net/p/openfoam-extend/foam-extend-3.1/ci/master/tree/doc/buildInstructions/Ubuntu/Ubuntu_14.04
The compilation procedure is actually very simple, but I modify it slightly to use more system installations. I have included some information that is commented, if anyone would like to do other modifications.
Open new terminal window and type (line-by-line, since you have to type your password on the “sudo” lines)
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install git-core build-essential binutils-dev flex zlib1g-dev qt4-dev-tools libqt4-dev
sudo apt-get install libncurses5-dev libiberty-dev libxt-dev rpm mercurial graphviz openmpi-bin libopenmpi-dev cmake
mkdir $HOME/foam
cd $HOME/foam
git clone git://git.code.sf.net/p/openfoam-extend/foam-extend-3.1 foam-extend-3.1
cd foam-extend-3.1
This part is where I do some changes to the installation procedure, to use more system installed software in Ubuntu 14.04. You can skip this if you like. But then you will not have Paraview compiled, and you will waste some disk space on software that may be installed in the system. Instead of compiling Paraview, you can also install it with “sudo apt-get paraview”, but then you don’t get the foam-extend-specific reader.
####################################################################
# Create a prefs.sh file
cp etc/prefs.sh-EXAMPLE etc/prefs.sh
# Make the sourcing less chatty
sed -i s/"FOAM_VERBOSE=1"/"FOAM_VERBOSE="/g etc/prefs.sh
# Use openmpi 1.6.5 as supplied by Ubuntu 14.04
sed -i s/"#export WM_MPLIB=SYSTEMOPENMPI"/"export WM_MPLIB=SYSTEMOPENMPI"/g etc/prefs.sh
sed -i s/"#export OPENMPI_DIR=path_to_system_installed_openmpi"/"export OPENMPI_DIR=\/usr"/g etc/prefs.sh
sed -i s/"#export OPENMPI_BIN_DIR=\$OPENMPI_DIR\/bin"/"export OPENMPI_BIN_DIR=\$OPENMPI_DIR\/bin"/g etc/prefs.sh
# Use Qt 4.8.6 as provided by Ubuntu 14.04 (instead of 4.8.5, in ThirdParty)
sed -i s/"#export QT_DIR=path_to_system_installed_qt"/"export QT_DIR=\/usr"/g etc/prefs.sh
sed -i s/"#export QT_BIN_DIR=\$QT_DIR\/bin"/"export QT_BIN_DIR=\$QT_DIR\/bin"/g etc/prefs.sh
# Use cmake 2.8.12.2 as provided by Ubuntu 14.04 (instead of 2.8.12, in ThirdParty)
sed -i s/"( rpm_make -p cmake"/"#( rpm_make -p cmake"/g ThirdParty/AllMake.stage1
# Compile and install bison-2.7 from the ThirdParty packages.
sed -i 0,/"#( rpm_make -p bison-2.7"/s//"( rpm_make -p bison-2.7"/ ThirdParty/AllMake.stage1
#
####################################################################
See the etc/prefs-sh-EXAMPLE file for more examples, e.g.:
#Tell the compiler to use the number of cores you have available (if you uncomment the line and change the number 4 to what you have)
#echo "export WM_NCOMPPROCS=4" >> etc/prefs.sh
#Use the system installation of paraview (if you uncomment the following lines)
#sed -i s/"#export PARAVIEW_SYSTEM=1"/"export PARAVIEW_SYSTEM=1"/g etc/prefs.sh
#sed -i s/"#export PARAVIEW_DIR=path_to_system_installed_paraview"/"export PARAVIEW_DIR=\/usr "/g etc/prefs.sh
#sed -i s/"#export PARAVIEW_BIN_DIR=\$PARAVIEW_DIR\/bin"/"export PARAVIEW_BIN_DIR=\$PARAVIEW_DIR\/bin"/g etc/prefs.sh
#sed -i -e 's=\.OpenFOAM=\.foam=' foam-extend-3.1/bin/paraFoam
####################################################################
Set up the foam-extend-3.1 environment:
echo "alias f31='. \$HOME/foam/foam-extend-3.1/etc/bashrc'" >> $HOME/.bashrc
Close the terminal window and open a new one (doing: CTRL-ALT_T) and type:
f31
Compile (this takes 5h or more – leave the computer over-night):
foam
./Allwmake.firstInstall #Wait 5h!
Again, to make sure that all went well (takes some minutes):
./Allwmake.firstInstall >& log&
Look for errors in the log file. There should be none.
It should say "up to date" on each application/library
Test the installation, in a new terminal window:
f31
mkdir -p $FOAM_RUN
run
cp -r $FOAM_TUTORIALS/incompressible/icoFoam/cavity .
cd cavity
blockMesh
icoFoam
paraFoam
When running paraFoam you may get some messages in the terminal window and in a pop-up-window. Just move that pop-up-window out of sight and ignore the messages.