スキームと代数方程式
離散化スキームと代数方程式も各領域ごとに設定します。
離散化スキーム
system/air/fvSchemes
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
ddtSchemes { default steadyState; } gradSchemes { default Gauss linear; } divSchemes { default none; div(phi,U) Gauss upwind; energy Gauss upwind; div(phi,K) Gauss linear; div(phi,h) $energy; turbulence Gauss upwind; div(phi,k) $turbulence; div(phi,epsilon) $turbulence; div(phi,R) $turbulence; div(R) Gauss linear; div(((rho*nuEff)*dev2(T(grad(U))))) Gauss linear; } laplacianSchemes { default Gauss linear corrected; } interpolationSchemes { default linear; } snGradSchemes { default corrected; } |
system/heatsink/fvSchemes
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
ddtSchemes { default steadyState; } gradSchemes { default Gauss linear; } divSchemes { default none; } laplacianSchemes { default none; laplacian(alpha,h) Gauss linear corrected; } interpolationSchemes { default linear; } snGradSchemes { default corrected; } |
代数方程式
system/air/fvSolution
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
solvers { rho { solver PCG; preconditioner DIC; tolerance 1e-7; relTol 0; } p_rgh { solver GAMG; tolerance 1e-7; relTol 0.01; smoother GaussSeidel; } "(U|h|k|epsilon|G|Ii)" { solver PBiCGStab; preconditioner DILU; tolerance 1e-7; relTol 0.1; } G { $p_rgh; tolerance 1e-05; relTol 0.1; } } SIMPLE { momentumPredictor yes; nNonOrthogonalCorrectors 0; pRefCell 0; pRefValue 100000; rhoMin 0.2; rhoMax 2; } relaxationFactors { fields { rho 1.0; p_rgh 0.7; } equations { U 0.3; h 0.7; "(k|epsilon|omega)" 0.7; G 0.7; "ILambda.*" 0.7; qr 0.7; } } |
system/heatsink/fvSolution
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
solvers { h { solver PCG; preconditioner DIC; tolerance 1e-06; relTol 0.1; } } SIMPLE { nNonOrthogonalCorrectors 0; } relaxationFactors { equations { h 0.7; } } |
計算制御の設定
計算ステップ数は2000としています。
結果の出力に壁面熱流束や熱伝達率の設定もしています。
system/controlDict
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
application chtMultiRegionSimpleFoam; startFrom latestTime; startTime 0; stopAt endTime; endTime 2000; deltaT 1; writeControl timeStep; writeInterval 200; purgeWrite 10; writeFormat ascii; writePrecision 7; writeCompression off; timeFormat general; timePrecision 6; runTimeModifiable true; functions { continuityError1 { type continuityError; libs ( fieldFunctionObjects ); // Mandatory entries (unmodifiable)// Optional entries (runtime modifiable) phi phi; // Optional (inherited) entries writePrecision 8; writeToFile yes; useUserTime yes; region region0; enabled yes; log yes; timeStart 0; timeEnd 8000; executeControl timeStep; executeInterval 1; writeControl timeStep; writeInterval 1; } residuals { type solverInfo; libs ( "libutilityFunctionObjects.so" ); fields ( ".*" ); } fieldMinMax1 { type fieldMinMax; libs ( fieldFunctionObjects ); // Mandatory entries (unmodifiable)// Mandatory entries (runtime modifiable) mode magnitude; fields ( U p T ); // Optional entries (runtime modifiable) location yes; writePrecision 8; writeToFile yes; useUserTime yes; region air; enabled yes; log yes; timeStart 0; timeEnd 8000; executeControl timeStep; executeInterval 1; writeControl timeStep; writeInterval 1; } yPlus1 { type yPlus; libs ( fieldFunctionObjects ); // Mandatory entries (unmodifiable)// Optional (inherited) entries writePrecision 8; writeToFile yes; useUserTime yes; region region0; enabled yes; log yes; timeStart 0; timeEnd 8000; executeControl timeStep; executeInterval 1; writeControl timeStep; writeInterval 100; } YMin { type surfaceFieldValue; libs ( "libfieldFunctionObjects.so" ); writeControl timeStep; log yes; writeFields no; regionType patch; name ZMax; operation sum; fields ( phi ); // Optional (inherited) entries writePrecision 8; writeToFile yes; useUserTime yes; region air; enabled yes; timeStart 0; timeEnd 8000; executeControl timeStep; executeInterval 1; writeInterval 100; } YMax { $YMin; name YMax; } //https://doc.openfoam.com/2306/tools/post-processing/function-objects/field/wallHeatFlux/ wallHeatFlux1 { // Mandatory entries (unmodifiable) type wallHeatFlux; libs (fieldFunctionObjects); // Optional entries (runtime modifiable) //patches (<patch1> ... <patchN>); // (wall1 "(wall2|wall3)"); //qr qr; // Optional (inherited) entries // writePrecision 8; // writeToFile true; // useUserTime true; region heatshink; // enabled true; // log true; // timeStart 0; // timeEnd 8000; executeControl timeStep; executeInterval 1; writeControl writeTime;//timeStep; writeInterval 1; } //https://doc.openfoam.com/2306/tools/post-processing/function-objects/field/heatTransferCoeff/ heatTransferCoeff1 { // Mandatory entries (unmodifiable) type heatTransferCoeff; libs (fieldFunctionObjects);//(fieldFunctionObjects); field T;//<field>; // patches ("([a-zA-Z]+-(left|right)-[0-9]+)");//(<patch1> <patch2> ... <patchN>); patches (heatshink air_to_heatshink);//(<patch1> <patch2> ... <patchN>); htcModel fixedReferenceTemperature;//<htcModel>; TRef 293.15; // UInf (20 0 0); // Cp CpInf; // CpInf 4000; // rho rhoInf; // rhoInf 1.2; // Optional (inherited) entries // result <fieldResult>; region heatshink; // enabled true; // log true; // timeStart 0; // timeEnd 8000; executeControl timeStep; executeInterval 1; writeControl writeTime;;//timeStep; writeInterval 1; } } |
計算実行
並列計算をさせない場合は以下のコマンドでOKです。
1 |
chtMultiRegionSimpleFoam |
以上で計算が実行されます。
並列計算させる場合
並列計算が必要な場合は以下を実行してから並列計算を実行します。
./Allrun.decomp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
#!/bin/sh cd "${0%/*}" || exit # Run from this directory . ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions # Tutorial run functions #------------------------------------------------------------------------------ for region in $(foamListRegions) do decomposePar -region $region done for region in $(foamListRegions) do runParallel $decompDict -s "$region" changeDictionary -region $region done #------------------------------------------------------------------------------ |
領域ごとに分割をしないといけないのでスクリプトにしておくと便利です。
1 |
Allrun.decomp |
並列分割できたら以下を実行し計算させます。
1 |
mpirun -np 4 chtMultiRegionSimpleFoam -parallel |
今回はそこまで計算時間がかからないので並列計算無しでも良いでしょう。
結果の確認
ヒートシンクの温度分布と熱流束の分布になります。
CFDで移動現象論111例題
ヒートシンクhttps://t.co/ceod0EWiq6 https://t.co/pz65L8pkjU pic.twitter.com/B4F6EO3UOb— カマキリ🐲計算力学頑張る (@t_kun_kamakiri) August 4, 2025
まとめ
本記事で見たようにマルチリージョン系はメッシュ作成と解析設定に少し癖があるので、手動で行うのは結構手間です。
可能ならTreeFoamのようなGUIで設定できる方が良いかもしれません。
WSLでもTreeFoamが使えそうなのを確認したので、おいおい設定方法をまとめたい思います。
もろもろインストールできてないのでエラー出るけど使えることがわかった。 pic.twitter.com/BAU4K4qriA
— カマキリ🐲計算力学頑張る (@t_kun_kamakiri) June 12, 2025
計算力学技術者のための問題アプリ
計算力学技術者熱流体2級、1級対策アプリをリリースしました。
- 下記をクリックしてホームページでダウンロードできます。
- LINE公式に登録すると無料で問題の一部を閲覧できます。
※LINEの仕様で数式がずれていますが、アプリでは問題ありません。
- 計算力学技術者の熱流体2級問題アプリ作成
リリース後も試行錯誤をしながら改善に努め日々アップデートしています。
備忘録として作成の過程を綴っています。
OpenFOAMに関する技術書を販売中!
OpenFOAMを自宅で学べるシリーズを販売中です。
OpenFOAM初学者から中級者向けの技術書となっていますので、ぜひよろしくお願いいたします。
おすすめ参考図書
本記事は以下の書籍の例題のひとつになります。
Fluentでの設定を確認したい方は本書を手に取ってみると良いでしょう(サンプルモデルが公開されています)
☟こちらは、OpenFOAMの日本語書籍が無い中唯一わかりやすい参考書だと思います。
☟こちらもOpenFOMの古いバージョンでの和訳になります。さすがにこちらはバージョンに対する日本語でのケアはしていないので、OpenFOAMに慣れている方は購入しても良いかと思います。僕は「日本語でまとまっている内容」なので少し重宝しています。
☟以下に、もっと初心者向けの同人誌を紹介しておきます。
初心者は「ってか、まずどうやってOpenFOAMをインストールするの?」というところからつまずきがちです。
そんな時は、以下の書籍をおすすめします。
改訂新版 OpenFOAMの歩き方 (技術の泉シリーズ(NextPublishing))