2013年7月の記事一覧

OpenFOAM-1.6-extをLubuntu 12.04(仮想マシン) にインストール

icoFsiFoamを試したいので,OpenFOAM-1.6-extをインストールした仮想マシンを作成した.その手順をメモします.

今回は,VMWarePlayer用仮想マシン(メモリ1GB,HDD 20GB)に,OSとしてLubuntu12.10 32bitをインストールした.仮想マシンを軽くしたいので,Lubuntuを採用.


下記サイトの情報に従ってインストール作業を実施する。ほぼ指示通りだが,一部のファイル入手先を変更する必要がある.

http://openfoamwiki.net/index.php/Installation/Linux/OpenFOAM-1.6-ext/Ubuntu


上記サイトで,Ubuntu12.10に追加が必要とされるパッケージ

git flex bison rpm g++ zlib1g-dev binutils-dev openmpi-bin libopenmpi-dev paraview libscotch-dev cmake libstdc++5

OpenFOAM公式版で Ubuntu に追加が必要とされているパッケージ

build-essential flex bison cmake zlib1g-dev qt4-dev-tools libqt4-dev gnuplot libreadline-dev libncurses-dev libxt-dev

Lubuntuなので,追加が必要と思われるパッケージ

gcc make qt4-qmake


これらパッケージを,まとめてインストール

sudo apt-get install git flex bison rpm g++ zlib1g-dev binutils-dev openmpi-bin libopenmpi-dev paraview libscotch-dev cmake libstdc++5 build-essential qt4-dev-tools libqt4-dev gnuplot libreadline-dev libncurses-dev libxt-dev gcc make qt4-qmake


vmware-toolsのインストール


OpenFOAM-1.6-extの入手

git clone git://git.code.sf.net/p/openfoam-extend/OpenFOAM-1.6-ext openfoam-extend-OpenFOAM-1.6-ext


入手したコードをユーザディレクトリ下に配置

mkdir ~/OpenFOAM/

mv openfoam-extend-OpenFOAM-1.6-ext ~/OpenFOAM/OpenFOAM-1.6-ext


インストールディレクトリに移動

cd OpenFOAM-1.6-ext


preferencesファイルに設定を書き込む。etc/prefs.sh-EXAMPLEというファイルをコピーして,etc/prefs.shを作成し,必要な設定を書き換えていく。(sedコマンドを利用する。)

下記コマンドを順に実行する。(#の行はコメントなので,実行不要.)

cp etc/prefs.sh-EXAMPLE etc/prefs.sh

#Use the system compiler and configure to use Gcc 4.7

sed -i s/"compilerInstall=System"/"compilerInstall=System"/g etc/prefs.sh

echo "export WM_COMPILER=Gcc47" >> etc/prefs.sh

# Use the system installation of OpenMPI

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"/"export OPENMPI_BIN_DIR"/g etc/prefs.sh

# Use the system's ParaView

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"/"export PARAVIEW_BIN_DIR"/g etc/prefs.sh

# Use the system's Scotch

sed -i s/"#export SCOTCH_SYSTEM=1"/"export SCOTCH_SYSTEM=1"/g etc/prefs.sh

sed -i s/"#export SCOTCH_DIR=path_to_system_installed_scotch"/"export SCOTCH_DIR=\/usr"/g etc/prefs.sh

sed -i s/"^#export SCOTCH"/"export SCOTCH"/g etc/prefs.sh

sed -i 's-SCOTCH_DIR/include$-SCOTCH_DIR/include/scotch-g' etc/prefs.sh

# Use the system's CMake

sed -i s/"#export CMAKE_SYSTEM=1"/"export CMAKE_SYSTEM=1"/g etc/prefs.sh

sed -i s/"#export CMAKE_DIR=path_to_system_installed_cmake"/"export CMAKE_DIR=\/usr"/g etc/prefs.sh

sed -i s/"^#export CMAKE"/"export CMAKE"/g etc/prefs.sh
コンパイルに使うCPUコア数を指定する.仮想マシンのコア数を2にしていたので,2コアとした.

#here you can change 4 to the number of cores you've got

echo "export WM_NCOMPPROCS=2" >> etc/prefs.sh
paraFoamの設定を変更する.

#we'll need to switch to the internal reader for ParaView

sed -i -e 's=\.OpenFOAM=\.foam=' bin/paraFoam

sed -i -e 's/^unset/export LC_ALL=C; unset/' bin/paraFoam

gmakeコマンドが使われる場合があるので,makeのリンクとして作成する。

#Create a symbolic link for gmake

ln -s /usr/bin/make bin/gmake

tecioのための設定.

#disable X dependencies in tecio

sed -i -e 's=\(U_WIN32\)$=\1 -DENGINE=g' applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio/tecsrc/Make/tecioOptions


OSが32bitか64bitかを確かめるために,下記コマンドを実行する。

この結果が,i686 であれば 32bit,x86_64 であれば64bitとなる。

uname -m


32bit版なので,下記を順に実行する.

echo "export WM_ARCH_OPTION=32" >> etc/prefs.sh

#copy the rules from ''Gcc46'' to ''Gcc47''

cp -r wmake/rules/linuxGcc46 wmake/rules/linuxGcc47

# due to stricter name lookup rules in 4.7 we need to tell the compiler to lighten up on this

sed -i 's/^\(c++FLAGS.*\)/\1 -fpermissive/g' wmake/rules/linuxGcc47/c++

もし,64bit版の場合は下記となる.

#copy the rules from ''Gcc46'' to ''Gcc47''
cp -r wmake/rules/linux64Gcc46 wmake/rules/linux64Gcc47
 # due to stricter name lookup rules in 4.7 we need to tell the compiler to lighten up on this
sed -i 's/^\(c++FLAGS.*\)/\1 -fpermissive/g' wmake/rules/linux64Gcc47/c++

bashrc設定ファイルを読み込んだ後,.bashrcに追記する.

source etc/bashrc

echo "source $HOME/OpenFOAM/OpenFOAM-1.6-ext/etc/bashrc" >> $HOME/.bashrc


ThridPartyに移動する.

cd ThirdParty


ParMGridGenのウェブサイトを変更

sed -i 's= http://www.mgnet.org/mgnet/Codes/parmgridgen=http://www-users.cs.umn.edu/~moulitsa/download=' rpmBuild/SPECS/ParMGridGen-1.0.spec AllMake.stage3


システムに追加したcmakeを使うため,cmakeのコンパイルをしない.

sed -i 's=^( rpm_make -p cmake=#( rpm_make -p cmake=' AllMake.stage1


ThirdPartyのコンパイルを実行.数分から30分程度は必要.メッセージはファイルに書き込む.

# This next command will take a while... somewhere between 5 to 30 minutes

./AllMake > log.AllMake 2>&1


もう一度,上記と同じものを実行する.これで,途中の細かいメッセージはなくなり,インストールの要約がファイルに書かれることになる.

#Run it a second time for getting a summary of the installation

./AllMake > log.AllMake 2>&1


log.AllMakeファイルの中身を確認する.

おそらく,libccmio のコンパイルに失敗している.対応方法は不明.設定ファイルを修正する必要がありそう.Star-CCMメッシュを扱わないときは,無視して良い?


ここから,OpenFOAM 1.6.ext本体のコンパイル作業に入る.


cd ~/OpenFOAM/OpenFOAM-1.6-ext

source etc/bashrc


OpenFOAM 1.6.ext本体のコンパイルを実行.30分から数時間程度は必要.メッセージはファイルに書き込む.

# This next command will take a while... somewhere between 30 minutes to 3-6 hours.

./Allwmake > make.log 2>&1

もう一度,上記と同じものを実行する.これで,途中の細かいメッセージはなくなり,インストールの要約がファイルに書かれることになる.

#Run it a second time for getting a summary of the installation

./Allwmake > make.log 2>&1


コンパイルができているかを確認するため,下記を実行.icoFoamの使い方が表示されればOK.

icoFoam -help


通常のOpenFOAMと同様に使うには,下記を順に実行して,tutorialsをコピーする.

mkdir -p $FOAM_RUN

cp -r $FOAM_TUTORIALS $FOAM_RUN


icoFoamのcavity例題で,動作を確認する.

cd $FOAM_RUN/tutorials/incompressible/icoFoam/cavity

blockMesh

icoFoam

paraFoam


0