CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Running, Solving & CFD (
-   -   Is it to possible to change time step DeltaT during a calculation (

dbxmcf March 13, 2007 00:44

I am using icoFoam to calculat
I am using icoFoam to calculate a simple fluid, however I want to change the time step dynamically, e.g. first time step is: deltaT[1]=0.001, the next time step is deltaT[2]=0.003, the next is deltaT[3]=0.002, and so on.

Maybe it is a wired problem, but in my program it seems that I need such kind of dynamic timestep, is it possible to program it in OpenFOAM? I didn't find any function like runTime.setTimeStep(DeltaT)...the only function I found is adjustDeltaT() but it is protected and after I read through the source, I found it is not doing what I want.

Thanks a lot!

tehache March 13, 2007 03:32

I use scalar
I use

scalar dt=runTime.deltaT()

to get the actual timestep, and


to set it to a new value, works.

Have fun ...


kdarc November 1, 2007 18:59

Hi. the example above, is e

the example above, is exactly what I'm trying to do and when I implement the code as shown above, NOTHING changes.

This makes me think that I also have to have some "include file" statements, or need to have some extra libraries mentioned in the "options" file.

Any advice?


dbxmcf November 1, 2007 19:48

it should work using setDeltaT
it should work using setDeltaT(dt):

like this:

runTime.setEndTime(runTime.value()+runTime.deltaT( ).value());

philippose November 4, 2007 14:21

Hello, A Good day to you!

A Good day to you!

Sorry I could not get into this post a little earlier... I saw the post, but was away, so could not react to it :-)!

Some time back, I had modified the icoFoam solver to include variable time step functionality as a question from another user on this forum.

Unfortunately, I am unable to find that post now... so... here is "icoFoamVarDt"... basically does exactly what you want..... it uses the built in capability in OpenFOAM to limit the Courant Number by adapting the time step size....

Hope this helps.... icoFoamVarDt.tar.gz

In order to activate this, you need to use the "adjustTimeStep yes" option, followed my "maxCo [maximum Co Number you want to limit to]" in the controlDict file.


All times are GMT -4. The time now is 04:35.