Merge branch 'PhasicFlow:main' into main
This commit is contained in:
commit
fe5f550d17
|
@ -25,8 +25,6 @@ bool pFlow::sphereDEMSystem::loop()
|
|||
|
||||
do
|
||||
{
|
||||
Control().timers().start();
|
||||
|
||||
//
|
||||
|
||||
if(! insertion_().insertParticles(
|
||||
|
@ -55,9 +53,6 @@ bool pFlow::sphereDEMSystem::loop()
|
|||
particles_->afterIteration();
|
||||
|
||||
geometry_->afterIteration();
|
||||
|
||||
|
||||
Control().timers().end();
|
||||
|
||||
}while(Control()++);
|
||||
|
||||
|
@ -80,9 +75,11 @@ pFlow::sphereDEMSystem::sphereDEMSystem(
|
|||
REPORT(0)<< "\nCreating surface geometry for sphereDEMSystem . . . "<<endREPORT;
|
||||
geometry_ = geometry::create(Control(), Property());
|
||||
|
||||
|
||||
REPORT(0)<<"\nReading sphere particles . . ."<<endREPORT;
|
||||
particles_ = makeUnique<sphereFluidParticles>(Control(), Property());
|
||||
|
||||
|
||||
insertion_ = makeUnique<sphereInsertion>(
|
||||
Control().caseSetup().path()+insertionFile__,
|
||||
particles_(),
|
||||
|
|
|
@ -54,6 +54,13 @@ pFlow::sphereFluidParticles::sphereFluidParticles(
|
|||
)
|
||||
{}
|
||||
|
||||
bool pFlow::sphereFluidParticles::beforeIteration()
|
||||
{
|
||||
sphereParticles::beforeIteration();
|
||||
zeroFluidForce_H();
|
||||
zeroFluidTorque_H();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool pFlow::sphereFluidParticles::iterate()
|
||||
|
|
|
@ -48,12 +48,24 @@ protected:
|
|||
realx3PointField_HD& fluidTorque_;
|
||||
|
||||
|
||||
void zeroFluidForce_H()
|
||||
{
|
||||
fluidForce_.fillHost(zero3);
|
||||
}
|
||||
|
||||
void zeroFluidTorque_H()
|
||||
{
|
||||
fluidTorque_.fillHost(zero3);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
/// construct from systemControl and property
|
||||
sphereFluidParticles(systemControl &control, const property& prop);
|
||||
|
||||
|
||||
/// before iteration step
|
||||
bool beforeIteration() override;
|
||||
|
||||
/// iterate particles
|
||||
bool iterate() override;
|
||||
|
||||
|
|
|
@ -65,7 +65,6 @@ if(!cmds.parse(argc, argv)) return 0;
|
|||
|
||||
do
|
||||
{
|
||||
Control.timers().start();
|
||||
|
||||
if(! sphInsertion.insertParticles(
|
||||
Control.time().currentTime(),
|
||||
|
@ -94,8 +93,6 @@ if(!cmds.parse(argc, argv)) return 0;
|
|||
surfGeometry.afterIteration();
|
||||
|
||||
|
||||
Control.timers().end();
|
||||
|
||||
}while(Control++);
|
||||
|
||||
REPORT(0)<<"\nEnd of time loop.\n"<<endREPORT;
|
||||
|
|
|
@ -72,8 +72,11 @@ bool pFlow::sphereParticles::diameterMassInertiaPropId
|
|||
|
||||
bool pFlow::sphereParticles::initializeParticles()
|
||||
{
|
||||
|
||||
int32IndexContainer indices(0, shapeName_.size());
|
||||
|
||||
int32IndexContainer indices(
|
||||
0,
|
||||
static_cast<int32>(shapeName_.size()));
|
||||
|
||||
return insertSphereParticles(shapeName_, indices);
|
||||
}
|
||||
|
||||
|
@ -148,7 +151,7 @@ bool pFlow::sphereParticles::insertSphereParticles(
|
|||
}
|
||||
|
||||
auto len = names.size();
|
||||
|
||||
|
||||
realVector diamVec(len, RESERVE());
|
||||
realVector massVec(len, RESERVE());
|
||||
realVector IVec(len, RESERVE());
|
||||
|
@ -160,6 +163,7 @@ bool pFlow::sphereParticles::insertSphereParticles(
|
|||
|
||||
ForAll(i, names )
|
||||
{
|
||||
|
||||
if (diameterMassInertiaPropId(names[i], d, m, I, pId))
|
||||
{
|
||||
diamVec.push_back(d);
|
||||
|
@ -297,7 +301,6 @@ pFlow::sphereParticles::sphereParticles(
|
|||
fatalExit;
|
||||
}
|
||||
|
||||
|
||||
if(rVelIntegration_->needSetInitialVals())
|
||||
{
|
||||
|
||||
|
@ -320,6 +323,7 @@ pFlow::sphereParticles::sphereParticles(
|
|||
|
||||
}
|
||||
|
||||
|
||||
if(!initializeParticles())
|
||||
{
|
||||
fatalExit;
|
||||
|
|
|
@ -77,18 +77,24 @@ bool pFlow::Timer::write(iOstream& os, bool subTree)const
|
|||
|
||||
if(lvl==0)
|
||||
os<<greenColor<<boldChar;
|
||||
else if(master())
|
||||
os<<yellowColor;
|
||||
|
||||
|
||||
os<<name_;
|
||||
|
||||
if(timerActive())
|
||||
if(master())
|
||||
os<<" execution time (s): total ("<<
|
||||
totalTime()<<"), av. ("<<
|
||||
averageTime()<<").";
|
||||
else
|
||||
os<<" execution time (s): total ("<<
|
||||
cyanText(totalTime())<<"), av. ("<<
|
||||
cyanText(averageTime())<<").";
|
||||
auto tt = accTimersTotal();
|
||||
if(abs(tt)>smallValue)
|
||||
{
|
||||
os<<" execution time (s): total ("<<
|
||||
tt<<")";
|
||||
|
||||
if(!master())
|
||||
{
|
||||
os<<", av. ("<<
|
||||
averageTime()<<").";
|
||||
}
|
||||
}
|
||||
|
||||
os<<defaultColor;
|
||||
os<<'\n';
|
||||
|
|
|
@ -109,31 +109,40 @@ public:
|
|||
accTime_ += lastTime_;
|
||||
}
|
||||
|
||||
inline
|
||||
bool timerActive()const
|
||||
{
|
||||
return numIteration_!=0;
|
||||
}
|
||||
|
||||
inline
|
||||
real lastTime()const
|
||||
{
|
||||
return lastTime_;
|
||||
}
|
||||
|
||||
inline
|
||||
real totalTime()const
|
||||
{
|
||||
return accTime_;
|
||||
}
|
||||
|
||||
inline
|
||||
real averageTime()const
|
||||
{
|
||||
|
||||
return accTime_/max(numIteration_, 1);
|
||||
}
|
||||
|
||||
virtual
|
||||
real accTimersTotal()const
|
||||
{
|
||||
return totalTime();
|
||||
}
|
||||
|
||||
//// - IO operations
|
||||
|
||||
virtual bool write(iOstream& os, bool subTree)const;
|
||||
|
||||
|
||||
virtual bool read(iIstream& is)
|
||||
{
|
||||
|
|
|
@ -21,6 +21,27 @@ Licence:
|
|||
|
||||
#include "Timers.hpp"
|
||||
|
||||
pFlow::real pFlow::Timers::accTimersTotal()const
|
||||
{
|
||||
// first this timer
|
||||
real total = 0;
|
||||
if(this->timerActive()) total += this->totalTime();
|
||||
|
||||
for(const auto tmr:timers_)
|
||||
{
|
||||
if(tmr -> master())
|
||||
{
|
||||
total += dynamic_cast<const Timers*>(tmr)->accTimersTotal();
|
||||
}
|
||||
else if(tmr->timerActive())
|
||||
{
|
||||
total += tmr->totalTime();
|
||||
}
|
||||
}
|
||||
|
||||
return total;
|
||||
}
|
||||
|
||||
|
||||
bool pFlow::Timers::write(iOstream& os, bool subTree)const
|
||||
{
|
||||
|
|
|
@ -18,8 +18,8 @@ Licence:
|
|||
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __Timers_hpp__
|
||||
#define __Timers_hpp__
|
||||
#ifndef __Timerss_hpp__
|
||||
#define __Timerss_hpp__
|
||||
|
||||
|
||||
#include "Timer.hpp"
|
||||
|
@ -30,11 +30,11 @@ namespace pFlow
|
|||
|
||||
class Timers
|
||||
:
|
||||
public Timer
|
||||
public pFlow::Timer
|
||||
{
|
||||
protected:
|
||||
|
||||
List<Timer*> timers_;
|
||||
List<pFlow::Timer*> timers_;
|
||||
|
||||
int32 level_ = 0;
|
||||
|
||||
|
@ -93,6 +93,8 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
real accTimersTotal()const override;
|
||||
|
||||
virtual bool write(iOstream& os, bool subTree = true)const;
|
||||
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ Licence:
|
|||
#include "KokkosUtilities.hpp"
|
||||
#include "ViewAlgorithms.hpp"
|
||||
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
|
@ -79,8 +80,8 @@ public:
|
|||
size_(end-begin),
|
||||
views_("indexContainer", size_)
|
||||
{
|
||||
pFlow::fillSequence(views_.d_view, 0, size_, min_);
|
||||
copy(views_.h_view, views_.d_view);
|
||||
pFlow::fillSequence(views_.h_view, 0, size_, min_);
|
||||
copy(views_.d_view, views_.h_view);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -100,6 +100,19 @@ pFlow::timeControl::timeControl(
|
|||
checkForOutputToFile();
|
||||
}
|
||||
|
||||
bool pFlow::timeControl::finalTime()const
|
||||
{
|
||||
if( currentTime_ >= endTime_ ) return true;
|
||||
if( abs(currentTime_-endTime_) < 0.5*dt_ )return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool pFlow::timeControl::reachedStopAt()const
|
||||
{
|
||||
if( currentTime_ >= stopAt_ ) return true;
|
||||
if( abs(currentTime_-stopAt_) < 0.5*dt_ )return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void pFlow::timeControl::checkForOutputToFile()
|
||||
{
|
||||
|
@ -124,10 +137,13 @@ void pFlow::timeControl::checkForOutputToFile()
|
|||
{
|
||||
lastSaved_ = currentTime_;
|
||||
save = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
outputToFile_ = save;
|
||||
|
||||
|
||||
}
|
||||
|
||||
bool pFlow::timeControl::timersReportTime()const
|
||||
|
|
|
@ -152,18 +152,9 @@ public:
|
|||
return currentIter_;
|
||||
}
|
||||
|
||||
bool finalTime()const
|
||||
{
|
||||
if( currentTime_ >= endTime_ ) return true;
|
||||
if( abs(currentTime_-endTime_) < 0.5*dt_ )return true;
|
||||
return false;
|
||||
}
|
||||
bool reachedStopAt()const
|
||||
{
|
||||
if( currentTime_ >= stopAt_ ) return true;
|
||||
if( abs(currentTime_-stopAt_) < 0.5*dt_ )return true;
|
||||
return false;
|
||||
}
|
||||
bool finalTime()const;
|
||||
|
||||
bool reachedStopAt()const;
|
||||
|
||||
bool outputToFile()const
|
||||
{
|
||||
|
|
|
@ -235,39 +235,43 @@ pFlow::systemControl::systemControl(
|
|||
bool pFlow::systemControl::operator ++(int)
|
||||
{
|
||||
|
||||
// skip writing to file for the first iteration
|
||||
//output<< "time()++"<<endl;
|
||||
auto finished = time()++;
|
||||
|
||||
writeToFileTimer_.start();
|
||||
if(time().currentIter() != 0)
|
||||
{
|
||||
//- save the results to file
|
||||
if( !time().write() )
|
||||
{
|
||||
fatalErrorInFunction;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if( time().finalTime() )
|
||||
{
|
||||
if( !time().write() )
|
||||
{
|
||||
fatalErrorInFunction;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
writeToFileTimer_.end();
|
||||
auto toContinue = time()++;
|
||||
|
||||
//output<< "after finalTime()"<<endl;
|
||||
if(toContinue)
|
||||
{
|
||||
writeToFileTimer_.start();
|
||||
//if(time().currentIter() != 0 )
|
||||
{
|
||||
//- save the results to file
|
||||
if( !time().write() )
|
||||
{
|
||||
fatalErrorInFunction;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
writeToFileTimer_.end();
|
||||
|
||||
if( time().timersReportTime() &&
|
||||
if( time().timersReportTime() &&
|
||||
timersReport() )
|
||||
{
|
||||
timers_.write(output, true);
|
||||
}
|
||||
|
||||
}
|
||||
else if (time().finalTime())
|
||||
{
|
||||
writeToFileTimer_.start();
|
||||
if( !time().write() )
|
||||
{
|
||||
fatalErrorInFunction;
|
||||
return false;
|
||||
}
|
||||
writeToFileTimer_.end();
|
||||
|
||||
timers_.write(output, true);
|
||||
}
|
||||
|
||||
return finished;
|
||||
return toContinue;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue