LoginSignup
5
6

More than 5 years have passed since last update.

PC2台を使ったOpenFOAMの計算

Posted at

流体解析のオープンソースソフトウェアであるOpenFOAMのバージョン4.1を使ってノード間計算を実施しようとしたときのメモ

OpenFOAMのインストール

インストール環境
 - Ubuntu 14.04LTS
 - OpenFOAM4.1
 - WS2台用意で同一のユーザー名(workstation01 workstaion02)
 - リポジトリからapt-getを用いてインストール
 - インストール先は/opt/
 - nfsは使わない

sudo add-apt-repository http://www.openfoam.org/download/ubuntu
sudo apt-get update
sudo apt-get install openfoam4 

ubuntuであれば特に問題なくインストールできる。
2台ともに入れる

SSHの設定

SSHの設定は以下を参照して設定
インフラエンジニアじゃなくても押さえておきたいSSHの基礎知識

チュートリアルcavityによる計算

cavityをコピーしてきてメッシュ作成、decomposeParを編集して4並列化する
まずは単体(workstation01)による並列計算

 cp -r $FOAM_TUTORIALS/..  ~/cavity
 cd ~/cavity
 blockMesh 
 decomposePar
 mpirun -np 4 icoFoam -parallel

正しくインストールできているのなら特に問題なく実行可能

caseファイルにmachinesを作成し、以下の内容を書き込み保存

nano ~/cavity/machines
machines
workstation01 cpu=2
workstation02 cpu=2

workstation02に同じ位置(~/cavity)にscpを使って転送する。そして実行

 mpirun --hostfile machines -np 4 icoFoam -parallel
-------------------------------------------------------------------------
mpirun was unable to launch the specified application as it could not find an executable:

Executable: icoFoam
Node: workstation02

while attempting to start process rank 2.
-------------------------------------------------------------------------

エラーが出た。エラーを見るとicoFoamが呼び出せていない
~/.bashrc で /opt/openfoam4/etc/bashrcは読み込む設定しておりそれぞれ単体では実行可能なのに

ssh  workstation02 icoFoam 

と打ってもicoFoamは存在しないようなので
mpirun実行時には ~/.bashrc で /opt/openfoam4/etc/bashrcは読めていないよう。

ssh  workstation02 echo $PATH 

としたら/opt/openfoam4以下のものが設定できていないことが判明。
~/.bashrc の先頭付近にある以下のもので上の部分ですぐ ~/.bashrc を抜けてしまって、それ以降の設定が反映されない。
これらをコメント文にすると/opt/openfoam4/etc/bashrcが読め込めた。

.bashrc
# If not running interactively, don't do anything
case $- in
    *i*) ;;
      *) return;;
esac

再び実行するが結果は同じ。

 mpirun --hostfile machines -np 4 icoFoam -parallel
-------------------------------------------------------------------------
mpirun was unable to launch the specified application as it could not find an executable:

Executable: icoFoam
Node: workstation02

while attempting to start process rank 2.
-------------------------------------------------------------------------

やはり/opt/だとroot権限がないためmpirun実行時には実行できなかった。
そこでapt-get installでは/opt/にしか入らないので、
ソースからコンパイルして任意の場所(/Home/user/OpenFOAM)に入れた。

コンパイルのやり方は以下を参照に
CentOSにOpenFOAM 4.0をインストール
大きな問題はなくコンパイルできた。(OpenFOAMのコンパイルは時間かかったけど)

openFOAMへのパスを通して

 mpirun --hostfile machines -np 4 icoFoam -parallel

ちゃんと動いた。

まとめ

mpirun もしくはsshからの実行時には
~/.bashrc の先頭付近ですぐ ~/.bashrc を抜けてしまって、それ以降の設定が反映されない。

抜ける処理の部分をコメント文にする。

リポジトリからapt-getを用いてインストールするとインストール先は/opt/になるためroot権限で実行できなかった。
ソースからコンパイルしてユーザー権限のある場所に入れる。

もしかしてrootユーザーでログインして/opt/をユーザー保有にすればよかったのか

参考

OpenFOAM のインストール
インフラエンジニアじゃなくても押さえておきたいSSHの基礎知識
CentOSにOpenFOAM 4.0をインストール

5
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
6