diff --git a/src/Integration/AdamsBashforth2/AdamsBashforth2.C b/src/Integration/AdamsBashforth2/AdamsBashforth2.C index baf76a54..7739e219 100644 --- a/src/Integration/AdamsBashforth2/AdamsBashforth2.C +++ b/src/Integration/AdamsBashforth2/AdamsBashforth2.C @@ -74,6 +74,13 @@ bool pFlow::AdamsBashforth2::correct return true; } +bool pFlow::AdamsBashforth2::setInitialVals( + const int32IndexContainer& newIndices, + const realx3Vector& y) +{ + return true; +} + bool pFlow::AdamsBashforth2::intAll( real dt, realx3Vector_D& y, diff --git a/src/Integration/AdamsBashforth2/AdamsBashforth2.H b/src/Integration/AdamsBashforth2/AdamsBashforth2.H index 22dd792c..aa191f4c 100644 --- a/src/Integration/AdamsBashforth2/AdamsBashforth2.H +++ b/src/Integration/AdamsBashforth2/AdamsBashforth2.H @@ -68,6 +68,20 @@ public: bool correct(real dt, realx3Vector_D& y, realx3Vector_D& dy) override; + bool setInitialVals( + const int32IndexContainer& newIndices, + const realx3Vector& y) override; + + bool needSetInitialVals()const override + { + return false; + } + + uniquePtr clone()const override + { + return makeUnique(*this); + } + bool intAll(real dt, realx3Vector_D& y, realx3Vector_D& dy, range activeRng); template diff --git a/src/Integration/AdamsBashforth3/AdamsBashforth3.C b/src/Integration/AdamsBashforth3/AdamsBashforth3.C index c772ad13..fa8e9927 100644 --- a/src/Integration/AdamsBashforth3/AdamsBashforth3.C +++ b/src/Integration/AdamsBashforth3/AdamsBashforth3.C @@ -60,7 +60,7 @@ pFlow::AdamsBashforth3::AdamsBashforth3 AB3History({zero3,zero3}))) { - + } bool pFlow::AdamsBashforth3::predict @@ -94,6 +94,13 @@ bool pFlow::AdamsBashforth3::correct return true; } +bool pFlow::AdamsBashforth3::setInitialVals( + const int32IndexContainer& newIndices, + const realx3Vector& y) +{ + return true; +} + bool pFlow::AdamsBashforth3::intAll( real dt, realx3Vector_D& y, diff --git a/src/Integration/AdamsBashforth3/AdamsBashforth3.H b/src/Integration/AdamsBashforth3/AdamsBashforth3.H index 6b9d9e94..d9baecb7 100644 --- a/src/Integration/AdamsBashforth3/AdamsBashforth3.H +++ b/src/Integration/AdamsBashforth3/AdamsBashforth3.H @@ -117,6 +117,20 @@ public: realx3Vector_D & y, realx3Vector_D& dy) override; + bool setInitialVals( + const int32IndexContainer& newIndices, + const realx3Vector& y) override; + + bool needSetInitialVals()const override + { + return false; + } + + uniquePtr clone()const override + { + return makeUnique(*this); + } + bool intAll(real dt, realx3Vector_D& y, realx3Vector_D& dy, diff --git a/src/Integration/AdamsBashforth4/AdamsBashforth4.C b/src/Integration/AdamsBashforth4/AdamsBashforth4.C index 13d25435..313eb58c 100644 --- a/src/Integration/AdamsBashforth4/AdamsBashforth4.C +++ b/src/Integration/AdamsBashforth4/AdamsBashforth4.C @@ -76,6 +76,13 @@ bool pFlow::AdamsBashforth4::correct return true; } +bool pFlow::AdamsBashforth4::setInitialVals( + const int32IndexContainer& newIndices, + const realx3Vector& y) +{ + return true; +} + bool pFlow::AdamsBashforth4::intAll( real dt, realx3Vector_D& y, diff --git a/src/Integration/AdamsBashforth4/AdamsBashforth4.H b/src/Integration/AdamsBashforth4/AdamsBashforth4.H index 00b7c752..7cb31e88 100644 --- a/src/Integration/AdamsBashforth4/AdamsBashforth4.H +++ b/src/Integration/AdamsBashforth4/AdamsBashforth4.H @@ -122,6 +122,20 @@ public: realx3Vector_D & y, realx3Vector_D& dy) override; + bool setInitialVals( + const int32IndexContainer& newIndices, + const realx3Vector& y) override; + + bool needSetInitialVals()const override + { + return false; + } + + uniquePtr clone()const override + { + return makeUnique(*this); + } + bool intAll(real dt, realx3Vector_D& y, realx3Vector_D& dy, diff --git a/src/Integration/AdamsBashforth5/AdamsBashforth5.C b/src/Integration/AdamsBashforth5/AdamsBashforth5.C index 19971468..23f7fc09 100644 --- a/src/Integration/AdamsBashforth5/AdamsBashforth5.C +++ b/src/Integration/AdamsBashforth5/AdamsBashforth5.C @@ -76,6 +76,13 @@ bool pFlow::AdamsBashforth5::correct return true; } +bool pFlow::AdamsBashforth5::setInitialVals( + const int32IndexContainer& newIndices, + const realx3Vector& y) +{ + return true; +} + bool pFlow::AdamsBashforth5::intAll( real dt, realx3Vector_D& y, diff --git a/src/Integration/AdamsBashforth5/AdamsBashforth5.H b/src/Integration/AdamsBashforth5/AdamsBashforth5.H index c389e8c4..aee15244 100644 --- a/src/Integration/AdamsBashforth5/AdamsBashforth5.H +++ b/src/Integration/AdamsBashforth5/AdamsBashforth5.H @@ -120,6 +120,20 @@ public: realx3Vector_D & y, realx3Vector_D& dy) override; + bool setInitialVals( + const int32IndexContainer& newIndices, + const realx3Vector& y) override; + + bool needSetInitialVals()const override + { + return false; + } + + uniquePtr clone()const override + { + return makeUnique(*this); + } + bool intAll(real dt, realx3Vector_D& y, realx3Vector_D& dy, diff --git a/src/Integration/AdamsMoulton3/AdamsMoulton3.C b/src/Integration/AdamsMoulton3/AdamsMoulton3.C new file mode 100644 index 00000000..aa6d45d9 --- /dev/null +++ b/src/Integration/AdamsMoulton3/AdamsMoulton3.C @@ -0,0 +1,175 @@ +/*------------------------------- 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 "AdamsMoulton3.H" + +//const real AB2_coef[] = { 3.0 / 2.0, 1.0 / 2.0}; + +pFlow::AdamsMoulton3::AdamsMoulton3 +( + const word& baseName, + repository& owner, + const pointStructure& pStruct, + const word& method +) +: + integration(baseName, owner, pStruct, method), + y0_( + owner.emplaceObject( + objectFile( + groupNames(baseName,"y0"), + "", + objectFile::READ_IF_PRESENT, + objectFile::WRITE_ALWAYS), + pStruct, + zero3, + false + ) + ), + dy0_( + owner.emplaceObject( + objectFile( + groupNames(baseName,"dy0"), + "", + objectFile::READ_IF_PRESENT, + objectFile::WRITE_ALWAYS), + pStruct, + zero3 + ) + ), + dy1_( + owner.emplaceObject( + objectFile( + groupNames(baseName,"dy1"), + "", + objectFile::READ_IF_PRESENT, + objectFile::WRITE_ALWAYS), + pStruct, + zero3 + ) + ) +{ + +} + +bool pFlow::AdamsMoulton3::predict +( + real dt, + realx3Vector_D& y, + realx3Vector_D& dy +) +{ + + if(this->pStruct().allActive()) + { + return predictAll(dt, y, dy, this->pStruct().activeRange()); + } + else + { + return predictRange(dt, y, dy, this->pStruct().activePointsMaskD()); + } + + return true; +} + +bool pFlow::AdamsMoulton3::correct +( + real dt, + realx3Vector_D& y, + realx3Vector_D& dy +) +{ + if(this->pStruct().allActive()) + { + return intAll(dt, y, dy, this->pStruct().activeRange()); + } + else + { + return intRange(dt, y, dy, this->pStruct().activePointsMaskD()); + } + + return true; +} + +bool pFlow::AdamsMoulton3::setInitialVals( + const int32IndexContainer& newIndices, + const realx3Vector& y) +{ + y0_.insertSetElement(newIndices, y); + //output<< "y0_ "<< y0_<(3.0 / 2.0) * d_dy[i] - static_cast(1.0 / 2.0) * d_dy1[i]); + + }); + Kokkos::fence(); + + return true; +} + +bool pFlow::AdamsMoulton3::intAll( + real dt, + realx3Vector_D& y, + realx3Vector_D& dy, + range activeRng) +{ + + auto d_dy = dy.deviceVectorAll(); + auto d_y = y.deviceVectorAll(); + + auto d_dy0 = dy0_.deviceVectorAll(); + auto d_y0 = y0_.deviceVectorAll(); + auto d_dy1 = dy1_.deviceVectorAll(); + + Kokkos::parallel_for( + "AdamsMoulton3::correct", + rpIntegration (activeRng.first, activeRng.second), + LAMBDA_HD(int32 i){ + auto corrct_y = d_y0[i] + dt*( + static_cast(5.0/12.0)*d_dy[i] + + static_cast(8.0/12.0)*d_dy0[i] + - static_cast(1.0/12.0)*d_dy1[i]); + d_y[i] = corrct_y; + d_y0[i] = corrct_y; + d_dy1[i]= d_dy0[i]; + }); + Kokkos::fence(); + + return true; +} \ No newline at end of file diff --git a/src/Integration/AdamsMoulton3/AdamsMoulton3.H b/src/Integration/AdamsMoulton3/AdamsMoulton3.H new file mode 100644 index 00000000..c6891966 --- /dev/null +++ b/src/Integration/AdamsMoulton3/AdamsMoulton3.H @@ -0,0 +1,179 @@ +/*------------------------------- 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 __AdamsMoulton3_H__ +#define __AdamsMoulton3_H__ + + +#include "integration.H" +#include "pointFields.H" + +namespace pFlow +{ + + +class AdamsMoulton3 +: + public integration +{ +protected: + + realx3PointField_D& y0_; + + realx3PointField_D& dy0_; + + realx3PointField_D& dy1_; + + using rpIntegration = Kokkos::RangePolicy< + DefaultExecutionSpace, + Kokkos::Schedule, + Kokkos::IndexType + >; +public: + + // type info + TypeName("AdamsMoulton3"); + + //// - Constructors + AdamsMoulton3( + const word& baseName, + repository& owner, + const pointStructure& pStruct, + const word& method); + + virtual ~AdamsMoulton3()=default; + + // - add a virtual constructor + add_vCtor( + integration, + AdamsMoulton3, + word); + + + //// - Methods + bool predict(real dt, realx3Vector_D& y, realx3Vector_D& dy) override; + + bool correct(real dt, realx3Vector_D& y, realx3Vector_D& dy) override; + + bool setInitialVals( + const int32IndexContainer& newIndices, + const realx3Vector& y) override; + + bool needSetInitialVals()const override + { + return true; + } + + uniquePtr clone()const override + { + return makeUnique(*this); + } + + bool predictAll(real dt, realx3Vector_D& y, realx3Vector_D& dy, range activeRng); + + template + bool predictRange(real dt, realx3Vector_D& y, realx3Vector_D& dy, activeFunctor activeP); + + bool intAll(real dt, realx3Vector_D& y, realx3Vector_D& dy, range activeRng); + + template + bool intRange(real dt, realx3Vector_D& y, realx3Vector_D& dy, activeFunctor activeP ); + +}; + + +template +bool AdamsMoulton3::predictRange( + real dt, + realx3Vector_D& y, + realx3Vector_D& dy, + activeFunctor activeP ) +{ + auto d_dy = dy.deviceVectorAll(); + auto d_y = y.deviceVectorAll(); + auto d_y0 = y0_.deviceVectorAll(); + auto d_dy0 = dy0_.deviceVectorAll(); + auto d_dy1= dy1_.deviceVectorAll(); + + auto activeRng = activeP.activeRange(); + + Kokkos::parallel_for( + "AdamsMoulton3::predictRange", + rpIntegration (activeRng.first, activeRng.second), + LAMBDA_HD(int32 i){ + if(activeP(i)) + { + d_dy0[i] = d_dy[i]; + d_y[i] = d_y0[i] + + dt* + ( + static_cast(3.0 / 2.0) * d_dy[i] + - static_cast(1.0 / 2.0) * d_dy1[i] + ); + } + }); + Kokkos::fence(); + + return true; + +} + + +template +bool pFlow::AdamsMoulton3::intRange( + real dt, + realx3Vector_D& y, + realx3Vector_D& dy, + activeFunctor activeP ) +{ + + auto d_dy = dy.deviceVectorAll(); + auto d_y = y.deviceVectorAll(); + + auto d_dy0 = dy0_.deviceVectorAll(); + auto d_y0 = y0_.deviceVectorAll(); + auto d_dy1 = dy1_.deviceVectorAll(); + + auto activeRng = activeP.activeRange(); + + Kokkos::parallel_for( + "AdamsMoulton3::correct", + rpIntegration (activeRng.first, activeRng.second), + LAMBDA_HD(int32 i){ + if( activeP(i)) + { + auto corrct_y = d_y0[i] + dt*( + static_cast(5.0/12.0)*d_dy[i] + + static_cast(8.0/12.0)*d_dy0[i] + - static_cast(1.0/12.0)*d_dy1[i]); + d_y[i] = corrct_y; + d_y0[i] = corrct_y; + d_dy1[i]= d_dy0[i]; + } + }); + Kokkos::fence(); + + + return true; +} + +} // pFlow + +#endif //__integration_H__ diff --git a/src/Integration/CMakeLists.txt b/src/Integration/CMakeLists.txt index c96de103..183b0477 100644 --- a/src/Integration/CMakeLists.txt +++ b/src/Integration/CMakeLists.txt @@ -5,6 +5,7 @@ AdamsBashforth5/AdamsBashforth5.C AdamsBashforth4/AdamsBashforth4.C AdamsBashforth3/AdamsBashforth3.C AdamsBashforth2/AdamsBashforth2.C +AdamsMoulton3/AdamsMoulton3.C ) set(link_libs Kokkos::kokkos phasicFlow) diff --git a/src/Integration/integration/integration.H b/src/Integration/integration/integration.H index 7050499d..d9b2f14d 100644 --- a/src/Integration/integration/integration.H +++ b/src/Integration/integration/integration.H @@ -78,6 +78,14 @@ public: virtual bool correct(real dt, realx3Vector_D& y, realx3Vector_D& dy) = 0; + virtual bool setInitialVals( + const int32IndexContainer& newIndices, + const realx3Vector& y) = 0; + + virtual bool needSetInitialVals()const = 0; + + virtual uniquePtr clone()const=0; + const word& baseName()const { return baseName_; diff --git a/src/Interaction/contactSearch/ContactSearch/ContactSearch.H b/src/Interaction/contactSearch/ContactSearch/ContactSearch.H index 11a7f90c..276e1ae3 100644 --- a/src/Interaction/contactSearch/ContactSearch/ContactSearch.H +++ b/src/Interaction/contactSearch/ContactSearch/ContactSearch.H @@ -162,7 +162,9 @@ public: } else return false; - + //output<<" ContactSearch::broadSearch::PP fater.\n"; + + //output<<" ContactSearch::broadSearch::PW before.\n"; if(wallMapping_) { sphereWallTimer_.start(); @@ -171,6 +173,8 @@ public: } else return false; + + //output<<" ContactSearch::broadSearch::PW after.\n"; return true; } diff --git a/src/Interaction/contactSearch/methods/NBS.H b/src/Interaction/contactSearch/methods/NBS.H index 7729f6a8..cf5aed45 100644 --- a/src/Interaction/contactSearch/methods/NBS.H +++ b/src/Interaction/contactSearch/methods/NBS.H @@ -302,11 +302,13 @@ public: performedSearch_ = false; if( !performSearch() ) return true; - + //Info<<"NBS::broadSearch(PairsContainer& pairs, range activeRange, bool force=false) before build"< -1 ) { auto ln = n; auto lm = m; + //output<<"lm "<< lm <<" ln "<< ln << " i j k "<< int32x3(i,j,k)<ln) Swap(lm,ln); if( auto res = pairs.insert(lm,ln); res <0) { diff --git a/src/Interaction/sphereInteraction/sphereInteraction.H b/src/Interaction/sphereInteraction/sphereInteraction.H index 89ca8cef..950276e2 100644 --- a/src/Interaction/sphereInteraction/sphereInteraction.H +++ b/src/Interaction/sphereInteraction/sphereInteraction.H @@ -134,19 +134,26 @@ public: bool iterate() override { - + +//Info<<"before contact search"<contactSearch_) { + if( this->contactSearch_().ppEnterBroadSearch()) { + //Info<<" before ppEnterBroadSearch"<contactSearch_().pwEnterBroadSearch()) { + //Info<<" before pwEnterBroadSearch"<contactSearch_().ppPerformedBroadSearch()) { + //Info<<" before afterBroadSearch"<contactSearch_().pwPerformedBroadSearch()) { + //Info<<" before pwContactList_().afterBroadSearch()"<dt(), accelertion_); + //Info<<"after dyn predict"<dt(),rVelocity_, rAcceleration_); + //Info<<"after rvel predict"<dt(), accelertion_); + //Info<<"after correct dyn "<dt(), rVelocity_, rAcceleration_); + //Info<<"after correct rvel "<needSetInitialVals()) + { + + auto [minInd, maxInd] = pStruct().activeRange(); + int32IndexContainer indexHD(minInd, maxInd); + + auto n = indexHD.size(); + auto index = indexHD.indicesHost(); + + realx3Vector rvel(n,RESERVE()); + const auto hrVel = rVelocity_.hostVector(); + + for(auto i=0; isetInitialVals(indexHD, rvel); + + } if(!initializeParticles()) { @@ -293,6 +327,32 @@ pFlow::sphereParticles::sphereParticles( } +bool pFlow::sphereParticles::update(const eventMessage& msg) +{ + + if(rVelIntegration_->needSetInitialVals()) + { + + + auto indexHD = pStruct().insertedPointIndex(); + + auto n = indexHD.size(); + auto index = indexHD.indicesHost(); + + realx3Vector rvel(n,RESERVE()); + const auto hrVel = rVelocity_.hostVector(); + + for(auto i=0; isetInitialVals(indexHD, rvel); + + } + + return true; +} bool pFlow::sphereParticles::insertParticles ( @@ -312,7 +372,7 @@ bool pFlow::sphereParticles::insertParticles auto exclusionListAllPtr = getFieldObjectList(); - auto newInsertedPtr = pStruct().insertPoints( position, exclusionListAllPtr()); + auto newInsertedPtr = pStruct().insertPoints( position, setField, time(), exclusionListAllPtr()); if(!newInsertedPtr) { @@ -337,10 +397,6 @@ bool pFlow::sphereParticles::insertParticles return false; } - for(auto sfEntry:setField) - { - if(!sfEntry.setPointFieldSelectedAll( time(), newInserted, false ))return false; - } auto activeR = this->activeRange(); diff --git a/src/Particles/SphereParticles/sphereParticles/sphereParticles.H b/src/Particles/SphereParticles/sphereParticles/sphereParticles.H index 0b451ac6..0b208844 100644 --- a/src/Particles/SphereParticles/sphereParticles/sphereParticles.H +++ b/src/Particles/SphereParticles/sphereParticles/sphereParticles.H @@ -157,11 +157,8 @@ public: shapes_.diameterMinMax(minDiam, maxDiam); } - bool update(const eventMessage& msg) override - { - CONSUME_PARAM(msg); - return true; - } + bool update(const eventMessage& msg) override; + realx3PointField_D& rAcceleration() override { diff --git a/src/Particles/dynamicPointStructure/dynamicPointStructure.C b/src/Particles/dynamicPointStructure/dynamicPointStructure.C index 1828e87a..606ba9e1 100644 --- a/src/Particles/dynamicPointStructure/dynamicPointStructure.C +++ b/src/Particles/dynamicPointStructure/dynamicPointStructure.C @@ -47,26 +47,28 @@ pFlow::dynamicPointStructure::dynamicPointStructure objectFile::READ_ALWAYS, objectFile::WRITE_ALWAYS ), - pStruct_, + pStruct(), zero3 ) ) { + this->subscribe(pStruct()); + Report(1)<< "Creating integration method "<< greenText(integrationMethod_)<<" for dynamicPointStructure."<needSetInitialVals()) return; + + + + auto [minInd, maxInd] = pStruct().activeRange(); + int32IndexContainer indexHD(minInd, maxInd); + + auto n = indexHD.size(); + auto index = indexHD.indicesHost(); + + realx3Vector pos(n,RESERVE()); + realx3Vector vel(n,RESERVE()); + const auto hVel = velocity().hostVector(); + const auto hPos = pStruct().pointPosition().hostVector(); + + for(auto i=0; isetInitialVals(indexHD, pos); + + Report(2)<< "Initializing the required vectors for velocity integratoin\n "<setInitialVals(indexHD, vel); } bool pFlow::dynamicPointStructure::predict @@ -91,7 +123,7 @@ bool pFlow::dynamicPointStructure::predict realx3PointField_D& acceleration ) { - auto& pos = pStruct_.pointPosition(); + auto& pos = pStruct().pointPosition(); if(!integrationPos_().predict(dt, pos.VectorField(), velocity_.VectorField() ))return false; if(!integrationVel_().predict(dt, velocity_.VectorField(), acceleration.VectorField()))return false; @@ -105,11 +137,82 @@ bool pFlow::dynamicPointStructure::correct realx3PointField_D& acceleration ) { - auto& pos = pStruct_.pointPosition(); + auto& pos = pStruct().pointPosition(); if(!integrationPos_().correct(dt, pos.VectorField(), velocity_.VectorField() ))return false; if(!integrationVel_().correct(dt, velocity_.VectorField(), acceleration.VectorField()))return false; return true; +} + +/*FUNCTION_H +pFlow::uniquePtr pFlow::dynamicPointStructure::insertPoints +( + const realx3Vector& pos, + const List& exclusionList +) +{ + auto newIndicesPtr = pointStructure::insertPoints(pos, exclusionList); + + // no new point is inserted + if( !newIndicesPtr ) return newIndicesPtr; + + if(!integrationPos_().needSetInitialVals()) return newIndicesPtr; + + auto hVel = velocity_.hostVector(); + auto n = newIndicesPtr().size(); + auto index = newIndicesPtr().indicesHost(); + + realx3Vector velVec(n, RESERVE()); + for(auto i=0; isetInitialVals(newIndicesPtr(), pos ); + integrationVel_->setInitialVals(newIndicesPtr(), velVec ); + + return newIndicesPtr; + +}*/ + + +bool pFlow::dynamicPointStructure::update( + const eventMessage& msg) +{ + if( msg.isInsert()) + { + + if(!integrationPos_->needSetInitialVals())return true; + + const auto indexHD = pStruct().insertedPointIndex(); + + + auto n = indexHD.size(); + + if(n==0) return true; + + auto index = indexHD.indicesHost(); + + realx3Vector pos(n,RESERVE()); + realx3Vector vel(n,RESERVE()); + const auto hVel = velocity().hostVector(); + const auto hPos = pStruct().pointPosition().hostVector(); + + for(auto i=0; isetInitialVals(indexHD, pos); + + integrationVel_->setInitialVals(indexHD, vel); + + } + + return true; } \ No newline at end of file diff --git a/src/Particles/dynamicPointStructure/dynamicPointStructure.H b/src/Particles/dynamicPointStructure/dynamicPointStructure.H index a62248d6..9a7c8649 100644 --- a/src/Particles/dynamicPointStructure/dynamicPointStructure.H +++ b/src/Particles/dynamicPointStructure/dynamicPointStructure.H @@ -31,12 +31,15 @@ namespace pFlow { class dynamicPointStructure +: + //public pointStructure +public eventObserver { protected: Time& time_; - const word integrationMethod_; + word integrationMethod_; pointStructure& pStruct_; @@ -52,8 +55,36 @@ public: dynamicPointStructure(Time& time, const word& integrationMethod); + dynamicPointStructure(const dynamicPointStructure& ps) = default; + + /*dynamicPointStructure(const dynamicPointStructure& ps): + pointStructure(ps), + time_(ps.time_), + integrationMethod_(ps.integrationMethod_), + velocity_(ps.velocity_), + integrationPos_(ps.integrationPos_->clone()), + integrationVel_(ps.integrationVel_->clone()) + { + + }*/ + + + // - no move construct + dynamicPointStructure(dynamicPointStructure&&) = delete; + + // - copy assignment + // + // should be changed, may causs undefined behavior + ////////////////////////////////////////////////////////////// + dynamicPointStructure& operator=(const dynamicPointStructure&) = default; + + // - no move assignment + dynamicPointStructure& operator=(dynamicPointStructure&&) = delete; + + // - destructor virtual ~dynamicPointStructure() = default; + inline pointStructure& pStruct() { return pStruct_; @@ -79,6 +110,19 @@ public: bool correct(real dt, realx3PointField_D& acceleration); + // - update data structure by inserting/setting new points + // Notifies all the fields in the registered list of data structure + // and exclude the fields that re in the exclusionList + // retrun nullptr if it fails + /*FUNCTION_H + virtual uniquePtr insertPoints( + const realx3Vector& pos, + const List& exclusionList={nullptr} + )override;*/ + + bool update(const eventMessage& msg) override; + + }; } diff --git a/src/Particles/particles/particles.C b/src/Particles/particles/particles.C index 391c8797..ae8c3a68 100644 --- a/src/Particles/particles/particles.C +++ b/src/Particles/particles/particles.C @@ -31,10 +31,21 @@ pFlow::particles::particles demParticles(control), time_(control.time()), integrationMethod_(integrationMethod), + /*dynPointStruct_( + time_.emplaceObject( + objectFile( + pointStructureFile__, + "", + objectFile::READ_ALWAYS, + objectFile::WRITE_ALWAYS + ), + control.time(), + integrationMethod + ) + ),*/ dynPointStruct_( control.time(), - integrationMethod - ), + integrationMethod), shapeName_( control.time().emplaceObject( objectFile( diff --git a/src/phasicFlow/containers/VectorHD/VectorSingle.H b/src/phasicFlow/containers/VectorHD/VectorSingle.H index b2898e29..80bdbd81 100644 --- a/src/phasicFlow/containers/VectorHD/VectorSingle.H +++ b/src/phasicFlow/containers/VectorHD/VectorSingle.H @@ -559,6 +559,8 @@ public: INLINE_FUNCTION_H bool insertSetElement(const int32IndexContainer& indices, const Vector& vals) { + + //Info<<"start of insertSetElement vecotsingle"< dVecVals( const_cast(vals.data()), vals.size()); + + hostViewType1D hVecVals( vals.data(), vals.size()); + deviceViewType1D dVecVals("dVecVals", indices.size()); + copy(dVecVals, hVecVals); - pFlow::algorithms::KOKKOS::fillSelected( - deviceVectorAll().data(), - indices.hostView().data(), - dVecVals.data(), - indices.size()); + using policy = Kokkos::RangePolicy< + execution_space, + Kokkos::IndexType >; + auto dVec = deviceVectorAll(); + auto dIndex = indices.deviceView(); + + Kokkos::parallel_for( + "insertSetElement", + policy(0,indices.size()), LAMBDA_HD(int32 i){ + dVec(dIndex(i))= dVecVals(i); + }); + Kokkos::fence(); - return true; + return true; - }else - { - - // TODO: remove const_cast - hostViewType1D hVecVals( const_cast(vals.data()), vals.size()); - deviceViewType1D dVecVals("dVecVals", indices.size()); - copy(dVecVals, hVecVals); - - - pFlow::algorithms::KOKKOS::fillSelected( - deviceVectorAll().data(), - indices.deviceView().data(), - dVecVals.data(), - indices.size()); - return true; - } - - return false; } INLINE_FUNCTION_H diff --git a/src/phasicFlow/setFieldList/setFieldEntry.C b/src/phasicFlow/setFieldList/setFieldEntry.C index 7e1c4222..8ceb9b14 100644 --- a/src/phasicFlow/setFieldList/setFieldEntry.C +++ b/src/phasicFlow/setFieldList/setFieldEntry.C @@ -57,36 +57,50 @@ bool pFlow::setFieldEntry::checkForTypeAndValueAll()const return true; } -bool pFlow::setFieldEntry::setPointFieldDefaultValueNewAll +void* pFlow::setFieldEntry::setPointFieldDefaultValueNewAll ( repository& owner, pointStructure& pStruct, bool verbose ) { - if( - !( - setPointFieldDefaultValueNew (owner, pStruct, verbose) || - setPointFieldDefaultValueNew(owner, pStruct, verbose) || - setPointFieldDefaultValueNew (owner, pStruct, verbose) || - setPointFieldDefaultValueNew (owner, pStruct, verbose) || - setPointFieldDefaultValueNew (owner, pStruct, verbose) || - setPointFieldDefaultValueNew