任意の値のプロット2011年11月27日 | |
はじめにpyFoamPlotRunner.py における任意の値のプロットについて。 使用バージョンOpenFOAM 2.0.1, PyFoam 0.5.6 pyFoamPlotRunner.py における任意の値のプロットcustomRegexp という仕組みを使う。これを使うと、ログに出力される値をグラフに表示することができる。 まず、グラフで表示させたい値を用意する。たとえば、速度と温度の体積平均値をログに出力させる。swak4Foam の swakFunctionObjects と simpleFunctionObjects を使う。system/controlDict で次のように設定する。
functions
{
magU
{
type expressionField;
functionObjectLibs ("libswakFunctionObjects.so");
outputControl outputTime;
fieldName magU;
expression "mag(U)";
autowrite true;
}
avgU
{
type volumeAverage;
functionObjectLibs ("libsimpleFunctionObjects.so");
fields
(
magU
);
verbose true;
}
avgT
{
type volumeAverage;
functionObjectLibs ("libsimpleFunctionObjects.so");
fields
(
T
);
verbose true;
}
}
"verbose true" がログへの出力設定であり、重要。buoyantSimpleFoam などで実行すると、次のような出力を得る。 Average of magU = 0.0119664 [0 0 0 0 0 0 0] Average of T = 300.248 [0 0 0 1 0 0 0] これをもとにケースファイル内に "customRegexp" という名前のファイルを作る。次のような内容になる。
avgU
{
expr "Average of magU = (%f%)";
name avgU;
theTitle "Volume Average of Velocity";
titles
(
Velocity
);
}
avgT
{
expr "Average of T = (%f%)";
name avgT;
theTitle "Volume Average of Temperature";
titles
(
Temperatre
);
}
"expr" がログファイル内から値を拾うための条件式である。出力は "Average of magU = 0.0119664" であったので、数値を "(%f%)" に置き換えて "Average of magU = (%f%)" としている。 これで pyFoamPlotRunner.py を実行すると、速度の平均値と温度の平均値のグラフが表示される。 | |
| PENGUINITIS | |