0% found this document useful (0 votes)
262 views

Open FOAM

The document provides instructions for installing OpenFOAM, foam-extend, and related software on an Ubuntu virtual machine. It describes downloading and installing Ubuntu in VirtualBox, then using apt-get and git to install OpenFOAM, foam-extend, ParaView, Python packages, and other utilities over several sections totaling around 15 hours of installation time. Testing instructions are provided to validate the OpenFOAM and foam-extend installations.

Uploaded by

ong
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
262 views

Open FOAM

The document provides instructions for installing OpenFOAM, foam-extend, and related software on an Ubuntu virtual machine. It describes downloading and installing Ubuntu in VirtualBox, then using apt-get and git to install OpenFOAM, foam-extend, ParaView, Python packages, and other utilities over several sections totaling around 15 hours of installation time. Testing instructions are provided to validate the OpenFOAM and foam-extend installations.

Uploaded by

ong
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 9

OpenFOAM and foam-extend on Your Own Laptop

The teaching is designed so that you should follow the steps I do on a computer.
It is highly recommended that you install the software on your own laptop so th
at you are independent. The Linux commands below are written for bash shell.
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., and later perhaps some additional useful things
that we will use in the course. We will pull the git source and compile from sc
ratch, since we will then get access to updates and bug fixes. OpenFOAM-2.3.0 ca
n also be installed as a package, which is much faster, but gives less control i
n 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!
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 arent (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 r
eason 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 Ill help you.
Installation and updating of Ubuntu 14.04 LTS in Virtual Box (under Windows 7, i
n this case):

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 con
tribution 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 C
D 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 v
ersion, 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 require
d 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 t
hird-party software
When it asks you if it should erase the whole disk, it refers to the virtual dis
k 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 virtua
l 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 drive
rs when you click on it. It might be good to do so, and activate virtual box driv
ers. 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 Mana
ger when you move the pointer over it. Use it to update the system, and restart U
buntu.
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 popup 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.
Install OpenFOAM-2.3.x

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/Ub
untu
Open a terminal window:
CTRL-ALT-T
type (copy-paste from homepage, 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.t
gz
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 star
ting again from where you opened a new terminal window above
./Allwmake
./Allwmake>& log_Allwmake #Second time is fast, just to easier check the log fil
e 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
cd $FOAM_UTILITIES/postProcessing/graphics/PV4Readers
wmSET
./Allwclean
./Allwmake
Test the installation:
CTRL-ALT_T #To open an new terminal window
OF23x
mkdir -p $FOAM_RUN
run
cp -r $FOAM_TUTORIALS/incompressible/icoFoam/cavity .
cd cavity
blockMesh
icoFoam
paraFoam
Install OpenFOAM-2.3.x Debug version (after the above, i.e. with OpenFOAM-2.3.x
installed)

This section takes about 4h to complete.


Compile Debug version, without recompiling ThirdParty:
echo "alias of23xd= . $HOME/OpenFOAM/OpenFOAM-2.3.x/etc/bashrc WM_COMPILE_OPTION
=Debug " >> $HOME/.bashrc
Open new terminal window
of23xd
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 fil
e for possible errors - in my case none.
cd $FOAM_UTILITIES/postProcessing/graphics/PV4Readers
Dont do wmSET since it will not pick Debug version see alias wmSET! Instead:
OF23xDebug
./Allwclean
./Allwmake

Test the installation:


CTRL-ALT_T #To open an new terminal window
OF23xDebug
mkdir -p $FOAM_RUN
run
cp -r $FOAM_TUTORIALS/incompressible/icoFoam/cavity .
cd cavity
blockMesh
icoFoam
paraFoam
Install Emacs, ddd, Python, Numpy, SciPy, Matplotlib, Gnuplot, PyFoam

This takes 10min to complete.

We will do debugging with gdb and Emacs. Emacs 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-sci
py
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-ext
end).
We will follow the installation instructions for PyFoam at http://openfoamwiki.n
et/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 pf62= export PYTHONPATH=\$HOME/OpenFOAM/PyFoam-0.6.2/lib/python2.7/s
ite-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.
Install foam-extend-3.1 (including PyFoam, swak4Foam etc.)

The foam-extend (foam-extend.org) fork has some features that are not in OpenFOA
M-x.x.x, such as the GGI interface. If you do not need those features, you do no
t have to follow this section.

This section takes about 5h or more leave the computer over-night (where this me
ssage is repeated).

For other installation instructions, see also:

http://sourceforge.net/p/openfoam-extend/wiki/Home/

http://openfoamwiki.net/index.php/Installation/Linux/foam-extend-3.1

And later the file $WM_PROJECT_DIR/doc/buildInstructions/Ubuntu/Ubuntu_1


4.04, also located here:
https://sourceforge.net/p/openfoam-extend/foam-extend-3.1/ci/master/tree/doc/bui
ldInstructions/Ubuntu/Ubuntu_14.04

The compilation procedure is actually very simple, but I modify it slightly to u


se 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 pas
sword 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-d
ev-tools libqt4-dev

sudo apt-get install libncurses5-dev libiberty-dev libxt-dev rpm mercurial graph


viz 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 th
en you will not have Paraview compiled, and you will waste some disk space on so
ftware that may be installed in the system. Instead of compiling Paraview, you c
an also install it with sudo apt-get paraview, but then you dont get the foam-exten
d-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 e
tc/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 ThirdP
arty)
sed -i s/"( rpm_make -p cmake"/"#( rpm_make -p cmake"/g ThirdParty/AllMake.stage
1
# 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/Al
lMake.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 uncom
ment 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.s
h
#sed -i s/"#export PARAVIEW_DIR=path_to_system_installed_paraview"/"export PAR
AVIEW_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= $HOME/foam/foam-extend-3.1/bin/paraFoam
####################################################################
Set up the foam-extend-3.1 environment:
echo "alias fe31= . \$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:
CTRL-ALT_T #To open an 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
.

-------------------------------------------------Installation/swak4Foam/Installing On/Ubuntu
< Installation | swak4Foam | Installing On
1 Introduction
This page is dedicated to explaining how to install swak4Foam in Ubuntu.
If you do not yet feel comfortable using Linux, then perhaps you better first re
ad the page Working with the Shell and train a bit with the shell/terminal envir
onments, so you can have a better perception of the steps shown below.
Contents
1 Introduction
2 Copy-Paste steps
2.1 Ubuntu 10.04 to 14.10
2 Copy-Paste steps
A few notes before you start copy-pasting:
Lines that start with # don t have to be copy-pasted. They are just comments
to let you know what s going on.
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 brea
k the copied characters!
2.1 Ubuntu 10.04 to 14.10
Discussion thread where you can ask questions about these steps: None available
at the moment.
Steps:
Install the necessary packages:
sudo apt-get install build-essential bison flex subversion git mercurial wge
t
The following packages are optional, depending on where you download it from
:
subversion - If you re going to download from an SVN repository.
git - If you re going to download from a Git repository.
mercurial - If you re going to download from a Mercurial repository.
wget - If you re going to download a snapshot directly from the command
line.
You might only know which optional package you ll need, when following the i
nstructions from the following step.
Now, to download and unpack swak4Foam, please follow the respective instruct
ions from this page: Installation/swak4Foam/Downloading - once you ve completed
the download and unpacking process, then you can proceed to the following step.
Now let s build swak4Foam:
#Go into swak4Foam s main source folder
cd swak4Foam
# This next command will take a while...

./Allwmake > make.log 2>&1


#Run it a second time for getting a summary of the installation
./Allwmake > make.log 2>&1
Tip
If using a GCC or ICC compiler (and not clang), then before running Allw
make, the following command can define the number of cores to be used for a fast
er build process:
export WM_NCOMPPROCS=4
Where 4 means that the machine has got 4 processor cores. Using a value
larger than the number of cores the machine has got, can risk using more memory
than the machine has got and leading to a freeze or crash.
If you re not familiar with OpenFOAM s build process, namely to check if eve
rything built as intended, then check the instructions given at this page: Insta
llation/swak4Foam/Understanding Error Messages
If everything went well, then head onto the main swak4Foam page: Contrib/swa
k4Foam
Discussion thread where you can ask questions about these steps: None available
at the moment.

You might also like