MCPcopy Create free account
hub / github.com/OpenFOAM/OpenFOAM-dev / adjustDeltaT

Function adjustDeltaT

src/OpenFOAM/db/Time/Time.C:84–124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

82// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
83
84void Foam::Time::adjustDeltaT()
85{
86 bool adjustTime = false;
87 scalar timeToNextWrite = VGREAT;
88
89 if (writeControl_ == wcAdjustableRunTime)
90 {
91 adjustTime = true;
92 timeToNextWrite = max
93 (
94 0.0,
95 (writeTimeIndex_ + 1)*writeInterval_ - (value() - startTime_)
96 );
97 }
98
99 if (adjustTime)
100 {
101 scalar nSteps = timeToNextWrite/deltaT_ - SMALL;
102
103 // For tiny deltaT the label can overflow!
104 if (nSteps < labelMax)
105 {
106 label nStepsToNextWrite = label(nSteps) + 1;
107
108 scalar newDeltaT = timeToNextWrite/nStepsToNextWrite;
109
110 // Control the increase of the time step to within a factor of 2
111 // and the decrease within a factor of 5.
112 if (newDeltaT >= deltaT_)
113 {
114 deltaT_ = min(newDeltaT, 2.0*deltaT_);
115 }
116 else
117 {
118 deltaT_ = max(newDeltaT, 0.2*deltaT_);
119 }
120 }
121 }
122
123 functionObjects_.adjustTimeStep();
124}
125
126
127void Foam::Time::setControls()

Callers 1

setDeltaTFunction · 0.85

Calls 3

maxFunction · 0.85
labelFunction · 0.85
minFunction · 0.85

Tested by

no test coverage detected