BUG: Time.C: adjustTimeStep overflow of scalar

This commit is contained in:
mattijs 2011-02-24 10:44:22 +00:00
parent c07e9f6600
commit acc8d7714a

View File

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