diff --git a/src/Integration/boundaries/boundaryIntegration.hpp b/src/Integration/boundaries/boundaryIntegration.hpp index b3a20805..d50e6016 100644 --- a/src/Integration/boundaries/boundaryIntegration.hpp +++ b/src/Integration/boundaries/boundaryIntegration.hpp @@ -77,6 +77,11 @@ public: return true; } + bool isActive()const override + { + return false; + } + static uniquePtr create( const boundaryBase& boundary, diff --git a/src/Integration/boundaries/boundaryIntegrationList.cpp b/src/Integration/boundaries/boundaryIntegrationList.cpp index 9dfa1538..636b0783 100644 --- a/src/Integration/boundaries/boundaryIntegrationList.cpp +++ b/src/Integration/boundaries/boundaryIntegrationList.cpp @@ -7,11 +7,11 @@ pFlow::boundaryIntegrationList::boundaryIntegrationList( integration &intgrtn ) : - ListPtr(6), + boundaryListPtr(), boundaries_(pStruct.boundaries()) { - - for(uint32 i=0; i<6; i++) + + ForAllBoundariesPtr(i, this) { this->set( i, @@ -19,25 +19,23 @@ pFlow::boundaryIntegrationList::boundaryIntegrationList( boundaries_[i], pStruct, method, - intgrtn - ) - ); + intgrtn + ) + ); } - } bool pFlow::boundaryIntegrationList::correct(real dt, realx3PointField_D &y, realx3PointField_D &dy) { - for(auto& bndry:*this) + ForAllActiveBoundariesPtr(i,this) { - if(!bndry->correct(dt, y, dy)) + if(!boundaryPtr(i)->correct(dt, y, dy)) { fatalErrorInFunction<<"Error in correcting boundary "<< - bndry->boundaryName()<boundaryName()<correctPStruct(dt, vel)) + if(!boundaryPtr(i)->correctPStruct(dt, vel)) { fatalErrorInFunction<<"Error in correcting boundary "<< - bndry->boundaryName()<<" in pointStructure."<boundaryName()<<" in pointStructure."< + public boundaryListPtr { private: diff --git a/src/Interaction/contactSearch/boundaries/boundaryContactSearch/boundaryContactSearch.hpp b/src/Interaction/contactSearch/boundaries/boundaryContactSearch/boundaryContactSearch.hpp index 55ecb47e..04c07080 100644 --- a/src/Interaction/contactSearch/boundaries/boundaryContactSearch/boundaryContactSearch.hpp +++ b/src/Interaction/contactSearch/boundaries/boundaryContactSearch/boundaryContactSearch.hpp @@ -98,6 +98,11 @@ public: return true; } + bool isActive()const override + { + return false; + } + static uniquePtr create( const dictionary &dict, const boundaryBase &boundary, diff --git a/src/Interaction/contactSearch/boundaries/boundaryContactSearchList.cpp b/src/Interaction/contactSearch/boundaries/boundaryContactSearchList.cpp index ae86d7ab..b0d3a4da 100644 --- a/src/Interaction/contactSearch/boundaries/boundaryContactSearchList.cpp +++ b/src/Interaction/contactSearch/boundaries/boundaryContactSearchList.cpp @@ -1,3 +1,23 @@ +/*------------------------------- phasicFlow --------------------------------- + O C enter of + O O E ngineering and + O O M ultiscale modeling of + OOOOOOO F luid flow +------------------------------------------------------------------------------ + Copyright (C): www.cemf.ir + email: hamid.r.norouzi AT gmail.com +------------------------------------------------------------------------------ +Licence: + This file is part of phasicFlow code. It is a free software for simulating + granular and multiphase flows. You can redistribute it and/or modify it under + the terms of GNU General Public License v3 or any other later versions. + + phasicFlow is distributed to help others in their research in the field of + granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +-----------------------------------------------------------------------------*/ + #include "boundaryContactSearchList.hpp" #include "boundaryList.hpp" @@ -5,7 +25,7 @@ void pFlow::boundaryContactSearchList::setList( const dictionary &dict, const contactSearch &cSearch) { - for(auto i=0; iset ( @@ -20,7 +40,7 @@ pFlow::boundaryContactSearchList::boundaryContactSearchList( const boundaryList& bndrs, const contactSearch &cSearch) : - ListPtr(bndrs.size()), + boundaryListPtr(), boundaries_(bndrs) { setList(dict, cSearch); diff --git a/src/Interaction/contactSearch/boundaries/boundaryContactSearchList.hpp b/src/Interaction/contactSearch/boundaries/boundaryContactSearchList.hpp index 9f1951b8..f588395d 100644 --- a/src/Interaction/contactSearch/boundaries/boundaryContactSearchList.hpp +++ b/src/Interaction/contactSearch/boundaries/boundaryContactSearchList.hpp @@ -1,4 +1,24 @@ -#include "ListPtr.hpp" +/*------------------------------- phasicFlow --------------------------------- + O C enter of + O O E ngineering and + O O M ultiscale modeling of + OOOOOOO F luid flow +------------------------------------------------------------------------------ + Copyright (C): www.cemf.ir + email: hamid.r.norouzi AT gmail.com +------------------------------------------------------------------------------ +Licence: + This file is part of phasicFlow code. It is a free software for simulating + granular and multiphase flows. You can redistribute it and/or modify it under + the terms of GNU General Public License v3 or any other later versions. + + phasicFlow is distributed to help others in their research in the field of + granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +-----------------------------------------------------------------------------*/ + +#include "boundaryListPtr.hpp" #include "boundaryContactSearch.hpp" namespace pFlow @@ -9,7 +29,7 @@ class contactSearch; class boundaryContactSearchList : - public ListPtr + public boundaryListPtr { private: diff --git a/src/Interaction/contactSearch/boundaries/periodicBoundaryContactSearch/periodicBoundaryContactSearch.hpp b/src/Interaction/contactSearch/boundaries/periodicBoundaryContactSearch/periodicBoundaryContactSearch.hpp index 3cab83ef..00d30e5c 100644 --- a/src/Interaction/contactSearch/boundaries/periodicBoundaryContactSearch/periodicBoundaryContactSearch.hpp +++ b/src/Interaction/contactSearch/boundaries/periodicBoundaryContactSearch/periodicBoundaryContactSearch.hpp @@ -74,6 +74,11 @@ public: csPairContainerType &ppPairs, csPairContainerType &pwPairs, bool force = false) override; + + bool isActive()const override + { + return true; + } }; } diff --git a/src/Interaction/grainInteraction/boundaries/boundaryGrainInteraction/boundaryGrainInteraction.hpp b/src/Interaction/grainInteraction/boundaries/boundaryGrainInteraction/boundaryGrainInteraction.hpp index 4800194c..91b113f0 100644 --- a/src/Interaction/grainInteraction/boundaries/boundaryGrainInteraction/boundaryGrainInteraction.hpp +++ b/src/Interaction/grainInteraction/boundaries/boundaryGrainInteraction/boundaryGrainInteraction.hpp @@ -152,8 +152,6 @@ public: return false; } - - bool hearChanges ( real t, @@ -170,6 +168,11 @@ public: return true; } + bool isActive()const override + { + return false; + } + static uniquePtr create( const boundaryBase& boundary, diff --git a/src/Interaction/grainInteraction/boundaries/boundaryGrainInteractionList.cpp b/src/Interaction/grainInteraction/boundaries/boundaryGrainInteractionList.cpp index 7875210d..7f59e061 100644 --- a/src/Interaction/grainInteraction/boundaries/boundaryGrainInteractionList.cpp +++ b/src/Interaction/grainInteraction/boundaries/boundaryGrainInteractionList.cpp @@ -7,11 +7,11 @@ pFlow::boundaryGrainInteractionList::boundaryGrainInteractionL const gMModel &geomMotion ) : - ListPtr>(6), + boundaryListPtr>(), boundaries_(grnPrtcls.pStruct().boundaries()) { //gSettings::sleepMiliSeconds(1000*pFlowProcessors().localRank()); - for(uint32 i=0; i<6; i++) + ForAllBoundariesPtr(i, this) { this->set( i, diff --git a/src/Interaction/grainInteraction/boundaries/boundaryGrainInteractionList.hpp b/src/Interaction/grainInteraction/boundaries/boundaryGrainInteractionList.hpp index ed4cabc8..29e1f8e0 100644 --- a/src/Interaction/grainInteraction/boundaries/boundaryGrainInteractionList.hpp +++ b/src/Interaction/grainInteraction/boundaries/boundaryGrainInteractionList.hpp @@ -3,7 +3,7 @@ #include "boundaryList.hpp" -#include "ListPtr.hpp" +#include "boundaryListPtr.hpp" #include "boundaryGrainInteraction.hpp" @@ -14,7 +14,7 @@ namespace pFlow template class boundaryGrainInteractionList : - public ListPtr> + public boundaryListPtr> { private: diff --git a/src/Interaction/grainInteraction/boundaries/periodicBoundaryGrainInteraction/periodicBoundaryGrainInteraction.hpp b/src/Interaction/grainInteraction/boundaries/periodicBoundaryGrainInteraction/periodicBoundaryGrainInteraction.hpp index e9148c9d..36c97eaf 100644 --- a/src/Interaction/grainInteraction/boundaries/periodicBoundaryGrainInteraction/periodicBoundaryGrainInteraction.hpp +++ b/src/Interaction/grainInteraction/boundaries/periodicBoundaryGrainInteraction/periodicBoundaryGrainInteraction.hpp @@ -78,13 +78,15 @@ public: ~periodicBoundaryGrainInteraction()override = default; - - - bool grainGrainInteraction( real dt, const ContactForceModel& cfModel, uint32 step)override; + + bool isActive()const override + { + return true; + } }; diff --git a/src/Interaction/sphereInteraction/boundaries/boundarySphereInteraction/boundarySphereInteraction.hpp b/src/Interaction/sphereInteraction/boundaries/boundarySphereInteraction/boundarySphereInteraction.hpp index b36188c5..1a5984ee 100644 --- a/src/Interaction/sphereInteraction/boundaries/boundarySphereInteraction/boundarySphereInteraction.hpp +++ b/src/Interaction/sphereInteraction/boundaries/boundarySphereInteraction/boundarySphereInteraction.hpp @@ -110,7 +110,7 @@ public: return geometryMotion_; } - ContactListType& ppPairs() + ContactListType& ppPairs() { return ppPairs_(); } @@ -170,6 +170,11 @@ public: return true; } + bool isActive()const override + { + return false; + } + static uniquePtr create( const boundaryBase& boundary, diff --git a/src/Interaction/sphereInteraction/boundaries/boundarySphereInteractionList.cpp b/src/Interaction/sphereInteraction/boundaries/boundarySphereInteractionList.cpp index 00b86bc4..d0e3972b 100644 --- a/src/Interaction/sphereInteraction/boundaries/boundarySphereInteractionList.cpp +++ b/src/Interaction/sphereInteraction/boundaries/boundarySphereInteractionList.cpp @@ -7,11 +7,11 @@ pFlow::boundarySphereInteractionList::boundarySphereInteractio const gMModel &geomMotion ) : - ListPtr>(6), + boundaryListPtr>(), boundaries_(sphPrtcls.pStruct().boundaries()) { - //gSettings::sleepMiliSeconds(1000*pFlowProcessors().localRank()); - for(uint32 i=0; i<6; i++) + + ForAllActiveBoundariesPtr(i, this) { this->set( i, diff --git a/src/Interaction/sphereInteraction/boundaries/boundarySphereInteractionList.hpp b/src/Interaction/sphereInteraction/boundaries/boundarySphereInteractionList.hpp index 1a5086fa..1073c156 100644 --- a/src/Interaction/sphereInteraction/boundaries/boundarySphereInteractionList.hpp +++ b/src/Interaction/sphereInteraction/boundaries/boundarySphereInteractionList.hpp @@ -3,7 +3,7 @@ #include "boundaryList.hpp" -#include "ListPtr.hpp" +#include "boundaryListPtr.hpp" #include "boundarySphereInteraction.hpp" @@ -14,7 +14,7 @@ namespace pFlow template class boundarySphereInteractionList : - public ListPtr> + public boundaryListPtr> { private: diff --git a/src/Interaction/sphereInteraction/boundaries/periodicBoundarySphereInteraction/periodicBoundarySphereInteraction.hpp b/src/Interaction/sphereInteraction/boundaries/periodicBoundarySphereInteraction/periodicBoundarySphereInteraction.hpp index 5f1e7a45..e61447b3 100644 --- a/src/Interaction/sphereInteraction/boundaries/periodicBoundarySphereInteraction/periodicBoundarySphereInteraction.hpp +++ b/src/Interaction/sphereInteraction/boundaries/periodicBoundarySphereInteraction/periodicBoundarySphereInteraction.hpp @@ -76,15 +76,17 @@ public: boundaryBase ); - ~periodicBoundarySphereInteraction()override = default; - - - + ~periodicBoundarySphereInteraction()override = default; bool sphereSphereInteraction( real dt, const ContactForceModel& cfModel, uint32 step)override; + + bool isActive()const override + { + return true; + } }; diff --git a/src/Interaction/sphereInteraction/sphereInteraction/sphereInteraction.cpp b/src/Interaction/sphereInteraction/sphereInteraction/sphereInteraction.cpp index 9001a5b8..df381c9e 100644 --- a/src/Interaction/sphereInteraction/sphereInteraction/sphereInteraction.cpp +++ b/src/Interaction/sphereInteraction/sphereInteraction/sphereInteraction.cpp @@ -145,11 +145,6 @@ pFlow::sphereInteraction::sphereInteraction { fatalExit; } - - for(uint32 i=0; i<6; i++) - { - activeBoundaries_[i] = boundaryInteraction_[i].ppPairsAllocated(); - } } template class cLT> @@ -193,15 +188,14 @@ bool pFlow::sphereInteraction::iterate() { contactListMangementBoundaryTimer_.start(); ComputationTimer().start(); - for(uint32 i=0; i<6u; i++) + + ForAllActiveBoundaries(i, boundaryInteraction_) { - if(activeBoundaries_[i]) - { - auto& BI = boundaryInteraction_[i]; - BI.ppPairs().beforeBroadSearch(); - BI.pwPairs().beforeBroadSearch(); - } + auto& BI = boundaryInteraction_[i]; + BI.ppPairs().beforeBroadSearch(); + BI.pwPairs().beforeBroadSearch(); } + ComputationTimer().end(); contactListMangementBoundaryTimer_.pause(); } @@ -219,22 +213,19 @@ bool pFlow::sphereInteraction::iterate() fatalExit; } - for(uint32 i=0; i<6u; i++) + ForAllActiveBoundaries(i, boundaryInteraction_) { - if(activeBoundaries_[i]) + auto& BI = boundaryInteraction_[i]; + if(!contactSearchRef.boundaryBroadSearch( + i, + ti, + BI.ppPairs(), + BI.pwPairs()) + ) { - auto& BI = boundaryInteraction_[i]; - if(!contactSearchRef.boundaryBroadSearch( - i, - ti, - BI.ppPairs(), - BI.pwPairs()) - ) - { - fatalErrorInFunction<< - "failed to perform broadSearch for boundary index "<::iterate() { contactListMangementBoundaryTimer_.resume(); ComputationTimer().start(); - for(uint32 i=0; i<6u; i++) + + ForAllActiveBoundaries(i, boundaryInteraction_ ) { - if(activeBoundaries_[i]) - { - auto& BI = boundaryInteraction_[i]; - BI.ppPairs().afterBroadSearch(); - BI.pwPairs().afterBroadSearch(); - } + auto& BI = boundaryInteraction_[i]; + BI.ppPairs().afterBroadSearch(); + BI.pwPairs().afterBroadSearch(); } + ComputationTimer().end(); contactListMangementBoundaryTimer_.end(); } @@ -274,7 +264,7 @@ bool pFlow::sphereInteraction::iterate() ComputationTimer().start(); while(requireStep.anyElement(true) && step <= 10) { - for(uint32 i=0; i<6u; i++) + ForAllBoundaries(i, boundaryInteraction_) { if(requireStep[i] ) { @@ -313,7 +303,7 @@ bool pFlow::sphereInteraction::iterate() const auto& cfModel = this->forceModel_(); while( requireStep.anyElement(true) && step < 20 ) { - for(uint32 i=0; i<6u; i++) + ForAllBoundaries(i, boundaryInteraction_) { if(requireStep[i]) { diff --git a/src/Particles/GrainParticles/boundaryGrainParticles.hpp b/src/Particles/GrainParticles/boundaryGrainParticles.hpp index 5557931e..47b75590 100644 --- a/src/Particles/GrainParticles/boundaryGrainParticles.hpp +++ b/src/Particles/GrainParticles/boundaryGrainParticles.hpp @@ -65,6 +65,11 @@ public: return true; } + bool isActive()const override + { + return false; + } + static uniquePtr create( const boundaryBase &boundary, diff --git a/src/Particles/GrainParticles/boundaryGrainParticlesList.cpp b/src/Particles/GrainParticles/boundaryGrainParticlesList.cpp index 4cd941bd..f41b96c8 100644 --- a/src/Particles/GrainParticles/boundaryGrainParticlesList.cpp +++ b/src/Particles/GrainParticles/boundaryGrainParticlesList.cpp @@ -5,10 +5,10 @@ pFlow::boundaryGrainParticlesList::boundaryGrainParticlesList( grainParticles &prtcls ) : - ListPtr(bndrs.size()), + boundaryListPtr(), boundaries_(bndrs) { - for(auto i=0; iset ( @@ -16,4 +16,5 @@ pFlow::boundaryGrainParticlesList::boundaryGrainParticlesList( boundaryGrainParticles::create(boundaries_[i], prtcls) ); } + } \ No newline at end of file diff --git a/src/Particles/GrainParticles/boundaryGrainParticlesList.hpp b/src/Particles/GrainParticles/boundaryGrainParticlesList.hpp index 4fe22ad8..c1b8baf0 100644 --- a/src/Particles/GrainParticles/boundaryGrainParticlesList.hpp +++ b/src/Particles/GrainParticles/boundaryGrainParticlesList.hpp @@ -3,7 +3,7 @@ #ifndef __boundaryGrainParticlesList_hpp__ #define __boundaryGrainParticlesList_hpp__ -#include "ListPtr.hpp" +#include "boundaryListPtr.hpp" #include "boundaryList.hpp" #include "boundaryGrainParticles.hpp" @@ -12,7 +12,7 @@ namespace pFlow class boundaryGrainParticlesList : - public ListPtr + public boundaryListPtr { private: diff --git a/src/Particles/GrainParticles/grainParticles/grainParticles.cpp b/src/Particles/GrainParticles/grainParticles/grainParticles.cpp index 8293a510..bc7b9def 100644 --- a/src/Particles/GrainParticles/grainParticles/grainParticles.cpp +++ b/src/Particles/GrainParticles/grainParticles/grainParticles.cpp @@ -316,9 +316,10 @@ bool pFlow::grainParticles::iterate() accelertion().deviceViewAll(), rAcceleration().deviceViewAll() ); - for(auto& bndry:boundaryGrainParticles_) + + ForAllActiveBoundaries(i,boundaryGrainParticles_) { - bndry->acceleration(ti, g); + boundaryGrainParticles_[i].acceleration(ti, g); } accelerationTimer_.end(); diff --git a/src/Particles/SphereParticles/boundarySphereParticles.hpp b/src/Particles/SphereParticles/boundarySphereParticles.hpp index f4662307..7e379e94 100644 --- a/src/Particles/SphereParticles/boundarySphereParticles.hpp +++ b/src/Particles/SphereParticles/boundarySphereParticles.hpp @@ -65,6 +65,11 @@ public: return true; } + bool isActive()const override + { + return false; + } + static uniquePtr create( const boundaryBase &boundary, diff --git a/src/Particles/SphereParticles/boundarySphereParticlesList.cpp b/src/Particles/SphereParticles/boundarySphereParticlesList.cpp index 5cbebc32..cd6618b3 100644 --- a/src/Particles/SphereParticles/boundarySphereParticlesList.cpp +++ b/src/Particles/SphereParticles/boundarySphereParticlesList.cpp @@ -5,10 +5,10 @@ pFlow::boundarySphereParticlesList::boundarySphereParticlesList( sphereParticles &prtcls ) : - ListPtr(bndrs.size()), + boundaryListPtr(), boundaries_(bndrs) { - for(auto i=0; iset ( diff --git a/src/Particles/SphereParticles/boundarySphereParticlesList.hpp b/src/Particles/SphereParticles/boundarySphereParticlesList.hpp index cd6770df..ddba226f 100644 --- a/src/Particles/SphereParticles/boundarySphereParticlesList.hpp +++ b/src/Particles/SphereParticles/boundarySphereParticlesList.hpp @@ -3,7 +3,7 @@ #ifndef __boundarySphereParticlesList_hpp__ #define __boundarySphereParticlesList_hpp__ -#include "ListPtr.hpp" +#include "boundaryListPtr.hpp" #include "boundaryList.hpp" #include "boundarySphereParticles.hpp" @@ -12,7 +12,7 @@ namespace pFlow class boundarySphereParticlesList : - public ListPtr + public boundaryListPtr { private: diff --git a/src/Particles/SphereParticles/sphereParticles/sphereParticles.cpp b/src/Particles/SphereParticles/sphereParticles/sphereParticles.cpp index 9274f48c..38618a79 100644 --- a/src/Particles/SphereParticles/sphereParticles/sphereParticles.cpp +++ b/src/Particles/SphereParticles/sphereParticles/sphereParticles.cpp @@ -552,10 +552,11 @@ bool pFlow::sphereParticles::iterate() accelertion().deviceViewAll(), rAcceleration().deviceViewAll() ); - for(auto& bndry:boundarySphereParticles_) + ForAllActiveBoundaries(i,boundarySphereParticles_) { - bndry->acceleration(ti, g); + boundarySphereParticles_[i].acceleration(ti, g); } + accelerationTimer_.end(); intCorrectTimer_.start(); diff --git a/src/phasicFlow/containers/pointField/boundaryField/boundaryField/boundaryField.hpp b/src/phasicFlow/containers/pointField/boundaryField/boundaryField/boundaryField.hpp index 4f7526be..81809cbd 100644 --- a/src/phasicFlow/containers/pointField/boundaryField/boundaryField/boundaryField.hpp +++ b/src/phasicFlow/containers/pointField/boundaryField/boundaryField/boundaryField.hpp @@ -184,6 +184,12 @@ public: return; } + + bool isActive()const override + { + return false; + } + static uniquePtr create( const boundaryBase& boundary, diff --git a/src/phasicFlow/containers/pointField/boundaryField/boundaryFieldList.hpp b/src/phasicFlow/containers/pointField/boundaryField/boundaryFieldList.hpp index 9d929490..92e862c2 100644 --- a/src/phasicFlow/containers/pointField/boundaryField/boundaryFieldList.hpp +++ b/src/phasicFlow/containers/pointField/boundaryField/boundaryFieldList.hpp @@ -22,7 +22,7 @@ Licence: #include "boundaryField.hpp" #include "boundaryList.hpp" -#include "ListPtr.hpp" +#include "boundaryListPtr.hpp" namespace pFlow @@ -31,7 +31,7 @@ namespace pFlow template< class T, class MemorySpace = void > class boundaryFieldList : - public ListPtr< boundaryField > + public boundaryListPtr< boundaryField > { public: @@ -50,10 +50,10 @@ public: boundaryFieldList(const boundaryList& boundaries, InternalFieldType& internal) : - ListPtr(boundaries.size()), + boundaryListPtr(), boundaries_(boundaries) { - for(auto i=0; iset ( @@ -68,26 +68,18 @@ public: if( direction == DataDirection::SlaveToMaster && slaveToMasterUpdateIter_ == iter) return; - - // first step - uint32 i=0; - for(auto b:*this) + ForAllBoundaries(i,*this) { - if(i==0 ) - { - //pOutput<<"request for update boundaries for field "<< b->name()<updateBoundary(1, direction); + this->boundaryPtr(i)->updateBoundary(1, direction); } // second step - for(auto b:*this) + ForAllBoundaries(i,*this) { - b->updateBoundary(2, direction); + this->boundaryPtr(i)->updateBoundary(1, direction); } - + if(direction == DataDirection::SlaveToMaster) { slaveToMasterUpdateIter_ = iter; @@ -96,9 +88,9 @@ public: void fill(const T& val) { - for(auto& bf: *this) + ForAllBoundaries(i, *this) { - bf->fill(val); + this->boundaryPtr(i)->fill(val); } } diff --git a/src/phasicFlow/containers/pointField/boundaryField/exitBoundaryField/exitBoundaryField.hpp b/src/phasicFlow/containers/pointField/boundaryField/exitBoundaryField/exitBoundaryField.hpp index 32ee2546..eef6c266 100644 --- a/src/phasicFlow/containers/pointField/boundaryField/exitBoundaryField/exitBoundaryField.hpp +++ b/src/phasicFlow/containers/pointField/boundaryField/exitBoundaryField/exitBoundaryField.hpp @@ -81,6 +81,11 @@ public: return true; } + bool isActive()const override + { + return false; + } + }; } diff --git a/src/phasicFlow/containers/pointField/boundaryField/generalBoundary/generalBoundary.hpp b/src/phasicFlow/containers/pointField/boundaryField/generalBoundary/generalBoundary.hpp index 8fef9628..932d2af0 100644 --- a/src/phasicFlow/containers/pointField/boundaryField/generalBoundary/generalBoundary.hpp +++ b/src/phasicFlow/containers/pointField/boundaryField/generalBoundary/generalBoundary.hpp @@ -147,6 +147,9 @@ public: } const Time& time()const; + + virtual + bool isActive()const = 0; }; diff --git a/src/phasicFlow/containers/pointField/boundaryField/reflectiveBoundaryField/reflectiveBoundaryField.hpp b/src/phasicFlow/containers/pointField/boundaryField/reflectiveBoundaryField/reflectiveBoundaryField.hpp index e79f4fe6..5f6b799e 100644 --- a/src/phasicFlow/containers/pointField/boundaryField/reflectiveBoundaryField/reflectiveBoundaryField.hpp +++ b/src/phasicFlow/containers/pointField/boundaryField/reflectiveBoundaryField/reflectiveBoundaryField.hpp @@ -81,6 +81,10 @@ public: return true; } + bool isActive()const override + { + return false; + } }; } diff --git a/src/phasicFlow/eventManagement/subscriber.cpp b/src/phasicFlow/eventManagement/subscriber.cpp index 75ec485c..29d2ac11 100644 --- a/src/phasicFlow/eventManagement/subscriber.cpp +++ b/src/phasicFlow/eventManagement/subscriber.cpp @@ -25,15 +25,12 @@ Licence: #include "message.hpp" pFlow::subscriber::subscriber(const subscriber & src) -: - subName_(src.subName_) { } pFlow::subscriber::subscriber(subscriber && src) : - observerList_(std::move(src.observerList_)), - subName_(std::move(src.subName_)) + observerList_(std::move(src.observerList_)) { for(size_t i=0; isubName_ = rhs.subName_; + //this->subName_ = rhs.subName_; return *this; } pFlow::subscriber &pFlow::subscriber::operator=(subscriber && rhs) { - this->subName_ = std::move(rhs.subName_); + //this->subName_ = std::move(rhs.subName_); this->observerList_ = std::move(rhs.observerList_); for(size_t i=0; i,message::numEvents()> observerList_; + mutable std::vector> observerList_{message::numEvents()}; - word subName_; + //word subName_; public: subscriber(const word& name) - : - subName_(name) {} /// Copy constructor, only copies the name, not the list @@ -82,9 +80,9 @@ public: const message msg, const anyList& varList); - const word& subscriberName()const + word subscriberName()const { - return subName_; + return "subscriber"; //subName_; } }; diff --git a/src/phasicFlow/structuredData/boundaries/boundariesMask.hpp b/src/phasicFlow/structuredData/boundaries/boundariesMask.hpp index 13875f2b..9a9625ab 100644 --- a/src/phasicFlow/structuredData/boundaries/boundariesMask.hpp +++ b/src/phasicFlow/structuredData/boundaries/boundariesMask.hpp @@ -1,4 +1,3 @@ - #ifndef __boundariesMask_hpp__ #define __boundariesMask_hpp__ diff --git a/src/phasicFlow/structuredData/boundaries/boundaryBase/boundaryBase.cpp b/src/phasicFlow/structuredData/boundaries/boundaryBase/boundaryBase.cpp index d375635b..6192eeb5 100644 --- a/src/phasicFlow/structuredData/boundaries/boundaryBase/boundaryBase.cpp +++ b/src/phasicFlow/structuredData/boundaries/boundaryBase/boundaryBase.cpp @@ -119,7 +119,7 @@ bool pFlow::boundaryBase::removeIndices if( !this->notify(iter, t, dt, msgBndry, aList) ) { fatalErrorInFunction<<"Error in notify operation in boundary "<< - name_ <("neighborLength")), - // updateInetrval_(dict.getVal("updateInterval")), boundaryExtntionLengthRatio_(dict.getVal("boundaryExtntionLengthRatio")), internal_(internal), boundaries_(bndrs), thisBoundaryIndex_(thisIndex), neighborProcessorNo_(dict.getVal("neighborProcessorNo")), - isBoundaryMaster_(thisProcessorNo() >= neighborProcessorNo()), - name_(dict.name()), - type_(dict.getVal("type")) + type_(makeUnique(dict.getVal("type"))) { + + isBoundaryMaster_ = thisProcessorNo() >= neighborProcessorNo(); + unSyncLists(); } diff --git a/src/phasicFlow/structuredData/boundaries/boundaryBase/boundaryBase.hpp b/src/phasicFlow/structuredData/boundaries/boundaryBase/boundaryBase.hpp index 86e71b89..2f363d10 100644 --- a/src/phasicFlow/structuredData/boundaries/boundaryBase/boundaryBase.hpp +++ b/src/phasicFlow/structuredData/boundaries/boundaryBase/boundaryBase.hpp @@ -31,6 +31,14 @@ Licence: namespace pFlow { +static +inline const std::array boundaryNames_ = +{ + "left", "right", + "bottom", "top", + "rear", "front" +}; + // forward class internalPoints; @@ -61,16 +69,18 @@ private: /// list of particles indieces on host mutable uint32Vector_H indexListHost_; - /// device and host list are sync - mutable bool listsSync_ = false; - /// The length defined for creating neighbor list real neighborLength_; + /// device and host list are sync + mutable bool listsSync_ = false; + bool updateTime_ = false; bool iterBeforeUpdate_ = false; + bool isBoundaryMaster_; + /// the extra boundary extension beyound actual limits of boundary real boundaryExtntionLengthRatio_; @@ -85,11 +95,7 @@ private: int neighborProcessorNo_; - bool isBoundaryMaster_; - - word name_; - - word type_; + uniquePtr type_; protected: @@ -251,13 +257,13 @@ public: inline const word& type()const { - return type_; + return type_(); } inline const word& name()const { - return name_; + return boundaryNames_[thisBoundaryIndex_]; } inline @@ -406,6 +412,12 @@ public: return 0u; } + inline + bool isActive()const + { + return true; + } + /// - static create static uniquePtr create diff --git a/src/phasicFlow/structuredData/boundaries/boundaryList.cpp b/src/phasicFlow/structuredData/boundaries/boundaryList.cpp index 444119e1..0eb5e41f 100644 --- a/src/phasicFlow/structuredData/boundaries/boundaryList.cpp +++ b/src/phasicFlow/structuredData/boundaries/boundaryList.cpp @@ -39,7 +39,8 @@ pFlow::boundaryList::setExtendedDomain() boundary(3).boundaryExtensionLength() + boundary(5).boundaryExtensionLength(); - extendedDomain_ = pStruct_.simDomain().extendThisDomain(lowerExt, upperExt); + extendedDomain_ = makeUnique( + pStruct_.simDomain().extendThisDomain(lowerExt, upperExt)); } bool @@ -66,7 +67,7 @@ pFlow::boundaryList::updateNeighborLists() dist[4] = boundary(4).neighborLength(); dist[5] = boundary(5).neighborLength(); - pStruct_.updateFlag(extendedDomain_, dist); + pStruct_.updateFlag(extendedDomain_(), dist); const auto& maskD = pStruct_.activePointsMaskDevice(); boundary(0).setSize(maskD.leftSize()); @@ -88,8 +89,8 @@ pFlow::boundaryList::updateNeighborLists() return true; } -pFlow::boundaryList::boundaryList(pointStructure& pStruct) - : ListPtr(pStruct.simDomain().sizeOfBoundaries()), +pFlow::boundaryList::boundaryList(pointStructure& pStruct): + boundaryListPtr(), pStruct_(pStruct) { const dictionary& dict= pStruct_.simDomain().thisBoundariesDict(); @@ -143,7 +144,7 @@ pFlow::boundaryList::createBoundaries() if (listSet_) return true; - for (auto i = 0; i < pStruct_.simDomain().sizeOfBoundaries(); i++) + ForAllBoundaries(i, *this) { this->set( i, @@ -155,7 +156,9 @@ pFlow::boundaryList::createBoundaries() i ) ); + } + listSet_ = true; setExtendedDomain(); return true; @@ -197,7 +200,24 @@ pFlow::boundaryList::beforeIteration(const timeInfo& ti, bool force) while(callAgain.anyElement(true) && step <= 10u) { - for(size_t i=0; i<6ul; i++) + ForAllBoundaries(i,*this) + { + if(callAgain[i]) + { + if(! boundary(i).beforeIteration( + step, + ti, + boundaryUpdate_, + iterBeforeBoundaryUpdate_, + callAgain[i])) + { + fatalErrorInFunction<<"error in performing beforeIteration for boundary"<< + boundary(i).name()<<" at step "<< step<updataBoundaryData(1); - } + }*/ - for (auto bdry : *this) + ForAllBoundaries(i,*this) + { + boundary(i).updataBoundaryData(2); + } + /*for (auto bdry : *this) { bdry->updataBoundaryData(2); - } + }*/ return true; } @@ -236,7 +263,16 @@ pFlow::boundaryList::beforeIteration(const timeInfo& ti, bool force) bool pFlow::boundaryList::iterate(const timeInfo& ti, bool force) { - for (auto& bdry : *this) + ForAllBoundaries(i, *this) + { + if (!boundary(i).iterate(ti)) + { + fatalErrorInFunction << "Error in iterate in boundary " + << boundary(i).name() << endl; + return false; + } + } + /*for (auto& bdry : *this) { if (!bdry->iterate(ti)) { @@ -244,7 +280,7 @@ pFlow::boundaryList::iterate(const timeInfo& ti, bool force) << bdry->name() << endl; return false; } - } + }*/ return true; } @@ -257,7 +293,7 @@ pFlow::boundaryList::afterIteration(const timeInfo& ti, bool force) int step = 1; while(callAgain.anyElement(true)&& step <=10) { - for(size_t i=0; i<6; i++) + ForAllBoundaries(i,*this) { if(callAgain[i]) { diff --git a/src/phasicFlow/structuredData/boundaries/boundaryList.hpp b/src/phasicFlow/structuredData/boundaries/boundaryList.hpp index ddcb708c..c11a63a9 100644 --- a/src/phasicFlow/structuredData/boundaries/boundaryList.hpp +++ b/src/phasicFlow/structuredData/boundaries/boundaryList.hpp @@ -22,7 +22,7 @@ Licence: #include "domain.hpp" #include "boundaryBase.hpp" -#include "ListPtr.hpp" +#include "boundaryListPtr.hpp" #include "timeInfo.hpp" #include "boundariesMask.hpp" @@ -34,13 +34,11 @@ class pointStructure; class boundaryList : - public ListPtr + public boundaryListPtr { private: //// - data members - pointStructure& pStruct_; - uint32 neighborListUpdateInterval_; uint32 updateInterval_; @@ -53,12 +51,14 @@ private: bool iterBeforeBoundaryUpdate_; - domain extendedDomain_; - - box internalDomainBox_; - bool listSet_ = false; + pointStructure& pStruct_; + + uniquePtr extendedDomain_; + + box internalDomainBox_; + void setExtendedDomain(); bool resetLists(); @@ -94,13 +94,13 @@ public: inline auto& boundary(size_t i) { - return ListPtr::operator[](i); + return boundaryListPtr::operator[](i); } inline const auto& boundary(size_t i)const { - return ListPtr::operator[](i); + return boundaryListPtr::operator[](i); } inline @@ -112,13 +112,13 @@ public: inline const auto& extendedDomain()const { - return extendedDomain_; + return extendedDomain_(); } inline const auto& extendedDomainBox()const { - return extendedDomain_.domainBox(); + return extendedDomain_->domainBox(); } box internalDomainBox()const; diff --git a/src/phasicFlow/structuredData/boundaries/boundaryListPtr.hpp b/src/phasicFlow/structuredData/boundaries/boundaryListPtr.hpp new file mode 100644 index 00000000..8d528ff7 --- /dev/null +++ b/src/phasicFlow/structuredData/boundaries/boundaryListPtr.hpp @@ -0,0 +1,186 @@ +/*------------------------------- phasicFlow --------------------------------- + O C enter of + O O E ngineering and + O O M ultiscale modeling of + OOOOOOO F luid flow +------------------------------------------------------------------------------ + Copyright (C): www.cemf.ir + email: hamid.r.norouzi AT gmail.com +------------------------------------------------------------------------------ +Licence: + This file is part of phasicFlow code. It is a free software for simulating + granular and multiphase flows. You can redistribute it and/or modify it under + the terms of GNU General Public License v3 or any other later versions. + + phasicFlow is distributed to help others in their research in the field of + granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +-----------------------------------------------------------------------------*/ +#ifndef __boundaryListPtr_hpp__ +#define __boundaryListPtr_hpp__ + +#include +#include + +#include "uniquePtr.hpp" +#include "error.h" +#include "iOstream.hpp" + +namespace pFlow +{ + +template +class boundaryListPtr +{ +private: + std::array boundaries_; + + std::bitset<6> activeBoundaries_=0B000000; + +public: + + boundaryListPtr(): + boundaries_({nullptr, nullptr, nullptr, nullptr, nullptr, nullptr}) + {} + + void set(size_t i, uniquePtr&& ptr ) + { + if( i > boundaries_.size() ) + { + fatalErrorInFunction<< + "Out of range access of boundaryListPtr members. List size is "<< + size() << "and you are accessing "<< i << "\n"; + fatalExit; + } + + if(boundaries_[i]) delete boundaries_[i]; + boundaries_[i] = ptr.release(); + + if(boundaries_[i]) + { + // query if this boundary active or not + activeBoundaries_.set(i,boundaries_[i]->isActive()); + } + } + + ~boundaryListPtr() + { + clear(); + } + + void clear() + { + for(auto& bndry:boundaries_) + { + if(bndry != nullptr) + { + delete bndry; + bndry = nullptr; + } + } + activeBoundaries_.reset(); + } + + // - access to ith element + inline + BoundaryType& operator[](size_t i) + { + if(boundaries_[i]== nullptr) + { + fatalErrorInFunction<<"Accessing nullptr element"<=5ul) return 6ul; + if(activeBoundaries_[i+1]) + return i+1; + else + return nextActive(i+1); + } + + inline + bool allActive()const + { + return activeBoundaries_.all(); + } + + inline + bool anyActive()const + { + return activeBoundaries_.any(); + } + + inline + bool noneActive()const + { + return activeBoundaries_.none(); + } +}; + +} + +#define ForAllBoundaries(i,bndryList) for(size_t i = 0ul; i<(bndryList).size(); i++) +#define ForAllBoundariesPtr(i,bndryList) for(size_t i = 0ul; isize(); i++) +#define ForAllActiveBoundaries(i,bndryList) for(size_t i = bndryList.firstActive(); ifirstActive(); isize(); i=bndryList->nextActive(i)) + +#endif //__boundaryListPtr_hpp__ \ No newline at end of file