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.

   Send article as PDF   

4 Replies to “Run a Case with Variable Time Step in OpenFOAM”

  1. Mr du ,I’m coming!
    I can’t understand what are you written!
    Oh,English,how terrible!
    We will leave there,we are all so glad to recognize you ,thank you very very much!

  2. @Foad

    The only thing you have to change is to add
    #include “createTimeControls.H”
    instead of
    #include “readTimeControls.H”

Leave a Reply

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

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.