function objects2015年10月9日 | |
はじめにfunction objects について。 使用バージョンOpenFOAM 2.4.0 function objectsfunction objects は、主にポスト処理に使うもので、計算結果を処理して出力させたりできる。設定はケースの system/controlDict で以下のように行う。
functions
{
name
{
type ...;
...
}
}
ここで name は任意の名前である。name 以下で各 function objects の設定を行う。function objects を使うにはライブラリを要求されることがある。ライブラリは、controlDict で以下のように設定する。
libs
(
"libIOFunctionObjects.so"
"libcloudFunctionObjects.so"
"libfieldFunctionObjects.so"
"libforces.so"
"libFVFunctionObjects.so"
"libjobControl.so"
"libsystemCall.so"
"libutilityFunctionObjects.so"
);
あるいは、function objects の設定ごとにライブラリを指定することもできる。
functions
{
name
{
type ...;
functionObjectLibs ("libfieldFunctionObjects.so");
...
}
}
共通設定以下はだいたい共通に使える設定である。
functions
{
func
{
...
enabled true;
outputControl timeStep;
outputInterval 1;
log true;
timeStart 1;
timeEnd 100;
...
}
}
また、マルチリージョンのケースでは、region でリージョンを指定できる。 実行function objects はソルバーの計算途中で実行される。すでに計算が終わってしまったデータに対して処理を行う場合は、execFlowFunctionObjects を使えば function objects だけを実行できる ("-noFlow" オプションが必要な場合もある)。 ファイルへの出力とグラフの描画function objects のタイプの中には、"postProcessing" ディレクトリにファイルを書き出すものがある。OpenFOAM 2.4.0 から、書き出されたファイルの内容をグラフとして描画し、モニターする foamMonitor コマンドが使える。 たとえば、次のようにすればグラフを表示できる。 $ foamMonitor postProcessing/avgU/0/cellSource.dat 計算中に出力をモニターするには、オプション "-r" を用いる。これは、指定した秒数ごとにグラフを更新する。 $ foamMonitor -r 1 postProcessing/avgU/0/cellSource.dat 計算が終ってもモニターし続けるが、デフォルトではファイルの更新が止まって 60 秒経てばモニターは停止する。オプション "-i" で停止までの時間を指定できる。 オプション "-l" でグラフの縦軸がログスケールになる。たとえば、残差の表示を行うには次のようにする。 $ foamMonitor -r 1 -l postProcessing/residuals/0/residuals.dat foamMonitor の使用には gnuplot が必要 (Ubuntu の場合、gnuplot, gnuplot-x11 のインストールが必要)。 タイプfunction objects のタイプには以下のようなものがある。 アルファベット順
ライブラリごとlibIOFunctionObjects.so
libcloudFunctionObjects.so
libfieldFunctionObjects.so
libforces.so
libFVFunctionObjects.so
libjobControl
libsystemCall
libutilityFunctionObjects
その他
各タイプの説明 (アルファベット順)CourantNo
functions
{
func
{
type CourantNo;
outputControl outputTime;
outputInterval 1;
}
}
各セルのクーラン数をフィールドとして出力する。 Peclet
functions
{
func
{
type Peclet;
outputControl outputTime;
outputInterval 1;
}
}
各セルのペクレ数をフィールドとして出力する。
functions
{
func
{
type abort;
action writeNow;
fileName "stop";
}
}
fileName で指定した名前のファイルを作成して計算を止めたりできる。action では以下のものを選択できる。
ファイルの作成には touch コマンドを使えばよい。 $ touch stop blendingFactor
functions
{
func
{
type blendingFactor;
fieldName U;
outputControl outputTime;
outputInterval 1;
}
}
blended 対流スキームを使った時の blending factor をフィールドとして出力する。 calcFvcDiv
functions
{
func
{
type calcFvcDiv;
fieldName U;
resultName divU;
outputControl outputTime;
outputInterval 1;
}
}
fieldName で指定したフィールの発散をフィールドとして出力する。system/fvSchems において指定フィールドに対する divSchemes の設定が必要。
div(U) Gauss linear;
resultName には出力フィールド名を指定する。 calcFvcGrad
functions
{
func
{
type calcFvcGrad;
fieldName p;
resultName gradp;
outputControl outputTime;
outputInterval 1;
}
}
fieldName で指定したフィールの勾配をフィールドとして出力する。system/fvSchems において指定フィールドに対する gradSchemes の設定が必要。
grad(p) Gauss linear;
resultName には出力フィールド名を指定する。 calcMag
functions
{
func
{
type calcMag;
fieldName U;
resultName magU;
outputControl outputTime;
outputInterval 1;
}
}
fieldName で指定したフィールの大きさをフィールドとして出力する。resultName には出力フィールド名を指定する。 cellSource
functions
{
func
{
type cellSource;
fields (U);
valueOutput false;
source all;
operation volAverage;
outputControl timeStep;
outputInterval 1;
}
}
fields で指定したフィールドについてセルに対して操作を行った結果をファイルに出力する。postProcessing ディレクトリにファイルが出力される。 source では以下のものを選択できる。
operation では以下のものを選択できる。
valueOutput を有効にすると、参照された値がフィールドとして出力される。 coded
functions
{
func
{
type coded;
redirectType test;
code
#{
Info<< "test" << endl;
#};
outputControl timeStep;
outputInterval 1;
}
}
コードを実行する。redirectType には任意の名前を指定する。 faceSource
functions
{
func1
{
type faceSource;
fields (phi);
valueOutput false;
source patch;
operation sum;
sourceName inlet;
outputControl timeStep;
outputInterval 1;
}
func2
{
type faceSource;
fields (phi);
valueOutput false;
source patch;
operation sum;
sourceName outlet;
outputControl timeStep;
outputInterval 1;
}
}
fields で指定したフィールドについてフェイスに対して操作を行った結果をファイルに出力する。postProcessing ディレクトリにファイルが出力される。 source では以下のものを選択できる。
operation では以下のものを選択できる。
valueOutput を有効にすると、参照された値がフィールドとして出力される。その場合、surfaceFormat で以下のようなフォーマットを指定する必要がある。
fieldAverage
functions
{
func
{
type fieldAverage;
fields
(
U
{
mean on;
prime2Mean off;
base time;
}
);
outputControl outputTime;
outputInterval 1;
}
}
fields で指定したフィールドについて時間方向に平均した結果をフィールドとして出力する。LES の計算結果の時間平均を出したりするときに使う。base には以下のものを指定できる。
fieldMinMax
functions
{
func
{
type fieldMinMax;
fields (U);
outputControl timeStep;
outputInterval 1;
}
}
fields で指定したフィールドについて最大値と最小値をファイルに出力する。postProcessing ディレクトリにファイルが出力される。 fieldValueDelta
functions
{
func
{
type fieldValueDelta;
operation add;
source1
{
type faceSource;
fields (phi);
valueOutput false;
source patch;
operation sum;
sourceName inlet;
}
source2
{
type faceSource;
fields (phi);
valueOutput false;
source patch;
operation sum;
sourceName outlet;
}
outputControl timeStep;
outputInterval 1;
}
}
source1、source2 について操作した結果をファイルに出力する。postProcessing ディレクトリにファイルが出力される。operation には以下のものを指定できる。
forceCoeffs
functions
{
func
{
type forceCoeffs;
patches (lowerWall);
rhoName rhoInf;
rhoInf 1;
CofR (0 0 0);
liftDir (0 1 0);
dragDir (1 0 0);
pitchAxis (0 0 1);
magUInf 1;
lRef 1;
Aref 1;
log true;
outputControl timeStep;
outputInterval 1;
}
}
効力係数を計算する。以下のような値が出力される。
Cm = 0.0115443
Cd = 0.0229475
Cl = 0.147925
Cl(f) = 0.085507
Cl(r) = 0.0624184
Cm、Cd、Cl はそれぞれモーメント、抗力、揚力の係数である。各設定は以下の通りである。
rhoInf は密度 (非圧縮性の場合)。 forces
functions
{
func
{
type forces;
patches (lowerWall);
rhoName rhoInf;
rhoInf 1;
CofR (0 0 0);
log true;
outputControl timeStep;
outputInterval 1;
}
}
力とモーメントを計算する。 nearWallFields
functions
{
func
{
type nearWallFields;
fields ((U UNear));
patches (lowerWall);
distance 0.001;
outputControl outputTime;
outputInterval 1;
}
}
fields で指定したフィールドの壁近傍の計算を行うらしい (ParaView で見ると壁の速度が 0 でなくなる)。fields のフィールドとペアになっているのは出力フィールド名。 partialWrite
functions
{
func
{
type partialWrite;
objectNames (U);
writeInterval 2;
}
}
書き出しのタイミングを調整できる。たとえば、上の例であれば、書き出しが 50 ステップごとであれば、50 ステップでは U が書き出されず、100 ステップで書き出される。 patchProbes
functions
{
func
{
type patchProbes;
probeLocations ((0 0 0));
fields (p);
patchName lowerWall;
outputControl timeStep;
outputInterval 1;
}
}
パッチ上の値をファイルに出力する。 pressureTools
functions
{
func
{
type pressureTools;
calcTotal no;
pRef 0;
calcCoeff no;
pInf 0;
UInf (1 0 0);
rhoInf 1;
outputControl outputTime;
outputInterval 1;
}
}
各種圧力の計算を行う。オプションの設定によって以下のようになるらしい (ソースコードのコメント)。
Mode | calcTotal | calcCoeff static pressure | no | no total pressure | yes | no pressure coefficient | no | yes total pressure coefficient | yes | yes static pressure p_s = rho p_k p_k は kinematic pressure (= p/rho) total pressure p_t = p_ref + p_s + 0.5 rho |U|^2 pressure coefficient Cp_s = (p_s - p_inf)/(0.5 rho_inf |U_inf|^2) total pressure coefficient Cp_t = (p_t - p_inf)(0.5 rho_inf |U_inf|^2) 設定は以下の通り。
probes
functions
{
func
{
type probes;
probeLocations ((0 0 0));
fields (p);
outputControl timeStep;
outputInterval 1;
}
}
指定した座標上の値をファイルに出力する。 processorField
functions
{
func
{
type processorField;
outputControl outputTime;
outputInterval 1;
}
}
領域分割の図が得られる。 residuals
functions
{
func
{
type residuals;
fields (U p);
}
}
残差をファイルに出力する。 scalarTransport
functions
{
func
{
type scalarTransport;
resetOnStartUp true;
autoSchemes true;
DT 1e-6;
fvOptions
{
option
{
type scalarExplicitSetValue;
active true;
selectionMode cellSet;
cellSet c0;
scalarExplicitSetValueCoeffs
{
injectionRate
{
func 1;
}
}
}
}
}
}
スカラー輸送方程式を解く (スカラーの名前は function objects の名前になる)。入力は fvOptions で行っている。拡散係数は DT で指定するが、設定しなければ乱流粘性が用いられるらしい。 sets
functions
{
func
{
type sets;
fields (U);
interpolationScheme cellPoint;
setFormat vtk;
sets
(
sample
{
type uniform;
axis y;
start (0.2 -0.0254 0);
end (0.2 0.0254 0);
nPoints 10;
}
);
outputControl outputTime;
outputInterval 1;
}
}
データのサンプリングを行う。 interpolationScheme
sets の type
streamLine
functions
{
func
{
type streamLine;
fields (U);
trackForward true;
lifeTime 10000;
trackLength 1;
seedSampleSet uniform;
uniformCoeffs
{
type uniform;
axis x;
start (-0.0205 0.001 0.00001);
end (-0.0205 0.0251 0.00001);
nPoints 10;
}
setFormat vtk;
outputControl outputTime;
outputInterval 1;
}
}
流線を出力する。 surfaceInterpolateFields
functions
{
func
{
type surfaceInterpolateFields;
fields ((p pNear));
outputControl outputTime;
outputInterval 1;
}
}
サーフェイスの値を計算する (nearWallFields とどう違う?)。 surfaces
functions
{
func
{
type surfaces;
fields (p);
interpolationScheme cellPoint;
surfaceFormat vtk;
surfaces
(
wall
{
type patch;
patches (lowerWall);
}
);
outputControl outputTime;
outputInterval 1;
}
}
functions
{
func
{
type surfaces;
fields (U);
interpolationScheme cellPoint;
surfaceFormat vtk;
surfaces
(
nearWall
{
type patchInternalField;
patches (lowerWall);
distance 1E-6;
interpolate true;
triangulate false;
}
);
outputControl outputTime;
outputInterval 1;
}
}
サーフェイスの値を VTK などで出力する。 interpolationScheme
surfaces の type
systemCall
functions
{
func
{
type systemCall;
executeCalls ("echo sysCall: execute");
endCalls ("echo sysCall: end");
writeCalls ("echo sysCall: write");
}
}
シェルコマンドを実行する。設定は以下の通りである。
timeActivatedFileUpdate
functions
{
func
{
type timeActivatedFileUpdate;
fileToUpdate "$FOAM_CASE/system/fvSolution";
timeVsFile
(
(-1 "$FOAM_CASE/system/fvSolution.0")
(10 "$FOAM_CASE/system/fvSolution.10")
);
}
}
fileToUpdate で指定したファイルの内容を計算途中で timeVsFile で指定したファイルの内容に置き換える。計算途中で自動的に緩和係数を変更したりしたい場合に使うのだろう。 ※最初のファイルの入れ替えに失敗することがある。再実行すればうまくいくようだ。 wallShearStress
functions
{
func
{
type wallShearStress;
patches ("lowerWall");
outputControl outputTime;
outputInterval 1;
}
}
壁面せん断応力を計算する。フィールドとファイル両方出力される。 writeRegisteredObject
functions
{
func
{
type writeRegisteredObject;
objectNames ("phi_0");
outputControl outputTime;
outputInterval 1;
}
}
自動では書き出されないフィールドを書き出す。 yPlusLES
functions
{
func
{
type yPlusLES;
outputControl outputTime;
outputInterval 1;
}
}
LES 用に y+ を計算する。 yPlusRAS
functions
{
func
{
type yPlusRAS;
outputControl outputTime;
outputInterval 1;
}
}
RANS 用に y+ を計算する。 参考 | |
| PENGUINITIS | |