From 347a4fee7a4ce7028f81481135803e38c7d0858d Mon Sep 17 00:00:00 2001 From: Hamidreza Norouzi Date: Tue, 14 Mar 2023 08:48:46 -0700 Subject: [PATCH 1/5] DEMSystem correction for fluid force --- .../sphereDEMSystem/sphereFluidParticles.cpp | 7 +++++++ .../sphereDEMSystem/sphereFluidParticles.hpp | 14 +++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/DEMSystems/sphereDEMSystem/sphereFluidParticles.cpp b/DEMSystems/sphereDEMSystem/sphereFluidParticles.cpp index 386ac859..9b3a44b0 100644 --- a/DEMSystems/sphereDEMSystem/sphereFluidParticles.cpp +++ b/DEMSystems/sphereDEMSystem/sphereFluidParticles.cpp @@ -54,6 +54,13 @@ pFlow::sphereFluidParticles::sphereFluidParticles( ) {} +bool pFlow::sphereFluidParticles::beforeIteration() +{ + sphereParticles::beforeIteration(); + zeroFluidForce_H(); + zeroFluidTorque_H(); + return true; +} bool pFlow::sphereFluidParticles::iterate() diff --git a/DEMSystems/sphereDEMSystem/sphereFluidParticles.hpp b/DEMSystems/sphereDEMSystem/sphereFluidParticles.hpp index 48b73f34..9890dac8 100644 --- a/DEMSystems/sphereDEMSystem/sphereFluidParticles.hpp +++ b/DEMSystems/sphereDEMSystem/sphereFluidParticles.hpp @@ -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; From c6ddf00d7b698e3c5c00b18ad34ff5689cc7578c Mon Sep 17 00:00:00 2001 From: hamidrezanorouzi Date: Wed, 15 Mar 2023 06:52:15 +0330 Subject: [PATCH 2/5] remove set to zero for fluid force --- DEMSystems/sphereDEMSystem/sphereFluidParticles.cpp | 5 ++--- src/phasicFlow/Timer/Timers.hpp | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/DEMSystems/sphereDEMSystem/sphereFluidParticles.cpp b/DEMSystems/sphereDEMSystem/sphereFluidParticles.cpp index 9b3a44b0..839bfdc3 100644 --- a/DEMSystems/sphereDEMSystem/sphereFluidParticles.cpp +++ b/DEMSystems/sphereDEMSystem/sphereFluidParticles.cpp @@ -56,9 +56,8 @@ pFlow::sphereFluidParticles::sphereFluidParticles( bool pFlow::sphereFluidParticles::beforeIteration() { - sphereParticles::beforeIteration(); - zeroFluidForce_H(); - zeroFluidTorque_H(); + return sphereParticles::beforeIteration(); + return true; } diff --git a/src/phasicFlow/Timer/Timers.hpp b/src/phasicFlow/Timer/Timers.hpp index 087b37ea..41aa5ab8 100644 --- a/src/phasicFlow/Timer/Timers.hpp +++ b/src/phasicFlow/Timer/Timers.hpp @@ -18,8 +18,8 @@ Licence: -----------------------------------------------------------------------------*/ -#ifndef __Timers_hpp__ -#define __Timers_hpp__ +#ifndef __Timerss_hpp__ +#define __Timerss_hpp__ #include "Timer.hpp" @@ -34,7 +34,7 @@ class Timers { protected: - List timers_; + List timers_; int32 level_ = 0; From ef1e3c1e33c7601cee21d03e619dc2b0bd96564a Mon Sep 17 00:00:00 2001 From: Hamidreza Norouzi Date: Thu, 16 Mar 2023 06:49:33 -0700 Subject: [PATCH 3/5] 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()++"< Date: Thu, 16 Mar 2023 21:22:24 +0330 Subject: [PATCH 4/5] bug fix for cudaRun in indexContainer --- DEMSystems/sphereDEMSystem/sphereDEMSystem.cpp | 2 ++ DEMSystems/sphereDEMSystem/sphereFluidParticles.cpp | 5 +++-- .../sphereParticles/sphereParticles.cpp | 12 ++++++++---- .../containers/indexContainer/indexContainer.hpp | 5 +++-- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/DEMSystems/sphereDEMSystem/sphereDEMSystem.cpp b/DEMSystems/sphereDEMSystem/sphereDEMSystem.cpp index a4e17394..37f7529f 100644 --- a/DEMSystems/sphereDEMSystem/sphereDEMSystem.cpp +++ b/DEMSystems/sphereDEMSystem/sphereDEMSystem.cpp @@ -75,9 +75,11 @@ pFlow::sphereDEMSystem::sphereDEMSystem( REPORT(0)<< "\nCreating surface geometry for sphereDEMSystem . . . "<(Control(), Property()); + insertion_ = makeUnique( Control().caseSetup().path()+insertionFile__, particles_(), diff --git a/DEMSystems/sphereDEMSystem/sphereFluidParticles.cpp b/DEMSystems/sphereDEMSystem/sphereFluidParticles.cpp index 839bfdc3..9b3a44b0 100644 --- a/DEMSystems/sphereDEMSystem/sphereFluidParticles.cpp +++ b/DEMSystems/sphereDEMSystem/sphereFluidParticles.cpp @@ -56,8 +56,9 @@ pFlow::sphereFluidParticles::sphereFluidParticles( bool pFlow::sphereFluidParticles::beforeIteration() { - return sphereParticles::beforeIteration(); - + sphereParticles::beforeIteration(); + zeroFluidForce_H(); + zeroFluidTorque_H(); return true; } diff --git a/src/Particles/SphereParticles/sphereParticles/sphereParticles.cpp b/src/Particles/SphereParticles/sphereParticles/sphereParticles.cpp index 6191a22e..f4908782 100644 --- a/src/Particles/SphereParticles/sphereParticles/sphereParticles.cpp +++ b/src/Particles/SphereParticles/sphereParticles/sphereParticles.cpp @@ -72,8 +72,11 @@ bool pFlow::sphereParticles::diameterMassInertiaPropId bool pFlow::sphereParticles::initializeParticles() { - - int32IndexContainer indices(0, shapeName_.size()); + + int32IndexContainer indices( + 0, + static_cast(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; diff --git a/src/phasicFlow/containers/indexContainer/indexContainer.hpp b/src/phasicFlow/containers/indexContainer/indexContainer.hpp index ddb3ccb8..14e88726 100644 --- a/src/phasicFlow/containers/indexContainer/indexContainer.hpp +++ b/src/phasicFlow/containers/indexContainer/indexContainer.hpp @@ -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); } From f1052acc390f3f9b7b7b10161aef5b8fc44f9d67 Mon Sep 17 00:00:00 2001 From: Hamidreza Norouzi Date: Thu, 16 Mar 2023 11:52:37 -0700 Subject: [PATCH 5/5] timeControl correct --- src/phasicFlow/repository/Time/timeControl.cpp | 5 ++++- src/phasicFlow/repository/systemControl/systemControl.cpp | 8 +++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/phasicFlow/repository/Time/timeControl.cpp b/src/phasicFlow/repository/Time/timeControl.cpp index 31cc7451..d27aac1a 100644 --- a/src/phasicFlow/repository/Time/timeControl.cpp +++ b/src/phasicFlow/repository/Time/timeControl.cpp @@ -137,10 +137,13 @@ void pFlow::timeControl::checkForOutputToFile() { lastSaved_ = currentTime_; save = true; - } + } + } outputToFile_ = save; + + } bool pFlow::timeControl::timersReportTime()const diff --git a/src/phasicFlow/repository/systemControl/systemControl.cpp b/src/phasicFlow/repository/systemControl/systemControl.cpp index 50715ea0..4cd60260 100644 --- a/src/phasicFlow/repository/systemControl/systemControl.cpp +++ b/src/phasicFlow/repository/systemControl/systemControl.cpp @@ -235,11 +235,9 @@ pFlow::systemControl::systemControl( bool pFlow::systemControl::operator ++(int) { - // skip writing to file for the first iteration - //output<< "time()++"<