boundaryProcessor for dataTransfer

- in boundaryList in afterIteration, data transfer occurs to transfer data between prcocessors
- transferData method is added to boundaryBase
- Some modification to format the output messages in terminal
This commit is contained in:
HRN 2024-05-05 23:05:23 +03:30
parent 97049760c3
commit 0e54e260e6
15 changed files with 99 additions and 38 deletions

View File

@ -76,10 +76,6 @@ public:
*this) *this)
{ {
/*auto method = dict().getVal<word>("method");
auto nbDict = dict().subDict(method+"Info");*/
real minD; real minD;
real maxD; real maxD;
this->Particles().boundingSphereMinMax(minD, maxD); this->Particles().boundingSphereMinMax(minD, maxD);
@ -110,9 +106,6 @@ public:
wVertices, wVertices,
wNormals wNormals
); );
REPORT(2)<<"Contact search algorithm for particle-particle is "<<
Green_Text(ppwContactSearch_().typeName())<<END_REPORT;
} }

View File

@ -50,13 +50,13 @@ pFlow::boundaryContactSearch::create(
if( boundaryBasevCtorSelector_.search(bType) ) if( boundaryBasevCtorSelector_.search(bType) )
{ {
REPORT(2)<<"Creating contact search boundary "<< Green_Text(bType)<< pOutput.space(4)<<"Creating contact search boundary "<< Green_Text(bType)<<
" for "<<boundary.name()<<endl; " for "<<boundary.name()<<endl;
return boundaryBasevCtorSelector_[bType](dict, boundary, cSearch); return boundaryBasevCtorSelector_[bType](dict, boundary, cSearch);
} }
else if(boundaryBasevCtorSelector_.search(altBType)) else if(boundaryBasevCtorSelector_.search(altBType))
{ {
REPORT(2)<<"Creating contact search boundary "<< Green_Text(altBType)<< pOutput.space(4)<<"Creating contact search boundary "<< Green_Text(altBType)<<
" for "<<boundary.name()<<endl; " for "<<boundary.name()<<endl;
return boundaryBasevCtorSelector_[altBType](dict, boundary, cSearch); return boundaryBasevCtorSelector_[altBType](dict, boundary, cSearch);
} }

View File

@ -56,12 +56,10 @@ pFlow::uniquePtr<pFlow::contactSearch> pFlow::contactSearch::create(
auto model = angleBracketsNames("ContactSearch", baseMethName); auto model = angleBracketsNames("ContactSearch", baseMethName);
REPORT(1)<<"Selecting contact search model . . ."<<END_REPORT; pOutput.space(2)<<"Selecting contact search model "<<Green_Text(model)<<endl;
if( dictionaryvCtorSelector_.search(model)) if( dictionaryvCtorSelector_.search(model))
{ {
auto objPtr = dictionaryvCtorSelector_[model] (dict, extDomain, prtcl, geom, timers); auto objPtr = dictionaryvCtorSelector_[model] (dict, extDomain, prtcl, geom, timers);
REPORT(2)<<"Model "<< Green_Text(model)<<" is created."<< END_REPORT;
return objPtr; return objPtr;
} }
else else

View File

@ -71,15 +71,14 @@ pFlow::uniquePtr<pFlow::interaction> pFlow::interaction::create
clType); clType);
gSettings::sleepMiliSeconds(
REPORT(1)<<"Creating interaction "<<Green_Text(interactionModel)<<" . . ."<<END_REPORT; 1000*(pFlowProcessors().localSize()-pFlowProcessors().localRank()-1));
pOutput.space(2)<<"Creating interaction "<<Green_Text(interactionModel)<<" . . ."<<END_REPORT;
if( systemControlvCtorSelector_.search(interactionModel) ) if( systemControlvCtorSelector_.search(interactionModel) )
{ {
auto objPtr = auto objPtr =
systemControlvCtorSelector_[interactionModel] systemControlvCtorSelector_[interactionModel]
(control, prtcl, geom); (control, prtcl, geom);
return objPtr; return objPtr;
} }
else else

View File

@ -56,7 +56,7 @@ pFlow::boundarySphereInteraction<cFM, gMM>::create(
if (boundaryBasevCtorSelector_.search(boundaryTypeName)) if (boundaryBasevCtorSelector_.search(boundaryTypeName))
{ {
REPORT(2) << "Creating boundry type " << Green_Text(boundaryTypeName) << pOutput.space(4) << "Creating boundry type " << Green_Text(boundaryTypeName) <<
" for boundary " << boundary.name() << " . . ." << END_REPORT; " for boundary " << boundary.name() << " . . ." << END_REPORT;
return boundaryBasevCtorSelector_[boundaryTypeName]( return boundaryBasevCtorSelector_[boundaryTypeName](
boundary, boundary,
@ -67,7 +67,7 @@ pFlow::boundarySphereInteraction<cFM, gMM>::create(
{ {
// if boundary condition is not implemented, the default is used // if boundary condition is not implemented, the default is used
REPORT(2) << "Creating boundry type " << Green_Text(altBTypeName) << pOutput.space(4) << "Creating boundry type " << Green_Text(altBTypeName) <<
" for boundary " << boundary.name() << " . . ." << END_REPORT; " for boundary " << boundary.name() << " . . ." << END_REPORT;
return boundaryBasevCtorSelector_[altBTypeName]( return boundaryBasevCtorSelector_[altBTypeName](
boundary, boundary,

View File

@ -10,7 +10,7 @@ pFlow::boundarySphereInteractionList<CFModel, gMModel>::boundarySphereInteractio
ListPtr<boundarySphereInteraction<CFModel,gMModel>>(6), ListPtr<boundarySphereInteraction<CFModel,gMModel>>(6),
boundaries_(sphPrtcls.pStruct().boundaries()) boundaries_(sphPrtcls.pStruct().boundaries())
{ {
//gSettings::sleepMiliSeconds(1000*pFlowProcessors().localRank());
for(uint32 i=0; i<6; i++) for(uint32 i=0; i<6; i++)
{ {
this->set( this->set(

View File

@ -26,7 +26,6 @@ bool pFlow::sphereInteraction<cFM,gMM, cLT>::createSphereInteraction()
auto modelDict = this->subDict("model"); auto modelDict = this->subDict("model");
REPORT(1)<<"Createing contact force model . . ."<<END_REPORT;
forceModel_ = makeUnique<ContactForceModel>( forceModel_ = makeUnique<ContactForceModel>(
this->numMaterials(), this->numMaterials(),
rhoD.deviceView(), rhoD.deviceView(),
@ -46,8 +45,6 @@ bool pFlow::sphereInteraction<cFM,gMM, cLT>::createSphereInteraction()
pwContactList_ = makeUnique<ContactListType>(nPrtcl/5+1); pwContactList_ = makeUnique<ContactListType>(nPrtcl/5+1);
return true; return true;
} }

View File

@ -47,13 +47,15 @@ public:
BNDR_TRANSFER = 9, // boundary indices transfered BNDR_TRANSFER = 9, // boundary indices transfered
BNDR_RESET = 10, // boundary indices reset entirely BNDR_RESET = 10, // boundary indices reset entirely
BNDR_DELETE = 11, // boundary indices deleted BNDR_DELETE = 11, // boundary indices deleted
BNDR_APPEND = 12 BNDR_APPEND = 12, //
BNDR_PROCTRANS1 = 13, // transfer of data between processors step 1
BNDR_PROCTRANS2 = 14 // transfer of data between processors step 2
}; };
private: private:
static constexpr size_t numberOfEvents_ = 13; static constexpr size_t numberOfEvents_ = 15;
std::bitset<numberOfEvents_> events_{0x0000}; std::bitset<numberOfEvents_> events_{0x0000};
@ -72,7 +74,9 @@ private:
"transferredIndices", "transferredIndices",
"", "",
"deletedIndices", "deletedIndices",
"appendedIndices" "appendedIndices",
"transferredIndices",
"numberRecieved"
}; };
public: public:

View File

@ -1,6 +1,14 @@
#include <chrono>
#include <thread>
#include "globalSettings.hpp" #include "globalSettings.hpp"
const double pFlow::gSettings::vectorGrowthFactor__ = 1.1; const double pFlow::gSettings::vectorGrowthFactor__ = 1.1;
void pFlow::gSettings::sleepMiliSeconds(int miliSeconds)
{
std::this_thread::sleep_for(std::chrono::milliseconds(miliSeconds));
}

View File

@ -28,6 +28,8 @@ namespace pFlow::gSettings
extern const double vectorGrowthFactor__; extern const double vectorGrowthFactor__;
void sleepMiliSeconds(int miliSeconds);
} }

View File

@ -98,15 +98,11 @@ bool pFlow::boundaryBase::removeIndices
keepIndices keepIndices
); );
if(!internal_.deletePoints(removeIndices)) if(!setRemoveKeepIndices(removeIndices, keepIndices))
{ {
fatalErrorInFunction<<
"error in deleting points from boundary "<< name()<<endl;
return false; return false;
} }
setNewIndices(keepIndices);
anyList aList; anyList aList;
aList.emplaceBack( aList.emplaceBack(
@ -129,6 +125,25 @@ bool pFlow::boundaryBase::removeIndices
return true; return true;
} }
bool pFlow::boundaryBase::setRemoveKeepIndices
(
const uint32Vector_D &removeIndices,
const uint32Vector_D &keepIndices
)
{
if(!internal_.deletePoints(removeIndices))
{
fatalErrorInFunction<<
"error in deleting points from boundary "<< name()<<endl;
return false;
}
setNewIndices(keepIndices);
return true;
}
bool pFlow::boundaryBase::transferPoints bool pFlow::boundaryBase::transferPoints
( (
uint32 numTransfer, uint32 numTransfer,

View File

@ -102,6 +102,10 @@ protected:
uint32 numRemove, uint32 numRemove,
const uint32Vector_D& removeMask); const uint32Vector_D& removeMask);
bool setRemoveKeepIndices(
const uint32Vector_D& removeIndices,
const uint32Vector_D& keepIndices);
bool transferPoints( bool transferPoints(
uint32 numTransfer, uint32 numTransfer,
const uint32Vector_D& transferMask, const uint32Vector_D& transferMask,
@ -134,6 +138,18 @@ protected:
return true; return true;
} }
/// @brief This method is called when a transfer of data
/// is to be performed between processors (in afterIteration).
/// @param step is the step in the transfer of data.
/// @return true: if operation requires at least one additional step
/// to complete. false: if the operation is complete and no need for
/// additional step in operation.
virtual
bool transferData(int step)
{
return false;
}
public: public:
TypeInfo("boundaryBase"); TypeInfo("boundaryBase");

View File

@ -67,14 +67,26 @@ void pFlow::boundaryBaseKernels::createRemoveKeepIndices
uint32 numRemove, uint32 numRemove,
const uint32Vector_D& removeMask, const uint32Vector_D& removeMask,
uint32Vector_D& removeIndices, uint32Vector_D& removeIndices,
uint32Vector_D& keepIndices uint32Vector_D& keepIndices,
bool exactCap
) )
{ {
uint32 numTotal = indices.size(); uint32 numTotal = indices.size();
uint32 numKeep = numTotal - numRemove; uint32 numKeep = numTotal - numRemove;
if(exactCap)
{
removeIndices.reallocate(numRemove, numRemove);
keepIndices.reallocate(numKeep, numKeep);
}
else
{
removeIndices.clear();
removeIndices.resize(numRemove);
keepIndices.clear();
keepIndices.resize(numKeep);
}
removeIndices.reallocate(numRemove, numRemove);
keepIndices.reallocate(numKeep, numKeep);
auto maskD = removeMask.deviceViewAll(); auto maskD = removeMask.deviceViewAll();
const auto& removeD = removeIndices.deviceViewAll(); const auto& removeD = removeIndices.deviceViewAll();

View File

@ -38,7 +38,8 @@ void createRemoveKeepIndices(
uint32 numRemove, uint32 numRemove,
const uint32Vector_D& removeMask, const uint32Vector_D& removeMask,
uint32Vector_D& removeIndices, uint32Vector_D& removeIndices,
uint32Vector_D& keepIndices); uint32Vector_D& keepIndices,
bool exactCap = true);
} }

View File

@ -205,7 +205,23 @@ pFlow::boundaryList::iterate(uint32 iter, real t, real dt)
bool bool
pFlow::boundaryList::afterIteration(uint32 iter, real t, real dt) pFlow::boundaryList::afterIteration(uint32 iter, real t, real dt)
{ {
for (auto& bdry : *this)
std::array<bool,6> requireStep{true, true, true, true, true, true};
int step = 1;
while(std::any_of(requireStep.begin(), requireStep.end(), [](bool v) { return v==true; }))
{
for(auto i=0uL; i<6; i++)
{
if(requireStep[i])
{
requireStep[i] = this->operator[](i).transferData(step);
}
}
step++;
}
/*for (auto& bdry : *this)
{ {
if (!bdry->afterIteration(iter, t, dt)) if (!bdry->afterIteration(iter, t, dt))
{ {
@ -213,6 +229,6 @@ pFlow::boundaryList::afterIteration(uint32 iter, real t, real dt)
<< bdry->name() << endl; << bdry->name() << endl;
return false; return false;
} }
} }*/
return true; return true;
} }