データのサンプリング

2015年1月18日

はじめに

計算結果から線上や面上のデータを取得する。

使用バージョン

OpenFOAM 2.3.0

データの用意

データとして、icoFoam のチュートリアルケース cavity を使う。

$ cp -r $FOAM_TUTORIALS/incompressible/icoFoam/cavity .
$ cd cavity
$ blockMesh
$ icoFoam

sampleDict の用意

データのサンプリングには sample コマンドを使う。そのために system/sampleDict を用意する。

system/sampleDict

FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    location    "system";
    object      sampleDict;
}

setFormat       raw;

surfaceFormat   raw;

interpolationScheme cellPoint;

fields          ( U p );

sets
(
    data
    {
        type    uniform;
        axis    x;
        start   ( 0 0.05 0.005 );
        end     ( 0.1 0.05 0.005 );
        nPoints 20;
    }
);

surfaces
(
    data
    {
        type patch;
        patches ( movingWall );
    }
);

fileds で、取得するデータの種類を指定する。ここでは速度ベクトルと圧力を指定している。

sets で直線上からデータを取る設定を行う。"data" はデータの名前 (任意)、axis は出力する位置情報の種類、start, end は直線の始点と終点、nPoints は始点と終点を結ぶ直線上の点の数である。つまり、直線上に点を発生させて、その点のデータを取得する。上記の例では、cavity モデルの真中の高さを横切る直線を指定している。

axis には以下のものを指定できる。

  • x
  • y
  • z
  • xyz
  • distance

surfaces でサーフェイス上からデータを取る設定を行う。type で "patch" を指定してパッチからデータを取るようにし、patchName でデータを取るパッチの名前を指定している。

surafces の type には、"patch" 以外に、領域内を横切る面のデータを取得する "cuttingPlane" もある。

surfaces
(
    data
    {
        type cuttingPlane;
        planeType pointAndNormal;
        pointAndNormalDict
        {
            basePoint (0 0.05 0);
            normalVector (0 1 0);
        }
    }
);

setFormat には以下のものを指定できる。

  • csv
  • ensight
  • gnuplot
  • jplot
  • raw
  • vtk
  • xmgr

surfaceFormat には以下のものを指定できる。

  • dx
  • ensight
  • foamFile
  • nastran
  • raw
  • starcd
  • vtk
  • ofs
  • x3d
  • obj
  • inp
  • stl
  • tri
  • off
  • stlb
  • vtk
  • smesh
  • ac
  • wrl
  • null

interpolationScheme には以下のものを指定できる。

  • cell
  • cellPatchConstrained
  • cellPoint
  • cellPointFace
  • cellPointWallModified
  • pointMVC

sample コマンドの実行

sample コマンドを実行する。

$ sample -latestTime

オプションの -latestTime で、最後の結果だけ取得する。ここでは 0.5 のデータを取得することになる。データは "postProcessing/sets/0.5/data_U.xy" のように書き出される。gnuplot でデータを確認できる。

$ gnuplot
...
gnuplot> plot 'postProcessing/sets/0.5/data_U.xy' using 1:3 title 'uy' with lines