CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   Varying time step increment in OpenFoam controlDict file (https://www.cfd-online.com/Forums/openfoam/255339-varying-time-step-increment-openfoam-controldict-file.html)

Origami April 2, 2024 16:39

Varying time step increment in OpenFoam controlDict file
 
I am modelling wind in built-in urban areas. The domain is (-1500 -1200 -4.65946) (2000 1200 500) in meters. The distance between the inlet and the outlet is 3500m. I would like the first 1000 time steps the time increment is 2 and later the increment is 1. How do I achieve this in controlDict file?
Many thanks.

unilord April 3, 2024 04:08

Quote:

Originally Posted by Origami (Post 867148)
I am modelling wind in built-in urban areas. The domain is (-1500 -1200 -4.65946) (2000 1200 500) in meters. The distance between the inlet and the outlet is 3500m. I would like the first 1000 time steps the time increment is 2 and later the increment is 1. How do I achieve this in controlDict file?
Many thanks.

Hey,

I am not sure if there is an automated way to do this. Nevertheless, you can set the runTimeModifiable option to true in the controlDict, and when you see the analysis reaching 1000 time steps change it to 2 seconds. It will proceed just like nothing has happened.

Hope this helps,
Pedro Gouveia

Origami April 4, 2024 18:32

worked out. the controlDict below works. This is a revision from the tutorial file (esi 2212)
combustion/XiEngineFoam/kivaTest/system/controlDict

// Make sure all utilities know specialised models
libs (atmosphericModels);

application simpleFoam;

startFrom latestTime;

startTime 0;

stopAt endTime;

endTime 5000;

deltaT 1;

writeControl timeStep;

writeInterval 1000;

purgeWrite 2;

writeFormat ascii;

writePrecision 6;

writeCompression off;

timeFormat general;

timePrecision 6;

runTimeModifiable yes;


functions
{
timeStep
{
name setDeltaT;
type coded;
libs (utilityFunctionObjects);

code
#{
#};

codeExecute
#{
const Time& runTime = mesh().time();
if (runTime.timeToUserTime(runTime.value()) <100)
{
const_cast<Time&>(runTime).setDeltaT
(
runTime.userTimeToTime(2)
);
}

else

{
const_cast<Time&>(runTime).setDeltaT
(
runTime.userTimeToTime(1)
);
}


#};
}

// #include "momentum"
}


All times are GMT -4. The time now is 23:03.