1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

PARIS Code Simulatorをインストールして使ってみる

Posted at

この記事は流体解析のオープンソースの一つであるPARIS Code Simulatorをインストールして計算を走らせてみるまでの備忘録です.

PARIS Simulator Code

PARIS Simulator CodeはフランスのSephane Zaleskiを中心として開発されている混相流解析ソルバーであり, A PArallel Robust Interface Simulator that combines VOF and Front-Trackingの頭文字をとってPARISと呼ばれている. PARISは以下の3種類のソースコードをマージして作られたものである.

  • FTC3D2011
  • Surfer VOF code
  • Gerris Flow solver

このうち,FTC3D2011がGretar TryggvasonのFront Trackingに対応するコードである. PARISで使われている数値スキームの特徴については書籍Direct Numerical Simulations of Gas–Liquid Multiphase Flowsを参照されたい.

今回は一般的なLinux OS (Ubuntu 18.04)にPARISを導入する方法を試みる.

PARISのバージョンと入手先

PARISはZaleski教授のHPから入手できる. paris-stable.tar.gzという名前のtarアーカイブで提供されているのでこれをダウンロードする.

以降,端末でのコマンド操作を順次示す.

$ cd
$ wget http://www.ida.upmc.fr/~zaleski/paris/paris-stable.tar.gz
$ tar zxvf paris-stable.tar.gz
$ cd paris-stable

解凍したparis-stableディレクトリには,DevelDocumentationTestsutilというサブディレクトリと,ソースコード,インストールの説明文(INSTALL),メイクファイル(Makefile)などが入っている.インスールの手順はZaleskiのHPよりはINSTALLに詳しいので、それに沿って進める.

Fortranのインストール

PARISのソースコードは主にFortranで書かれているため,Fortranコンパイラが入っていない場合はgfortaranをインストールする.

$ sudo apt-get install gfortran

gitのインストール

一部のライブラリはgitレポジトリからダウンロードするため,gitが入っていなければインストールする.

$ sudo apt-get install git

Vofiのインストール

INSTALLの説明には,PARIS本体以外に,

  • Vofi: VOF関数の初期値作成
  • HYPRE: 高速なPoissionソルバー
  • SILO: 並列分割データの圧縮出力

などのライブラリもインストールした方がよいとされている.

まず,Vofiをインストールする.

$ git clone https://github.com/VOFTracking/Vofi
$ cd Vofi
$ ./configure
$ make
$ sudo make install

Vofiは標準では/usr/localにインストールされるため,ユーザのホームディレクトリにインストールしたい場合は以下のようにprefixをつけてインストールする.

$ ./configure --prefix=/home/hoge/Vofi
$ make
$ sudo make install

HYPREのインストール

次にHYPREをインストールする.

$ cd
$ wget http://computation.llnl.gov/projects/hypre-scalable-linear-solvers-multigrid-method/download/hypre-2.11.2.tar.gz
$ tar zxvf hypre-2.11.2.tar.gz
$ cd hypre-2.11.2/src
$ ./configure
$ make
$ sudo make install

SILOのインストール

最後にSILOをインストールする.

$ cd
$ wget https://wci.llnl.gov/content/assets/docs/simulation/computer-codes/silo/silo-4.10.2/silo-4.10.2.tar.gz
$ tar zxvf silo-4.10.2.tar.gz
$ cd silo-4.10.2
$ ./configure
$ make
$ make check
$ sudo make install

PARIS本体のインストール

PARISをコンパイルする前に,Makefileを一部編集して修正する.

$ cd
$ cd paris-stable
$ vi Makefile
...
# SILO_DIR = $(HOME)/cfd/libs/silo-4.10.2
SILO_DIR = $(HOME)/silo-4.10.2

# HYPRE_DIR = $(HOME)/cfd/libs/hypre-2.10.0b/src/lib
HYPRE_DIR = $(HOME)/hypre-2.11.2/src/lib
...
# VOFI_DIR = $(HOME)/lib
VOFI_DIR = /usr/local/lib

Makefileの編集が終わったら,オプションをつけてmakeする.

$ make HAVE_VOFI=1 HAVE_SILO=1

先にコンパイルしたVofi及びSILOをライブラリリンクするオプションをつけたが,このとき以下のエラーが出て正常にコンパイルができない.

vofmodules.o: 関数 `__module_vof_MOD_levelset2vof' 内:
vofmodules.f90:(.text+0xe71e): `get_fh_' に対する定義されていない参照です
vofmodules.f90:(.text+0xe960): `get_cc_' に対する定義されていない参照です
vofmodules.o: 関数 `__module_vof_MOD_initconditions_vof' 内:
vofmodules.f90:(.text+0x116dc): `get_fh_' に対する定義されていない参照です
vofmodules.f90:(.text+0x1191f): `get_cc_' に対する定義されていない参照です
collect2: error: ld returned 1 exit status
Makefile:78: recipe for target 'install' failed
make: *** [install] Error 1

vofmodules.f90内でget_fhget_ccの参照が間違っているので,sedで修正する.

$ sed -i 's/get_fh/vofi_get_fh/g' vofmodules.f90
$ sed -i 's/get_cc/vofi_get_cc/g' vofmodules.f90

再度コンパイルして実行モジュールparisが生成される.

$ make HAVE_VOFI=1 HAVE_SILO=1

最後にPATHの設定をするため,.bashrcの末尾に追記する(bashを利用する場合).

$ cd
$ vi .bashrc
...
PATH="$PATH:$HOME/bin"

PATHの設定を反映させる.

$ . .bashrc

PARISのテスト計算

paris-stableディレクトリの中にTestsディレクトリがあり,いくつかのテスト計算が置かれている.

$ cd $HOME/paris-stable/Tests
$ ls
Bubble             FrontBubble        PresDisk         VOF
CapWave            FrontDroplet       PresPoiseuille   beginreport.html
ComplexSolid       Height             README.txt       clean.sh
Curvature          InflowDisk         RainDrop         distribute_inputfiles.sh
CylinderAdvection  Kelvin-Hemlholtz   RainDrop4paper   endreport.html
Disk               Mini               ShearMultiphase  runlongtests.sh
Droplet            ParasiticCurrents  Speed            runtests.sh
ExpandingCavity    PoissonMG          TagDrop

BubbleDropletに対応してFrontBubbleFrontDropletがあり,VOF法で解くケースとFront Tracking法で解くケースの両者が用意されている.FrontBubbleのケースを実行してみる.

$ cd
$ mkdir paris-run
$ cd paris-run
$ cp -r ../paris-stable/Tests/FrontBubble ./
$ cd FrontBubble
$ ls
inputlong   inputvof     plot.sh   reference_Ek.txt
inputshort  longtest.sh  plot4.gp  run.sh
$ ./run.sh &

ここで実行したスクリプトrun.shの中身は以下のようになっている.

# !/bin/bash
# set -x

rm -fR input out
ln -s inputshort input
mpirun -np 3 paris > tmpout
echo `awk ' /Step:/ { cpu = $8 } END { print "cpu = " cpu } ' < tmpout`
rm -f input

cat stats | awk '{ print $1 , $13+$14 }' | tail +2 > test_Ek.txt
sh plot.sh

precision=2e-1
pariscompare test_Ek.txt reference_Ek.txt $precision 1 0

GREEN="\\033[1;32m"
NORMAL="\\033[0m"

mpirunで3並列計算を実行し,出力からgnuplotによるプロットを生成する(グラフを画像出力するにはplot4.gpを修正する必要がある).計算が終了すると,outディレクトリが作られ,この中に計算結果がまとめられており,ParaViewやVisItを用いて可視化ができる.

まとめ

今回,PARISのインストールを行い,計算実行までを確認した.PARISは直交不等間隔格子のみで計算が可能であり(物体形状の表現にはカットセルを用いると思われる),どちらかというと基礎研究向けのソルバーである.しかしながら,Fortranで書かれていて(Modernかと聞かれるとどうかはわからない),記事を書いている私には親しみやすいので細々と機能を検証するつもりである.

1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?