coupling modifictions for timeControl and iterate

This commit is contained in:
hamidrezanorouzi 2023-01-08 14:06:26 +03:30
parent fef0c4fe96
commit 782c0d5667
5 changed files with 100 additions and 15 deletions

View File

@ -144,7 +144,13 @@ public:
bool beforeIteration() = 0;
virtual
bool iterate(int32 n, real timeToWrite, word timeName) = 0;
bool iterate(
real upToTime,
real timeToWrite,
word timeName) = 0;
virtual
bool iterate(real upToTime) = 0;

View File

@ -20,6 +20,36 @@ Licence:
#include "sphereDEMSystem.hpp"
void pFlow::sphereDEMSystem::loop()
{
do
{
Control().timers().start();
geometry_->beforeIteration();
interaction_->beforeIteration();
particles_->beforeIteration();
interaction_->iterate();
particles_->iterate();
geometry_->iterate();
particles_->afterIteration();
geometry_->afterIteration();
Control().timers().end();
}while(Control()++);
}
pFlow::sphereDEMSystem::sphereDEMSystem(
word demSystemName,
@ -161,10 +191,23 @@ bool pFlow::sphereDEMSystem::beforeIteration()
bool pFlow::sphereDEMSystem::iterate(
int32 n,
real upToTime,
real timeToWrite,
word timeName)
{
Control().time().setEndTime(upToTime);
Control().time().setOutputToFile(timeToWrite, timeName);
loop();
return true;
}
bool pFlow::sphereDEMSystem::iterate(real upToTime)
{
Control().time().setEndTime(upToTime);
loop();
return true;
}

View File

@ -82,6 +82,8 @@ protected:
return interaction_();
}
void loop();
public:
TypeInfo("sphereDEMSystem");
@ -128,7 +130,12 @@ public:
bool beforeIteration() override;
bool iterate(int32 n, real timeToWrite, word timeName) override;
bool iterate(
real upToTime,
real timeToWrite,
word timeName) override;
bool iterate(real upToTime) override;
real maxBounndingSphereSize()const override;

View File

@ -102,19 +102,27 @@ pFlow::timeControl::timeControl(
void pFlow::timeControl::checkForOutputToFile()
{
if(managedExternaly_) return;
bool save = false;
if ( abs(currentTime_ - lastSaved_ - saveInterval_) < 0.5 * dt_ )
{
lastSaved_ = currentTime_;
save = true;
}
else if( abs(currentTime_ - lastSaved_) < min( pow(10.0,-1.0*timePrecision_), 0.5 *dt_) )
if(managedExternaly_)
{
lastSaved_ = currentTime_;
save = true;
if( abs(currentTime_-writeTime_) < 0.5*dt_)
{
save = true;
lastSaved_ = currentTime_;
}
}
else
{
if ( abs(currentTime_ - lastSaved_ - saveInterval_) < 0.5 * dt_ )
{
lastSaved_ = currentTime_;
save = true;
}
else if( abs(currentTime_ - lastSaved_) < min( pow(10.0,-1.0*timePrecision_), 0.5 *dt_) )
{
lastSaved_ = currentTime_;
save = true;
}
}
outputToFile_ = save;

View File

@ -67,7 +67,9 @@ protected:
bool managedExternaly_ = false;
word timeName_ = "wrongSettings";
word timeName_ = "wrongSettings"; // for managedExternamly
real writeTime_ = 0; // for managedExternamly
realStridedRange timersReportInterval_;
@ -108,6 +110,15 @@ public:
return tmp;
}
void setEndTime(real eT)
{
if(managedExternaly_)
{
endTime_ = eT;
}
}
real startTime()const
{
return startTime_;
@ -141,6 +152,7 @@ public:
bool finished()const
{
if( currentTime_ >= endTime_ ) return true;
if( abs(currentTime_-endTime_) < 0.5*dt_ )return true;
return false;
}
@ -151,6 +163,15 @@ public:
bool timersReportTime()const;
bool setOutputToFile(real writeTime, const word& timeName)
{
if(managedExternaly_)
{
timeName_ = timeName;
writeTime_ = writeTime;
}
return true;
}
bool operator ++(int)
{