| 82 | // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // |
| 83 | |
| 84 | void 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 | |
| 127 | void Foam::Time::setControls() |