Update OpenFOAM numerical settings automatically
In the past posts about simulation schemes and function object, we talked about the possibility of setting a first or second order analysis and the possibility of running custom actions while openfoam is actually executing the simulation. This post is dedicated on automation: update OpenFOAM numerical settings automatically
Given the fact that usually first order simulations are more stable but less accurate, while second order analyses are more accurate but less stable, a common configuration would require to execute few steps with a first order scheme and move to a second order once a partial convergence is achieved. In this way, the second order analysis can benefit of the partial results computed and be more stable than the same analysis when starts from scratch.
A dedicated function object, named timeActivatedFileUpdate, come into help in these situations. As all the function objects, to make it work it has to be specified in controlDict and it requires the following arguments:
fUpdate // File Update
( -1 "$FOAM_CASE/system/fvSchemes-1st")
( 3000 "$FOAM_CASE/system/fvSchemes-2nd")
This block specifies a variable fvSchemes file with OpenFOAM numerical settings (as specified in fileToUpdate). The sequence of this file are then reported in the block timeVsFile, where at iteration -1 the solver replaces the current fvSchemes with the one located in “$FOAM_CASE/system/fvSchemes-1st” and at iteration 3000 the file is once again replaced with the file “$FOAM_CASE/system/fvSchemes-2nd“.
As it is easy to understand, this function object allows you to modify any file in the OpenFOAM system folder, including for example fvSolution. Files into other folders may not be affected by this function object as they are usually read just at the beginning of your analysis and not at every time step.