Miscellaneous tips and tricks

This page is mainly for myself, but I have made it available if it is useful for someone else.

General hints on installing OpenFOAM

If you need to install a proper version of gcc, Qt etc. for 2.0.x, have a look at the scripts in ThirdParty, such as makeGcc, see which versions they require, get those versions from the Internet, compile by running the script.

Raw notes from installing OpenFOAM-2.0.x on my 64-bit laptop with Ubuntu-10.04 LTS 64-bit:

Follow original instructions, except for cmake:

OF20x

sed -i s/"cmake-2.8.4"/"cmake-2.8.5"/g $HOME/OpenFOAM/OpenFOAM-2.0.x/etc/config/myParaview.sh

sed -i s/"cmake-2.8.3"/"cmake-2.8.5"/g $THIRD_PARTY_DIR/makeCmake

cd $THIRD_PARTY_DIR
wget http://www.cmake.org/files/v2.8/cmake-2.8.5.tar.gz

tar xzf cmake-2.8.5.tar.gz

rm cmake-2.8.5.tar.gz

./makeCmake

 

Raw notes from installing OpenFOAM-2.0.x in FoDAT (non-root), Redhat Enterprise 5.6, HT11
Note that minus signs and perhaps some other characters have been destroyed by Word, so copy-paste might not work!

This info should also be available in 00README_installation

uname -a:

Linux sugi.medic.chalmers.se 2.6.39-1.el5.elrepo #1 SMP PREEMPT Fri Jun 3 19:17:28 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux
cd /scratch/hani/
mkdir OpenFOAM
cd OpenFOAM/
git clone git://github.com/OpenCFD/OpenFOAM-2.0.x.git
wget --no-check-certificate https://downloads.sourceforge.net/project/foam/foam/2.0.1/ThirdParty-2.0.1.gtgz?r=http%3A%2F%2Fopenfoam.com%2Fdownload%2Fgit.php&ts=1312968761&use_mirror=switch
tar xzf ThirdParty-2.0.1.gtgz
rm ThirdParty-2.0.1.gtgz
mv ThirdParty-2.0.1 ThirdParty-2.0.x
echo "alias OF20x='export FOAM_INST_DIR=/scratch/hani/OpenFOAM; source $FOAM_INST_DIR/OpenFOAM-2.0.x/etc/bashrc'" >> $HOME/.bashrc
Open a new window
OF20x
cd $WM_THIRD_PARTY_DIR
gcc --version #Required: 4.3.?, recommended: 4.4.?. The one default is too old!
See $WM_THIRD_PARTY_DIR/makeGcc for which packages are needed
wget ftp://ftp.gmplib.org/pub/gmp-5.0.1/gmp-5.0.1.tar.gz
tar xzf gmp-5.0.1.tar.gz
rm gmp-5.0.1.tar.gz
wget http://www.mpfr.org/mpfr-2.4.2/mpfr-2.4.2.tar.gz
tar xzf mpfr-2.4.2.tar.gz
rm mpfr-2.4.2.tar.gz
wget http://www.multiprecision.org/mpc/download/mpc-0.8.1.tar.gz
tar xzf mpc-0.8.1.tar.gz
rm mpc-0.8.1.tar.gz
wget ftp://ftp.fu-berlin.de/unix/languages/gcc/releases/gcc-4.5.1/gcc-4.5.1.tar.gz
tar xzf gcc-4.5.1.tar.gz
rm gcc-4.5.1.tar.gz
./makeGcc #Can be killed and restarted
sed -i s/"export WM_COMPILER=Gcc"/"export WM_COMPILER=Gcc45"/g $FOAM_INST_DIR/OpenFOAM-2.0.x/etc/bashrc
sed -i s/"foamCompiler=system/"foamCompiler=ThirdParty"/g $FOAM_INST_DIR/OpenFOAM-2.0.x/etc/bashrc
sed -i s/"gcc-4.5.2"/"gcc-4.5.1"/g $FOAM_INST_DIR/OpenFOAM-2.0.x/etc/bashrc
flex --version #Available, but it will not work properly (“error: no ‘int yyFlexLexer::ywrap()’ member function declared in class ‘yyFlexer’”,):

cd $WM_THIRD_PARTY_DIR
wget http://downloads.sourceforge.net/project/flex/flex/flex-2.5.35/flex-2.5.35.tar.gz?r=http%3A%2F%2Fflex.sourceforge.net%2F&ts=1282292981&mirror=garr
tar xzf flex-2.5.35.tar.gz
rm flex-2.5.35.tar.gz
cd flex-2.5.35
./configure --prefix $WM_THIRD_PARTY_DIR/platforms/linux64/flex-2.5.35
make
make install
Set in settings.sh:
_foamAddPath $WM_THIRD_PARTY_DIR/platforms/linux64/flex-2.5.35/bin
For all the files that complained about flex, add in Make/options:
-I$(WM_THIRD_PARTY_DIR)/platforms/$(WM_ARCH)/flex-2.5.35/include
I.e.:
  src/triSurface/Make/options
  src/surfMesh/Make/options
  src/thermophysicalModels/reactionThermo/Make/options
  applications/utilities/mesh/conversion/ansysToFoam/Make/options
  applications/utilities/mesh/conversion/fluent3DMeshToFoam/Make/options
  applications/utilities/mesh/conversion/fluentMeshToFoam/Make/options
  applications/utilities/mesh/conversion/gambitToFoam/Make/options
Open new terminal window and type:
OF20x
foam
./Allwmake >& log_Allwmake_1&

Parafoam:
qmake --version #Required: 3.6.2 or newer. bash: qmake: command not found
cmake --version #Required: 2.8.2 or newer. Ok!
cd $WM_THIRD_PARTY_DIR
wget http://get.qt.nokia.com/qt/source/qt-everywhere-opensource-src-4.7.3.tar.gz
tar xzf qt-everywhere-opensource-src-4.7.3.tar.gz
./makeQt
echo "export QT_DIR=\$WM_THIRD_PARTY_DIR/platforms/\$WM_ARCH\$WM_COMPILER/qt-4.7.3" >> $FOAM_INST_DIR/OpenFOAM-2.0.x/etc/config/paraview.sh
echo "export QT_BIN_DIR=\$QT_DIR/bin" >> $FOAM_INST_DIR/OpenFOAM-2.0.x/etc/config/paraview.sh
echo "export PATH=\$QT_BIN_DIR:\$PATH" >> $FOAM_INST_DIR/OpenFOAM-2.0.x/etc/config/paraview.sh
echo "export LD_LIBRARY_PATH=\$QT_DIR/lib:\$LD_LIBRARY_PATH" >> $FOAM_INST_DIR/OpenFOAM-2.0.x/etc/config/paraview.sh

Open a new terminal:
OF20x
cd $WM_THIRD_PARTY_DIR
./makeParaView
cd $FOAM_UTILITIES/postProcessing/graphics/PV3Readers
wmSET
./Allwclean
./Allwmake

 

Compile 1.6-ext in Debug mode without re-compiling ThirdParty

First do soft links from linux64GccDPOpt to linux64GccDPDebug in the following

(ln -s linux64GccDPOpt linux64GccDPDebug)
[hani@vcs64-5 ThirdParty]$ find $WM_THIRD_PARTY_DIR -name linux64GccDPDebug
/chalmers/sw/unsup64/OpenFOAM/OpenFOAM-1.6-ext/ThirdParty/packages/mesquite-2.1.2/platforms/linux64GccDPDebug
/chalmers/sw/unsup64/OpenFOAM/OpenFOAM-1.6-ext/ThirdParty/packages/cmake-2.8.3/platforms/linux64GccDPDebug
/chalmers/sw/unsup64/OpenFOAM/OpenFOAM-1.6-ext/ThirdParty/packages/ParMetis-3.1.1/platforms/linux64GccDPDebug
/chalmers/sw/unsup64/OpenFOAM/OpenFOAM-1.6-ext/ThirdParty/packages/openmpi-1.4.3/platforms/linux64GccDPDebug
/chalmers/sw/unsup64/OpenFOAM/OpenFOAM-1.6-ext/ThirdParty/packages/metis-5.0pre2/platforms/linux64GccDPDebug
/chalmers/sw/unsup64/OpenFOAM/OpenFOAM-1.6-ext/ThirdParty/packages/ParMGridGen-1.0/platforms/linux64GccDPDebug
/chalmers/sw/unsup64/OpenFOAM/OpenFOAM-1.6-ext/ThirdParty/packages/ParaView-3.8.1/platforms/linux64GccDPDebug
/chalmers/sw/unsup64/OpenFOAM/OpenFOAM-1.6-ext/ThirdParty/packages/scotch-5.1.10b/platforms/linux64GccDPDebug

Then use WM_COMPILE_OPTION=Debug and run Allwmake

Installation of Python etc. in unsup64

 

Check out www.enthought.com for an academic licence of a complete package.

After installation by running the *.sh file, simply add the path:

alias EDP='export PATH=/chalmers/sw/unsup64/OpenFOAM/edp-7.1.2-rh5-x86_64/bin:$PATH'

This seems to work nicely!

 

Some initial attempts to install Python-2.6.7 and numpy-1.6.1:

2.7* did not work to make

Done directly in unsup64:
cd /chalmers/sw/unsup64/OpenFOAM/linuxSrc/
wget http://www.python.org/ftp/python/2.6.7/Python-2.6.7.tgz
tar xzf Python-2.6.7.tgz
rm Python-2.6.7.tgz
cd Python-2.6.7
Read README file:
Don't have PYTHONPATH and PYTHONHOME set when making Python
./configure --prefix /chalmers/sw/unsup64/OpenFOAM/Python-2.6.7
make
make install

add PATH to the bin directory of the installation, overriding other installations:

alias PNM='export PATH=/chalmers/sw/unsup64/OpenFOAM/Python-2.6.7/bin:$PATH;export PYTHONPATH=/chalmers/sw/unsup64/OpenFOAM/numpy-1.6.1/lib/python2.6/site-packages:$PYTHONPATH'

(the numpy part is of course so that Python finds numpy when importing)

 

Make sure to use Python2.6 first
/chalmers/sw/unsup64/OpenFOAM/linuxSrc/
wget --no-check-certificate https://downloads.sourceforge.net/project/numpy/NumPy/1.6.1/numpy-1.6.1.tar.gz?r=&ts=1313070315&use_mirror=netcologne
tar xzf numpy-1.6.1.tar.gz
rm numpy-1.6.1.tar.gz
cd numpy-1.6.1
python setup.py install --prefix /chalmers/sw/unsup64/OpenFOAM/numpy-1.6.1
export PYTHONPATH=/chalmers/sw/unsup64/OpenFOAM/numpy-1.6.1/lib/python2.6/site-packages:$PYTHONPATH

Compilation of gcc-4.3.1 and using it to compile OpenFOAM-1.5-dev

If you don't have the correct version of gcc (4.3.1 or newer, see gcc.gnu.org), then do the following (for 32 bit, some minor changes are required for 64 bit, like linux64 instead of linux):

1.      Install gcc 4.3.1. This requires that either any version of cc or gcc are available already. It also requires that two libraries, mpfr and gmp, are available, which is the reason to the lengthy installation procedure below:

cd $HOME/OpenFOAM/ThirdParty
mkdir gmp-4.3.2
mkdir mpfr-2.3.2
mv gcc-4.3.1 gcc-4.3.1_orig; mkdir -p gcc-4.3.1/platforms/linux
mkdir linuxSrc; cd linuxSrc
wget ftp://ftp.gmplib.org/pub/gmp-4.3.2/gmp-4.3.2.tar.gz
tar xzf gmp-4.3.2.tar.gz
cd gmp-4.3.2
./configure --prefix=$HOME/OpenFOAM/ThirdParty/gmp-4.3.2 2>&1 | tee log_configure
make 2>&1 | tee log_make #Check this file for error messages!
make check 2>&1 | tee log_make_check #Check this file for error messages!
make install 2>&1 | tee log_make_install #Check this file for error messages!
cd ..
wget http://www.mpfr.org/mpfr-2.3.2/mpfr-2.3.2.tar.gz
tar xzf mpfr-2.3.2.tar.gz
cd mpfr-2.3.2
./configure --prefix=$HOME/OpenFOAM/ThirdParty/mpfr-2.3.2 --with-gmp=$HOME/OpenFOAM/ThirdParty/gmp-4.3.2 2>&1 | tee log_configure
make 2>&1 | tee log_make #Check this file for error messages!
make check 2>&1 | tee log_make_check #Check this file for error messages!
make install 2>&1 | tee log_make_install #Check this file for error messages!
cd ..
wget http://gcc-uk.internet.bs/releases/gcc-4.3.1/gcc-4.3.1.tar.gz
tar xzf gcc-4.3.1.tar.gz
cd gcc-4.3.1
make distclean #This is only necessary if gcc has been built before, but doesn't hurt
./configure --prefix=$HOME/OpenFOAM/ThirdParty/gcc-4.3.1/platforms/linux -enable-languages=c,c++ --with-gmp=$HOME/OpenFOAM/ThirdParty/gmp-4.3.2 --with-mpfr=$HOME/OpenFOAM/ThirdParty/mpfr-2.3.2 2>&1 | tee log_configure
make 2>&1 | tee log_make #Check this file for error messages!
make install 2>&1 | tee log_make_install #Check this file for error messages!

Before compiling OpenFOAM-1.5-dev we need to make sure that our freshly compiled gcc will be used, which is done by a change in $WM_PROJECT_DIR/etc/settings.h:
Change:

#compilerInstall=OpenFOAM
compilerInstall=System

to:

compilerInstall=OpenFOAM
#compilerInstall=System

Then open a new terminal window and do the following:

OF15dev
foam
./Allwmake 2>&1 | tee log_Allwmake

The compilation will take something in the order of four hours.

Problem with flex

If you get an error message saying something like: “error: no ‘int yyFlexLexer::ywrap()’ member function declared in class ‘yyFlexer’”, then that can be solved by compiling your own flex-2.5.35:

 

mkdir -p $WM_THIRD_PARTY_DIR/flex-2.5.35
cd $WM_THIRD_PARTY_DIR/linuxSrc
wget http://downloads.sourceforge.net/project/flex/flex/flex-2.5.35/flex-2.5.35.tar.gz?r=http%3A%2F%2Fflex.sourceforge.net%2F&ts=1282292981&mirror=garr
tar xzf flex-2.5.35.tar.gz
cd flex-2.5.35
./configure --prefix $WM_THIRD_PARTY_DIR/flex-2.5.35 2>&1 | tee log_configure
make 2>&1 | tee log_make
make install 2>&1 | tee log_make_install

Set in settings.sh:

export PATH=$WM_THIRD_PARTY_DIR/flex-2.5.35/bin:$PATH

For all the files that complained about flex, add in Make/options:
-I$(WM_THIRD_PARTY_DIR)/flex-2.5.35/include

Install VTK to make a GUI with a visualization window

Here I dump some preliminary information on how to install VTK in FoDAT

For some reason you need the tk_dev package in order to use Python wrap.

cd $HOME/OpenFOAM/linuxSrc

wget http://www.vtk.org/files/release/5.6/vtk-5.6.1.tar.gz

tar xzf vtk-5.6.1.tar.gz

cd ..

mkdir VTK-build

cd VTK-build

ccmake ../linuxSrc/VTK

In ccmake, press ‘c’ to configure, and ‘Enter’ to change values:

Make sure to set:

BUILD_SHARED_LIBS to ON

VTK_WRAP_PYTHON to ON

CMAKE_INSTALL_PREFIX to $HOME/OpenFOAM/VTK-build (or wherever you have put it)

Then press ‘c’ to configure again and ‘g’ to save the configuration and exit, and continue in the terminal window…

make

Before the next command it seems to be necessary to do “export PYTHONPATH=$FOAM_INST_DIR/VTK-build/lib/python2.4/site-packages”

make install

Then it failed since there was a directory missing. I just added it and run make install again.

Then set:

export LD_LIBRARY_PATH=/chalmers/sw/unsup64/OpenFOAM/VTK-build/bin:$FOAM_INST_DIR/VTK-build/lib/python2.4/site-packages/VTK-5.6.1-py2.4.egg/vtk:$FOAM_INST_DIR/VTK-build/lib/vtk-5.6:$LD_LIBRARY_PATH

export PYTHONPATH=/chalmers/sw/unsup64/OpenFOAM/VTK/Wrapping/Python:/chalmers/sw/unsup64/OpenFOAM/VTK-build/bin:$FOAM_INST_DIR/VTK-build/lib/python2.4/site-packages:$PYTHONPATH

i.e. note that the original VTK directory can not be removed. Don’t know why Wrapping is not installed to VTK-build.

Install PyQt4 to make a GUI

Here I dump some preliminary information on how to install PyQt4 in FoDAT:

First make sure that qt was installed in the same location as it is located, i.e. DON’T MOVE QT after it has been installed – it remembers the original path!

First source OpenFOAM and the available qt installation (see above for OF-1.7.x. Note: QMAKESPEC, below, should not be set before installing qt):

OF17x

Then install SIP:

cd $FOAM_INST_DIR

mkdir sip-4.11.2

cd $FOAM_INST_DIR/linuxSrc/sip-4.11.2

python configure.py –b $FOAM_INST_DIR/sip-4.11.2 –e $FOAM_INST_DIR/sip-4.11.2 –d $FOAM_INST_DIR/sip-4.11.2 –v $FOAM_INST_DIR/sip-4.11.2

Then install PyQt-x11-gpl-4.8.1:

cd $FOAM_INST_DIR/linuxSrc/PyQt-x11-gpl-4.8.1

export PYTHONPATH=$FOAM_INST_DIR/sip-4.11.2

export QTDIR=$FOAM_INST_DIR/ThirdParty-1.7.x/qt-everywhere-opensource-src-4.6.3

export QMAKESPEC=$QTDIR/mkspecs/linux-g++-64

python configure.py --verbose --confirm-license -b $FOAM_INST_DIR/PyQt-x11-gpl-4.8.1 -d $FOAM_INST_DIR/PyQt-x11-gpl-4.8.1

make

make install

The following is probably not needed:

export LD_LIBRARY_PATH=$FOAM_INST_DIR/PyQt-x11-gpl-4.8.1/PyQt:$LD_LIBRARY_PATH

The following IS needed:

export PYTHONPATH=$FOAM_INST_DIR/PyQt-x11-gpl-4.8.1:$PYTHONPATH

Qt documentation:

doc.qt.nokia.com