Update OpenFOAM numerical settings automatically

Published by rupole1185 on

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
        {
            type            timeActivatedFileUpdate;
            libs            ("libutilityFunctionObjects.so");
            writeControl    timeStep;
            writeInterval   1;
            fileToUpdate    "$FOAM_CASE/system/fvSchemes";
            timeVsFile
            (
                ( -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.


CloudHPC is a HPC provider to run engineering simulations on the cloud. CloudHPC provides from 1 to 224 vCPUs for each process in several configuration of HPC infrastructure - both multi-thread and multi-core. Current software ranges includes several CAE, CFD, FEA, FEM software among which OpenFOAM, FDS, Blender and several others.

New users benefit of a FREE trial of 300 vCPU/Hours to be used on the platform in order to test the platform, all each features and verify if it is suitable for their needs


Categories: OpenFOAM

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *