correction for timeFolder save

This commit is contained in:
Hamidreza Norouzi 2023-02-16 02:33:11 -08:00
parent 4f44fe5e4c
commit aa4ac3372c
4 changed files with 27 additions and 14 deletions

View File

@ -197,7 +197,7 @@ bool pFlow::sphereDEMSystem::iterate(
word timeName) word timeName)
{ {
Control().time().setEndTime(upToTime); Control().time().setStopAt(upToTime);
Control().time().setOutputToFile(timeToWrite, timeName); Control().time().setOutputToFile(timeToWrite, timeName);
loop(); loop();
@ -207,7 +207,7 @@ bool pFlow::sphereDEMSystem::iterate(
bool pFlow::sphereDEMSystem::iterate(real upToTime) bool pFlow::sphereDEMSystem::iterate(real upToTime)
{ {
Control().time().setEndTime(upToTime); Control().time().setStopAt(upToTime);
loop(); loop();
return true; return true;
} }

View File

@ -45,6 +45,7 @@ pFlow::timeControl::timeControl
( (
dict.getVal<real>("endTime") dict.getVal<real>("endTime")
), ),
stopAt_(endTime_),
currentTime_(startTime_), currentTime_(startTime_),
saveInterval_ saveInterval_
( (
@ -79,6 +80,7 @@ pFlow::timeControl::timeControl(
), ),
startTime_(startTime), startTime_(startTime),
endTime_(endTime), endTime_(endTime),
stopAt_(endTime_),
currentTime_(startTime_), currentTime_(startTime_),
saveInterval_(saveInterval), saveInterval_(saveInterval),
lastSaved_(startTime_), lastSaved_(startTime_),

View File

@ -50,6 +50,9 @@ protected:
// - end time of simulation // - end time of simulation
real endTime_; real endTime_;
// - stopAt
real stopAt_;
// - current time of simulation // - current time of simulation
real currentTime_; real currentTime_;
@ -110,13 +113,12 @@ public:
return tmp; return tmp;
} }
void setEndTime(real eT) void setStopAt(real sT)
{ {
if(managedExternaly_) if(managedExternaly_)
{ {
endTime_ = eT; stopAt_ = sT;
} }
} }
real startTime()const real startTime()const
@ -131,17 +133,18 @@ public:
word currentTimeWord(bool forSave = true)const word currentTimeWord(bool forSave = true)const
{ {
if(forSave) return real2FixedStripZeros( currentTime(), timePrecision());
/*if(forSave)
{ {
if(!managedExternaly_) if(!managedExternaly_)
return real2FixedStripZeros( currentTime(), timePrecision());
else else
return timeName_; return timeName_;
} }
else else
{ {
return real2FixedStripZeros( currentTime(), timePrecision()); return real2FixedStripZeros( currentTime(), timePrecision());
} }*/
} }
int32 currentIter()const int32 currentIter()const
@ -149,12 +152,18 @@ public:
return currentIter_; return currentIter_;
} }
bool finished()const bool finalTime()const
{ {
if( currentTime_ >= endTime_ ) return true; if( currentTime_ >= endTime_ ) return true;
if( abs(currentTime_-endTime_) < 0.5*dt_ )return true; if( abs(currentTime_-endTime_) < 0.5*dt_ )return true;
return false; return false;
} }
bool reachedStopAt()const
{
if( currentTime_ >= stopAt_ ) return true;
if( abs(currentTime_-stopAt_) < 0.5*dt_ )return true;
return false;
}
bool outputToFile()const bool outputToFile()const
{ {
@ -176,7 +185,7 @@ public:
bool operator ++(int) bool operator ++(int)
{ {
if( finished() ) return false; if( reachedStopAt() ) return false;
// increament iteration number // increament iteration number
currentIter_++; currentIter_++;

View File

@ -234,6 +234,8 @@ bool pFlow::systemControl::operator ++(int)
{ {
// skip writing to file for the first iteration // skip writing to file for the first iteration
auto finished = time()++;
writeToFileTimer_.start(); writeToFileTimer_.start();
if(time().currentIter() != 0) if(time().currentIter() != 0)
{ {
@ -244,8 +246,9 @@ bool pFlow::systemControl::operator ++(int)
return false; return false;
} }
} }
else if( time().finished() ) else if( time().finalTime() )
{ {
output<<"****************************************************************"<<endl;
if( !time().write() ) if( !time().write() )
{ {
fatalErrorInFunction; fatalErrorInFunction;
@ -260,8 +263,7 @@ bool pFlow::systemControl::operator ++(int)
timers_.write(output, true); timers_.write(output, true);
} }
return time()++; return finished;
} }