はじめに
前回までにメッシュの変換(ideasUnvToFoam)が成功したので、2次元流動計算のためのOpenFOAM設定をやります。シンプルな二次元等温非圧縮性流れです。境界条件の修正、メッシュ検証、物理物性・初期条件の設定を順番に進めていきます。
1. 全体ファイル構成
OpenFOAMでいつもこんがらがるファイル構成です。各種辞書ファイル(***Dict)に設定条件が書き込まれています。
ex_1/ ← ケースディレクトリ
├── 0/ ← 初期・境界条件ディレクトリ
│ ├── p ← 圧力場(非圧縮性の場合は [m2/s2])
│ └── U ← 流速ベクトル場 [m/s]
│
├── constant/ ← 物理プロパティ・メッシュ情報
│ ├── transportProperties ← 流体の物性値(動粘性係数 nu など)
│ ├── turbulenceProperties ← 層流・乱流の設定(層流でもファイルは必要)
│ └── polyMesh/ ← メッシュデータ(Salome等から変換後生成)
│ ├── boundary ← 境界パッチ情報(inlet, outlet, walls 等)
│ ├── faces ← メッシュの面情報
│ ├── neighbour ← 隣接セル情報
│ ├── owner ← セル所有情報
│ └── points ← 節点座標
│
└── system/ ← 解法・数値スキーム・計算制御設定
├── controlDict ← ソルバー指定、計算時間、出力間隔の設定
├── fvSchemes ← 離散化スキーム(ddt, grad, div, laplacian 等)
└── fvSolution ← 方程式ソルバー(GAMG, PBiCGStab)および PIMPLE 制御
(参考)
端末上で以下を実行するとエクスプローラーが起動して、ubuntuとwindowsとの間のコピーが簡単にできます。
explorer.exe .
2. 各種ファイルの設定
(1) 0/U, 0/p
速度、圧力の初期・境界条件を設定します。
入側 x 方向流速 1m/s、出側 自然流出(pressure_outlet)、壁はno-slip、frontAndBackは二次元計算用で empty(Z方向は計算しない)。ファイルはエディタ nano で開く場合は以下のコマンドを使う。以下、ファイルの確認・修正は同様。修正後上書きする場合は ^O で書き込み予定のファイル名が表示されるので Enter を押下、その後 ^x で終了。
cd ~/ex1 # ワークスペースフォルダ ws が間にあれば、 cd ~/ws/ex1
nano 0/U
ファイル内容は以下の通り。
FoamFile
{
version 2.0;
format ascii;
class volVectorField;
location "0";
object U;
}
dimensions [0 1 -1 0 0 0 0];
internalField uniform (0 0 0);
boundaryField
{
inlet
{
type fixedValue;
value uniform (1 0 0); // 例: X方向に 1 m/s で流入
}
outlet
{
type zeroGradient;
}
".*walls.*|billets.*|defaultFaces" // 壁面(複数ある場合は正規表現で指定)
{
type noSlip;
}
frontAndBack
{
type empty;
}
}
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object p;
}
dimensions [0 2 -2 0 0 0 0]; // m2/s2 (非圧縮性ソルバーの圧力単位)
internalField uniform 0;
boundaryField
{
inlet
{
type zeroGradient;
}
outlet
{
type fixedValue; // pressure_outlet 条件
value uniform 0;
}
".*walls.*|billets.*|defaultFaces"
{
type zeroGradient;
}
frontAndBack
{
type empty;
}
}
(2) system/transportProperties
流体物性(ここでは粘性)を設定
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object transportProperties;
}
transportModel Newtonian;
nu [0 2 -1 0 0 0 0] 1e-06;
(3) constant/turbulenceProperties
層流・乱流の設定です。今回は、層流にしています。
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object turbulenceProperties;
}
simulationType laminar; // ← 乱流モデルを使わず層流として計算する指定
(4) system/controlDict
ソルバーには非圧縮性非定常流体の pimpleFoam(または定常なら simpleFoam)を設定。他に、開始・終了・刻み時間、など。
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object controlDict;
}
application pimpleFoam;
startFrom startTime;
startTime 0;
stopAt endTime;
endTime 10;
deltaT 0.001;
writeControl timeStep;
writeInterval 100;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
(5) system/fvSchemes
差分化方法(風上差分など)を設定。
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object fvSchemes;
}
ddtSchemes
{
default Euler;
}
gradSchemes
{
default Gauss linear;
}
divSchemes
{
default none;
div(phi,U) Gauss linearUpwind grad(U);
div((nuEff*dev2(T(grad(U))))) Gauss linear;
}
laplacianSchemes
{
default Gauss linear orthogonal;
}
interpolationSchemes
{
default linear;
}
snGradSchemes
{
default orthogonal;
}
(6) system/fvSolution
その他の設定を行う。
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object fvSolution;
}
solvers
{
p
{
solver GAMG;
tolerance 1e-06;
relTol 0.01;
smoother GaussSeidel;
}
pFinal
{
$p;
relTol 0;
}
U
{
solver smoothSolver;
smoother GaussSeidel;
tolerance 1e-05;
relTol 0.1;
}
UFinal
{
$U;
relTol 0;
}
}
PIMPLE
{
nOuterCorrectors 2;
nCorrectors 2;
nNonOrthogonalCorrectors 0;
}
(7) constant/polyMesh/boundary
境界の type が適切か確認する。OpenFOAM で 2D 計算を行う場合、押し出した手前と奥の 2 面(frontAndBack)のタイプを empty に設定されているかを確認し、違っていたら empty に修正する。もし、壁の type が patch になっていたら、wall に修正する。
patch は、「流体が流入・流出部所(inlet、outlet 等)や一般境界」の基本形を意味する。
wall は「物理的な「壁」を表す境界タイプ」で、壁関数条件や noSlip 条件を適用する。
empty は、二次元計算用で厚み方向の計算をしないことを意味します。
FoamFile
{
version 2.0;
format ascii;
arch "LSB;label=32;scalar=64";
class polyBoundaryMesh;
location "constant/polyMesh";
object boundary;
}
5
(
inlet_extruded
{
type patch;
nFaces 40;
startFace 7675;
}
outlet_extruded
{
type patch;
nFaces 40;
startFace 7715;
}
walls_extruded
{
type wall;
nFaces 120;
startFace 7755;
}
frontAndBack
{
type empty;
nFaces 10379;
startFace 7875;
}
defaultFaces
{
type patch;
nFaces 41;
startFace 18254;
}
)
2. checkMesh の実行
ここで、メッシュのチェックをするために checkMesh を実行したいのですが、system/ ディレクトリに必要な設定ファイル(fvSchemes や fvSolution)が存在していないで実行すると以下のエラーがでます。
...
--> FOAM FATAL ERROR: (openfoam-2406 patch=260127)
cannot find file "/home/********/system/fvSchemes"
From virtual Foam::autoPtr<Foam::ISstream> Foam::fileOperations::uncollatedFileOperation::readStream(Foam::regIOobject&, const Foam::fileName&, const Foam::word&, bool) const
in file global/fileOperations/uncollatedFileOperation/uncollatedFileOperation.C at line 629.
上記のように設定していればいいのですが、その暇がなくチェックを速くしたい場合は、チュートリアルからコピーします。何でも良いので、icoFoamからコピーする場合の例を示します。
cp -r /usr/lib/openfoam/openfoam2406/tutorials/incompressible/icoFoam/cavity/cavity/system/* system/
チェックメッシュを実行して、Mesh OK. End が出れば問題ありません。
checkMesh
checkMeshの結果です。
Create time
Create mesh for time = 0
Check mesh...
Time = 0
Mesh stats
points: 5424
internal points: 0
faces: 18295
internal faces: 7675
cells: 5194
faces per cell: 5
boundary patches: 5
point zones: 0
face zones: 0
cell zones: 1
Overall number of cells of each type:
hexahedra: 0
prisms: 5194
wedges: 0
pyramids: 0
tet wedges: 0
tetrahedra: 0
polyhedra: 0
Checking topology...
Boundary definition OK.
***Total number of faces on empty patches is not divisible by the number of cells in the mesh. Hence this mesh is not 1D or 2D.
Cell to face addressing OK.
Point usage OK.
Upper triangular ordering OK.
Face vertices OK.
Number of regions: 1 (OK).
Checking patch topology for multiply connected surfaces...
Patch Faces Points Surface topology
inlet 40 82 ok (non-closed singly connected)
outlet 40 82 ok (non-closed singly connected)
walls 120 244 ok (non-closed singly connected)
frontAndBack 10379 5422 ok (non-closed singly connected)
defaultFaces 41 76 ok (non-closed singly connected)
".*" 10620 5424 ok (closed singly connected)
Checking faceZone topology for multiply connected surfaces...
No faceZones found.
Checking basic cellZone addressing...
CellZone Cells Points Volume BoundingBox
billets 120 560 5.78218e-05 (0.0523259 -0.156635 0) (0.548325 0.157088 0.01)
Checking basic pointZone addressing...
No pointZones found.
Checking geometry...
Overall domain bounding box (0 -0.2 0) (0.6 0.2 0.01)
Mesh has 2 geometric (non-empty/wedge) directions (1 1 0)
Mesh has 2 solution (non-empty) directions (1 1 0)
All edges aligned with or perpendicular to non-empty directions.
Boundary openness (1.20353e-18 -2.29081e-18 -8.29015e-16) OK.
Max cell openness = 2.04242e-16 OK.
Max aspect ratio = 1.79987 OK.
Minimum face area = 2.86051e-05. Maximum face area = 0.00015945. Face area magnitudes OK.
Min volume = 2.86051e-07. Max volume = 8.39386e-07. Total volume = 0.00236173. Cell volumes OK.
Mesh non-orthogonality Max: 26.5465 average: 5.95796
Non-orthogonality check OK.
Face pyramids OK.
Max skewness = 0.333333 OK.
Coupled point location match (average 0) OK.
Mesh OK.
End
3. 計算実行
以下でバックグラウンドでの計算を開始します。
pimpleFoam > log.pimpleFoam 2>&1 &
これでlogが見られますが、画面を文字が高速で駆け抜けます。
tail -f log.pimpleFoam
文字を読もうとしたら、こちらの方が好いです。
tail -n 30 log.pimpleFoam
おわりに
何度か失敗しましたが、計算ができたようです。しかし、計算結果が妥当であるかはまだわかりません。結果の可視化が必要です。そのため、次はフリーの可視化ツールである paraview にトライします。