BUG: Time.C: adjustTimeStep overflow of scalar
This commit is contained in:
parent
c07e9f6600
commit
acc8d7714a
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -86,18 +86,25 @@ void Foam::Time::adjustDeltaT()
|
|||||||
(outputTimeIndex_ + 1)*writeInterval_ - (value() - startTime_)
|
(outputTimeIndex_ + 1)*writeInterval_ - (value() - startTime_)
|
||||||
);
|
);
|
||||||
|
|
||||||
label nStepsToNextWrite = label(timeToNextWrite/deltaT_ - SMALL) + 1;
|
scalar nSteps = timeToNextWrite/deltaT_ - SMALL;
|
||||||
scalar newDeltaT = timeToNextWrite/nStepsToNextWrite;
|
|
||||||
|
|
||||||
// Control the increase of the time step to within a factor of 2
|
// For tiny deltaT the label can overflow!
|
||||||
// and the decrease within a factor of 5.
|
if (nSteps < labelMax)
|
||||||
if (newDeltaT >= deltaT_)
|
|
||||||
{
|
{
|
||||||
deltaT_ = min(newDeltaT, 2.0*deltaT_);
|
label nStepsToNextWrite = label(nSteps) + 1;
|
||||||
}
|
|
||||||
else
|
scalar newDeltaT = timeToNextWrite/nStepsToNextWrite;
|
||||||
{
|
|
||||||
deltaT_ = max(newDeltaT, 0.2*deltaT_);
|
// Control the increase of the time step to within a factor of 2
|
||||||
|
// and the decrease within a factor of 5.
|
||||||
|
if (newDeltaT >= deltaT_)
|
||||||
|
{
|
||||||
|
deltaT_ = min(newDeltaT, 2.0*deltaT_);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
deltaT_ = max(newDeltaT, 0.2*deltaT_);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user