CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (http://www.cfd-online.com/Forums/openfoam-solving/)
-   -   Varying time step (http://www.cfd-online.com/Forums/openfoam-solving/128713-varying-time-step.html)

guserik January 19, 2014 18:00

Varying time step
 
Is it possible to set a fixed varying time step in openfoam? Let say i want

deltaT = 0.0001 if t>=0 && t<=1
deltaT = 0.001 if t>1 && t<=2
deltaT = 0.01 if t>2 && t<=3

If there is i would be really happy if someone have an example of this. At the moment I'm not satisfied with adjustableTimeStep.

Thanks

msuaeronautics January 19, 2014 22:22

This is certainly possible if you modify the source code of the particular solver you want to use. Would require a set of if statements.

joshm January 20, 2014 02:54

A less-than-elegant solution might be just to run a bash script which replaces the controlDict file and runs the solver again.

alexeym January 20, 2014 04:55

Hi,

You can create 3 different controlDicts with required deltaT parameter and then use function objects to update control dictionary during the time. Put something like:

Code:

functions
{
    fileUpdate1
    {
        type            timeActivatedFileUpdate;
        functionObjectLibs ("libutilityFunctionObjects.so");
        outputControl  timeStep;
        outputInterval  1;
        fileToUpdate    "$FOAM_CASE/system/controlDict";
        timeVsFile
        (
            (-1    "$FOAM_CASE/system/controlDict_1")
            (1    "$FOAM_CASE/system/controlDict_2")
            (2    "$FOAM_CASE/system/controlDict_3")
        );
    }
}

in controlDicts you've created.

So from the beginning of the simulation it will use controlDict_1 where you put deltaT=0.0001, from 1 to 2 s it will use controlDict_2 where you put deltatT=0.001 etc.

guserik January 20, 2014 04:58

Quote:

Originally Posted by alexeym (Post 470833)
Hi,

You can create 3 different controlDicts with required deltaT parameter and then use function objects to update control dictionary during the time. Put something like:

Code:

functions
{
    fileUpdate1
    {
        type            timeActivatedFileUpdate;
        functionObjectLibs ("libutilityFunctionObjects.so");
        outputControl  timeStep;
        outputInterval  1;
        fileToUpdate    "$FOAM_CASE/system/controlDict";
        timeVsFile
        (
            (-1    "$FOAM_CASE/system/controlDict_1")
            (1    "$FOAM_CASE/system/controlDict_2")
            (2    "$FOAM_CASE/system/controlDict_3")
        );
    }
}

in controlDicts you've created.

So from the beginning of the simulation it will use controlDict_1 where you put deltaT=0.0001, from 1 to 2 s it will use controlDict_2 where you put deltatT=0.001 etc.

Thanks for the suggestion, i will try this :)

(-1 "$FOAM_CASE/system/controlDict_1")
(1 "$FOAM_CASE/system/controlDict_2")
(2 "$FOAM_CASE/system/controlDict_3")

-1 / 1 / 2 is those number related to time?

alexeym January 20, 2014 07:37

Quote:

Originally Posted by guserik (Post 470834)
(-1 "$FOAM_CASE/system/controlDict_1")
(1 "$FOAM_CASE/system/controlDict_2")
(2 "$FOAM_CASE/system/controlDict_3")

-1 / 1 / 2 is those number related to time?

Yes. Actually it is time in seconds when file update will occure.


All times are GMT -4. The time now is 02:22.