controlDict, fvScheme,
fvSolution
の設定について
一関高専・若嶋
2014/12/5
第3回OpenCAE初歩情報交換会@北東北
1
調査報告
※
OpenFOAM 2.3.x
についてのみ調査
OF
のケースフォルダの基本構成
[waku@ensis10 pitzDaily]$ pwd
/home/waku/OpenFOAM/waku-2.3.x/tutorials/incompressible/pimpleFoam/pitzDaily
[waku@ensis10 pitzDaily]$ tree -L 2 .
.
|-- 0
・・・・・初期条件,境界条件フォルダ(
t=0
)
| |-- U
| |-- epsilon
| |-- k
| |-- nuTilda
| |-- nut
| `-- p
|-- constant
・・・・・物性値,乱流モデル選択
(laminar/RAS/LES),
メッシュデータ,移動メッシュ設定等(
***Dict/***Propeties
)
| |-- RASProperties
| |-- polyMesh
| |-- transportProperties
| `-- turbulenceProperties
`-- system
・・・・・時間ステップなどの計算設定ファイル,離散化スキーム指定,ソルバー設定
,
各種コマンド設定等
(***Dict)
|-- controlDict
|-- fvSchemes
`-- fvSolution
controlDict
2014/12/5
第3回OpenCAE初歩情報交換会@北東北
3
/*---*- C++ -*---*¥ | ========= | | | ¥¥ / F ield | OpenFOAM: The Open Source CFD Toolbox | | ¥¥ / O peration | Version: 2.3.0 | | ¥¥ / A nd | Web: www.OpenFOAM.org | | ¥¥/ M anipulation | | ¥*---*/ FoamFile { version 2.0; format ascii; class dictionary; location "system"; object controlDict; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // application pimpleFoam; startFrom latestTime; startTime 0; stopAt endTime; endTime 1; deltaT 0.0001; writeControl adjustableRunTime; writeInterval 0.001; purgeWrite 0; writeFormat ascii; writePrecision 6; writeCompression off; timeFormat general; timePrecision 6; runTimeModifiable yes; adjustTimeStep yes; maxCo 5; // ************************************************************************* //
Tutorial: pimpleFoam/pitzDaily
を例題としています
Dictionary
ファイルのヘッダー部(必須):
FoamFile{
~
}
コピーして来た場合は注意
OF
のソルバー名(
pyFoam
などのスクリプトファイルで参照されることが多い)
計算開始時間,終了時間の設定
時間ステップ
[s]
,指数表示可(
1.0e-4
)
注意:
各行のセミコロン;を忘れない!
計算結果の書き出しタイミング,形式(書式)など
時間の書式,精度(小数点)
時間ステップを計算中に変更できるか,クーラン数を超えないように自動的に調整するか
controlDict
/*---*- C++ -*---*¥ | ========= | | | ¥¥ / F ield | OpenFOAM: The Open Source CFD Toolbox | | ¥¥ / O peration | Version: 2.3.0 | | ¥¥ / A nd | Web: www.OpenFOAM.org | | ¥¥/ M anipulation | | ¥*---*/ FoamFile { version 2.0; format ascii; class dictionary; location "system"; object controlDict; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // application pimpleFoam; startFrom latestTime; startTime 0; stopAt endTime; endTime 1; deltaT 0.0001; writeControl adjustableRunTime; writeInterval 0.001; purgeWrite 0; writeFormat ascii; writePrecision 6; writeCompression off; timeFormat general; timePrecision 6; runTimeModifiable yes; adjustTimeStep yes; maxCo 5; // ************************************************************************* //startFrom
どの時間ディレクトリから計算を開始するか
- firstTime
時間ディレクトリの内,一番早いものを使用
- startTime
“
startTime
”で指定された時間ディレクトリを使用
- latestTime
時間ディレクトリの内,一番遅いものを使用
(※ リスタートする時に良く使います)
startTime
計算をスタートする時間ディレクトリ
stopAt
どの場合に計算をストップするかを指定
- endTime
“
endTime
”で指定した時間でストップ
- writeNow
現在の時間でストップし,計算結果を書き出す
- noWriteNow
現在の時間でストップし,計算結果は書き出さ
ない
- nextWrite
“writeControl”
でスケジュールされた次の
write
のタイミングでストップ
controlDict
2014/12/5
第3回OpenCAE初歩情報交換会@北東北
5
/*---*- C++ -*---*¥ | ========= | | | ¥¥ / F ield | OpenFOAM: The Open Source CFD Toolbox | | ¥¥ / O peration | Version: 2.3.0 | | ¥¥ / A nd | Web: www.OpenFOAM.org | | ¥¥/ M anipulation | | ¥*---*/ FoamFile { version 2.0; format ascii; class dictionary; location "system"; object controlDict; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // application pimpleFoam; startFrom latestTime; startTime 0; stopAt endTime; endTime 1; deltaT 0.0001; writeControl adjustableRunTime; writeInterval 0.001; purgeWrite 0; writeFormat ascii; writePrecision 6; writeCompression off; timeFormat general; timePrecision 6; runTimeModifiable yes; adjustTimeStep yes; maxCo 5; // ************************************************************************* //
writeControl
データ出力のタイミングの指定
- timeStep†
時間ステップ毎に毎回出力
- runTime
“writeInterval”
で指定した時間毎に出力
- adjustableRunTime
“runTime
と同様だが,時間ステップの大きさが変化し
ても自動的に計算して出力してくれる”
- cpuTime
計算におけるtimeではなくCPUtimeで,“writeInterval”
で指定した時間毎に出力
- clockTime
計算における
time
ではなく
WallClock
で,
“writeInterval”で指定した時間毎に出力
writeInterval
“writeControl”
で使用される時間間隔
purgeWrite
繰り返し出力のための整数値を指定.
0:
各時間ごとに出力(非定常計算)
1:時間ディレクトリ1つにずっと出力し続ける(定常計算)
2以上: 例えば3と指定すると,3つめの時間フォルダに出力後
は
1
つ目の時間フォルダに出力する.以下,繰り返す
writeFormat
解析データファイルの書式指定(
ascii/binary
)
- ascii
アスキーフォーマット(
”writePrecision”
で精度指定)
- binary
バイナリフォーマット(データサイズ小)
writePrecision
アスキーフォーマット時の小数点以下の精度(デフォルト
6
桁)
writeCompression
解析データの非圧縮/圧縮(gzip)を指定
- uncompressed
非圧縮
- compressed
gzip
で圧縮
controlDict
/*---*- C++ -*---*¥ | ========= | | | ¥¥ / F ield | OpenFOAM: The Open Source CFD Toolbox | | ¥¥ / O peration | Version: 2.3.0 | | ¥¥ / A nd | Web: www.OpenFOAM.org | | ¥¥/ M anipulation | | ¥*---*/ FoamFile { version 2.0; format ascii; class dictionary; location "system"; object controlDict; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // application pimpleFoam; startFrom latestTime; startTime 0; stopAt endTime; endTime 1; deltaT 0.0001; writeControl adjustableRunTime; writeInterval 0.001; purgeWrite 0; writeFormat ascii; writePrecision 6; writeCompression off; timeFormat general; timePrecision 6; runTimeModifiable yes; adjustTimeStep yes; maxCo 5; // ************************************************************************* //timeFormat
時間ディレクトリの数値フォーマット
- fixed
“
timePrecision
”した精度で固定
小数点表示
(
±
m.dddddd)
- scientific
“
timePrecision
”した精度で固定
指数表示
(
±
m.dddddde
±
xx)
- general
上記を自動で切り替え
(
±
10
-4
以下で指数表示
)
timePrecision
小数点以下の桁数(デフォルト
6
桁)
runTimeModifiable
各時間ステップで
controlDict
を読み込
むかどうかを指定
adjustTimeStep
maxCo
(最大クーラン数)を超えないよ
うに時間ステップを自動調整するかど
うかを指定
maxCo
Maximum Courant number
※ 原則として
1
以下.
simpleFoam
など
の定常解法や
pimpleFoam
などは
1
以
controlDict(advanced):
実行時ライブラリの
load
2014/12/5
第3回OpenCAE初歩情報交換会@北東北
7
/*---*- C++ -*---*¥ | ========= | | | ¥¥ / F ield | OpenFOAM: The Open Source CFD Toolbox | | ¥¥ / O peration | Version: 2.3.0 | | ¥¥ / A nd | Web: www.OpenFOAM.org | | ¥¥/ M anipulation | | ¥*---*/ FoamFile { version 2.0; format ascii; class dictionary; location "system"; object controlDict; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // application pimpleFoam; startFrom latestTime; startTime 0; stopAt endTime; endTime 1; deltaT 0.0001; writeControl adjustableRunTime; writeInterval 0.001; purgeWrite 0; writeFormat ascii; writePrecision 6; writeCompression off; timeFormat general; timePrecision 6; runTimeModifiable yes; adjustTimeStep yes; maxCo 5;
libs ( “libgroovyBC.so” “libUSERLIB.so ) ;
// ************************************************************************* //
•
libs (
“ライブラリ1”
“
ライブラリ
2” );
などと記述
して実行時にライブラリをロード可能
•
swak4foam
を導入した場合はここに記述する.
libs ( “libgroovyBC.so” “libUSERLIB.so ) ;
•
自作ライブラリも可
•
libs(“libgroovyBC.so”);
などとするとエラー
libs
と ( の間の空白
(
と
“lib***.so”
の空白
“lib***.so”
と
)
の空白
セミコロン;に注意
controlDict(advanced): Function Object
/*---*- C++ -*---*¥ | ========= | | | ¥¥ / F ield | OpenFOAM: The Open Source CFD Toolbox | | ¥¥ / O peration | Version: 2.3.0 | | ¥¥ / A nd | Web: www.OpenFOAM.org | | ¥¥/ M anipulation | | ¥*---*/ FoamFile { version 2.0; format ascii; class dictionary; location "system"; object controlDict; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // application pimpleFoam; startFrom latestTime; startTime 0; stopAt endTime; endTime 1; deltaT 0.0001; writeControl adjustableRunTime; writeInterval 0.001; purgeWrite 0; writeFormat ascii; writePrecision 6; writeCompression off; timeFormat general; timePrecision 6; runTimeModifiable yes; adjustTimeStep yes; maxCo 5;
libs ( “libgroovyBC.so” “libUSERLIB.so ) ; functions { ここに複数のFunction Objectを記述 } // ************************************************************************* //
Ref. http://www.slideshare.net/fumiyanozaki96/openfoam-function-object
•
controlDict
内に
functions{…}
を記述すること
で以下のような計算を行い,出力すること
ができます
パッチを通過する流量計算
変数の最大・最小値(パッチ,セル)
変数の平均値
変数の特定点の抽出
(probe)
力,トルク,抗力係数,揚力係数,トル
ク係数
断面データ,境界データ生成
など
controlDict(advanced): Function Object
2014/12/5
第3回OpenCAE初歩情報交換会@北東北
9
functions { } // ************************************************************************* //Ref. http://www.slideshare.net/fumiyanozaki96/openfoam-function-object
outletFlux { type faceSource; : } minMax { type fieldMinMax; : } forces { type forces; : } forceCoeffs { type forceCoeffs; : } midZplane { type surfaces; : } probePoint { type probes; : }パッチを通る流量
最大値・最小値
力・トルク
各種係数
断面プロット
特定点を
probe
•
青字
は,
FunctionObject
名で任意の名前可
•
赤字
は,
FunctionObejct
の
type
で,希望する内
容に合わせて選択する必要がある
個々の
type
の設定内容は,今回は時間
の都合で省略
•
それぞれの結果は,
postProcessing
フォルダに
生成される
•
どのような
type
があるかは(他にも多数あり),
source
を見ましょう
OpenFOAM-2.3.x/src/postProcessing/functionObjects
例:
fvSchemes
/*---*- C++ -*---*¥ | ========= | | | ¥¥ / F ield | OpenFOAM: The Open Source CFD Toolbox | | ¥¥ / O peration | Version: 2.3.0 | | ¥¥ / A nd | Web: www.OpenFOAM.org | | ¥¥/ M anipulation | | ¥*---*/ FoamFile { version 2.0; format ascii; class dictionary; location "system"; object fvSchemes; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ddtSchemes { default Euler; } gradSchemes {default Gauss linear; grad(p) Gauss linear; grad(U) Gauss linear; }
divSchemes
{
default none;
div(phi,U) bounded Gauss linearUpwind grad(U); div(phi,k) bounded Gauss upwind;
div(phi,epsilon) bounded Gauss upwind; div(phi,R) bounded Gauss upwind; div(R) Gauss linear; div(phi,nuTilda) bounded Gauss upwind; div((nuEff*dev(T(grad(U))))) Gauss linear; }
laplacianSchemes
{
default none;
laplacian(nuEff,U) Gauss linear corrected; laplacian(rAUf,p) Gauss linear corrected; laplacian(DkEff,k) Gauss linear corrected;
laplacian(DepsilonEff,epsilon) Gauss linear corrected; laplacian(DREff,R) Gauss linear corrected;
laplacian(DnuTildaEff,nuTilda) Gauss linear corrected; } interpolationSchemes { default linear; interpolate(U) linear; } snGradSchemes { default corrected; } fluxRequired { default no; p ; } // ************************************************************************* //
①時間積分離散化スキームの選択
②セル中⼼の勾配の離散化スキーム選択
③セル中⼼の発散(対流項)の
離散化スキームの選択
④セル中⼼のラブラシアン離散化スキームの選択
⑤セル界⾯の物理量補間スキームの選択
⑥セル界⾯の勾配スキームの選択
⑦質量フラックスの計算が必要な物理量の指定
※ 各項目とも,
default
指定と個別指定の組み合わせ
※ セミコロン;を忘れずに!
See: http://www.openfoam.org/docs/user/fvSchemes.php
OF
はセル中心有限体積法です
fvSchemes
:
①
ddtSchemes
2014/12/5
第3回OpenCAE初歩情報交換会@北東北
11
ddtSchemes
{
default
Euler;
}
Valid ddt schemes are :
8
(
CoEuler
:
オイラー法(
1
次精度前進差分)+
LocalTimeStepping(Co
数に応じて
)
CrankNicolson
:
クランクニコルソン法(
2
次精度前進差分)
, weight 0
(
Euler
)~1
(C-N)
指定
Euler :
オイラー法(
1
次精度前進差分)
SLTS : Stabilized Local Time-Stepping
backward :
ギア法(
2
次精度後退差分)
bounded :
勾配制限(
bounded
)
div
スキームを使うときに併用
“bounded Euler”
localEuler
:
オイラー法(
1
次精度前進差分)+
LocalTimeStepping
steadyState
:
定常計算(時間項なし)
)
d2dt2Schemes:
の離散化(
Euler
のみ)・・・・振動や電磁界解析の場合に利用
2
2
t
∂
∂
fvSchemes
:
②
gradSchemes
gradSchemes
{
default Gauss linear;
grad(p) Gauss linear;
grad(U) Gauss linear;
}
•
スカラー量の勾配
(gradient)
計算のスキーム選択
•
補間法
”interpolationScheme”
は,別に指定する
1. Gauss <interpolationScheme>
:
ガウス積分
2. leastSquares
:
最小自乗法
(2
次精度
)
3. fourth
:
最小自乗法(4次精度)
4. cellLimited <gradScheme>
: Gauss/leastSquares/fourth
の
cellLimited
版
5. faceLimited <gradScheme>
: Gauss/leastSquares/fourth
の
faceLimited
版
fvSchemes
:
③
divSchemes
2014/12/5
第3回OpenCAE初歩情報交換会@北東北
13
•
対流項の計算スキーム選択(
phi
は
mass flux
=
ρU
)
•
Gauss <interpolationScheme>
の形が基本で,頭に
bounded
をつけると制限付スキームになる
•
補間スキームの選択肢・・・・60個!(
Gauss
U
pwind
とわざと間違えると出てきます.)
•
代表的なもの
linear/limitedLinear
(2
次線形補間
)
sckewLinear
(
2
次線形補間
,
メッシュの
skewness
補間)
upwind (1
次風上
)
linearUpwind
(
2
次風上,制限付)
QUICK
(
2
次風上,制限付)
MUSCL/Minmod/SuperBee/vanAlbada/vanLeer
(
TVD
スキーム)
SFCD/gamma
(
NVD
スキーム)
divSchemes
{
default
none;
div(phi,U)
bounded Gauss linearUpwind grad(U);
div(phi,k) bounded Gauss upwind;
div(phi,epsilon) bounded Gauss upwind;
div(phi,R)
bounded Gauss upwind;
※
R = Reynolds stress tensor
div(R)
Gauss linear;
div(phi,nuTilda) bounded Gauss upwind;
※
nuTilda = kinematic turbulent viscosity
div((nuEff*dev(T(grad(U))))) Gauss linear;
}
速度Uなどのベクトルには,以下も指定できる(Vをつける)
limitedLinearV, vanLeerV, GammaV, limitedCubicV, SFCDV
fvSchemes
:
④
laplacianSchemes
•
いわゆる粘性項
/
拡散項の計算スキーム選択
・・・・
laplacian(nuEff,U)=
∇・(
ν
eff
∇
U
)
•
Gauss <interpolationScheme> <snGradScheme>
の形で指定
•
<interpolationScheme>・・・・選択肢
55個(linear/harmonic/reverseLinear/midpoint/….)
•
<snGradScheme>
・・・・・・・・・選択肢
7
個
1.
corrected
:非直交性補正
2.
faceCorrected
:セル境界での非直交性補正
3.
limited
:勾配制限付の非直交性を考慮した修正
Gauss linear limited 1;
4.
linearFit
:
?
5.
orthogonal :
?
6.
quadraticFit
:
?
7.
uncorrected :
非直交性補正なし
laplacianSchemes
{
default
none;
laplacian(nuEff,U)
Gauss linear corrected;
laplacian(rAUf,p)
Gauss linear corrected;
laplacian(DkEff,k)
Gauss linear corrected;
laplacian(DepsilonEff,epsilon) Gauss linear corrected;
laplacian(DREff,R)
Gauss linear corrected;
laplacian(DnuTildaEff,nuTilda) Gauss linear corrected;
}
fvSchemes
:
⑤
interpolationSchemes
⑥
snGradSchemes
2014/12/5
第3回OpenCAE初歩情報交換会@北東北
15
•
<interpolationScheme>
・・・・選択肢
55
個
(linear/harmonic/reverseLinear/midpoint/….)
•
<snGradScheme>
・・・・・・・・・選択肢
7
個
1.
corrected
:非直交性補正
2.
faceCorrected
:セル境界での非直交性補正
3.
limited
:勾配制限付の非直交性を考慮した修正
Gauss linear limited 1;
4.
linearFit
:
?
5.
orthogonal :
?
6.
quadraticFit
:
?
7.
uncorrected :非直交性補正なし
interpolationSchemes
{
default linear;
interpolate(U) linear;
}
snGradSchemes
{
default corrected;
}
snGrad:
セル界面
(face)
での外向き法線ベクトル(大きさは
face
面積)
fvSchemes
:
⑦
fluxRequired
•
flux
を計算する物理量リストを指定
•
上記の場合,圧力場
p
を計算後,
flux
を計算する.
•
一般的な計算では,
p(pcorr)
だけ指定すればよさそう.
fluxRequired
{
default no;
p ;
}
fvSolution
2014/12/5
第3回OpenCAE初歩情報交換会@北東北
17
/*---*- C++ -*---*¥ | ========= | | | ¥¥ / F ield | OpenFOAM: The Open Source CFD Toolbox | | ¥¥ / O peration | Version: 2.3.0 | | ¥¥ / A nd | Web: www.OpenFOAM.org | | ¥¥/ M anipulation | | ¥*---*/ FoamFile { version 2.0; format ascii; class dictionary; location "system"; object fvSolution; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // solvers { p { solver GAMG; tolerance 1e-7; relTol 0.01; smoother DICGaussSeidel; cacheAgglomeration true; nCellsInCoarsestLevel 10; agglomerator faceAreaPair; mergeLevels 1; } pFinal { $p; relTol 0; } "(U|k|epsilon)" { solver smoothSolver; smoother symGaussSeidel; tolerance 1e-05; relTol 0.1; } "(U|k|epsilon)Final" { $U; relTol 0; } } PIMPLE { nNonOrthogonalCorrectors 0; nCorrectors 2; } // ************************************************************************* //