Run a Case with Variable Time Step in OpenFOAM

Generally, in the explicit schemes of differential method, Courant number is an important number which should be less than 1 in order to assure the stability. However, if the Courant number is too small, much computation time will be lost. So the Courant number could be one of those important parameters affecting computation cost and stability. we could use Courant number to control the time step in the transient simulation in CFD codes. Here is some configuration parameters which could be used in simulation with OpenFOAM.

In the file $case/system/controlDict, the following options should be set:

maxCo 0.5; // Or other Courant number you wish

adjustTimeStep yes; // Or no

These two lines could be added to any position in the file, but being assumed OpenFOAM can recognize it. Also, you may wish limit the maximum deltaT:

maxDeltaT 1; // Maximum deltaT in seconds

In addition, we always want to get regular writing data in order to analyze cases simply, so the following lines would be helpful:

writeControl adjustableRunTime; 
writeInterval   1e-2;  // time interval in seconds

writeControl adjustableRunTime writes data every writeInterval seconds of simulated time, and adjusts the time steps to coincide with the writeInterval if necessary — used in cases with automatic time step adjustment.

However, this is just the configuration of a case. The solver should be modified if the original solver cannot run with adjustable time step. You could know this if you try. If it cannot run with variable time step, the source code of the main program solver.C should have some modification:

#   include "readTimeControls.H"

Added this line immediately after the including files after the “main” line. This line is used to read the control parameters used by setDeltaT.

Use while() instead of for():

while (runTime.run())       // added
 //   for (runTime++; !runTime.end(); runTime++)  // Dropped

Add the two lines in front of the line Info<< "Time = " ....

#       include "setDeltaT.H" // added

        runTime++;            // added

and also move the two lines before the above lines:

#       include "readPISOControls.H"

#       include "compressibleCourantNo.H"
// different from models

juse like:

#       include "readPISOControls.H"
#       include "compressibleCourantNo.H"
#       include "setDeltaT.H"

        runTime++;

That’s OK. you should remake the executable program for your application through wmake.

References
1. Transient analysis with turbFoam / very high Courant nr. http://openfoam.cfd-online.com/forum/messages/1/5087.html. June 12, 2008
2. OpenFOAM User Guide, v 1.4.1. 2007.

Print Friendly

Please comment with your real name using good manners.

Leave a Reply