From ef1e3c1e33c7601cee21d03e619dc2b0bd96564a Mon Sep 17 00:00:00 2001 From: Hamidreza Norouzi Date: Thu, 16 Mar 2023 06:49:33 -0700 Subject: [PATCH] timers modefied --- .../sphereDEMSystem/sphereDEMSystem.cpp | 5 -- solvers/sphereGranFlow/sphereGranFlow.cpp | 3 -- src/phasicFlow/Timer/Timer.cpp | 24 +++++---- src/phasicFlow/Timer/Timer.hpp | 11 +++- src/phasicFlow/Timer/Timers.cpp | 21 ++++++++ src/phasicFlow/Timer/Timers.hpp | 4 +- .../repository/Time/timeControl.cpp | 13 +++++ .../repository/Time/timeControl.hpp | 15 ++---- .../systemControl/systemControl.cpp | 52 +++++++++++-------- 9 files changed, 94 insertions(+), 54 deletions(-) diff --git a/DEMSystems/sphereDEMSystem/sphereDEMSystem.cpp b/DEMSystems/sphereDEMSystem/sphereDEMSystem.cpp index 8416e505..a4e17394 100644 --- a/DEMSystems/sphereDEMSystem/sphereDEMSystem.cpp +++ b/DEMSystems/sphereDEMSystem/sphereDEMSystem.cpp @@ -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()++); diff --git a/solvers/sphereGranFlow/sphereGranFlow.cpp b/solvers/sphereGranFlow/sphereGranFlow.cpp index a4920b86..7b9785cf 100755 --- a/solvers/sphereGranFlow/sphereGranFlow.cpp +++ b/solvers/sphereGranFlow/sphereGranFlow.cpp @@ -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"<smallValue) + { + os<<" execution time (s): total ("<< + tt<<")"; + + if(!master()) + { + os<<", av. ("<< + averageTime()<<")."; + } + } os<timerActive()) total += this->totalTime(); + + for(const auto tmr:timers_) + { + if(tmr -> master()) + { + total += dynamic_cast(tmr)->accTimersTotal(); + } + else if(tmr->timerActive()) + { + total += tmr->totalTime(); + } + } + + return total; +} + bool pFlow::Timers::write(iOstream& os, bool subTree)const { diff --git a/src/phasicFlow/Timer/Timers.hpp b/src/phasicFlow/Timer/Timers.hpp index 41aa5ab8..cd2630fb 100644 --- a/src/phasicFlow/Timer/Timers.hpp +++ b/src/phasicFlow/Timer/Timers.hpp @@ -30,7 +30,7 @@ namespace pFlow class Timers : - public Timer + public pFlow::Timer { protected: @@ -93,6 +93,8 @@ public: return true; } + real accTimersTotal()const override; + virtual bool write(iOstream& os, bool subTree = true)const; diff --git a/src/phasicFlow/repository/Time/timeControl.cpp b/src/phasicFlow/repository/Time/timeControl.cpp index 02e94359..31cc7451 100644 --- a/src/phasicFlow/repository/Time/timeControl.cpp +++ b/src/phasicFlow/repository/Time/timeControl.cpp @@ -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() { diff --git a/src/phasicFlow/repository/Time/timeControl.hpp b/src/phasicFlow/repository/Time/timeControl.hpp index 2051f1ac..59d9fc21 100644 --- a/src/phasicFlow/repository/Time/timeControl.hpp +++ b/src/phasicFlow/repository/Time/timeControl.hpp @@ -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 { diff --git a/src/phasicFlow/repository/systemControl/systemControl.cpp b/src/phasicFlow/repository/systemControl/systemControl.cpp index eabde21a..50715ea0 100644 --- a/src/phasicFlow/repository/systemControl/systemControl.cpp +++ b/src/phasicFlow/repository/systemControl/systemControl.cpp @@ -237,33 +237,39 @@ bool pFlow::systemControl::operator ++(int) // skip writing to file for the first iteration //output<< "time()++"<