液滴着弾計算 その2(OF2406)

1 液滴接触半径と高さを書き出す処理追加

着弾時の液滴接触半径と高さを書き出す処理を追加しよう.

参考: https://qiita.com/inabower/items/396794e65b66a424e4fe

1-1 コピー

・interrFoam のプログラムをまるごと作業領域にコピーして、interDropletFoam と名前を変更する。

・VOFフォルダをinterDropFoam の直下にコピーする。

・filesを以下に修正

interFoam.C

EXE = $(FOAM_USER_APPBIN)/interDropletFoam

・option を以下に修正

EXE_INC = \
-I./VoF \
-I$(LIB_SRC)/phaseSystemModels/twoPhaseInter/incompressibleInterPhaseTransportModel/lnInclude \
-I$(LIB_SRC)/phaseSystemModels/twoPhaseInter/VoFphaseIncompressibleTurbulenceModels/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude \

・試しにコンパイルしてみる。 問題なければOK。

1-2 outputInitial.H を作る

・テキストエディタ(gedit 等)で 以下を入力し、outputInitial.H と名前をつけて保存

onst fileName dPath = "postProcessing";
if(!isDir(dPath)) mkDir(dPath);
const fileName fPath = dPath / "DropletRadius.csv";
OFstream os(fPath);
os << "#time[s]" << "," << "Radius[m]" << "," << "Height[m]" <<endl;


1-3 write.H を作る

・テキストエディタ(gedit 等)で 以下を入力し、write.H と名前をつけて保存

if (runTime.writeTime()) {
double maxInterX=0.0;
double maxInterY=0.0;
double inter=0.0;
double rowy=0.0;
double rowx=0.0;
forAll(mesh.cells(), cid) {
const vector &C = mesh.C()[cid]; //cell center
if( (rowy<SMALL) && (C[1] > rowy) ) {
rowy=C[1];
}
if( (rowx<SMALL) && (C[0] > rowx) ) {
rowx=C[0];
}
//---- serch in X
if (mag(C[1])<=rowy+SMALL && cid>1) {
const vector &Cm1 = mesh.C()[cid-1];
if ((alpha1[cid]-0.5)*(alpha1[cid-1]-0.5)<0.) {
scalar y1=alpha1[cid-1];
scalar y2=alpha1[cid];
scalar x1=Cm1[0];
scalar x2=C[0];
if((y2-y1!=0.)&&(x2-x1!=0.)){
inter = (0.5-y1)/( (y2-y1)/(x2-x1) ) + x1;
} else {
inter=0;
}
if (inter>maxInterX) {
maxInterX = inter;
}
}
}
//---- serch in Y
if (mag(C[0])<=rowx+SMALL && cid>1) {
const vector &Cm1 = mesh.C()[cid-1];
if ((alpha1[cid]-0.5)*(alpha1[cid-1]-0.5)<0.) {
scalar x1=alpha1[cid-1];
scalar x2=alpha1[cid];
scalar y1=Cm1[1];
scalar y2=C[1];
if((y2-y1!=0.)&&(x2-x1!=0.)){
inter = (0.5-x1)/( (x2-x1)/(y2-y1) ) + y1;
} else {
inter=0;
}
if (inter>maxInterY) {
maxInterY = inter;
}
}
}
} // forAll loop-cid
double dCur= atof(runTime.timeName().c_str());
if(maxInterX*maxInterY>0) os << dCur<< "," << maxInterX<<","<<maxInterY<<endl;
// In parallel calc. sometimes, maxInter=0.
}

1-4 interFoam.C を修正

 #include "outputInitial.H" と #include "write.H" を追加する。

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Info<< "\nStarting time loop\n" << endl;
#include "outputInitial.H"
while (runTime.run())
・・・・・・・・
・・・・・・・・
runTime.write();
#include "write.H"
runTime.printExecutionTime(Info);
}
Info<< "End\n" << endl;
return 0;
}


注意:この方法はdynamicMesh では修正が必要。

1-5 コンパイル

・wclean ↵

・wmake ↵

1-6 試し計算

・ケース dropletDepo1 をdropletDepo2 と変更する

・./Allclean で初期化

・interDropletFoam を実行

・paraFoamで結果を確認する。

・postProcessingを確認。postProcessing\DropletRadius.csv をダブルクリック

・ubuntuであればLibreOffice で以下の画面が出るのでOKを押す。

・挿入、グラフ、散布図 で以下のグラフができる。Windowsに持っていってExcellで加工してもよい。


かどらぼ

0コメント

  • 1000 / 1000