Merge branch 'develop' into MPIdev

This commit is contained in:
Hamidreza Norouzi
2024-05-18 19:14:01 +03:30
111 changed files with 2006 additions and 703 deletions

View File

@ -7,8 +7,8 @@ contactSearch/methods/cellBased/NBS/NBS.cpp
contactSearch/methods/cellBased/NBS/cellsWallLevel0.cpp
contactSearch/boundaries/boundaryContactSearch/boundaryContactSearch.cpp
contactSearch/boundaries/twoPartContactSearch/twoPartContactSearchKernels.cpp
contactSearch/boundaries/twoPartContactSearch/twoPartContactSearch.cpp
#contactSearch/boundaries/twoPartContactSearch/twoPartContactSearchKernels.cpp
#contactSearch/boundaries/twoPartContactSearch/twoPartContactSearch.cpp
contactSearch/boundaries/periodicBoundaryContactSearch/ppwBndryContactSearchKernels.cpp
contactSearch/boundaries/periodicBoundaryContactSearch/ppwBndryContactSearch.cpp
contactSearch/boundaries/periodicBoundaryContactSearch/wallBoundaryContactSearch.cpp

View File

@ -138,7 +138,7 @@ public:
start,
end,
newPair);
idx0!=-1)
idx0!=static_cast<uint32>(-1))
{
values_[idx] = values0_[idx0];
}
@ -147,7 +147,7 @@ public:
start,
end,
newPair);
idx0!=-1)
idx0!= static_cast<uint32>(-1) )
{
values_[idx] = values0_[idx0];

View File

@ -95,7 +95,8 @@ public:
// swap conainer and values
swapViews(values0_, values_);
swapViews(container0_, this->container_);
return UnsortedPairs::beforeBroadSearch();
UnsortedPairs::beforeBroadSearch();
return true;
}
bool afterBroadSearch()
@ -110,7 +111,7 @@ public:
rpFillPairs(0,this->capacity()),
*this);
Kokkos::fence();
return true;
}
@ -123,7 +124,7 @@ public:
INLINE_FUNCTION_HD
bool getValue(const PairType& p, ValueType& val)const
{
if(auto idx = this->find(p); idx!=-1)
if(auto idx = this->find(p); idx!=static_cast<uint32>(-1))
{
val = getValue(idx);
return true;
@ -140,7 +141,7 @@ public:
INLINE_FUNCTION_HD
bool setValue(const PairType& p, const ValueType& val)const
{
if(uint32 idx = this->find(p); idx!=-1)
if(uint32 idx = this->find(p); idx!=static_cast<uint32>(-1))
{
setValue(idx, val);
return true;;
@ -155,7 +156,7 @@ public:
{
if( uint32 idx0 =
container0_.find(this->getPair(idx));
idx0!=-1 )
idx0!= static_cast<uint32>(-1) )
{
values_[idx] = values0_[idx0];
}

View File

@ -105,7 +105,7 @@ public:
uint32 insert(idType i, idType j)const
{
if(auto insertResult = container_.insert(PairType(i,j)); insertResult.failed())
return -1;
return static_cast<uint32>(-1);
else
return insertResult.index();
@ -115,7 +115,7 @@ public:
uint32 insert(const PairType& p)const
{
if(auto insertResult = container_.insert(p); insertResult.failed())
return -1;
return static_cast<uint32>(-1);
else
return insertResult.index();
@ -154,7 +154,7 @@ public:
idx != Kokkos::UnorderedMapInvalidIndex )
return idx;
else
return -1;
return static_cast<uint32>(-1);
}
INLINE_FUNCTION_HD

View File

@ -160,7 +160,8 @@ public:
csPairContainerType& pwPairs,
bool force = false)override
{
Particles().boundingSphere().updateBoundaries(DataDirection::SlaveToMaster);
if(i==0u)
Particles().boundingSphere().updateBoundaries(DataDirection::SlaveToMaster);
return csBoundaries_[i].broadSearch(
iter,
t,
@ -183,6 +184,23 @@ public:
{
return ppwContactSearch_().performedSearch();
}
uint32 updateInterval()const override
{
return ppwContactSearch_().updateInterval();
}
real sizeRatio()const override
{
return ppwContactSearch_().sizeRatio();
}
real cellExtent()const override
{
return ppwContactSearch_().cellExtent();
}
};

View File

@ -72,11 +72,6 @@ public:
return contactSearch_;
}
void fill(const std::any &val) override
{
return;
}
bool hearChanges(
real t,
real dt,

View File

@ -80,14 +80,14 @@ pFlow::uint32 pFlow::pweBndryContactSearchKernels::broadSearchPP
if(!searchCells.inCellRange(ind))continue;
uint32 thisI = head(ind.x(),ind.y(),ind.z());
while (thisI!=-1)
while (thisI!=static_cast<uint32>(-1))
{
auto d_n = sizeRatio*diams[thisI];
// first item is for this boundary and second itme, for mirror
if(sphereSphereCheckB(p_m, points[thisI], d_m, d_n)&&
ppPairs.insert(thisI,mrrI) == -1)
ppPairs.insert(thisI,mrrI) == static_cast<uint32>(-1))
{
getFullUpdate++;
}

View File

@ -113,7 +113,10 @@ pFlow::uint32 pFlow::wallBoundaryContactSearch::findPairsElementRangeCount
uint32 nNotInserted = 0;
uint32 nThis = pPoints.size();
const auto& numElements = numElements_;
const auto& elementBox = elementBox_;
const auto& validBox = validBox_;
Kokkos::parallel_reduce(
"pFlow::wallBoundaryContactSearch::findPairsElementRangeCount",
deviceRPolicyDynamic(0,nThis),
@ -123,11 +126,11 @@ pFlow::uint32 pFlow::wallBoundaryContactSearch::findPairsElementRangeCount
int32x3 ind;
if( searchCells.pointIndexInDomain(p, ind) )
{
for(uint32 nTri=0; nTri<numElements_; nTri++)
for(uint32 nTri=0; nTri<numElements; nTri++)
{
if( validBox_[nTri]== 0)continue;
if( elementBox_[nTri].isInside(ind)&&
pairs.insert(i,nTri+baseTriIndex) == -1)
if( validBox[nTri]== 0)continue;
if( elementBox[nTri].isInside(ind)&&
pairs.insert(i,nTri+baseTriIndex) == static_cast<uint32>(-1))
{
notInsertedUpdate++;
}

View File

@ -140,6 +140,15 @@ public:
virtual
bool performedBroadSearch()const = 0;
virtual
uint32 updateInterval()const = 0;
virtual
real sizeRatio()const = 0;
virtual
real cellExtent()const = 0;
static
uniquePtr<contactSearch> create(
const dictionary& dict,

View File

@ -134,6 +134,16 @@ public:
{
return 1;
}
real sizeRatio()const
{
return sizeRatio_;
}
real cellExtent()const
{
return cellExtent_;
}
auto getCellIterator([[maybe_unused]] uint32 lvl)const
{

View File

@ -43,7 +43,7 @@ while( m != mapperNBS::NoPos)
auto lm = m;
if(lm>ln) Swap(lm,ln);
if( pairs.insert(lm,ln) == -1)
if( pairs.insert(lm,ln) == static_cast<uint32>(-1))
{
getFullUpdate++;
}
@ -86,7 +86,7 @@ while( m != mapperNBS::NoPos)
auto ln = n;
auto lm = m;
if(lm>ln) Swap(lm,ln);
if( pairs.insert(lm,ln) == -1)
if( pairs.insert(lm,ln) == static_cast<uint32>(-1))
{
getFullUpdate++;
}

View File

@ -85,21 +85,26 @@ bool pFlow::cellsWallLevel0::broadSearch
bool pFlow::cellsWallLevel0::build(const cells & searchBox)
{
const auto& points = points_;
const auto& vertices = vertices_;
const auto& elementBox = elementBox_;
const auto cellExtent = cellExtent_;
Kokkos::parallel_for(
"pFlow::cellsWallLevel0::build",
deviceRPolicyStatic(0,numElements_),
CLASS_LAMBDA_HD(uint32 i)
LAMBDA_HD(uint32 i)
{
auto v = vertices_[i];
auto p1 = points_[v.x()];
auto p2 = points_[v.y()];
auto p3 = points_[v.z()];
auto v = vertices[i];
auto p1 = points[v.x()];
auto p2 = points[v.y()];
auto p3 = points[v.z()];
realx3 minP;
realx3 maxP;
searchBox.extendBox(p1, p2, p3, cellExtent_, minP, maxP);
elementBox_[i] = iBoxType(searchBox.pointIndex(minP), searchBox.pointIndex(maxP));
searchBox.extendBox(p1, p2, p3, cellExtent, minP, maxP);
elementBox[i] = iBoxType(searchBox.pointIndex(minP), searchBox.pointIndex(maxP));
});
Kokkos::fence();
@ -153,7 +158,12 @@ pFlow::int32 pFlow::cellsWallLevel0::findPairsElementRangeCount
{
uint32 getFull =0;
const auto& elementBox = elementBox_;
const auto& normals = normals_;
const auto& points = points_;
const auto& vertices = vertices_;
const auto cellExtent = cellExtent_;
Kokkos::parallel_reduce(
"pFlow::cellsWallLevel0::findPairsElementRangeCount",
tpPWContactSearch(numElements_, Kokkos::AUTO),
@ -163,10 +173,10 @@ pFlow::int32 pFlow::cellsWallLevel0::findPairsElementRangeCount
const uint32 iTri = teamMember.league_rank();
const auto triBox = elementBox_[iTri];
const auto triBox = elementBox[iTri];
const auto triPlane = infinitePlane(
normals_[iTri],
points_[vertices_[iTri].x()]);
normals[iTri],
points[vertices[iTri].x()]);
uint32 getFull2 = 0;
@ -186,11 +196,12 @@ pFlow::int32 pFlow::cellsWallLevel0::findPairsElementRangeCount
while( n != particleMap.NoPos)
{
// id is wall id the pair is (particle id, wall id)
if( abs(triPlane.pointFromPlane(pPoints[n]))< pDiams[n]*sizeRatio*cellExtent_)
if( abs(triPlane.pointFromPlane(pPoints[n]))< pDiams[n]*sizeRatio*cellExtent)
{
if( pairs.insert(
static_cast<csIdType>(n),
static_cast<csIdType>(iTri) ) == -1 )
static_cast<csIdType>(iTri) ) == static_cast<csIdType>(-1)
)
innerUpdate++;
}
n = particleMap.next(n);

View File

@ -113,6 +113,21 @@ public:
return false;
}
uint32 updateInterval()const
{
return updateInterval_;
}
real sizeRatio()const
{
return getMethod().sizeRatio();
}
real cellExtent()const
{
return getMethod().cellExtent();
}
};

View File

@ -72,7 +72,7 @@ pFlow::uniquePtr<pFlow::interaction> pFlow::interaction::create
gSettings::sleepMiliSeconds(
1000*(pFlowProcessors().localSize()-pFlowProcessors().localRank()-1));
100*(pFlowProcessors().localSize()-pFlowProcessors().localRank()-1));
pOutput.space(2)<<"Creating interaction "<<Green_Text(interactionModel)<<" . . ."<<END_REPORT;
if( systemControlvCtorSelector_.search(interactionModel) )
{

View File

@ -1,3 +1,4 @@
#include "boundarySphereInteraction.hpp"
/*------------------------------- phasicFlow ---------------------------------
O C enter of
O O E ngineering and
@ -18,6 +19,20 @@ Licence:
-----------------------------------------------------------------------------*/
template <typename cFM, typename gMM>
void pFlow::boundarySphereInteraction<cFM, gMM>::allocatePPPairs()
{
ppPairs_.reset(nullptr);
ppPairs_ = makeUnique<ContactListType>(1);
}
template <typename cFM, typename gMM>
void pFlow::boundarySphereInteraction<cFM, gMM>::allocatePWPairs()
{
pwPairs_.reset(nullptr);
pwPairs_ = makeUnique<ContactListType>(1);
}
template <typename cFM, typename gMM>
pFlow::boundarySphereInteraction<cFM, gMM>::boundarySphereInteraction(
@ -28,8 +43,6 @@ pFlow::boundarySphereInteraction<cFM, gMM>::boundarySphereInteraction(
geometryMotion_(geomMotion),
sphParticles_(sphPrtcls)
{
ppPairs_ = makeUnique<ContactListType>(1);
pwPairs_ = makeUnique<ContactListType>(1);
}
template <typename cFM, typename gMM>

View File

@ -22,7 +22,7 @@ Licence:
#include "virtualConstructor.hpp"
#include "generalBoundary.hpp"
#include "unsortedContactList.hpp"
#include "sortedContactList.hpp"
#include "sphereParticles.hpp"
namespace pFlow
@ -51,7 +51,7 @@ public:
using IndexType = uint32;
using ContactListType =
unsortedContactList<ModelStorage, DefaultExecutionSpace, IdType>;
sortedContactList<ModelStorage, DefaultExecutionSpace, IdType>;
private:
@ -60,9 +60,15 @@ private:
/// const reference to sphere particles
const sphereParticles& sphParticles_;
uniquePtr<ContactListType> ppPairs_;
uniquePtr<ContactListType> ppPairs_ = nullptr;
uniquePtr<ContactListType> pwPairs_;
uniquePtr<ContactListType> pwPairs_ = nullptr;
protected:
void allocatePPPairs();
void allocatePWPairs();
public:
@ -124,15 +130,30 @@ public:
return pwPairs_();
}
bool ppPairsAllocated()const
{
if( ppPairs_)return true;
return false;
}
bool pwPairsAllocated()const
{
if( pwPairs_)return true;
return false;
}
virtual
bool sphereSphereInteraction(
real dt,
const ContactForceModel& cfModel)
const ContactForceModel& cfModel,
uint32 step)
{
// for default boundary, no thing to be done
return true;
return false;
}
bool hearChanges
(
real t,
@ -149,11 +170,6 @@ public:
return true;
}
void fill(const std::any& val)override
{
notImplementedFunction;
}
static
uniquePtr<BoundarySphereInteractionType> create(
const boundaryBase& boundary,

View File

@ -30,7 +30,10 @@ pFlow::periodicBoundarySphereInteraction<cFM, gMM>::periodicBoundarySphereIntera
{
if(boundary.thisBoundaryIndex()%2==1)
{
masterInteraction_ = true;
masterInteraction_ = true;
this->allocatePPPairs();
this->allocatePWPairs();
}
else
{
@ -42,10 +45,11 @@ template <typename cFM, typename gMM>
bool pFlow::periodicBoundarySphereInteraction<cFM, gMM>::sphereSphereInteraction
(
real dt,
const ContactForceModel &cfModel
const ContactForceModel &cfModel,
uint32 step
)
{
if(!masterInteraction_) return true;
if(!masterInteraction_) return false;
pFlow::periodicBoundarySIKernels::sphereSphereInteraction(
dt,
@ -61,5 +65,5 @@ bool pFlow::periodicBoundarySphereInteraction<cFM, gMM>::sphereSphereInteraction
this->sphParticles().contactForce().deviceViewAll(),
this->sphParticles().contactTorque().deviceViewAll());
return true;
return false;
}

View File

@ -83,7 +83,8 @@ public:
bool sphereSphereInteraction(
real dt,
const ContactForceModel& cfModel)override;
const ContactForceModel& cfModel,
uint32 step)override;
};

View File

@ -137,7 +137,9 @@ pFlow::sphereInteraction<cFM,gMM, cLT>::sphereInteraction
ppInteractionTimer_("sphere-sphere interaction", &this->timers()),
pwInteractionTimer_("sphere-wall interaction", &this->timers()),
contactListMangementTimer_("contact-list management", &this->timers()),
boundaryInteractionTimer_("interaction for boundary", &this->timers())
boundaryContactSearchTimer_("contact search for boundary", &this->timers()),
boundaryInteractionTimer_("interaction for boundary", &this->timers()),
contactListBoundaryTimer_("contact-list management for boundary", &this->timers())
{
if(!createSphereInteraction())
@ -179,11 +181,14 @@ bool pFlow::sphereInteraction<cFM,gMM, cLT>::iterate()
contactListMangementTimer_.pause();
}
contactListBoundaryTimer_.start();
for(uint32 i=0; i<6u; i++)
{
boundaryInteraction_[i].ppPairs().beforeBroadSearch();
boundaryInteraction_[i].pwPairs().beforeBroadSearch();
auto& BI = boundaryInteraction_[i];
if(BI.ppPairsAllocated()) BI.ppPairs().beforeBroadSearch();
if(BI.pwPairsAllocated()) BI.pwPairs().beforeBroadSearch();
}
contactListBoundaryTimer_.pause();
if( sphParticles_.numActive()<=0)return true;
@ -200,21 +205,27 @@ bool pFlow::sphereInteraction<cFM,gMM, cLT>::iterate()
fatalExit;
}
boundaryContactSearchTimer_.start();
for(uint32 i=0; i<6u; i++)
{
if( !contactSearch_().boundaryBroadSearch(
i,
iter,
t,
dt,
boundaryInteraction_[i].ppPairs(),
boundaryInteraction_[i].pwPairs()))
auto& BI =boundaryInteraction_[i];
if(BI.ppPairsAllocated())
{
fatalErrorInFunction<<
"failed to perform broadSearch for boundary index "<<i<<endl;
return false;
}
if( !contactSearch_().boundaryBroadSearch(
i,
iter,
t,
dt,
BI.ppPairs(),
BI.pwPairs()))
{
fatalErrorInFunction<<
"failed to perform broadSearch for boundary index "<<i<<endl;
return false;
}
}
}
boundaryContactSearchTimer_.end();
if(broadSearch && contactSearch_().performedBroadSearch())
{
@ -224,12 +235,44 @@ bool pFlow::sphereInteraction<cFM,gMM, cLT>::iterate()
contactListMangementTimer_.end();
}
contactListBoundaryTimer_.resume();
for(uint32 i=0; i<6u; i++)
{
boundaryInteraction_[i].ppPairs().afterBroadSearch();
boundaryInteraction_[i].pwPairs().afterBroadSearch();
auto& BI = boundaryInteraction_[i];
if(BI.ppPairsAllocated()) BI.ppPairs().afterBroadSearch();
if(BI.pwPairsAllocated()) BI.pwPairs().afterBroadSearch();
}
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;
const auto& cfModel = this->forceModel_();
while( std::any_of(requireStep.begin(), requireStep.end(), [](bool v) { return v==true; }))
{
for(uint32 i=0; i<6u; i++)
{
if(step==1u || requireStep[i] )
{
requireStep[i] = boundaryInteraction_[i].sphereSphereInteraction(
dt,
this->forceModel_(),
step
);
}
}
step++;
}
boundaryInteractionTimer_.pause();
}
ppInteractionTimer_.start();
sphereSphereInteraction();
ppInteractionTimer_.end();
@ -239,14 +282,36 @@ bool pFlow::sphereInteraction<cFM,gMM, cLT>::iterate()
sphereWallInteraction();
pwInteractionTimer_.end();
boundaryInteractionTimer_.start();
for(uint32 i=0; i<6u; i++)
{
boundaryInteraction_[i].sphereSphereInteraction(
dt,
this->forceModel_());
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()};
int step = 2;
const auto& cfModel = this->forceModel_();
while(std::any_of(requireStep.begin(), requireStep.end(), [](bool v) { return v==true; }))
{
for(uint32 i=0; i<6u; i++)
{
if(requireStep[i])
{
requireStep[i] = boundaryInteraction_[i].sphereSphereInteraction(
dt,
this->forceModel_(),
step
);
}
}
step++;
}
boundaryInteractionTimer_.end();
}
return true;
}

View File

@ -96,9 +96,12 @@ private:
/// timer for managing contact lists (only inernal points)
Timer contactListMangementTimer_;
Timer boundaryContactSearchTimer_;
/// timer for boundary interaction time
Timer boundaryInteractionTimer_;
Timer contactListBoundaryTimer_;
bool createSphereInteraction();

View File

@ -261,7 +261,7 @@ struct pwInteractionFunctor
int32 propId_i = propId_[i];
int32 wPropId_j = wPropId_[tj];
realx3 FCn, FCt, Mri, Mrj, Mij, Mji;
realx3 FCn, FCt, Mri, Mrj, Mij;
//output<< "before "<<history.overlap_t_<<endl;
// calculates contact force
forceModel_.contactForce(