Interaction folder is finalized with adjustable box and tested for rotating drum

This commit is contained in:
Hamidreza Norouzi
2024-03-24 01:46:19 -07:00
parent be56d8ee2e
commit d21b7276e1
48 changed files with 2252 additions and 3260 deletions

View File

@ -18,22 +18,18 @@ Licence:
-----------------------------------------------------------------------------*/
template<
typename contactForceModel,
typename geometryMotionModel,
template <class, class, class> class contactListType >
bool pFlow::sphereInteraction<contactForceModel,geometryMotionModel, contactListType>::
createSphereInteraction()
template<typename cFM,typename gMM,template <class, class, class> class cLT>
bool pFlow::sphereInteraction<cFM,gMM, cLT>::createSphereInteraction()
{
realVector_D rhoD(this->densities());
realVector_D rhoD("densities", this->densities());
auto modelDict = this->fileDict().subDict("model");
auto modelDict = this->subDict("model");
REPORT(1)<<"Createing contact force model . . ."<<endREPORT;
REPORT(1)<<"Createing contact force model . . ."<<END_REPORT;
forceModel_ = makeUnique<ContactForceModel>(
this->numMaterials(),
rhoD.deviceVector(),
rhoD.deviceView(),
modelDict );
@ -47,17 +43,9 @@ bool pFlow::sphereInteraction<contactForceModel,geometryMotionModel, contactList
}
template<
typename contactForceModel,
typename geometryMotionModel,
template <class, class, class> class contactListType >
bool pFlow::sphereInteraction<contactForceModel,geometryMotionModel, contactListType>::
sphereSphereInteraction()
template<typename cFM,typename gMM,template <class, class, class> class cLT>
bool pFlow::sphereInteraction<cFM,gMM, cLT>::sphereSphereInteraction()
{
auto lastItem = ppContactList_().loopCount();
// create the kernel functor
@ -66,17 +54,17 @@ bool pFlow::sphereInteraction<contactForceModel,geometryMotionModel, contactList
this->dt(),
this->forceModel_(),
ppContactList_(), // to be read
sphParticles_.diameter().deviceVectorAll(),
sphParticles_.propertyId().deviceVectorAll(),
sphParticles_.pointPosition().deviceVectorAll(),
sphParticles_.velocity().deviceVectorAll(),
sphParticles_.rVelocity().deviceVectorAll(),
sphParticles_.contactForce().deviceVectorAll(),
sphParticles_.contactTorque().deviceVectorAll()
sphParticles_.diameter().deviceViewAll(),
sphParticles_.propertyId().deviceViewAll(),
sphParticles_.pointPosition().deviceViewAll(),
sphParticles_.velocity().deviceViewAll(),
sphParticles_.rVelocity().deviceViewAll(),
sphParticles_.contactForce().deviceViewAll(),
sphParticles_.contactTorque().deviceViewAll()
);
Kokkos::parallel_for(
"",
"ppInteraction",
rpPPInteraction(0,lastItem),
ppInteraction
);
@ -87,34 +75,32 @@ bool pFlow::sphereInteraction<contactForceModel,geometryMotionModel, contactList
}
template<
typename contactForceModel,
typename geometryMotionModel,
template <class, class, class> class contactListType >
bool pFlow::sphereInteraction<contactForceModel,geometryMotionModel, contactListType>::
sphereWallInteraction()
template<typename cFM,typename gMM,template <class, class, class> class cLT>
bool pFlow::sphereInteraction<cFM,gMM, cLT>::sphereWallInteraction()
{
int32 lastItem = pwContactList_().loopCount();
uint32 lastItem = pwContactList_().loopCount();
uint32 iter = this->currentIter();
real t = this->currentTime();
real dt = this->dt();
pFlow::sphereInteractionKernels::pwInteractionFunctor
pwInteraction(
this->dt(),
dt,
this->forceModel_(),
pwContactList_(),
geometryMotion_.getTriangleAccessor(),
geometryMotion_.getModel(t) ,
sphParticles_.diameter().deviceVectorAll() ,
sphParticles_.propertyId().deviceVectorAll(),
sphParticles_.pointPosition().deviceVectorAll(),
sphParticles_.velocity().deviceVectorAll(),
sphParticles_.rVelocity().deviceVectorAll() ,
sphParticles_.contactForce().deviceVectorAll(),
sphParticles_.contactTorque().deviceVectorAll() ,
geometryMotion_.triMotionIndex().deviceVectorAll(),
geometryMotion_.propertyId().deviceVectorAll(),
geometryMotion_.contactForceWall().deviceVectorAll()
geometryMotion_.getModel(iter, t, dt) ,
sphParticles_.diameter().deviceViewAll() ,
sphParticles_.propertyId().deviceViewAll(),
sphParticles_.pointPosition().deviceViewAll(),
sphParticles_.velocity().deviceViewAll(),
sphParticles_.rVelocity().deviceViewAll() ,
sphParticles_.contactForce().deviceViewAll(),
sphParticles_.contactTorque().deviceViewAll() ,
geometryMotion_.triMotionIndex().deviceViewAll(),
geometryMotion_.propertyId().deviceViewAll(),
geometryMotion_.contactForceWall().deviceViewAll()
);
Kokkos::parallel_for(
@ -127,4 +113,123 @@ bool pFlow::sphereInteraction<contactForceModel,geometryMotionModel, contactList
Kokkos::fence();
return true;
}
}
template<typename cFM,typename gMM,template <class, class, class> class cLT>
pFlow::sphereInteraction<cFM,gMM, cLT>::sphereInteraction
(
systemControl& control,
const particles& prtcl,
const geometry& geom
)
:
interaction(control, prtcl, geom),
geometryMotion_(dynamic_cast<const GeometryMotionModel&>(geom)),
sphParticles_(dynamic_cast<const sphereParticles&>(prtcl)),
ppInteractionTimer_("sphere-sphere interaction", &this->timers()),
pwInteractionTimer_("sphere-wall interaction", &this->timers()),
contactListTimer_("contact list management", &this->timers()),
contactListTimer0_("contact list clear", &this->timers())
{
contactSearch_ = contactSearch::create(
subDict("contactSearch"),
prtcl.thisDomain().domainBox(),
prtcl,
geom,
timers());
if(!createSphereInteraction())
{
fatalExit;
}
}
template<typename cFM,typename gMM,template <class, class, class> class cLT>
bool pFlow::sphereInteraction<cFM,gMM, cLT>::beforeIteration()
{
return true;
}
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();
//output<<"iter, t, dt "<< iter<<" "<< t << " "<<dt<<endl;
bool broadSearch = contactSearch_().enterBroadSearch(iter, t, dt);
if(broadSearch)
{
contactListTimer0_.start();
ppContactList_().beforeBroadSearch();
pwContactList_().beforeBroadSearch();
contactListTimer0_.end();
}
if( sphParticles_.numActive()<=0)return true;
if( !contactSearch_().broadSearch(
iter,
t,
dt,
ppContactList_(),
pwContactList_()) )
{
fatalErrorInFunction<<
"unable to perform broadSearch.\n";
fatalExit;
}
if(broadSearch && contactSearch_().performedBroadSearch())
{
contactListTimer_.start();
ppContactList_().afterBroadSearch();
pwContactList_().afterBroadSearch();
contactListTimer_.end();
}
ppInteractionTimer_.start();
sphereSphereInteraction();
ppInteractionTimer_.end();
pwInteractionTimer_.start();
sphereWallInteraction();
pwInteractionTimer_.end();
return true;
}
template<typename cFM,typename gMM,template <class, class, class> class cLT>
bool pFlow::sphereInteraction<cFM,gMM, cLT>::afterIteration()
{
return true;
}
template<typename cFM,typename gMM,template <class, class, class> class cLT>
bool pFlow::sphereInteraction<cFM,gMM, cLT>::hearChanges
(
real t,
real dt,
uint32 iter,
const message& msg,
const anyList& varList
)
{
if(msg.equivalentTo(message::ITEM_REARRANGE))
{
notImplementedFunction;
}
return true;
}

View File

@ -23,7 +23,6 @@ Licence:
#include "interaction.hpp"
#include "sphereParticles.hpp"
#include "sphereInteractionKernels.hpp"
namespace pFlow
@ -43,22 +42,19 @@ public:
using ContactForceModel = contactForceModel;
using MotionModel = typename geometryMotionModel::MotionModel;
using MotionModel = typename geometryMotionModel::MotionModel;
using ModelStorage = typename ContactForceModel::contactForceStorage;
using ModelStorage = typename ContactForceModel::contactForceStorage;
using IdType = typename interaction::IdType;
using IdType = uint32;
using IndexType = typename interaction::IndexType;
using ExecutionSpace = typename interaction::ExecutionSpace;
using IndexType = uint32;
using ContactListType =
contactListType<ModelStorage, ExecutionSpace, IdType>;
contactListType<ModelStorage, DefaultExecutionSpace, IdType>;
using PairsContainerType= typename contactSearch::PairContainerType;
protected:
private:
/// const reference to geometry
const GeometryMotionModel& geometryMotion_;
@ -66,15 +62,17 @@ protected:
/// const reference to particles
const sphereParticles& sphParticles_;
/// contact search object for pp and pw interactions
uniquePtr<contactSearch> contactSearch_ = nullptr;
/// contact force model
uniquePtr<ContactForceModel> forceModel_ = nullptr;
uniquePtr<ContactForceModel> forceModel_ = nullptr;
/// contact list for particle-particle interactoins (keeps the history)
uniquePtr<ContactListType> ppContactList_ = nullptr;
uniquePtr<ContactListType> ppContactList_ = nullptr;
/// contact list for particle-wall interactions (keeps the history)
uniquePtr<ContactListType> pwContactList_ = nullptr;
uniquePtr<ContactListType> pwContactList_ = nullptr;
/// timer for particle-particle interaction computations
Timer ppInteractionTimer_;
@ -82,42 +80,39 @@ protected:
/// timer for particle-wall interaction computations
Timer pwInteractionTimer_;
Timer contactListTimer_;
Timer contactListTimer0_;
bool createSphereInteraction();
bool managePPContactLists();
bool sphereSphereInteraction();
bool managePWContactLists();
bool sphereWallInteraction();
//bool managePPContactLists();
//bool managePWContactLists();
/// range policy for p-p interaction execution
using rpPPInteraction =
Kokkos::RangePolicy<Kokkos::IndexType<int32>, Kokkos::Schedule<Kokkos::Dynamic>>;
Kokkos::RangePolicy<Kokkos::IndexType<uint32>, Kokkos::Schedule<Kokkos::Dynamic>>;
/// range policy for p-w interaction execution
using rpPWInteraction = rpPPInteraction;
public:
TypeInfoTemplate3("sphereInteraction", ContactForceModel, MotionModel, ContactListType);
// constructor
TypeInfoTemplate13("sphereInteraction", ContactForceModel, MotionModel, ContactListType);
/// Constructor from components
sphereInteraction(
systemControl& control,
const particles& prtcl,
const geometry& geom)
:
interaction(control, prtcl, geom),
geometryMotion_(dynamic_cast<const GeometryMotionModel&>(geom)),
sphParticles_(dynamic_cast<const sphereParticles&>(prtcl)),
ppInteractionTimer_("sphere-sphere interaction", &this->timers()),
pwInteractionTimer_("sphere-wall interaction", &this->timers())
{
if(!createSphereInteraction())
{
fatalExit;
}
}
const geometry& geom);
/// Add virtual constructor
add_vCtor
(
interaction,
@ -125,97 +120,25 @@ public:
systemControl
);
/// This is called in time loop, before iterate. (overriden from demComponent)
bool beforeIteration() override;
/// This is called in time loop. Perform the main calculations
/// when the component should evolve along time. (overriden from demComponent)
bool iterate() override;
/// This is called in time loop, after iterate. (overriden from demComponent)
bool afterIteration() override;
bool beforeIteration() override
{
return true;
}
bool iterate() override
{
//Info<<"before contact search"<<endInfo;
////Info<<"interaction iterrate start"<<endInfo;
if(this->contactSearch_)
{
if( this->contactSearch_().ppEnterBroadSearch())
{
//Info<<" before ppEnterBroadSearch"<<endInfo;
ppContactList_().beforeBroadSearch();
//Info<<" after ppEnterBroadSearch"<<endInfo;
}
if(this->contactSearch_().pwEnterBroadSearch())
{
//Info<<" before pwEnterBroadSearch"<<endInfo;
pwContactList_().beforeBroadSearch();
//Info<<" after pwEnterBroadSearch"<<endInfo;
}
//Info<<" before broadSearch"<<endInfo;
if( !contactSearch_().broadSearch(
ppContactList_(),
pwContactList_()) )
{
fatalErrorInFunction<<
"unable to perform broadSearch.\n";
fatalExit;
}
//Info<<" before broadSearch"<<endInfo;
if(this->contactSearch_().ppPerformedBroadSearch())
{
//Info<<" before afterBroadSearch"<<endInfo;
ppContactList_().afterBroadSearch();
//Info<<" after afterBroadSearch"<<endInfo;
}
if(this->contactSearch_().pwPerformedBroadSearch())
{
//Info<<" before pwContactList_().afterBroadSearch()"<<endInfo;
pwContactList_().afterBroadSearch();
//Info<<" after pwContactList_().afterBroadSearch()"<<endInfo;
}
}
//Info<<"after contact search"<<endInfo;
if( sphParticles_.numActive()<=0)return true;
//Info<<"before sphereSphereInteraction "<<endInfo;
ppInteractionTimer_.start();
sphereSphereInteraction();
ppInteractionTimer_.end();
//Info<<"after sphereSphereInteraction "<<endInfo;
//Info<<"before sphereWallInteraction "<<endInfo;
pwInteractionTimer_.start();
sphereWallInteraction();
pwInteractionTimer_.end();
//Info<<"after sphereWallInteraction "<<endInfo;
return true;
}
bool afterIteration() override
{
return true;
}
bool update(const eventMessage& msg)override
{
// it requires not action regarding any changes in the
// point structure
return true;
}
bool sphereSphereInteraction();
bool sphereWallInteraction();
/// Check for changes in the point structures. (overriden from observer)
bool hearChanges(
real t,
real dt,
uint32 iter,
const message& msg,
const anyList& varList)override;
};

View File

@ -42,7 +42,7 @@ struct ppInteractionFunctor
ContactListType tobeFilled_;
deviceViewType1D<real> diam_;
deviceViewType1D<int8> propId_;
deviceViewType1D<uint32> propId_;
deviceViewType1D<realx3> pos_;
deviceViewType1D<realx3> lVel_;
deviceViewType1D<realx3> rVel_;
@ -55,7 +55,7 @@ struct ppInteractionFunctor
ContactForceModel forceModel,
ContactListType tobeFilled,
deviceViewType1D<real> diam,
deviceViewType1D<int8> propId,
deviceViewType1D<uint32> propId,
deviceViewType1D<realx3> pos,
deviceViewType1D<realx3> lVel,
deviceViewType1D<realx3> rVel,
@ -75,7 +75,7 @@ struct ppInteractionFunctor
{}
INLINE_FUNCTION_HD
void operator()(const int32 n)const
void operator()(const uint32 n)const
{
if(!tobeFilled_.isValid(n))return;
@ -181,14 +181,14 @@ struct pwInteractionFunctor
MotionModel motionModel_;
deviceViewType1D<real> diam_;
deviceViewType1D<int8> propId_;
deviceViewType1D<uint32> propId_;
deviceViewType1D<realx3> pos_;
deviceViewType1D<realx3> lVel_;
deviceViewType1D<realx3> rVel_;
deviceViewType1D<realx3> cForce_;
deviceViewType1D<realx3> cTorque_;
deviceViewType1D<int8> wTriMotionIndex_;
deviceViewType1D<int8> wPropId_;
deviceViewType1D<uint32> wTriMotionIndex_;
deviceViewType1D<uint32> wPropId_;
deviceViewType1D<realx3> wCForce_;
@ -199,14 +199,14 @@ struct pwInteractionFunctor
TraingleAccessor triangles,
MotionModel motionModel ,
deviceViewType1D<real> diam ,
deviceViewType1D<int8> propId,
deviceViewType1D<uint32> propId,
deviceViewType1D<realx3> pos ,
deviceViewType1D<realx3> lVel,
deviceViewType1D<realx3> rVel,
deviceViewType1D<realx3> cForce,
deviceViewType1D<realx3> cTorque ,
deviceViewType1D<int8> wTriMotionIndex,
deviceViewType1D<int8> wPropId,
deviceViewType1D<uint32> wTriMotionIndex,
deviceViewType1D<uint32> wPropId,
deviceViewType1D<realx3> wCForce)
:
dt_(dt),

View File

@ -28,22 +28,22 @@ Licence:
template class pFlow::sphereInteraction<
pFlow::cfModels::limitedLinearNormalRolling,
pFlow::fixedGeometry,
pFlow::stationaryGeometry,
pFlow::unsortedContactList>;
template class pFlow::sphereInteraction<
pFlow::cfModels::limitedLinearNormalRolling,
pFlow::fixedGeometry,
pFlow::stationaryGeometry,
pFlow::sortedContactList>;
template class pFlow::sphereInteraction<
pFlow::cfModels::nonLimitedLinearNormalRolling,
pFlow::fixedGeometry,
pFlow::stationaryGeometry,
pFlow::unsortedContactList>;
template class pFlow::sphereInteraction<
pFlow::cfModels::nonLimitedLinearNormalRolling,
pFlow::fixedGeometry,
pFlow::stationaryGeometry,
pFlow::sortedContactList>;
template class pFlow::sphereInteraction<
@ -88,7 +88,7 @@ template class pFlow::sphereInteraction<
pFlow::sortedContactList>;
template class pFlow::sphereInteraction<
/*template class pFlow::sphereInteraction<
pFlow::cfModels::limitedLinearNormalRolling,
pFlow::multiRotationAxisMotionGeometry,
pFlow::unsortedContactList>;
@ -106,28 +106,28 @@ template class pFlow::sphereInteraction<
template class pFlow::sphereInteraction<
pFlow::cfModels::nonLimitedLinearNormalRolling,
pFlow::multiRotationAxisMotionGeometry,
pFlow::sortedContactList>;
pFlow::sortedContactList>;*/
/// non-linear models
template class pFlow::sphereInteraction<
pFlow::cfModels::limitedNonLinearNormalRolling,
pFlow::fixedGeometry,
pFlow::stationaryGeometry,
pFlow::unsortedContactList>;
template class pFlow::sphereInteraction<
pFlow::cfModels::limitedNonLinearNormalRolling,
pFlow::fixedGeometry,
pFlow::stationaryGeometry,
pFlow::sortedContactList>;
template class pFlow::sphereInteraction<
pFlow::cfModels::nonLimitedNonLinearNormalRolling,
pFlow::fixedGeometry,
pFlow::stationaryGeometry,
pFlow::unsortedContactList>;
template class pFlow::sphereInteraction<
pFlow::cfModels::nonLimitedNonLinearNormalRolling,
pFlow::fixedGeometry,
pFlow::stationaryGeometry,
pFlow::sortedContactList>;
template class pFlow::sphereInteraction<
@ -171,7 +171,7 @@ template class pFlow::sphereInteraction<
pFlow::vibratingMotionGeometry,
pFlow::sortedContactList>;
template class pFlow::sphereInteraction<
/*template class pFlow::sphereInteraction<
pFlow::cfModels::limitedNonLinearNormalRolling,
pFlow::multiRotationAxisMotionGeometry,
pFlow::unsortedContactList>;
@ -189,28 +189,28 @@ template class pFlow::sphereInteraction<
template class pFlow::sphereInteraction<
pFlow::cfModels::nonLimitedNonLinearNormalRolling,
pFlow::multiRotationAxisMotionGeometry,
pFlow::sortedContactList>;
pFlow::sortedContactList>;*/
// - nonLinearMod models
template class pFlow::sphereInteraction<
pFlow::cfModels::limitedNonLinearModNormalRolling,
pFlow::fixedGeometry,
pFlow::stationaryGeometry,
pFlow::unsortedContactList>;
template class pFlow::sphereInteraction<
pFlow::cfModels::limitedNonLinearModNormalRolling,
pFlow::fixedGeometry,
pFlow::stationaryGeometry,
pFlow::sortedContactList>;
template class pFlow::sphereInteraction<
pFlow::cfModels::nonLimitedNonLinearModNormalRolling,
pFlow::fixedGeometry,
pFlow::stationaryGeometry,
pFlow::unsortedContactList>;
template class pFlow::sphereInteraction<
pFlow::cfModels::nonLimitedNonLinearModNormalRolling,
pFlow::fixedGeometry,
pFlow::stationaryGeometry,
pFlow::sortedContactList>;
template class pFlow::sphereInteraction<
@ -255,7 +255,7 @@ template class pFlow::sphereInteraction<
pFlow::sortedContactList>;
template class pFlow::sphereInteraction<
/*template class pFlow::sphereInteraction<
pFlow::cfModels::limitedNonLinearModNormalRolling,
pFlow::multiRotationAxisMotionGeometry,
pFlow::unsortedContactList>;
@ -274,3 +274,4 @@ template class pFlow::sphereInteraction<
pFlow::cfModels::nonLimitedNonLinearModNormalRolling,
pFlow::multiRotationAxisMotionGeometry,
pFlow::sortedContactList>;
*/