During an OpenFOAM simulation it is sometimes necessary to update a numerical scheme, for example, switching from first order to second order schemes to improve accuracy vs stability.
In order to perform these modifications automatically, we can add a function object to our controlDict, as shown in the following example, where after iteration 100 the fvSchemes is automatically updated:
functions { fileUpdate1 { type timeActivatedFileUpdate; libs ("libutilityFunctionObjects.so"); writeControl timeStep; writeInterval 1; fileToUpdate "$FOAM_CASE/system/fvSchemes"; timeVsFile ( // start with first order (-1 "$FOAM_CASE/system/fvSchemes_1") // after 100 iterations use second order (100 "$FOAM_CASE/system/fvSchemes_2") ); } }
In addition to the previous function object, we also need to make 2 copies of the “fvSchemes” file and rename them as “fvSchemes_1” and “fvSchemes_2”, both saved in the system directory.
In fvSchemes_1, divergence schemes are set to first order bounded “upwind” scheme:
divSchemes { default none; div(phi,U) bounded Gauss upwind; div(phi,k) bounded Gauss upwind; div(phi,omega) bounded Gauss upwind; div((nuEff*dev(T(grad(U))))) Gauss linear; div(phi,nuTilda) bounded Gauss upwind; }
And in fv_Schemes_2, divergence schemes are set to second order bounded “linearUpwind” scheme:
divSchemes { default none; div(phi,U) bounded Gauss linearUpwind grad(U); div(phi,k) bounded Gauss linearUpwind default; div(phi,omega) bounded Gauss linearUpwind default; div((nuEff*dev(T(grad(U))))) Gauss linear; div(phi,nuTilda) bounded Gauss linearUpwind default; }
In this way OpenFOAM when iteration 100 is reached, will use second order accuracy, so that when the number of grid points doubles, the discretization error will be reduced by a factor of 4.
シンクタンクにてリスクマネージメントにCAEを活用,その後,外資系CAEベンダーでサポートエンジニア,技術営業を得て,ESIに入社.OpenFOAMを軸としたCFD関連のエンジニアリングサービスを担当