code recovery regular part

This commit is contained in:
HRN
2024-10-18 23:13:20 +03:30
parent 173d3c4917
commit d3ccf354b7
54 changed files with 1108 additions and 695 deletions

View File

@ -53,6 +53,47 @@ private:
boundaryContactSearchList csBoundaries_;
bool BroadSearch(
const timeInfo& ti,
csPairContainerType& ppPairs,
csPairContainerType& pwPairs,
bool force = false) override
{
const auto& position = Particles().pointPosition().deviceViewAll();
const auto& flags = Particles().dynPointStruct().activePointsMaskDevice();
const auto& diam = Particles().boundingSphere().deviceViewAll();
return ppwContactSearch_().broadSearch(
ti.iter(),
ti.t(),
ti.dt(),
ppPairs,
pwPairs,
position,
flags,
diam,
force
);
}
bool BoundaryBroadSearch(
uint32 bndryIndex,
const timeInfo& ti,
csPairContainerType& ppPairs,
csPairContainerType& pwPairs,
bool force = false)override
{
return csBoundaries_[bndryIndex].broadSearch(
ti.iter(),
ti.t(),
ti.dt(),
ppPairs,
pwPairs,
force
);
}
public:
TypeInfoTemplate11("ContactSearch", SearchMethodType);
@ -108,87 +149,14 @@ public:
);
}
add_vCtor(
contactSearch,
ContactSearch,
dictionary);
bool broadSearch(
uint32 iter,
real t,
real dt,
csPairContainerType& ppPairs,
csPairContainerType& pwPairs,
bool force = false) override
bool enterBroadSearchBoundary(const timeInfo& ti, bool force=false)const override
{
ppTimer().start();
const auto& position = Particles().pointPosition().deviceViewAll();
const auto& flags = Particles().dynPointStruct().activePointsMaskDevice();
const auto& diam = Particles().boundingSphere().deviceViewAll();
if( !ppwContactSearch_().broadSearch(
iter,
t,
dt,
ppPairs,
pwPairs,
position,
flags,
diam,
force) )
{
fatalErrorInFunction;
return false;
}
ppTimer().end();
return true;
}
bool boundaryBroadSearch(
uint32 i,
uint32 iter,
real t,
real dt,
csPairContainerType& ppPairs,
csPairContainerType& pwPairs,
bool force = false)override
{
if(i==0u)
Particles().boundingSphere().updateBoundaries(DataDirection::SlaveToMaster);
return csBoundaries_[i].broadSearch(
iter,
t,
dt,
ppPairs,
pwPairs,
force);
}
bool enterBroadSearch(uint32 iter, real t, real dt)const override
{
if(ppwContactSearch_)
{
return ppwContactSearch_().performSearch(iter);
}
return false;
}
bool performedBroadSearch()const override
{
return ppwContactSearch_().performedSearch();
}
uint32 updateInterval()const override
{
return ppwContactSearch_().updateInterval();
return enterBroadSearch(ti, force) || csBoundaries_.boundariesUpdated();
}
real sizeRatio()const override
@ -196,7 +164,6 @@ public:
return ppwContactSearch_().sizeRatio();
}
real cellExtent()const override
{
return ppwContactSearch_().cellExtent();

View File

@ -26,4 +26,7 @@ pFlow::boundaryContactSearchList::boundaryContactSearchList(
setList(dict, cSearch);
}
bool pFlow::boundaryContactSearchList::boundariesUpdated() const
{
return boundaries_.boundariesUpdated();
}

View File

@ -28,6 +28,14 @@ public:
const contactSearch& cSearch);
~boundaryContactSearchList()=default;
inline
const boundaryList& boundaries()const
{
return boundaries_;
}
bool boundariesUpdated()const;
};

View File

@ -33,8 +33,8 @@ pFlow::contactSearch::contactSearch(
extendedDomainBox_(extDomain),
particles_(prtcl),
geometry_(geom),
ppTimer_("particle-particle contact search", &timers),
pwTimer_("particle-wall contact search", &timers),
bTimer_("Boundary particles contact search", &timers),
ppTimer_("Internal particles contact search", &timers),
dict_(dict)
{
@ -45,6 +45,76 @@ const pFlow::pointStructure &pFlow::contactSearch::pStruct() const
return particles_.pStruct();
}
bool pFlow::contactSearch::broadSearch
(
const timeInfo &ti,
csPairContainerType &ppPairs,
csPairContainerType &pwPairs,
bool force
)
{
if(enterBroadSearch(ti, force))
{
ppTimer_.start();
if( !BroadSearch(
ti,
ppPairs,
pwPairs,
force ) )
{
fatalErrorInFunction;
performedSearch_ = false;
return false;
}
ppTimer_.end();
performedSearch_ = true;
}
else
{
performedSearch_ = false;
}
return true;
}
bool pFlow::contactSearch::boundaryBroadSearch
(
uint32 bndryIndex,
const timeInfo &ti,
csPairContainerType &ppPairs,
csPairContainerType &pwPairs,
bool force
)
{
if(enterBroadSearchBoundary(ti, force))
{
bTimer_.start();
for(uint32 i=0u; i<6u; i++)
{
if(!BoundaryBroadSearch(
i,
ti,
ppPairs,
pwPairs,
force))
{
performedSearchBoundary_ = false;
return false;
}
}
bTimer_.end();
performedSearchBoundary_ = true;
}
else
{
performedSearchBoundary_ = false;
}
return true;
}
pFlow::uniquePtr<pFlow::contactSearch> pFlow::contactSearch::create(
const dictionary &dict,
const box &extDomain,

View File

@ -26,6 +26,7 @@ Licence:
#include "contactSearchGlobals.hpp"
#include "dictionary.hpp"
#include "virtualConstructor.hpp"
#include "timeInfo.hpp"
#include "Timer.hpp"
namespace pFlow
@ -44,16 +45,47 @@ private:
const box& extendedDomainBox_;
/// @brief update interval in terms of iteration numebr
uint32 updateInterval_= 1;
/// @brief last iteration number which contact search has been performed
uint32 lastUpdated_ = 0;
/// @brief performed search?
bool performedSearch_ = false;
/// @brief performed search in boundaries
bool performedSearchBoundary_ = false;
/// const ref to particles
const particles& particles_;
/// const ref to geometry
const geometry& geometry_;
Timer bTimer_;
Timer ppTimer_;
Timer pwTimer_;
dictionary dict_;
virtual
bool BroadSearch(
const timeInfo& ti,
csPairContainerType& ppPairs,
csPairContainerType& pwPairs,
bool force
)=0;
virtual
bool BoundaryBroadSearch(
uint32 bndryIndex,
const timeInfo& ti,
csPairContainerType& ppPairs,
csPairContainerType& pwPairs,
bool force = false
)=0;
public:
TypeInfo("contactSearch");
@ -82,66 +114,92 @@ public:
(dict, domain, prtcl, geom, timers)
);
const auto& dict()const
inline
bool performedSearch()const
{
return performedSearch_;
}
inline
bool performedSearchBoundary()const
{
return performedSearchBoundary_;
}
inline
bool performSearch(uint32 iter, bool force = false)const
{
if((iter-lastUpdated_) % updateInterval_ == 0 || iter == 0 || force )
{
return true;
}
return false;
}
bool enterBroadSearch(const timeInfo& ti, bool force = false)const
{
return performSearch(ti.iter(), force);
}
virtual
bool enterBroadSearchBoundary(const timeInfo& ti, bool force=false)const = 0;
inline
uint32 updateInterval()const
{
return updateInterval_;
}
inline
const dictionary& dict()const
{
return dict_;
}
const auto& extendedDomainBox()const
inline
const box& extendedDomainBox()const
{
return extendedDomainBox_;
}
const auto& Particles()const
inline
const particles& Particles()const
{
return particles_;
}
const pointStructure& pStruct()const;
const auto& Geometry()const
inline
const geometry& Geometry()const
{
return geometry_;
}
auto& ppTimer()
inline
Timer& ppTimer()
{
return ppTimer_;
}
auto& pwTimer()
inline
Timer& bTimer()
{
return pwTimer_;
return bTimer_;
}
virtual
bool broadSearch(
uint32 iter,
real t,
real dt,
const timeInfo& ti,
csPairContainerType& ppPairs,
csPairContainerType& pwPairs,
bool force = false) = 0;
bool force = false);
virtual
bool boundaryBroadSearch(
uint32 i,
uint32 iter,
real t,
real dt,
uint32 bndryIndex,
const timeInfo& ti,
csPairContainerType& ppPairs,
csPairContainerType& pwPairs,
bool force = false)=0;
virtual
bool enterBroadSearch(uint32 iter, real t, real dt)const = 0;
virtual
bool performedBroadSearch()const = 0;
virtual
uint32 updateInterval()const = 0;
bool force = false);
virtual
real sizeRatio()const = 0;

View File

@ -31,48 +31,36 @@ pFlow::particleWallContactSearchs<method>::particleWallContactSearchs
const ViewType1D<real, memory_space> &diam
)
:
domainBox_(domain),
updateInterval_
(
max(dict.getValOrSet<uint32>("updateInterval", 1),1u)
)
{
}
domainBox_(domain)
{}
template <typename method>
bool pFlow::particleWallContactSearchs<method>::broadSearch
(
uint32 iter,
real t,
real dt,
csPairContainerType& ppPairs,
csPairContainerType& pwPairs,
const deviceViewType1D<realx3>& pointPos,
const pFlagTypeDevice& flags,
const deviceViewType1D<real>& diameter,
bool force
)
(
uint32 iter,
real t,
real dt,
csPairContainerType& ppPairs,
csPairContainerType& pwPairs,
const deviceViewType1D<realx3>& pointPos,
const pFlagTypeDevice& flags,
const deviceViewType1D<real>& diameter,
bool force
)
{
if(!getMethod().impl_broadSearch(
ppPairs,
pwPairs,
pointPos,
flags,
diameter))
{
performedSearch_ = false;
if( !performSearch(iter, force) ) return true;
if(!getMethod().impl_broadSearch(
ppPairs,
pwPairs,
pointPos,
flags,
diameter))
{
fatalErrorInFunction<<
"Error in performing particle-particle broadSearch in method"<<
getMethod().typeName()<<endl;
return false;
}
lastUpdated_ = iter;
performedSearch_ = true;
return true;
}
fatalErrorInFunction<<
"Error in performing particle-particle broadSearch in method"<<
getMethod().typeName()<<endl;
return false;
}
return true;
}

View File

@ -48,18 +48,6 @@ private:
/// @brief box enclosing the simulation domain (local to processor)
box domainBox_;
/*/// @brief box enclosing the area for contact search (region with points)
box searchBox_;*/
/// @brief update interval in terms of iteration numebr
uint32 updateInterval_= 1;
/// @brief last iteration number which contact search has been performed
uint32 lastUpdated_ = 0;
/// @brief performed search?
bool performedSearch_ = false;
protected:
inline
@ -98,25 +86,6 @@ public:
const deviceViewType1D<real>& diameter,
bool force = false
);
bool performedSearch()const
{
return performedSearch_;
}
bool performSearch(uint32 iter, bool force = false)const
{
if((iter-lastUpdated_) % updateInterval_ == 0 || iter == 0 || force )
{
return true;
}
return false;
}
uint32 updateInterval()const
{
return updateInterval_;
}
real sizeRatio()const
{

View File

@ -165,7 +165,7 @@ public:
{
pOutput<<"Function (hearChanges in boundarySphereInteractions)is not implmented Message "<<
msg <<endl<<" name "<< this->name() <<" type "<< this->type()<<endl;;
msg <<endl<<" name "<< this->boundaryName() <<" type "<< this->type()<<endl;;
//notImplementedFunction;
return true;
}

View File

@ -134,18 +134,22 @@ pFlow::sphereInteraction<cFM,gMM, cLT>::sphereInteraction
geometryMotion_(dynamic_cast<const GeometryMotionModel&>(geom)),
sphParticles_(dynamic_cast<const sphereParticles&>(prtcl)),
boundaryInteraction_(sphParticles_,geometryMotion_),
ppInteractionTimer_("sphere-sphere interaction", &this->timers()),
pwInteractionTimer_("sphere-wall interaction", &this->timers()),
contactListMangementTimer_("contact-list management", &this->timers()),
boundaryContactSearchTimer_("contact search for boundary", &this->timers()),
boundaryInteractionTimer_("interaction for boundary", &this->timers()),
contactListBoundaryTimer_("contact-list management for boundary", &this->timers())
ppInteractionTimer_("sphere-sphere interaction (internal)", &this->timers()),
pwInteractionTimer_("sphere-wall interaction (internal)", &this->timers()),
boundaryInteractionTimer_("sphere-sphere interaction (boundary)",&this->timers()),
contactListMangementTimer_("list management (interal)", &this->timers()),
contactListMangementBoundaryTimer_("list management (boundary)", &this->timers())
{
if(!createSphereInteraction())
{
fatalExit;
}
for(uint32 i=0; i<6; i++)
{
activeBoundaries_[i] = boundaryInteraction_[i].ppPairsAllocated();
}
}
template<typename cFM,typename gMM,template <class, class, class> class cLT>
@ -158,45 +162,55 @@ template<typename cFM,typename gMM,template <class, class, class> class cLT>
bool pFlow::sphereInteraction<cFM,gMM, cLT>::iterate()
{
auto iter = this->currentIter();
auto t = this->currentTime();
auto dt = this->dt();
timeInfo ti = this->TimeInfo();
auto iter = ti.iter();
auto t = ti.t();
auto dt = ti.dt();
bool broadSearch = contactSearch_().enterBroadSearch(iter, t, dt);
auto& contactSearchRef = contactSearch_();
bool broadSearch = contactSearchRef.enterBroadSearch(ti);
bool broadSearchBoundary = contactSearchRef.enterBroadSearchBoundary(ti);
/// update boundaries of the fields that are being used by inreaction
sphParticles_.diameter().updateBoundaries(DataDirection::SlaveToMaster);
sphParticles_.velocity().updateBoundaries(DataDirection::SlaveToMaster);
sphParticles_.rVelocity().updateBoundaries(DataDirection::SlaveToMaster);
sphParticles_.mass().updateBoundaries(DataDirection::SlaveToMaster);
sphParticles_.I().updateBoundaries(DataDirection::SlaveToMaster);
sphParticles_.propertyId().updateBoundaries(DataDirection::SlaveToMaster);
/// lists
if(broadSearch)
{
contactListMangementTimer_.start();
ppContactList_().beforeBroadSearch();
pwContactList_().beforeBroadSearch();
ComputationTimer().start();
ppContactList_().beforeBroadSearch();
pwContactList_().beforeBroadSearch();
ComputationTimer().end();
contactListMangementTimer_.pause();
}
contactListBoundaryTimer_.start();
for(uint32 i=0; i<6u; i++)
if(broadSearchBoundary)
{
auto& BI = boundaryInteraction_[i];
if(BI.ppPairsAllocated()) BI.ppPairs().beforeBroadSearch();
if(BI.pwPairsAllocated()) BI.pwPairs().beforeBroadSearch();
contactListMangementBoundaryTimer_.start();
ComputationTimer().start();
for(uint32 i=0; i<6u; i++)
{
if(activeBoundaries_[i])
{
auto& BI = boundaryInteraction_[i];
BI.ppPairs().beforeBroadSearch();
BI.pwPairs().beforeBroadSearch();
}
}
ComputationTimer().end();
contactListMangementBoundaryTimer_.pause();
}
contactListBoundaryTimer_.pause();
if( sphParticles_.numActive()<=0)return true;
if( !contactSearch_().broadSearch(
iter,
t,
dt,
ComputationTimer().start();
if( !contactSearchRef.broadSearch(
ti,
ppContactList_(),
pwContactList_()) )
{
@ -205,62 +219,64 @@ bool pFlow::sphereInteraction<cFM,gMM, cLT>::iterate()
fatalExit;
}
boundaryContactSearchTimer_.start();
for(uint32 i=0; i<6u; i++)
{
auto& BI =boundaryInteraction_[i];
if(BI.ppPairsAllocated())
if(activeBoundaries_[i])
{
if( !contactSearch_().boundaryBroadSearch(
auto& BI = boundaryInteraction_[i];
if(!contactSearchRef.boundaryBroadSearch(
i,
iter,
t,
dt,
ti,
BI.ppPairs(),
BI.pwPairs()))
BI.pwPairs())
)
{
fatalErrorInFunction<<
"failed to perform broadSearch for boundary index "<<i<<endl;
return false;
}
}
}
}
boundaryContactSearchTimer_.end();
ComputationTimer().end();
if(broadSearch && contactSearch_().performedBroadSearch())
if(broadSearch && contactSearchRef.performedSearch())
{
contactListMangementTimer_.resume();
ppContactList_().afterBroadSearch();
pwContactList_().afterBroadSearch();
ComputationTimer().start();
ppContactList_().afterBroadSearch();
pwContactList_().afterBroadSearch();
ComputationTimer().end();
contactListMangementTimer_.end();
}
contactListBoundaryTimer_.resume();
for(uint32 i=0; i<6u; i++)
if(broadSearchBoundary && contactSearchRef.performedSearchBoundary())
{
auto& BI = boundaryInteraction_[i];
if(BI.ppPairsAllocated()) BI.ppPairs().afterBroadSearch();
if(BI.pwPairsAllocated()) BI.pwPairs().afterBroadSearch();
contactListMangementBoundaryTimer_.resume();
ComputationTimer().start();
for(uint32 i=0; i<6u; i++)
{
if(activeBoundaries_[i])
{
auto& BI = boundaryInteraction_[i];
BI.ppPairs().afterBroadSearch();
BI.pwPairs().afterBroadSearch();
}
}
ComputationTimer().end();
contactListMangementBoundaryTimer_.end();
}
contactListBoundaryTimer_.end();
{
boundaryInteractionTimer_.start();
std::array<bool,6> requireStep{
boundaryInteraction_[0].isBoundaryMaster(),
boundaryInteraction_[1].isBoundaryMaster(),
boundaryInteraction_[2].isBoundaryMaster(),
boundaryInteraction_[3].isBoundaryMaster(),
boundaryInteraction_[4].isBoundaryMaster(),
boundaryInteraction_[5].isBoundaryMaster()};
int step = 1;
/// peform contact search on boundareis with active contact search (master boundaries)
auto requireStep = boundariesMask<6>(true);
const auto& cfModel = this->forceModel_();
while( std::any_of(requireStep.begin(), requireStep.end(), [](bool v) { return v==true; }))
uint32 step=1;
boundaryInteractionTimer_.start();
ComputationTimer().start();
while(requireStep.anyElement(true) && step <= 10)
{
for(uint32 i=0; i<6u; i++)
{
if(step==1u || requireStep[i] )
if(requireStep[i] )
{
requireStep[i] = boundaryInteraction_[i].sphereSphereInteraction(
dt,
@ -271,30 +287,31 @@ bool pFlow::sphereInteraction<cFM,gMM, cLT>::iterate()
}
step++;
}
ComputationTimer().end();
boundaryInteractionTimer_.pause();
}
ppInteractionTimer_.start();
ComputationTimer().start();
sphereSphereInteraction();
ComputationTimer().end();
ppInteractionTimer_.end();
pwInteractionTimer_.start();
ComputationTimer().start();
sphereWallInteraction();
ComputationTimer().start();
pwInteractionTimer_.end();
{
boundaryInteractionTimer_.resume();
std::array<bool,6> requireStep{
!boundaryInteraction_[0].isBoundaryMaster(),
!boundaryInteraction_[1].isBoundaryMaster(),
!boundaryInteraction_[2].isBoundaryMaster(),
!boundaryInteraction_[3].isBoundaryMaster(),
!boundaryInteraction_[4].isBoundaryMaster(),
!boundaryInteraction_[5].isBoundaryMaster()};
ComputationTimer().start();
auto requireStep = boundariesMask<6>(true);
int step = 2;
uint32 step = 11;
const auto& cfModel = this->forceModel_();
while(std::any_of(requireStep.begin(), requireStep.end(), [](bool v) { return v==true; }))
while( requireStep.anyElement(true) && step < 20 )
{
for(uint32 i=0; i<6u; i++)
{
@ -302,13 +319,14 @@ bool pFlow::sphereInteraction<cFM,gMM, cLT>::iterate()
{
requireStep[i] = boundaryInteraction_[i].sphereSphereInteraction(
dt,
this->forceModel_(),
cfModel,
step
);
}
}
step++;
}
ComputationTimer().end();
boundaryInteractionTimer_.end();
}
@ -336,5 +354,4 @@ bool pFlow::sphereInteraction<cFM,gMM, cLT>::hearChanges
notImplementedFunction;
}
return true;
}
}

View File

@ -25,6 +25,8 @@ Licence:
#include "sphereParticles.hpp"
#include "boundarySphereInteractionList.hpp"
#include "sphereInteractionKernels.hpp"
#include "boundariesMask.hpp"
#include "MPITimer.hpp"
//#include "unsortedContactList.hpp"
@ -74,6 +76,9 @@ private:
/// particle-particle and particle-wall interactions at boundaries
BoundaryListType boundaryInteraction_;
/// a mask for active boundaries (boundaries with intreaction)
boundariesMask<6> activeBoundaries_;
/// contact search object for pp and pw interactions
uniquePtr<contactSearch> contactSearch_ = nullptr;
@ -93,14 +98,13 @@ private:
/// timer for particle-wall interaction computations
Timer pwInteractionTimer_;
/// timer for managing contact lists (only inernal points)
Timer contactListMangementTimer_;
Timer boundaryContactSearchTimer_;
/// timer for boundary interaction time
Timer boundaryInteractionTimer_;
Timer contactListBoundaryTimer_;
/// timer for managing contact lists (only inernal points)
Timer contactListMangementTimer_;
Timer contactListMangementBoundaryTimer_;
@ -110,10 +114,6 @@ private:
bool sphereWallInteraction();
//bool managePPContactLists();
//bool managePWContactLists();
/// range policy for p-p interaction execution
using rpPPInteraction =
Kokkos::RangePolicy<Kokkos::IndexType<uint32>, Kokkos::Schedule<Kokkos::Dynamic>>;