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/CMakeLists-old.txt b/src/phasicFlow/CMakeLists-old.txt deleted file mode 100644 index b6b68815..00000000 --- a/src/phasicFlow/CMakeLists-old.txt +++ /dev/null @@ -1,87 +0,0 @@ - -list(APPEND SourceFiles -types/basicTypes/bTypesFunctions.cpp -types/basicTypes/Logical.cpp -types/types.cpp - -globals/error.cpp - -streams/token/tokenIO.cpp -streams/token/token.cpp -streams/iStream/IOstream.cpp -streams/iStream/iIstream.cpp -streams/iStream/iOstream.cpp -streams/Stream/Istream.cpp -streams/Stream/Ostream.cpp -streams/Fstream/iFstream.cpp -streams/Fstream/oFstream.cpp -streams/Fstream/fileStream.cpp -streams/TStream/iTstream.cpp -streams/TStream/oTstream.cpp -streams/streams.cpp - -dictionary/dictionary.cpp -dictionary/entry/iEntry.cpp -dictionary/entry/dataEntry.cpp -dictionary/twoPartEntry/twoPartEntry.cpp - -fileSystem/fileSystem.cpp - -commandLine/commandLine.cpp - -random/randomReal/randomReal.cpp -random/randomReal/randomReals.cpp - -Timer/Timer.cpp -Timer/Timers.cpp - -repository/Time/Time.cpp -repository/Time/timeControl.cpp -repository/systemControl/systemControl.cpp -repository/systemControl/dynamicLinkLibs.cpp -repository/repository/repository.cpp -repository/IOobject/objectFile.cpp -repository/IOobject/IOobject.cpp -repository/IOobject/IOfileHeader.cpp - -structuredData/box/box.cpp -structuredData/cells/cells.cpp -structuredData/cylinder/cylinder.cpp -structuredData/sphere/sphere.cpp -structuredData/iBox/iBoxs.cpp -structuredData/line/line.cpp -structuredData/zAxis/zAxis.cpp -structuredData/pointStructure/pointStructure.cpp -structuredData/pointStructure/mortonIndexing.cpp -structuredData/pointStructure/selectors/pStructSelector/pStructSelector.cpp -structuredData/pointStructure/selectors/selectBox/selectBox.cpp -structuredData/pointStructure/selectors/selectRange/selectRange.cpp -structuredData/pointStructure/selectors/selectRandom/selectRandom.cpp -structuredData/trisurfaceStructure/triSurface.cpp -structuredData/trisurfaceStructure/multiTriSurface.cpp -structuredData/trisurfaceStructure/stlFile.cpp -structuredData/peakableRegion/sphereRegion/sphereRegion.cpp -structuredData/peakableRegion/cylinderRegion/cylinderRegion.cpp -structuredData/peakableRegion/boxRegion/boxRegion.cpp -structuredData/peakableRegion/peakableRegion/peakableRegion.cpp -structuredData/peakableRegion/peakableRegions.cpp - -containers/Vector/Vectors.cpp -containers/Field/Fields.cpp -containers/symArrayHD/symArrays.cpp -containers/triSurfaceField/triSurfaceFields.cpp -containers/bitsetHD/bitsetHDs.cpp -containers/indexContainer/indexContainer.cpp - -setFieldList/setFieldList.cpp -setFieldList/setFieldEntry.cpp - -eventSubscriber/eventSubscriber.cpp -eventSubscriber/eventObserver.cpp) - -set(link_libs Kokkos::kokkos tbb) - -pFlow_add_library_install(phasicFlow SourceFiles link_libs) - -target_include_directories(phasicFlow PUBLIC ./Kokkos ./algorithms ./globals) - 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/containers/span/span.hpp b/src/phasicFlow/containers/span/span.hpp index 91deb71f..879bcb84 100644 --- a/src/phasicFlow/containers/span/span.hpp +++ b/src/phasicFlow/containers/span/span.hpp @@ -26,60 +26,65 @@ Licence: namespace pFlow { - +/// +/// @class span +/// @brief Represents a view into a contiguous sequence of elements. +/// +/// `span` provides a lightweight way to work with arrays and other contiguous +/// sequences without the overhead of copying. This will word on both GPU and CPU template class span { - public: - - using iterator = T*; + + using iterator = T*; - using constIterator = const T*; - - using reference = T&; - - using constReference = const T&; + using constIterator = const T*; + + using reference = T&; + + using constReference = const T&; - using valueType = T; - - using pointer = T*; - - using constPointer = const T*; + using valueType = T; + + using pointer = T*; + + using constPointer = const T*; -protected: +private: - T* data_ = nullptr; - - uint32 size_ = 0; + mutable T* data_ = nullptr; + + index size_ = 0; public: TypeInfoTemplateNV11("span", T); - /// Constructor + /// Constructor with no arguments INLINE_FUNCTION_HD span() = default; + /// Constructor that takes a pointer to the beginning of the data and the size of the span INLINE_FUNCTION_HD span(T* data, uint32 size) : data_(data), size_(size) {} - /// copy + /// copy constructor INLINE_FUNCTION_HD span(const span&) = default; - /// assignment + /// copy assignment operator INLINE_FUNCTION_HD span& operator=(const span&) = default; - /// move + /// move constructor INLINE_FUNCTION_HD span(span&&) = default; - /// assignment + /// move assignment operator INLINE_FUNCTION_HD span& operator=(span&) = default; @@ -90,6 +95,7 @@ public: return size_ == 0; } + /// Returns a pointer to the beginning of the data INLINE_FUNCTION_HD T* data() const { @@ -98,7 +104,7 @@ public: /// Returns the number of elements in the span INLINE_FUNCTION_HD - uint32 size() const + index size() const { return size_; } @@ -110,7 +116,7 @@ public: return data_; } - /// Returns an iterator to the beginning of the span + /// Returns an iterator to the beginning of the span (const version) INLINE_FUNCTION_HD constIterator cbegin() const { @@ -124,93 +130,59 @@ public: return data_ + size_; } - /// Returns an iterator to one past the end of the span + /// Returns an iterator to one past the end of the span (const version) INLINE_FUNCTION_HD constIterator cend() const { return data_ + size_; } + /// Returns a reference to the element at the specified index INLINE_FUNCTION_HD - T& operator[](uint32 i) + T& operator[](index i) { - return data_[i]; + return data_[i]; } + /// Returns a const reference to the element at the specified index INLINE_FUNCTION_HD - const T& operator[](uint32 i)const + T& operator[](index i)const { - return data_[i]; - } - - INLINE_FUNCTION_HD - T& operator[](int32 i) - { - return data_[i]; - } - - INLINE_FUNCTION_HD - const T& operator[](int32 i)const - { - return data_[i]; + return data_[i]; } }; -/*template class Container> -size_t makeSpan(Container& container) -{ - return span(container.data(), container.size()); -} - -template class Container> -size_t makeSpan(const Container& container) -{ - return span( - const_cast(container.data()), - container.size()); -}*/ - +/// Creates a span of char from a span of any type. +/// +/// This helper function reinterprets the underlying memory of the given span +/// as a span of char. template inline span charSpan(span s) { - auto el = sizeof(T); - return span( - reinterpret_cast(s.data()), - s.size()*el); + auto el = sizeof(T); + return span( + reinterpret_cast(s.data()), + s.size()*el); } +/// Creates a span of const char from a span of const any type. +/// +/// This helper function reinterprets the underlying memory of the given span +/// as a span of const char. template inline span charSpan(span s) { - auto el = sizeof(T); - return span( - reinterpret_cast(s.data()), - s.size()*el); + auto el = sizeof(T); + return span( + reinterpret_cast(s.data()), + s.size()*el); } -/*template class Container> -span makeSpan(Container& container) -{ - return span(container.data(), container.size()); -} - -template class Container> -span makeSpan(const Container& container) -{ - return span( - const_cast(container.data()), - container.size()); -}*/ - - - - - } // pFlow -#endif //__span_hpp__ +#endif //__span_hpp__ \ No newline at end of file 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/globals/error.cpp b/src/phasicFlow/globals/error.cpp index 9135c69b..d9d7efc3 100644 --- a/src/phasicFlow/globals/error.cpp +++ b/src/phasicFlow/globals/error.cpp @@ -32,41 +32,35 @@ Licence: static pFlow::Ostream& errorStream = pFlow::pOutput; pFlow::iOstream& -fatalErrorMessage(const char* fileName, int linNumber) +pFlow::fatalErrorMessage(const char* fileName, int lineNumber) { - errorStream << "\n>>> Fatal error in phasicFlow\n" - << "Error occured in source file " << Red_Text(fileName) - << " at line " << Red_Text(linNumber) << '\n'; + errorStream << "\nError occured in file ("<>> Fatal error in phasicFlow\n" - << " Error is issued in function " << Red_Text(fnName) - << ", located in file " << Red_Text(fileName) << " at line " - << Red_Text(linNumber) << '\n'; + errorStream << "\nError occured in file ("<>> Fatal error in phasicFlow\n"; - errorStream << " Function " << Red_Text(fnName) + errorStream << "\n Function " << Yellow_Text(fnName) << " has not been implemented yet!\n" - << " File " << Yellow_Text(fileName) << " at line " - << Yellow_Text(lineNumber) << '\n'; + << " Look into file ("<>> Warning in phasicFlow\n" << " Warning is issued in function " << Yellow_Text(fnName) @@ -108,7 +102,7 @@ warningMessage(const char* fnName, const char* fileName, int linNumber) } pFlow::iOstream& -reportAndExit(int errorCode) +pFlow::reportAndExit(int errorCode) { errorStream << "\n>>> phasicFlow is exiting . . ." << pFlow::endl; fatalExitPhasicFlow(errorCode); @@ -116,7 +110,7 @@ reportAndExit(int errorCode) } int -fatalExitPhasicFlow(int errorCode) +pFlow::fatalExitPhasicFlow(int errorCode) { // Kokkos should be finalized first Kokkos::finalize(); diff --git a/src/phasicFlow/globals/error.hpp b/src/phasicFlow/globals/error.hpp index 7e16d379..f658e465 100644 --- a/src/phasicFlow/globals/error.hpp +++ b/src/phasicFlow/globals/error.hpp @@ -27,7 +27,7 @@ Licence: namespace pFlow { class iOstream; -} + //- Decleartions @@ -66,35 +66,37 @@ warningMessage(const char* fnName, const char* fileName, int linNumber); pFlow::iOstream& reportAndExit(int errorCode = EXIT_FAILURE); +} + /// Report a fatal error and exit the applicaiton -#define fatalError fatalErrorMessage(__FILE__, __LINE__) +#define fatalError pFlow::fatalErrorMessage(__FILE__, __LINE__) /// Report a fatal error and supplied function name and exit the application #define fatalErrorIn(functionName) \ - fatalErrorInMessage((functionName), __FILE__, __LINE__) + pFlow::fatalErrorInMessage((functionName), __FILE__, __LINE__) /// Report a fatal error and function name and exit the application #define fatalErrorInFunction fatalErrorIn(FUNCTION_NAME) /// Report that a function is yet not implemented with supplied function name. #define Not_Implemented(functionName) \ - notImplementedErrorMessage((functionName), __FILE__, __LINE__) + pFlow::notImplementedErrorMessage((functionName), __FILE__, __LINE__) /// Report that a function is yet not implemented. #define notImplementedFunction Not_Implemented(FUNCTION_NAME) /// Report an error in file operation with supplied fileName and lineNumber. #define ioErrorInFile(fileName, lineNumber) \ - ioErrorMessage(fileName, lineNumber, FUNCTION_NAME, __FILE__, __LINE__) + pFlow::ioErrorMessage(fileName, lineNumber, FUNCTION_NAME, __FILE__, __LINE__) /// Report a warning with supplied function name #define warningIn(functionName) \ - warningMessage((functionName), __FILE__, __LINE__) + pFlow::warningMessage((functionName), __FILE__, __LINE__) /// Report a warning #define warningInFunction warningIn(FUNCTION_NAME) /// Fatal exit -#define fatalExit reportAndExit() +#define fatalExit pFlow::reportAndExit() #endif diff --git a/src/phasicFlow/repository/IOobject/objectFile.hpp b/src/phasicFlow/repository/IOobject/objectFile.hpp index ee0cf85a..c0bb281b 100644 --- a/src/phasicFlow/repository/IOobject/objectFile.hpp +++ b/src/phasicFlow/repository/IOobject/objectFile.hpp @@ -60,7 +60,7 @@ private: fileSystem localPath_ = ""; /// Number of bytes used for writing/reading real variable (used for binray) - int numBytesForReal_ = numBytesForReal__; + int numBytesForReal_ = sizeof(real); /// Does the objectFile read & write the header? bool readWriteHeader_ = true; 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 diff --git a/src/phasicFlow/types/basicTypes/bTypesFunctions.hpp b/src/phasicFlow/types/basicTypes/bTypesFunctions.hpp index 764866d2..87f0408a 100755 --- a/src/phasicFlow/types/basicTypes/bTypesFunctions.hpp +++ b/src/phasicFlow/types/basicTypes/bTypesFunctions.hpp @@ -277,7 +277,7 @@ equal(const uint32& s1, const uint32& s2) } /// Are two words equal (host only)? -INLINE_FUNCTION +inline bool equal(const word& s1, const word& s2) { diff --git a/src/phasicFlow/types/basicTypes/builtinTypes.hpp b/src/phasicFlow/types/basicTypes/builtinTypes.hpp index ab8673ed..be3d5647 100755 --- a/src/phasicFlow/types/basicTypes/builtinTypes.hpp +++ b/src/phasicFlow/types/basicTypes/builtinTypes.hpp @@ -29,20 +29,22 @@ namespace pFlow { #ifdef pFlow_Build_Double -#define useDouble 1 -inline const char* floatingPointType__ = "double"; -inline const bool usingDouble__ = true; + #define UseDouble 1 + inline const char* floatingPointType__ = "double"; + inline const bool usingDouble__ = true; #else -#define useDouble 0 -inline const char* floatingPointType__ = "float"; -inline const bool usingDouble__ = false; + #define UseDouble 0 + inline const char* floatingPointType__ = "float"; + inline const bool usingDouble__ = false; #endif + + // scalars -#if useDouble -using real = double; +#if UseDouble + using real = double; #else -using real = float; + using real = float; #endif using int8 = signed char; @@ -57,21 +59,27 @@ using uint32 = unsigned int; using uint64 = unsigned long long int; -using id_t = uint32; - -using size_t = std::size_t; - using word = std::string; using timeValue = double; -inline const int numBytesForReal__ = sizeof(real); +#ifdef pFlow_Build_Index64 + #define Index64 1 + using index = std::size_t; + inline const char* IndexType__ = "std::size_t"; +#else + #define Index64 0 + using index = uint32; + inline const char* IndexType__ = "uint32"; +#endif + inline word floatingPointDescription() { return word("In this build, ") + word(floatingPointType__) + - word(" is used for floating point operations."); + word(" is used for floating point operations and ") + + IndexType__ + "for indexing."; } } // end of pFlow diff --git a/src/phasicFlow/types/triple/triple.hpp b/src/phasicFlow/types/triple/triple.hpp index 8b6735af..64662aa6 100644 --- a/src/phasicFlow/types/triple/triple.hpp +++ b/src/phasicFlow/types/triple/triple.hpp @@ -114,13 +114,13 @@ struct triple triple& operator=(triple&& src) = default; /// clone - INLINE_FUNCTION + inline uniquePtr> clone() const { return makeUnique>(*this); } - INLINE_FUNCTION + inline triple* clonePtr() const { return new triple(*this); diff --git a/src/phasicFlow/types/triple/tripleFwd.hpp b/src/phasicFlow/types/triple/tripleFwd.hpp index e9d36b0e..90e638c2 100644 --- a/src/phasicFlow/types/triple/tripleFwd.hpp +++ b/src/phasicFlow/types/triple/tripleFwd.hpp @@ -103,13 +103,13 @@ INLINE_FUNCTION_HD bool operator>=(const triple& opr1, const triple& opr2); template -INLINE_FUNCTION iOstream& +inline iOstream& operator<<(iOstream& str, const triple& ov); template -INLINE_FUNCTION iIstream& +inline iIstream& operator>>(iIstream& str, triple& iv); template -INLINE_FUNCTION void +inline void readIstream(iIstream& str, triple& iv); \ No newline at end of file diff --git a/src/phasicFlow/types/triple/tripleI.hpp b/src/phasicFlow/types/triple/tripleI.hpp index b829d56e..6b630cc2 100644 --- a/src/phasicFlow/types/triple/tripleI.hpp +++ b/src/phasicFlow/types/triple/tripleI.hpp @@ -287,8 +287,8 @@ pFlow::operator>=(const triple& opr1, const triple& opr2) } template -INLINE_FUNCTION pFlow::iOstream& - pFlow::operator<<(iOstream& str, const triple& ov) +inline pFlow::iOstream& + pFlow::operator<<(iOstream& str, const triple& ov) { str << token::BEGIN_LIST << ov.x_ << token::SPACE << ov.y_ << token::SPACE << ov.z_ << token::END_LIST; @@ -299,8 +299,8 @@ INLINE_FUNCTION pFlow::iOstream& } template -INLINE_FUNCTION pFlow::iIstream& - pFlow::operator>>(iIstream& str, triple& iv) +inline pFlow::iIstream& + pFlow::operator>>(iIstream& str, triple& iv) { str.readBegin("triple"); @@ -316,7 +316,7 @@ INLINE_FUNCTION pFlow::iIstream& } template -INLINE_FUNCTION void +inline void pFlow::readIstream(iIstream& str, triple& iv) { str.readBegin("triple");