From 02e0b72082b40fb3db6ffdcf600e81bf556cf9d9 Mon Sep 17 00:00:00 2001 From: HRN Date: Thu, 6 Feb 2025 11:04:30 +0330 Subject: [PATCH] All messages are revisited for internal points and boundaries --- .../grainDEMSystem/grainFluidParticles.cpp | 8 +- .../sphereDEMSystem/sphereFluidParticles.cpp | 8 +- .../AdamsBashforth2/AdamsBashforth2.cpp | 27 +- .../AdamsBashforth2/AdamsBashforth2.hpp | 25 +- .../AdamsBashforth3/AdamsBashforth3.cpp | 45 +-- .../AdamsBashforth3/AdamsBashforth3.hpp | 17 +- .../AdamsBashforth4/AdamsBashforth4.cpp | 51 ++-- .../AdamsBashforth4/AdamsBashforth4.hpp | 16 +- .../boundaries/boundaryIntegration.hpp | 4 +- src/Integration/integration/integration.cpp | 40 ++- src/Integration/integration/integration.hpp | 18 +- .../boundaryContactSearch.hpp | 8 +- .../boundaryGrainInteraction.hpp | 15 +- .../grainInteraction/grainInteraction.cpp | 12 +- .../grainInteraction/grainInteraction.hpp | 4 +- src/Interaction/interaction/interaction.hpp | 2 +- .../boundarySphereInteraction.hpp | 8 +- .../sphereInteraction/sphereInteraction.cpp | 12 +- .../sphereInteraction/sphereInteraction.hpp | 4 +- .../GrainParticles/boundaryGrainParticles.hpp | 4 +- .../grainParticles/grainParticles.cpp | 14 +- .../grainParticles/grainParticles.hpp | 4 +- .../boundarySphereParticles.hpp | 4 +- .../sphereParticles/sphereParticles.cpp | 272 +----------------- .../sphereParticles/sphereParticles.hpp | 4 +- .../dynamicPointStructure.cpp | 33 ++- .../dynamicPointStructure.hpp | 19 +- .../particleIdHandler/particleIdHandler.cpp | 10 +- .../particleIdHandler/particleIdHandler.hpp | 6 +- src/Particles/particles/particles.cpp | 11 - src/Particles/particles/particles.hpp | 13 +- .../containers/List/anyList/anyList.hpp | 18 +- .../boundaryField/boundaryField.cpp | 7 +- .../boundaryField/boundaryField.hpp | 16 +- .../exitBoundaryField/exitBoundaryField.cpp | 4 +- .../exitBoundaryField/exitBoundaryField.hpp | 20 -- .../periodicBoundaryField.cpp | 5 +- .../periodicBoundaryField.hpp | 23 -- .../reflectiveBoundaryField.cpp | 4 +- .../reflectiveBoundaryField.hpp | 20 -- .../internalField/internalField.cpp | 73 +++-- .../internalField/internalField.hpp | 21 +- .../triSurfaceField/triSurfaceField.cpp | 4 +- .../triSurfaceField/triSurfaceField.hpp | 4 +- src/phasicFlow/eventManagement/message.hpp | 76 +++-- src/phasicFlow/eventManagement/observer.hpp | 11 + src/phasicFlow/eventManagement/subscriber.cpp | 21 +- src/phasicFlow/eventManagement/subscriber.hpp | 1 + .../boundaryReflective/boundaryReflective.cpp | 2 - .../boundaryReflective/boundaryReflective.hpp | 14 + .../domain/simulationDomain.cpp | 15 +- .../internalPoints/internalPoints.cpp | 198 +++---------- .../pointStructure/pointStructure.cpp | 2 +- 53 files changed, 431 insertions(+), 846 deletions(-) diff --git a/DEMSystems/grainDEMSystem/grainFluidParticles.cpp b/DEMSystems/grainDEMSystem/grainFluidParticles.cpp index 2ead2ec3..b70cbc05 100644 --- a/DEMSystems/grainDEMSystem/grainFluidParticles.cpp +++ b/DEMSystems/grainDEMSystem/grainFluidParticles.cpp @@ -67,7 +67,7 @@ bool pFlow::grainFluidParticles::beforeIteration() bool pFlow::grainFluidParticles::iterate() { - + const auto ti = this->TimeInfo(); accelerationTimer().start(); pFlow::grainFluidParticlesKernels::acceleration( control().g(), @@ -78,16 +78,16 @@ bool pFlow::grainFluidParticles::iterate() contactTorque().deviceViewAll(), fluidTorque_.deviceViewAll(), pStruct().activePointsMaskDevice(), - accelertion().deviceViewAll(), + acceleration().deviceViewAll(), rAcceleration().deviceViewAll() ); accelerationTimer().end(); intCorrectTimer().start(); - dynPointStruct().correct(this->dt(), accelertion()); + dynPointStruct().correct(ti.dt()); - rVelIntegration().correct(this->dt(), rVelocity(), rAcceleration()); + rVelIntegration().correct(ti.dt(), rVelocity(), rAcceleration()); intCorrectTimer().end(); diff --git a/DEMSystems/sphereDEMSystem/sphereFluidParticles.cpp b/DEMSystems/sphereDEMSystem/sphereFluidParticles.cpp index f3ce902c..8f13fb70 100644 --- a/DEMSystems/sphereDEMSystem/sphereFluidParticles.cpp +++ b/DEMSystems/sphereDEMSystem/sphereFluidParticles.cpp @@ -65,7 +65,7 @@ bool pFlow::sphereFluidParticles::beforeIteration() bool pFlow::sphereFluidParticles::iterate() { - + const auto ti = this->TimeInfo(); accelerationTimer().start(); pFlow::sphereFluidParticlesKernels::acceleration( control().g(), @@ -76,16 +76,16 @@ bool pFlow::sphereFluidParticles::iterate() contactTorque().deviceViewAll(), fluidTorque_.deviceViewAll(), pStruct().activePointsMaskDevice(), - accelertion().deviceViewAll(), + acceleration().deviceViewAll(), rAcceleration().deviceViewAll() ); accelerationTimer().end(); intCorrectTimer().start(); - dynPointStruct().correct(this->dt(), accelertion()); + dynPointStruct().correct(ti.dt()); - rVelIntegration().correct(this->dt(), rVelocity(), rAcceleration()); + rVelIntegration().correct(ti.dt(), rVelocity(), rAcceleration()); intCorrectTimer().end(); diff --git a/src/Integration/AdamsBashforth2/AdamsBashforth2.cpp b/src/Integration/AdamsBashforth2/AdamsBashforth2.cpp index 54af527c..0768a2e8 100644 --- a/src/Integration/AdamsBashforth2/AdamsBashforth2.cpp +++ b/src/Integration/AdamsBashforth2/AdamsBashforth2.cpp @@ -114,8 +114,11 @@ pFlow::AdamsBashforth2::AdamsBashforth2 zero3, zero3 ), + initialValField_(initialValField), boundaryList_(pStruct, method, *this) -{} +{ + realx3PointField_D::addEvent(message::ITEMS_INSERT); +} void pFlow::AdamsBashforth2::updateBoundariesSlaveToMasterIfRequested() { @@ -186,11 +189,21 @@ bool pFlow::AdamsBashforth2::correctPStruct( return success; } - -bool pFlow::AdamsBashforth2::setInitialVals( - const int32IndexContainer& newIndices, - const realx3Vector& y) +bool pFlow::AdamsBashforth2::hearChanges +( + const timeInfo &ti, + const message &msg, + const anyList &varList +) { - return true; + if(msg.equivalentTo(message::ITEMS_INSERT)) + { + + return insertValues(varList, initialValField_.deviceViewAll(), dy1()); + } + else + { + return realx3PointField_D::hearChanges(ti, msg, varList); + } + } - diff --git a/src/Integration/AdamsBashforth2/AdamsBashforth2.hpp b/src/Integration/AdamsBashforth2/AdamsBashforth2.hpp index 91b5902b..f3d164db 100644 --- a/src/Integration/AdamsBashforth2/AdamsBashforth2.hpp +++ b/src/Integration/AdamsBashforth2/AdamsBashforth2.hpp @@ -41,6 +41,8 @@ class AdamsBashforth2 { private: + const realx3Field_D& initialValField_; + boundaryIntegrationList boundaryList_; friend class processorAB2BoundaryIntegration; @@ -57,6 +59,11 @@ protected: return static_cast(*this); } + auto& initialValField() + { + return initialValField_; + } + boundaryIntegrationList& boundaryList() { return boundaryList_; @@ -116,25 +123,13 @@ public: real dt, pointStructure& pStruct, realx3PointField_D& vel) override; - - /*bool hearChanges + bool hearChanges ( - real t, - real dt, - uint32 iter, + const timeInfo& ti, const message& msg, const anyList& varList - ) override;*/ - - bool setInitialVals( - const int32IndexContainer& newIndices, - const realx3Vector& y) override; - - bool needSetInitialVals()const override - { - return false; - } + ) override; }; diff --git a/src/Integration/AdamsBashforth3/AdamsBashforth3.cpp b/src/Integration/AdamsBashforth3/AdamsBashforth3.cpp index e8198512..57875eac 100644 --- a/src/Integration/AdamsBashforth3/AdamsBashforth3.cpp +++ b/src/Integration/AdamsBashforth3/AdamsBashforth3.cpp @@ -184,35 +184,20 @@ bool pFlow::AdamsBashforth3::correctPStruct( return success; } - -bool pFlow::AdamsBashforth3::setInitialVals( - const int32IndexContainer& newIndices, - const realx3Vector& y) +bool pFlow::AdamsBashforth3::hearChanges +( + const timeInfo &ti, + const message &msg, + const anyList &varList +) { - return true; + if(msg.equivalentTo(message::ITEMS_INSERT)) + { + return insertValues(varList, initialValField().deviceViewAll(), dy1()) && + insertValues(varList, initialValField().deviceViewAll(), dy2()); + } + else + { + return realx3PointField_D::hearChanges(ti, msg, varList); + } } - -/*bool pFlow::AdamsBashforth3::intAll( - real dt, - realx3Vector_D& y, - realx3Vector_D& dy, - range activeRng) -{ - auto d_dy = dy.deviceViewAll(); - auto d_y = y.deviceViewAll(); - auto d_history = history_.deviceViewAll(); - - Kokkos::parallel_for( - "AdamsBashforth3::correct", - rpIntegration (activeRng.first, activeRng.second), - LAMBDA_HD(int32 i){ - auto ldy = d_dy[i]; - d_y[i] += dt*( static_cast(23.0 / 12.0) * ldy - - static_cast(16.0 / 12.0) * d_history[i].dy1_ - + static_cast(5.0 / 12.0) * d_history[i].dy2_); - d_history[i] = {ldy ,d_history[i].dy1_}; - }); - Kokkos::fence(); - - return true; -}*/ \ No newline at end of file diff --git a/src/Integration/AdamsBashforth3/AdamsBashforth3.hpp b/src/Integration/AdamsBashforth3/AdamsBashforth3.hpp index e9f71c69..f9e366ff 100644 --- a/src/Integration/AdamsBashforth3/AdamsBashforth3.hpp +++ b/src/Integration/AdamsBashforth3/AdamsBashforth3.hpp @@ -108,23 +108,12 @@ public: realx3PointField_D& vel) override; - /*bool hearChanges + bool hearChanges ( - real t, - real dt, - uint32 iter, + const timeInfo& ti, const message& msg, const anyList& varList - ) override;*/ - - bool setInitialVals( - const int32IndexContainer& newIndices, - const realx3Vector& y) override; - - bool needSetInitialVals()const override - { - return false; - } + ) override; }; diff --git a/src/Integration/AdamsBashforth4/AdamsBashforth4.cpp b/src/Integration/AdamsBashforth4/AdamsBashforth4.cpp index b6cc481b..6d881a94 100644 --- a/src/Integration/AdamsBashforth4/AdamsBashforth4.cpp +++ b/src/Integration/AdamsBashforth4/AdamsBashforth4.cpp @@ -190,40 +190,21 @@ bool pFlow::AdamsBashforth4::correctPStruct( return success; } -bool pFlow::AdamsBashforth4::setInitialVals( - const int32IndexContainer& newIndices, - const realx3Vector& y) +bool pFlow::AdamsBashforth4::hearChanges +( + const timeInfo &ti, + const message &msg, + const anyList &varList +) { - return true; + if(msg.equivalentTo(message::ITEMS_INSERT)) + { + return insertValues(varList, initialValField().deviceViewAll(), dy1()) && + insertValues(varList, initialValField().deviceViewAll(), dy2()) && + insertValues(varList, initialValField().deviceViewAll(), dy3()); + } + else + { + return realx3PointField_D::hearChanges(ti, msg, varList); + } } - -/*bool pFlow::AdamsBashforth4::intAll( - real dt, - realx3Vector_D& y, - realx3Vector_D& dy, - range activeRng) -{ - auto d_dy = dy.deviceViewAll(); - auto d_y = y.deviceViewAll(); - auto d_history = history_.deviceViewAll(); - - Kokkos::parallel_for( - "AdamsBashforth4::correct", - rpIntegration (activeRng.first, activeRng.second), - LAMBDA_HD(int32 i){ - d_y[i] += dt*( - static_cast(55.0 / 24.0) * d_dy[i] - - static_cast(59.0 / 24.0) * d_history[i].dy1_ - + static_cast(37.0 / 24.0) * d_history[i].dy2_ - - static_cast( 9.0 / 24.0) * d_history[i].dy3_ - ); - d_history[i].dy3_ = d_history[i].dy2_; - d_history[i].dy2_ = d_history[i].dy1_; - d_history[i].dy1_ = d_dy[i]; - - - }); - Kokkos::fence(); - - return true; -}*/ \ No newline at end of file diff --git a/src/Integration/AdamsBashforth4/AdamsBashforth4.hpp b/src/Integration/AdamsBashforth4/AdamsBashforth4.hpp index 32d82c22..fa877357 100644 --- a/src/Integration/AdamsBashforth4/AdamsBashforth4.hpp +++ b/src/Integration/AdamsBashforth4/AdamsBashforth4.hpp @@ -103,17 +103,13 @@ public: real dt, pointStructure& pStruct, realx3PointField_D& vel) override; - - bool setInitialVals( - const int32IndexContainer& newIndices, - const realx3Vector& y) override; - - bool needSetInitialVals()const override - { - return false; - } - + bool hearChanges + ( + const timeInfo& ti, + const message& msg, + const anyList& varList + ) override; }; diff --git a/src/Integration/boundaries/boundaryIntegration.hpp b/src/Integration/boundaries/boundaryIntegration.hpp index d50e6016..d7aa4d39 100644 --- a/src/Integration/boundaries/boundaryIntegration.hpp +++ b/src/Integration/boundaries/boundaryIntegration.hpp @@ -51,9 +51,7 @@ public: ); bool hearChanges( - real t, - real dt, - uint32 iter, + const timeInfo& ti, const message &msg, const anyList &varList) override { diff --git a/src/Integration/integration/integration.cpp b/src/Integration/integration/integration.cpp index f3126e1e..d9fc8ba8 100644 --- a/src/Integration/integration/integration.cpp +++ b/src/Integration/integration/integration.cpp @@ -22,17 +22,39 @@ Licence: #include "pointStructure.hpp" #include "repository.hpp" -pFlow::integration::integration +bool pFlow::integration::insertValues ( - const word& baseName, - pointStructure& pStruct, - const word&, - const realx3Field_D& + const anyList& varList, + const deviceViewType1D& srcVals, + realx3PointField_D& dstFeild ) -: - owner_(*pStruct.owner()), - pStruct_(pStruct), - baseName_(baseName) +{ + const word eventName = message::eventName(message::ITEMS_INSERT); + + if(!varList.checkObjectType(eventName)) + { + fatalErrorInFunction<<"Insertion failed in integration for "<< baseName_<< + ", variable "<< eventName << + " does not exist or the type is incorrect"<( + eventName); + + dstFeild.field().insertSetElement(indices, srcVals); + + return true; +} + +pFlow::integration::integration( + const word &baseName, + pointStructure &pStruct, + const word &, + const realx3Field_D &) + : owner_(*pStruct.owner()), + pStruct_(pStruct), + baseName_(baseName) {} diff --git a/src/Integration/integration/integration.hpp b/src/Integration/integration/integration.hpp index 94f91f70..fb0d84df 100644 --- a/src/Integration/integration/integration.hpp +++ b/src/Integration/integration/integration.hpp @@ -63,6 +63,13 @@ private: /// The base name for integration const word baseName_; +protected: + + bool insertValues( + const anyList& varList, + const deviceViewType1D& srcVals, + realx3PointField_D& dstFeild); + public: /// Type info @@ -151,17 +158,6 @@ public: virtual bool correctPStruct(real dt, pointStructure& pStruct, realx3PointField_D& vel) = 0; - /// Set the initial values for new indices - virtual - bool setInitialVals( - const int32IndexContainer& newIndices, - const realx3Vector& y) = 0; - - /// Check if the method requires any set initial vals - virtual - bool needSetInitialVals()const = 0; - - /// Create the polymorphic object based on inputs static uniquePtr create( diff --git a/src/Interaction/contactSearch/boundaries/boundaryContactSearch/boundaryContactSearch.hpp b/src/Interaction/contactSearch/boundaries/boundaryContactSearch/boundaryContactSearch.hpp index 04c07080..9395d939 100644 --- a/src/Interaction/contactSearch/boundaries/boundaryContactSearch/boundaryContactSearch.hpp +++ b/src/Interaction/contactSearch/boundaries/boundaryContactSearch/boundaryContactSearch.hpp @@ -73,9 +73,7 @@ public: } bool hearChanges( - real t, - real dt, - uint32 iter, + const timeInfo& ti, const message &msg, const anyList &varList) override { @@ -83,8 +81,10 @@ public: if (msg.equivalentTo(message::BNDR_RESET)) { // do nothing + return true; } - return true; + fatalErrorInFunction; + return false; } virtual bool broadSearch( diff --git a/src/Interaction/grainInteraction/boundaries/boundaryGrainInteraction/boundaryGrainInteraction.hpp b/src/Interaction/grainInteraction/boundaries/boundaryGrainInteraction/boundaryGrainInteraction.hpp index 91b113f0..e024c62a 100644 --- a/src/Interaction/grainInteraction/boundaries/boundaryGrainInteraction/boundaryGrainInteraction.hpp +++ b/src/Interaction/grainInteraction/boundaries/boundaryGrainInteraction/boundaryGrainInteraction.hpp @@ -154,18 +154,17 @@ public: bool hearChanges ( - real t, - real dt, - uint32 iter, + const timeInfo& ti, const message& msg, const anyList& varList ) override { - - pOutput<<"Function (hearChanges in boundarySphereInteractions)is not implmented Message "<< - msg <boundaryName() <<" type "<< this->type()<::afterIteration() template class cLT> bool pFlow::grainInteraction::hearChanges ( - real t, - real dt, - uint32 iter, + const timeInfo& ti, const message& msg, const anyList& varList ) { - if(msg.equivalentTo(message::ITEM_REARRANGE)) - { - notImplementedFunction; - } - return true; + fatalErrorInFunction<<"Event "<< msg.eventNames()<< + " is not handled in grainInteraction"<boundaryName() <<" type "<< this->type()<boundaryName() <<" type "<< this->type()<::afterIteration() template class cLT> bool pFlow::sphereInteraction::hearChanges ( - real t, - real dt, - uint32 iter, + const timeInfo& ti, const message& msg, const anyList& varList ) { - if(msg.equivalentTo(message::ITEM_REARRANGE)) + if(msg.equivalentTo(message::ITEMS_REARRANGE)) { notImplementedFunction; + return false; } - return true; + + fatalErrorInFunction<<"Event "<< msg.eventNames()<< + " is not handled in sphereInteraction"<dt(); - dynPointStruct().predict(dt, accelertion()); + dynPointStruct().predict(dt); rVelIntegration_().predict(dt,rVelocity_, rAcceleration_); intPredictTimer_.end(); @@ -296,8 +296,8 @@ bool pFlow::grainParticles::beforeIteration() bool pFlow::grainParticles::iterate() { - timeInfo ti = TimeInfo(); - realx3 g = control().g(); + const timeInfo ti = TimeInfo(); + const realx3 g = control().g(); particles::iterate(); accelerationTimer_.start(); @@ -308,7 +308,7 @@ bool pFlow::grainParticles::iterate() I().deviceViewAll(), contactTorque().deviceViewAll(), dynPointStruct().activePointsMaskDevice(), - accelertion().deviceViewAll(), + acceleration().deviceViewAll(), rAcceleration().deviceViewAll() ); @@ -320,12 +320,12 @@ bool pFlow::grainParticles::iterate() intCorrectTimer_.start(); - if(!dynPointStruct().correct(dt(), accelertion())) + if(!dynPointStruct().correct(ti.dt())) { return false; } if(!rVelIntegration_().correct( - dt(), + ti.dt(), rVelocity_, rAcceleration_)) { diff --git a/src/Particles/GrainParticles/grainParticles/grainParticles.hpp b/src/Particles/GrainParticles/grainParticles/grainParticles.hpp index 4d8e3fa7..3c7c1efe 100644 --- a/src/Particles/GrainParticles/grainParticles/grainParticles.hpp +++ b/src/Particles/GrainParticles/grainParticles/grainParticles.hpp @@ -172,9 +172,7 @@ public: } bool hearChanges( - real t, - real dt, - uint32 iter, + const timeInfo& ti, const message& msg, const anyList& varList ) override diff --git a/src/Particles/SphereParticles/boundarySphereParticles.hpp b/src/Particles/SphereParticles/boundarySphereParticles.hpp index 7e379e94..b49aa393 100644 --- a/src/Particles/SphereParticles/boundarySphereParticles.hpp +++ b/src/Particles/SphereParticles/boundarySphereParticles.hpp @@ -50,9 +50,7 @@ public: const sphereParticles& Particles()const; bool hearChanges( - real t, - real dt, - uint32 iter, + const timeInfo& ti, const message &msg, const anyList &varList) override { diff --git a/src/Particles/SphereParticles/sphereParticles/sphereParticles.cpp b/src/Particles/SphereParticles/sphereParticles/sphereParticles.cpp index 39ede64f..744fd97d 100644 --- a/src/Particles/SphereParticles/sphereParticles/sphereParticles.cpp +++ b/src/Particles/SphereParticles/sphereParticles/sphereParticles.cpp @@ -24,180 +24,6 @@ Licence: #include "sphereParticlesKernels.hpp" -//#include "setFieldList.hpp" -/*pFlow::uniquePtr> -pFlow::sphereParticles::getFieldObjectList()const -{ - auto objListPtr = particles::getFieldObjectList(); - - objListPtr().push_back( - static_cast(&I_) ); - - return objListPtr; -} - -bool pFlow::sphereParticles::diameterMassInertiaPropId -( - const word& shName, - real& diam, - real& mass, - real& I, - int8& propIdx -) -{ - uint32 idx; - if( !shapes_.nameToIndex(shName, idx) ) - { - printKeys(fatalErrorInFunction<< - " wrong shape name in the input: "<< shName<(pIdx); - return true; -} - -bool pFlow::sphereParticles::initializeParticles() -{ - - int32IndexContainer indices( - 0, - static_cast(shapeName_.size())); - - return insertSphereParticles(shapeName_, indices, false); -}*/ - - -/*bool pFlow::sphereParticles::beforeIteration() -{ - particles::beforeIteration(); - - intPredictTimer_.start(); - - //INFO<<"before dyn predict"<dt(), accelertion_); - //INFO<<"after dyn predict"<dt(),rVelocity_, rAcceleration_); - //INFO<<"after rvel predict"<needSetInitialVals()) - { - - - auto indexHD = pStruct().insertedPointIndex(); - - auto n = indexHD.size(); - auto index = indexHD.indicesHost(); - - realx3Vector rvel(n,RESERVE()); - const auto hrVel = rVelocity_.hostView(); - - for(auto i=0; isetInitialVals(indexHD, rvel); - - } - - return true; -}*/ - -/*bool pFlow::sphereParticles::insertParticles -( - const realx3Vector& position, - const wordVector& shapes, - const setFieldList& setField - ) -{ - - if( position.size() != shapes.size() ) - { - fatalErrorInFunction<< - " size of vectors position ("<activeRange(); - - REPORT(1)<< "Active range is "<numActive())<< - " and pointStructure capacity is "<capacity())<dt(); - dynPointStruct().predict(dt, accelertion()); + dynPointStruct().predict(dt); rVelIntegration_().predict(dt,rVelocity_, rAcceleration_); intPredictTimer_.end(); @@ -532,8 +272,8 @@ bool pFlow::sphereParticles::beforeIteration() bool pFlow::sphereParticles::iterate() { - timeInfo ti = TimeInfo(); - realx3 g = control().g(); + const timeInfo ti = TimeInfo(); + const realx3 g = control().g(); particles::iterate(); accelerationTimer_.start(); @@ -544,7 +284,7 @@ bool pFlow::sphereParticles::iterate() I().deviceViewAll(), contactTorque().deviceViewAll(), dynPointStruct().activePointsMaskDevice(), - accelertion().deviceViewAll(), + acceleration().deviceViewAll(), rAcceleration().deviceViewAll() ); ForAllActiveBoundaries(i,boundarySphereParticles_) @@ -556,7 +296,7 @@ bool pFlow::sphereParticles::iterate() intCorrectTimer_.start(); - if(!dynPointStruct().correct(dt(), accelertion())) + if(!dynPointStruct().correct(ti.dt())) { return false; } diff --git a/src/Particles/SphereParticles/sphereParticles/sphereParticles.hpp b/src/Particles/SphereParticles/sphereParticles/sphereParticles.hpp index 6453f962..5f2eac52 100644 --- a/src/Particles/SphereParticles/sphereParticles/sphereParticles.hpp +++ b/src/Particles/SphereParticles/sphereParticles/sphereParticles.hpp @@ -175,9 +175,7 @@ public: } bool hearChanges( - real t, - real dt, - uint32 iter, + const timeInfo& ti, const message& msg, const anyList& varList ) override diff --git a/src/Particles/dynamicPointStructure/dynamicPointStructure.cpp b/src/Particles/dynamicPointStructure/dynamicPointStructure.cpp index b6e52b2c..8d7489c9 100644 --- a/src/Particles/dynamicPointStructure/dynamicPointStructure.cpp +++ b/src/Particles/dynamicPointStructure/dynamicPointStructure.cpp @@ -40,6 +40,16 @@ pFlow::dynamicPointStructure::dynamicPointStructure *this, zero3 ), + acceleration_( + objectFile( + "acceleration", + "", + objectFile::READ_IF_PRESENT, + objectFile::WRITE_ALWAYS + ), + *this, + zero3 + ), velocityUpdateTimer_("velocity boundary update", &timers()), integrationMethod_ ( @@ -54,7 +64,7 @@ pFlow::dynamicPointStructure::dynamicPointStructure "pStructPosition", *this, integrationMethod_, - pointPosition() + velocity_.field() ); if( !integrationPos_ ) @@ -69,7 +79,7 @@ pFlow::dynamicPointStructure::dynamicPointStructure "pStructVelocity", *this, integrationMethod_, - velocity_.field() + acceleration_.field() ); if( !integrationVel_ ) @@ -90,6 +100,7 @@ bool pFlow::dynamicPointStructure::beforeIteration() if(!pointStructure::beforeIteration())return false; velocityUpdateTimer_.start(); velocity_.updateBoundariesSlaveToMasterIfRequested(); + acceleration_.updateBoundariesSlaveToMasterIfRequested(); integrationPos_->updateBoundariesSlaveToMasterIfRequested(); integrationVel_->updateBoundariesSlaveToMasterIfRequested(); velocityUpdateTimer_.end(); @@ -116,29 +127,21 @@ bool pFlow::dynamicPointStructure::afterIteration() return succs; } -bool pFlow::dynamicPointStructure::predict( - real dt, - realx3PointField_D &acceleration) +bool pFlow::dynamicPointStructure::predict(real dt) { if(!integrationPos_().predict(dt, pointPosition(), velocity_ ))return false; - if(!integrationVel_().predict(dt, velocity_, acceleration))return false; + if(!integrationVel_().predict(dt, velocity_, acceleration_))return false; return true; } -bool pFlow::dynamicPointStructure::correct -( - real dt, - realx3PointField_D& acceleration -) +bool pFlow::dynamicPointStructure::correct(real dt) { - //auto& pos = pStruct().pointPosition(); - const auto ti = TimeInfo(); + const auto& ti = TimeInfo(); if(!integrationPos_().correctPStruct(dt, *this, velocity_) )return false; - - if(!integrationVel_().correct(dt, velocity_, acceleration, velDamping_().dampingFactor(ti)))return false; + if(!integrationVel_().correct(dt, velocity_, acceleration_, velDamping_().dampingFactor(ti)))return false; return true; } diff --git a/src/Particles/dynamicPointStructure/dynamicPointStructure.hpp b/src/Particles/dynamicPointStructure/dynamicPointStructure.hpp index f9559a3c..8abd66b5 100644 --- a/src/Particles/dynamicPointStructure/dynamicPointStructure.hpp +++ b/src/Particles/dynamicPointStructure/dynamicPointStructure.hpp @@ -42,6 +42,9 @@ private: realx3PointField_D velocity_; + /// acceleration on device + realx3PointField_D acceleration_; + uniquePtr integrationPos_ = nullptr; uniquePtr integrationVel_ = nullptr; @@ -86,6 +89,18 @@ public: return velocity_; } + inline + const realx3PointField_D& acceleration()const + { + return acceleration_; + } + + inline + realx3PointField_D& acceleration() + { + return acceleration_; + } + /// In the time loop before iterate bool beforeIteration() override; @@ -96,10 +111,10 @@ public: bool afterIteration()override; /// prediction step (if any), is called in beforeIteration - bool predict(real dt, realx3PointField_D& acceleration); + bool predict(real dt); /// correction step, is called in iterate - bool correct(real dt, realx3PointField_D& acceleration); + bool correct(real dt); }; diff --git a/src/Particles/particles/particleIdHandler/particleIdHandler.cpp b/src/Particles/particles/particleIdHandler/particleIdHandler.cpp index 5288e156..1f45bdf8 100644 --- a/src/Particles/particles/particleIdHandler/particleIdHandler.cpp +++ b/src/Particles/particles/particleIdHandler/particleIdHandler.cpp @@ -41,16 +41,14 @@ pFlow::particleIdHandler::particleIdHandler(pointStructure& pStruct) bool pFlow::particleIdHandler::hearChanges( - real t, - real dt, - uint32 iter, + const timeInfo& ti, const message& msg, const anyList& varList ) { - if(msg.equivalentTo(message::ITEM_INSERT)) + if(msg.equivalentTo(message::ITEMS_INSERT)) { - const word eventName = message::eventName(message::ITEM_INSERT); + const word eventName = message::eventName(message::ITEMS_INSERT); const auto& indices = varList.getObject( eventName); @@ -66,7 +64,7 @@ pFlow::particleIdHandler::hearChanges( } else { - return uint32PointField_D::hearChanges(t,dt,iter, msg,varList); + return uint32PointField_D::hearChanges(ti, msg, varList); } } diff --git a/src/Particles/particles/particleIdHandler/particleIdHandler.hpp b/src/Particles/particles/particleIdHandler/particleIdHandler.hpp index 836e0141..a70988c6 100644 --- a/src/Particles/particles/particleIdHandler/particleIdHandler.hpp +++ b/src/Particles/particles/particleIdHandler/particleIdHandler.hpp @@ -60,15 +60,11 @@ public: virtual uint32 maxId()const = 0; - - // heat change for possible insertion of particles // overrdie from internalField bool hearChanges ( - real t, - real dt, - uint32 iter, + const timeInfo& ti, const message& msg, const anyList& varList ) override; diff --git a/src/Particles/particles/particles.cpp b/src/Particles/particles/particles.cpp index 22e1c77e..4c50cc53 100644 --- a/src/Particles/particles/particles.cpp +++ b/src/Particles/particles/particles.cpp @@ -34,16 +34,6 @@ pFlow::particles::particles(systemControl& control, const shape& shapes) dynPointStruct_, 0 ), - accelertion_( - objectFile( - "accelertion", - "", - objectFile::READ_IF_PRESENT, - objectFile::WRITE_ALWAYS - ), - dynPointStruct_, - zero3 - ), contactForce_( objectFile( "contactForce", @@ -84,7 +74,6 @@ pFlow::particles::beforeIteration() zeroTorque(); baseFieldBoundaryUpdateTimer_.start(); shapeIndex_.updateBoundariesSlaveToMasterIfRequested(); - accelertion_.updateBoundariesSlaveToMasterIfRequested(); idHandler_().updateBoundariesSlaveToMasterIfRequested(); baseFieldBoundaryUpdateTimer_.end(); return true; diff --git a/src/Particles/particles/particles.hpp b/src/Particles/particles/particles.hpp index 675604b9..2e7b508e 100644 --- a/src/Particles/particles/particles.hpp +++ b/src/Particles/particles/particles.hpp @@ -45,9 +45,6 @@ private: /// shape index of each particle uint32PointField_D shapeIndex_; - /// acceleration on device - realx3PointField_D accelertion_; - /// contact force field realx3PointField_D contactForce_; @@ -60,7 +57,7 @@ private: Timer baseFieldBoundaryUpdateTimer_; /// messages for this objects - static inline const message defaultMessage_{ message::DEFAULT }; + static inline const message defaultMessage_= message::Empty(); protected: @@ -156,14 +153,14 @@ public: return dynPointStruct_.velocity(); } - inline const auto& accelertion() const + inline const auto& acceleration() const { - return accelertion_; + return dynPointStruct_.acceleration(); } - inline auto& accelertion() + inline auto& acceleration() { - return accelertion_; + return dynPointStruct_.acceleration(); } inline auto& contactForce() diff --git a/src/phasicFlow/containers/List/anyList/anyList.hpp b/src/phasicFlow/containers/List/anyList/anyList.hpp index c8abef63..0b655d56 100644 --- a/src/phasicFlow/containers/List/anyList/anyList.hpp +++ b/src/phasicFlow/containers/List/anyList/anyList.hpp @@ -53,7 +53,7 @@ private: /// List of variable names in anyList_ wordList names_; - wordList types_; + wordList types_; public: @@ -162,12 +162,26 @@ public: { fatalErrorInFunction<< "variable name "<< name << " does not exist in the anyList."<(static_cast(i)); } + template + bool checkObjectType(const word& name)const + { + int32 i = names_.findi(name); + if(i == -1 ) + { + fatalErrorInFunction<< + "variable name "<< name << " does not exist in the anyList."<() != types_[i]; + } + /// Get the const reference to variable by name template const T& getObject(const word& name)const diff --git a/src/phasicFlow/containers/pointField/boundaryField/boundaryField/boundaryField.cpp b/src/phasicFlow/containers/pointField/boundaryField/boundaryField/boundaryField.cpp index 1d31e39b..941d3fe0 100644 --- a/src/phasicFlow/containers/pointField/boundaryField/boundaryField/boundaryField.cpp +++ b/src/phasicFlow/containers/pointField/boundaryField/boundaryField/boundaryField.cpp @@ -34,15 +34,14 @@ pFlow::boundaryField::boundaryField memory_space::name() ), internal_(internal) -{} +{ +} template typename pFlow::boundaryField::ProcVectorType& pFlow::boundaryField::neighborProcField() { static ProcVectorType dummyVector{"dummyVector"}; - //notImplementedFunction; - //fatalExit; return dummyVector; } @@ -51,8 +50,6 @@ const typename pFlow::boundaryField::ProcVectorType& pFlow::boundaryField::neighborProcField() const { static ProcVectorType dummyVector{"dummyVector"}; - //notImplementedFunction; - //fatalExit; return dummyVector; } diff --git a/src/phasicFlow/containers/pointField/boundaryField/boundaryField/boundaryField.hpp b/src/phasicFlow/containers/pointField/boundaryField/boundaryField/boundaryField.hpp index 81809cbd..5a09932f 100644 --- a/src/phasicFlow/containers/pointField/boundaryField/boundaryField/boundaryField.hpp +++ b/src/phasicFlow/containers/pointField/boundaryField/boundaryField/boundaryField.hpp @@ -102,23 +102,21 @@ public: bool hearChanges ( - real t, - real dt, - uint32 iter, + const timeInfo& ti, const message& msg, const anyList& varList ) override { - - if(msg.equivalentTo(message::BNDR_REARRANGE)) - { - // do nothing - } + if(msg.equivalentTo(message::BNDR_RESET)) { //do nothing + return true; } - return true; + + fatalErrorInFunction<<"Event"<< msg.eventNames()<<"with code "<< msg << + " is not handled in boundaryField."< ) : BoundaryFieldType(boundary, pStruct, internal) -{ - this->addEvent(message::BNDR_DELETE); -} \ No newline at end of file +{} \ No newline at end of file diff --git a/src/phasicFlow/containers/pointField/boundaryField/exitBoundaryField/exitBoundaryField.hpp b/src/phasicFlow/containers/pointField/boundaryField/exitBoundaryField/exitBoundaryField.hpp index eef6c266..d1015d7b 100644 --- a/src/phasicFlow/containers/pointField/boundaryField/exitBoundaryField/exitBoundaryField.hpp +++ b/src/phasicFlow/containers/pointField/boundaryField/exitBoundaryField/exitBoundaryField.hpp @@ -61,26 +61,6 @@ public: boundaryBase ); - - bool hearChanges - ( - real t, - real dt, - uint32 iter, - const message& msg, - const anyList& varList - ) override - { - BoundaryFieldType::hearChanges(t,dt,iter, msg,varList); - - if(msg.equivalentTo(message::BNDR_DELETE)) - { - // do nothing; - } - - return true; - } - bool isActive()const override { return false; diff --git a/src/phasicFlow/containers/pointField/boundaryField/periodicBoundaryField/periodicBoundaryField.cpp b/src/phasicFlow/containers/pointField/boundaryField/periodicBoundaryField/periodicBoundaryField.cpp index 28177b23..2808b4ef 100644 --- a/src/phasicFlow/containers/pointField/boundaryField/periodicBoundaryField/periodicBoundaryField.cpp +++ b/src/phasicFlow/containers/pointField/boundaryField/periodicBoundaryField/periodicBoundaryField.cpp @@ -26,7 +26,4 @@ template ) : BoundaryFieldType(boundary, pStruct, internal) -{ - this->addEvent(message::BNDR_APPEND) - .addEvent(message::BNDR_TRANSFER); -} \ No newline at end of file +{} \ No newline at end of file diff --git a/src/phasicFlow/containers/pointField/boundaryField/periodicBoundaryField/periodicBoundaryField.hpp b/src/phasicFlow/containers/pointField/boundaryField/periodicBoundaryField/periodicBoundaryField.hpp index 712a5a07..8d379e4b 100644 --- a/src/phasicFlow/containers/pointField/boundaryField/periodicBoundaryField/periodicBoundaryField.hpp +++ b/src/phasicFlow/containers/pointField/boundaryField/periodicBoundaryField/periodicBoundaryField.hpp @@ -61,29 +61,6 @@ public: boundaryBase ); - - bool hearChanges - ( - real t, - real dt, - uint32 iter, - const message& msg, - const anyList& varList - ) override - { - BoundaryFieldType::hearChanges(t,dt,iter, msg,varList); - - if(msg.equivalentTo(message::BNDR_APPEND)) - { - // do nothing; - } - if(msg.equivalentTo(message::BNDR_TRANSFER)) - { - //do nothing - } - return true; - } - }; } diff --git a/src/phasicFlow/containers/pointField/boundaryField/reflectiveBoundaryField/reflectiveBoundaryField.cpp b/src/phasicFlow/containers/pointField/boundaryField/reflectiveBoundaryField/reflectiveBoundaryField.cpp index 91bcc7b5..c769fbb1 100644 --- a/src/phasicFlow/containers/pointField/boundaryField/reflectiveBoundaryField/reflectiveBoundaryField.cpp +++ b/src/phasicFlow/containers/pointField/boundaryField/reflectiveBoundaryField/reflectiveBoundaryField.cpp @@ -26,6 +26,4 @@ template ) : BoundaryFieldType(boundary, pStruct, internal) -{ - //this->addEvent(message::BNDR_DELETE); -} \ No newline at end of file +{} \ No newline at end of file diff --git a/src/phasicFlow/containers/pointField/boundaryField/reflectiveBoundaryField/reflectiveBoundaryField.hpp b/src/phasicFlow/containers/pointField/boundaryField/reflectiveBoundaryField/reflectiveBoundaryField.hpp index 5f6b799e..470b84d6 100644 --- a/src/phasicFlow/containers/pointField/boundaryField/reflectiveBoundaryField/reflectiveBoundaryField.hpp +++ b/src/phasicFlow/containers/pointField/boundaryField/reflectiveBoundaryField/reflectiveBoundaryField.hpp @@ -61,26 +61,6 @@ public: boundaryBase ); - - bool hearChanges - ( - real t, - real dt, - uint32 iter, - const message& msg, - const anyList& varList - ) override - { - BoundaryFieldType::hearChanges(t,dt,iter, msg,varList); - - if(msg.equivalentTo(message::BNDR_DELETE)) - { - // do nothing; - } - - return true; - } - bool isActive()const override { return false; diff --git a/src/phasicFlow/containers/pointField/internalField/internalField.cpp b/src/phasicFlow/containers/pointField/internalField/internalField.cpp index 4b7c01e9..87ab830e 100644 --- a/src/phasicFlow/containers/pointField/internalField/internalField.cpp +++ b/src/phasicFlow/containers/pointField/internalField/internalField.cpp @@ -21,7 +21,14 @@ Licence: template bool pFlow::internalField::insert(const anyList& varList) { - const word eventName = message::eventName(message::ITEM_INSERT); + const word eventName = message::eventName(message::ITEMS_INSERT); + + if(!varList.checkObjectType(eventName)) + { + fatalErrorInFunction<<"Insertion failed in internalField, "<< eventName << + " does not exist or the type is incorrect"<( eventName); @@ -30,14 +37,24 @@ bool pFlow::internalField::insert(const anyList& varList) if(varList.contains(name())) { // a single value is assigned + if(!varList.checkObjectType(name())) + { + fatalErrorInFunction<<"wrong type for variable "<< name()<(name()); success = field_.insertSetElement(indices, val); } - else if(varList.contains(name()+"Vector")) + else if(word fn = name()+"Vector"; varList.contains(fn)) { // a vector of values is going to be assigned - const auto& valVec = varList.getObject>(name()+"Vector"); + if(!varList.checkObjectType>(fn)) + { + fatalErrorInFunction<<"wrong type for variable "<< fn<>(fn); success = field_.insertSetElement(indices,valVec); } else @@ -57,8 +74,13 @@ bool pFlow::internalField::insert(const anyList& varList) template bool pFlow::internalField::rearrange(const anyList& varList) { - const word eventName = message::eventName(message::ITEM_REARRANGE); + const word eventName = message::eventName(message::ITEMS_REARRANGE); + if(!varList.checkObjectType(eventName)) + { + fatalErrorInFunction<<"Wrong type for variable "<< eventName<( eventName); @@ -162,40 +184,47 @@ typename pFlow::internalField::FieldTypeHost template bool pFlow::internalField:: hearChanges ( - real t, - real dt, - uint32 iter, + const timeInfo& ti, const message& msg, const anyList& varList ) { - if(msg.equivalentTo(message::CAP_CHANGED)) + if(msg.equivalentTo(message::RANGE_CHANGED)) { - auto newCap = varList.getObject( - message::eventName(message::CAP_CHANGED)); + auto varName = message::eventName(message::RANGE_CHANGED); + if( !varList.checkObjectType(varName) ) + { + fatalErrorInFunction<<"Wrong type for variable "<< varName<(varName); + + if(newRange.end() > size()) + field_.resize(newRange.end()); + return true; } - if(msg.equivalentTo(message::SIZE_CHANGED)) - { - auto newSize = varList.getObject( - message::eventName(message::SIZE_CHANGED)); - field_.resize(newSize); - } - if(msg.equivalentTo(message::ITEM_DELETE)) + else if(msg.equivalentTo(message::ITEMS_DELETE)) { // do nothing + return true; } - if(msg.equivalentTo(message::ITEM_INSERT)) + else if(msg.equivalentTo(message::ITEMS_INSERT)) { return insert(varList); } - if(msg.equivalentTo(message::ITEM_REARRANGE)) + else if(msg.equivalentTo(message::ITEMS_REARRANGE)) { return rearrange(varList); - } - return true; + else + { + fatalErrorInFunction<<"hear changes in internal field is not processing "<< + message::eventName(message::RANGE_CHANGED)<< + " event with message code "<< msg< diff --git a/src/phasicFlow/containers/pointField/internalField/internalField.hpp b/src/phasicFlow/containers/pointField/internalField/internalField.hpp index 9b6df04b..e3ba8ef8 100644 --- a/src/phasicFlow/containers/pointField/internalField/internalField.hpp +++ b/src/phasicFlow/containers/pointField/internalField/internalField.hpp @@ -64,13 +64,12 @@ protected: static inline const message defaultMessage_ = ( - message::CAP_CHANGED+ - message::SIZE_CHANGED+ - message::ITEM_INSERT+ - message::ITEM_REARRANGE+ - message::ITEM_DELETE + message::RANGE_CHANGED + + message::ITEMS_INSERT + + message::ITEMS_REARRANGE + + message::ITEMS_DELETE ); - + bool insert(const anyList& varList); bool rearrange(const anyList& varList); @@ -188,11 +187,15 @@ public: return internalPoints_.time(); } + inline + const internalPoints& InternalPoints()const + { + return internalPoints_; + } + bool hearChanges ( - real t, - real dt, - uint32 iter, + const timeInfo& ti, const message& msg, const anyList& varList ) override; diff --git a/src/phasicFlow/containers/triSurfaceField/triSurfaceField.cpp b/src/phasicFlow/containers/triSurfaceField/triSurfaceField.cpp index 8ba0abf4..0bc3550c 100644 --- a/src/phasicFlow/containers/triSurfaceField/triSurfaceField.cpp +++ b/src/phasicFlow/containers/triSurfaceField/triSurfaceField.cpp @@ -56,7 +56,7 @@ pFlow::triSurfaceField::triSurfaceField observer ( &surface, - message::Default() + message::Empty() ), field_ ( @@ -130,7 +130,7 @@ pFlow::triSurfaceField::triSurfaceField observer ( &surface, - message::Default() + message::Empty() ), field_ ( diff --git a/src/phasicFlow/containers/triSurfaceField/triSurfaceField.hpp b/src/phasicFlow/containers/triSurfaceField/triSurfaceField.hpp index 54c4c0db..2de4803b 100644 --- a/src/phasicFlow/containers/triSurfaceField/triSurfaceField.hpp +++ b/src/phasicFlow/containers/triSurfaceField/triSurfaceField.hpp @@ -166,9 +166,7 @@ public: } bool hearChanges( - real t, - real dt, - uint32 iter, + const timeInfo& ti, const message& msg, const anyList& varList) override { diff --git a/src/phasicFlow/eventManagement/message.hpp b/src/phasicFlow/eventManagement/message.hpp index 0593221a..7b283647 100644 --- a/src/phasicFlow/eventManagement/message.hpp +++ b/src/phasicFlow/eventManagement/message.hpp @@ -25,6 +25,7 @@ Licence: #include "types.hpp" #include "iOstream.hpp" +#include "List.hpp" namespace pFlow @@ -35,52 +36,42 @@ class message public: enum EVENT : size_t { - DEFAULT = 0, - CAP_CHANGED = 1, // internal points capacity changed - SIZE_CHANGED = 2, // internal points size changed - ITEM_DELETE = 3, // internal points item deleted - ITEM_INSERT = 4, // internal points item inserted - RANGE_CHANGED = 5, // internal points range changed - ITEM_REARRANGE = 6, // internal points item rearrange - ITEM_FLAGCHANGED= 7, // internal points item flag changed, this occurs when transfer occurs - BNDR_REARRANGE = 8, // boundary indices rearrange - BNDR_TRANSFER = 9, // boundary indices transfered - BNDR_RESET = 10, // boundary indices reset entirely - BNDR_DELETE = 11, // boundary indices deleted - BNDR_APPEND = 12, // - BNDR_PROCTRANSFER_SEND = 13, // transfer of data between processors step 1 - BNDR_PROCTRANSFER_RECIEVE = 14, // transfer of data between processors step 2 - BNDR_PROCTRANSFER_WAITFILL = 15, // wait for data and fill the field - BNDR_PROC_SIZE_CHANGED = 16 + RANGE_CHANGED = 0, // internal points active range has been changed + ITEMS_INSERT = 1, // internal points are being inserted + ITEMS_DELETE = 2, // internal points are being deleted + ITEMS_REARRANGE = 3, // internal points are being rearrange + ITEMS_FLAGCHANGED = 4, // internal points flag changed, this occurs when transfer occurs + BNDR_APPEND = 5, // boundary: new indices are appended + BNDR_RESET = 6, // boundary: indices are reset entirely + BNDR_DELETE = 7, // boundary: indices are deleted + BNDR_PROC_SIZE_CHANGED = 8, // processor boundary: size has been changed + BNDR_PROCTRANSFER_SEND = 9, // processor boundary: transfer of data between processors step 1 (send) + BNDR_PROCTRANSFER_RECIEVE = 10, // processor boundary: transfer of data between processors step 2 (recieve) + BNDR_PROCTRANSFER_WAITFILL = 11 // processor boundary: wait for data and fill the field }; private: - static constexpr size_t numberOfEvents_ = 17; + static constexpr size_t numberOfEvents_ = 12; std::bitset events_{0x0000}; static inline const std::array eventNames_ { - "", - "capacity", - "size", - "deletedIndices", + "activeRange", "insertedIndices", - "range", - "rearrangedIndices", - "transferredIndices", - "rearrangedIndices", - "transferredIndices", - "", "deletedIndices", - "appendedIndices", - "transferredIndices", - "numToRecieve", - "insertedIndices", - "size" + "rearrangedIndices", + "flagChange", + "bndryAppendedIndices", + "bndryReset", + "bndryDeletedIndices", + "bndrySize", + "bndryTransferIndices", + "bndryNumToRecieve", + "bndryWait" }; public: @@ -173,18 +164,23 @@ public: return *this; } + wordList eventNames()const + { + wordList lst; + for(size_t i=0; ihearChanges + ( + ti, + message(i), + varList + ); + } + } + } + return true; } diff --git a/src/phasicFlow/eventManagement/subscriber.hpp b/src/phasicFlow/eventManagement/subscriber.hpp index 8e7283f9..2690b470 100644 --- a/src/phasicFlow/eventManagement/subscriber.hpp +++ b/src/phasicFlow/eventManagement/subscriber.hpp @@ -68,6 +68,7 @@ public: virtual bool unsubscribe(observer* obsevr)const; + /// TODO: remove this API from thie class bool notify( uint32 iter, real t, diff --git a/src/phasicFlow/structuredData/boundaries/boundaryReflective/boundaryReflective.cpp b/src/phasicFlow/structuredData/boundaries/boundaryReflective/boundaryReflective.cpp index 3d4296e7..4357c05d 100644 --- a/src/phasicFlow/structuredData/boundaries/boundaryReflective/boundaryReflective.cpp +++ b/src/phasicFlow/structuredData/boundaries/boundaryReflective/boundaryReflective.cpp @@ -145,7 +145,5 @@ bool pFlow::boundaryReflective::afterIteration ); Kokkos::fence(); - // TODO: notify integration for changes in the velocity - return true; } diff --git a/src/phasicFlow/structuredData/boundaries/boundaryReflective/boundaryReflective.hpp b/src/phasicFlow/structuredData/boundaries/boundaryReflective/boundaryReflective.hpp index e864873c..44253e2f 100644 --- a/src/phasicFlow/structuredData/boundaries/boundaryReflective/boundaryReflective.hpp +++ b/src/phasicFlow/structuredData/boundaries/boundaryReflective/boundaryReflective.hpp @@ -71,6 +71,20 @@ public: bool afterIteration(const timeInfo& ti)final; + const real restitution()const + { + return restitution_; + } + + const word& velocityName()const + { + return velocityName_; + } + + const word& diameterName()const + { + return diameterName_; + } }; diff --git a/src/phasicFlow/structuredData/domain/simulationDomain.cpp b/src/phasicFlow/structuredData/domain/simulationDomain.cpp index edc0d475..3b4c876a 100644 --- a/src/phasicFlow/structuredData/domain/simulationDomain.cpp +++ b/src/phasicFlow/structuredData/domain/simulationDomain.cpp @@ -36,12 +36,19 @@ bool pFlow::simulationDomain::prepareBoundaryDicts() (1+boundaryExtntionLengthRatio)*maxBoundingSphere_); uint32 updateInterval = - boundaries.getValOrSetMax("updateInterval", 1u); + boundaries.getValOrSet("updateInterval", 5u); + + updateInterval = max(updateInterval, 1u); uint32 neighborListUpdateInterval = - boundaries.getValMax("neighborListUpdateInterval", updateInterval); - - boundaries.addOrReplace("neighborListUpdateInterval", neighborListUpdateInterval); + boundaries.getValOrSet("neighborListUpdateInterval", 50u); + + neighborListUpdateInterval = max(neighborListUpdateInterval, updateInterval); + + boundaries.addOrReplace("neighborListUpdateInterval", neighborListUpdateInterval); + boundaries.addOrReplace("updateInterval", updateInterval); + boundaries.addOrReplace("neighborLength", neighborLength); + boundaries.addOrReplace("boundaryExtntionLengthRatio", boundaryExtntionLengthRatio); // create this boundaries dictionary this->addDict(thisBoundariesDictName(), boundaries); diff --git a/src/phasicFlow/structuredData/pointStructure/internalPoints/internalPoints.cpp b/src/phasicFlow/structuredData/pointStructure/internalPoints/internalPoints.cpp index 0ea527f6..20f61b85 100644 --- a/src/phasicFlow/structuredData/pointStructure/internalPoints/internalPoints.cpp +++ b/src/phasicFlow/structuredData/pointStructure/internalPoints/internalPoints.cpp @@ -40,7 +40,6 @@ bool pFlow::internalPoints::deletePoints(const uint32Vector_D& delPoints) if(delPoints.empty())return true; auto oldRange = pFlagsD_.activeRange(); - auto oldSize = size(); if(!pFlagsD_.deletePoints(delPoints.deviceView())) { @@ -51,46 +50,35 @@ bool pFlow::internalPoints::deletePoints(const uint32Vector_D& delPoints) unSyncFlag(); auto newRange = pFlagsD_.activeRange(); - auto newSize = size(); anyList varList; + message msg; varList.emplaceBack( - message::eventName(message::ITEM_DELETE), - delPoints); - message msg(message::ITEM_DELETE); - - if(oldSize!= newSize) - { - msg.add(message::SIZE_CHANGED); - varList.emplaceBack( - message::eventName(message::SIZE_CHANGED), - newSize); - } + msg.addAndName(message::ITEMS_DELETE), + delPoints.deviceView()); if(oldRange!=newRange) { msg.add(message::RANGE_CHANGED); varList.emplaceBack( - message::eventName(message::RANGE_CHANGED), + msg.addAndName(message::RANGE_CHANGED), newRange); } - auto iter = time().currentIter(); - auto t = time().currentTime(); - auto dt = time().dt(); - - if( !notify(iter, t, dt, msg, varList) ) + + const auto& ti = time().TimeInfo(); + + if( !notify(ti , msg, varList) ) { fatalErrorInFunction; return false; } - return true; } bool pFlow::internalPoints::changePointsFlagPosition ( - const uint32Vector_D& changePoints, + const uint32Vector_D& changePointsIndices, realx3 transferVector, uint32 fromBoundaryIndex, uint32 toBoundaryIndex @@ -104,14 +92,14 @@ bool pFlow::internalPoints::changePointsFlagPosition } // change the flag - pFlagsD_.changeFlags(changePoints.deviceView(), toBoundaryIndex); + pFlagsD_.changeFlags(changePointsIndices.deviceView(), toBoundaryIndex); unSyncFlag(); // change the position pFlow::internalPointsKernels::changePosition ( pointPosition_.deviceViewAll(), - changePoints.deviceView(), + changePointsIndices.deviceView(), transferVector ); @@ -119,17 +107,13 @@ bool pFlow::internalPoints::changePointsFlagPosition message msg; varList.emplaceBack( - message::eventName(message::ITEM_FLAGCHANGED), - changePoints); + msg.addAndName(message::ITEMS_FLAGCHANGED), + changePointsIndices.deviceView()); varList.emplaceBack("fromBoundaryIndex", fromBoundaryIndex); varList.emplaceBack("toBoundaryIndex", toBoundaryIndex); - msg.add(message::ITEM_FLAGCHANGED); - if( !notify( - time().currentIter(), - time().currentTime(), - time().dt(), + time().TimeInfo(), msg, varList)) { @@ -313,106 +297,16 @@ pFlow::internalPoints::insertPoints( anyList& varList ) { - uint32 numNew = static_cast(points.size()); - - auto aRange = pFlagsD_.activeRange(); - uint32 emptySpots = pFlagsD_.capacity() - pFlagsD_.numActive(); - - if(emptySpots!= 0) emptySpots--; - + message msg; - - if( numNew > emptySpots ) + realx3Vector_D points_D(points.name(), points); + if(!insertPointsOnly(points_D, msg, varList)) { - // increase the capacity to hold new points - aRange = pFlagsD_.activeRange(); - uint32 newCap = pFlagsD_.changeCapacity(numNew); - unSyncFlag(); - varList.emplaceBack( - msg.addAndName(message::CAP_CHANGED), - newCap); + return false; } - - - // first check if it is possible to add to the beggining of list - if(numNew <= aRange.start()) - { - varList.emplaceBack( - msg.addAndName(message::ITEM_INSERT), - 0u, numNew); - } - // check if it is possible to add to the end of the list - else if( numNew <= pFlagsD_.capacity() - aRange.end() ) - { - varList.emplaceBack( - msg.addAndName(message::ITEM_INSERT), - aRange.end(), aRange.end()+numNew); - } - // we should fill the scattered empty spots - else - { - auto newIndices = pFlagsD_.getEmptyPoints(numNew); - if(numNew != newIndices.size()) - { - fatalErrorInFunction<<"not enough empty points in pointFlag"<< - numNew<< " "<( - msg.addAndName(message::ITEM_INSERT), - newIndices - ); - } - - const auto& indices = varList.getObject( - message::eventName(message::ITEM_INSERT) - ); - - auto nAdded = pFlagsD_.addInternalPoints(indices.deviceView()); - unSyncFlag(); - - if(nAdded != numNew ) - { - fatalErrorInFunction; - return false; - } - - pointPosition_.reserve( pFlagsD_.capacity() ); - if(!pointPosition_.insertSetElement(indices, points)) - { - fatalErrorInFunction<< - "Error in inserting new positions into pointPosition"<< - " internalPoints field"<(points.size()); - auto aRange = pFlagsD_.activeRange(); + auto oldActiveRange = pFlagsD_.activeRange(); + uint32 emptySpots = pFlagsD_.capacity() - pFlagsD_.numActive(); - if(emptySpots!= 0) emptySpots--; - + if(emptySpots!= 0) emptySpots--; + if( numNew > emptySpots ) { // increase the capacity to hold new points - aRange = pFlagsD_.activeRange(); - uint32 newCap = pFlagsD_.changeCapacity(numNew); + pFlagsD_.changeCapacity(numNew); unSyncFlag(); - varList.emplaceBack( - msg.addAndName(message::CAP_CHANGED), - newCap); } - // first check if it is possible to add to the beggining of list - if(numNew <= aRange.start()) + if(numNew <= oldActiveRange.start()) { varList.emplaceBack( - msg.addAndName(message::ITEM_INSERT), + msg.addAndName(message::ITEMS_INSERT), 0u, numNew); - }// check if it is possible to add to the end of the list - else if( numNew <= pFlagsD_.capacity() - aRange.end() ) + } + // check if it is possible to add to the end of the list + else if( numNew <= pFlagsD_.capacity() - oldActiveRange.end() ) { varList.emplaceBack( - msg.addAndName(message::ITEM_INSERT), - aRange.end(), aRange.end()+numNew); - }// we should fill the scattered empty spots + msg.addAndName(message::ITEMS_INSERT), + oldActiveRange.end(), oldActiveRange.end()+numNew); + } + // we should fill the scattered empty spots else { - auto newIndices = pFlagsD_.getEmptyPoints(numNew); if(numNew != newIndices.size()) { @@ -477,14 +368,13 @@ bool pFlow::internalPoints::insertPointsOnly( } varList.emplaceBack( - msg.addAndName(message::ITEM_INSERT), + msg.addAndName(message::ITEMS_INSERT), newIndices ); } const auto& indices = varList.getObject( - message::eventName(message::ITEM_INSERT) - ); + message::eventName(message::ITEMS_INSERT)); auto nAdded = pFlagsD_.addInternalPoints(indices.deviceView()); unSyncFlag(); @@ -496,7 +386,6 @@ bool pFlow::internalPoints::insertPointsOnly( } pointPosition_.reserve( pFlagsD_.capacity() ); - if(!pointPosition_.insertSetElement(indices, points.deviceView())) { fatalErrorInFunction<< @@ -505,25 +394,16 @@ bool pFlow::internalPoints::insertPointsOnly( return false; } - auto newARange = pFlagsD_.activeRange(); + auto newActiveRange = pFlagsD_.activeRange(); - if( aRange.end() != newARange.end() ) + if(oldActiveRange != newActiveRange) { varList.emplaceBack( msg.addAndName(message::RANGE_CHANGED), - newARange); - varList.emplaceBack( - msg.addAndName(message::SIZE_CHANGED), - newARange.end()); - } - else if(aRange.start() != newARange.start()) - { - varList.emplaceBack( - msg.addAndName(message::RANGE_CHANGED), - newARange); + newActiveRange); } - return true; + return true; } bool pFlow::internalPoints::read diff --git a/src/phasicFlow/structuredData/pointStructure/pointStructure/pointStructure.cpp b/src/phasicFlow/structuredData/pointStructure/pointStructure/pointStructure.cpp index 1f19e0ec..03394c75 100644 --- a/src/phasicFlow/structuredData/pointStructure/pointStructure/pointStructure.cpp +++ b/src/phasicFlow/structuredData/pointStructure/pointStructure/pointStructure.cpp @@ -204,7 +204,7 @@ bool pFlow::pointStructure::beforeIteration() anyList varList; varList.emplaceBack( - msg.addAndName(message::ITEM_REARRANGE), + msg.addAndName(message::ITEMS_REARRANGE), sortedIndices); if(!notify(ti, msg, varList))