The teaching is designed so
that you should follow the steps I do on a computer. We will have access to
computers with pre-installed software during the lectures, but it is highly
recommended that you install the software on your own laptop so that you are
independent. The Linux commands below are written for bash shell.
By following the
instructions below, you should be able to install Ubuntu 12.04 LTS,
OpenFOAM-2.1.x (one optimal and one debug version), OpenFOAM-1.6-ext, PyFoam, Python packages, Gnuplot
etc., and later perhaps some additional useful things that we will use in the
course. We will pull the git source and compile from
scratch. Both versions can also be installed as packages, which is much faster,
but gives less control in my opinion (http://openfoam.com/download/ubuntu.php,
and
http://openfoamwiki.net/index.php/Installation#OpenFOAM-dev_subversion_repository
– section 2.3.2). Feel free to try it out if you like – you can have both those
versions and the git versions installed at the same
time!
Note that I am
(unfortunately) using Word to generate this web page, which means that Word
sometimes decides to change some characters to other characters that look the
same, but aren’t (e.g. – is not the same as - or -- and “ is not the same as
"). I think that I have fixed this everywhere, but you never know. That is
one reason for copy-pasting single rows rather than multiple rows, and check
that all went well. Another reason is that 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.
NOTE that there is an unresolved problem with the OpenFOAM
reader for paraview, for OpenFOAM-1.6-ext after
following these instructions (see http://www.cfd-online.com/Forums/openfoam-installation/69929-parafoam-reader-openfoam-1-6-a.html). Such issues can always be avoided by a slight change in work flow at
post-processing.
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
Create new virtual disk:
Click on New
Name: Ubuntu 12.04 LTS
Operating System: Linux
Version: Ubuntu
Base memory: 2048MB (25% of total on the machine in my case)
Create new virtual disk
VDI
Fixed size, 30GB (2GB is enough to just test one OpenFOAM
installation)
Settings can be changed later, using "settings"
Download Ubuntu 12.04 LTS:
http://www.ubuntu.com/download, get Ubuntu Desktop (in my case 64 bit)
Optional: burn iso to CD (if you do, make sure to
burn it as iso, to make the CD bootable!)
Install on the virtual
disk:
Double-click on the virtual disk
Choose installation media by browsing to the downloaded iso-file
Click on Install Ubuntu and choose your specific settings
Install drivers on request
Install updates
Straight-forward according
to http://www.openfoam.org/download/git.php (for 2.1.x, later in
http://www.openfoam.org/archive/2.1.0/download/)
Open a terminal window an
type
mkdir $HOME/OpenFOAM
cd $HOME/OpenFOAM
sudo apt-get install git binutils-dev
git clone
git://github.com/OpenFOAM/OpenFOAM-2.1.x.git
wget http://downloads.sourceforge.net/project/foam/foam/2.1.1/ThirdParty-2.1.1.tgz?r=http%3A%2F%2Fopenfoam.org%2Fdownload%2Fgit.php&ts=1344267545&use_mirror=garr
mv ThirdParty-2.1.1.tgz\?r\=http\:%2F%2Fopenfoam.org%2Fdownload%2Fgit.php
ThirdParty-2.1.1.tgz
tar xzf ThirdParty-2.1.1.tgz
rm ThirdParty-2.1.1.tgz
mv ThirdParty-2.1.1 ThirdParty-2.1.x
sudo apt-get install build-essential flex bison cmake zlib1g-dev qt4-dev-tools libqt4-dev gnuplot libreadline-dev libncurses-dev libxt-dev
#sudo apt-get install libscotch-dev
libopenmpi-dev #For parallel simulations, if system
versions of these are to be used. I didn't do this.
echo "alias OF21x='. $HOME/OpenFOAM/OpenFOAM-2.1.x/etc/bashrc'" >>
$HOME/.bashrc
gcc --version #Gives 4.6.3. Required: 4.3.?,
recommended: 4.4.?. Ok!
flex --version #Gives 2.5.35. Seems to have worked ok!
Open a new window and type:
OF21x
foam
./Allwmake #This takes 5 hours
./Allwmake>& log_Allwmake
#Second time is fast, just to easier check the log file for possible errors -
in my case none.
ParaFoam:
qmake --version #Gives 4.8.1.
Required: 4.6.2 or newer. Ok!
cmake --version #Gives 2.8.7. Required: 2.8.2 or
newer. Ok!
cd $WM_THIRD_PARTY_DIR
./makeParaView #This takes several hours
cd $FOAM_UTILITIES/postProcessing/graphics/PV3Readers
wmSET
./Allwclean
./Allwmake
Compile Debug version,
without recompiling ThirdParty:
echo "alias
OF21xDebug='. $HOME/OpenFOAM/OpenFOAM-2.1.x/etc/bashrc
WM_COMPILE_OPTION=Debug'" >> $HOME/.bashrc
Open new terminal window
OF21xDebug
cd $WM_THIRD_PARTY_DIR/platforms
ln -s linux64GccDPOpt linux64GccDPDebug
foam
./Allwmake #This takes 5 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/PV3Readers
wmSET
./Allwclean
./Allwmake
We will do debugging with gdb and Emacs. Emacs needs to be installed:
sudo apt-get install emacs23
You can also try ddd (not available at Chalmers):
sudo apt-get install ddd
Open new terminal window
and type
sudo apt-get install rpm
sudo ln -s /usr/bin/make /usr/bin/gmake #gmake is the same as make,
but missing in Ubuntu
cd $HOME/OpenFOAM
git clone
git://openfoam-extend.git.sourceforge.net/gitroot/openfoam-extend/OpenFOAM-1.6-ext
cd OpenFOAM-1.6-ext
echo "alias OF16ext='export QT_BIN_DIR=/usr/bin;.
\$HOME/OpenFOAM/OpenFOAM-1.6-ext/etc/bashrc'" >> $HOME/.bashrc
(setting QT_BIN_DIR makes sure that paraview is
compiled with system Qt)
Open a new terminal window
and type
OF16ext
foam3rdParty
./AllMake #This takes several hours
./AllMake >& log #Second time is fast, just to
check the log file for errors, none in my case ("...is already
installed" on all packages)
Open a new terminal window and type OF16ext, to make sure that all new
installations are recognized.
Hint: Have a look inside the AllMake.stage? files to
see what they do! They give you hints on how to install additional packages.
foam
./Allwmake #This takes 5 hours
./Allwmake >& log_Allwmake
#Second time is fast, just to check the log file for errors, none in my case
Issue with the OpenFOAM
reader for paraview with OpenFOAM-1.6-ext
I had problems with the paraFoam reader with
OpenFOAM-1.6-ext, so I re-compiled:
cd $FOAM_UTILITIES/postProcessing/graphics/PV3FoamReader
./Allwclean
./Allwmake
Unfortunately, the re-compilation of the reader didn’t help, so try to
interactively click on the OpenFOAM reader in the
pop-up window, or run foamToVTK and post-process
directly in paraview.
If you try for instance to re-compile Qt, you also
need to do:
sudo apt-get install libxrender-dev
To re-compile Paraview after compiling Qt:
foam3rdParty
mv rpmBuild/RPMS/x86_64/ParaView-3.12.0-linux64GccDPOpt.x86_64.rpm
rpmBuild/RPMS/x86_64/ParaView-3.12.0-linux64GccDPOpt.x86_64.rpm_old
./AllMake >& log
First, just
to make sure that we have all the packages we will need later, by copy-pasting
into a terminal window:
sudo apt-get install python python-dev python-matplotlib python-numpy python-scipy gnuplot
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/d/dc/PyFoam-0.5.7.tar.gz
tar xzf
PyFoam-0.5.7.tar.gz
rm
PyFoam-0.5.7.tar.gz
cd PyFoam-0.5.7
Install as
regular user (recommended):
python setup.py install --prefix=$HOME/OpenFOAM/PyFoam-0.5.7
echo "alias PF057='export
PYTHONPATH=$HOME/OpenFOAM/PyFoam-0.5.7/lib/python-2.7/site-packages:\$PYTHONPATH;
export PATH=$HOME/OpenFOAM/PyFoam-0.5.7/bin:\$PATH'"
>> $HOME/.bashrc
Open a new
window and type (<TAB> refers to the tab key):
PF057
pyFoam<TAB><TAB>
You will
see numerous pyFoam commands that can be used to help
you use OpenFOAM efficiently.