# PhasicFlow: src/Interaction/sphereInteraction/sphereInteraction.hpp Source File

sphereInteraction.hpp
Go to the documentation of this file.
/*------------------------------- 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 __sphereInteraction_hpp__
#define __sphereInteraction_hpp__
#include "interaction.hpp"
#include "sphereParticles.hpp"
#include "sphereInteractionKernels.hpp"
namespace pFlow
{
template<
typename contactForceModel,
typename geometryMotionModel,
template <class, class, class> class contactListType>
class sphereInteraction
:
public interaction
{
public:
using GeometryMotionModel = geometryMotionModel;
using ContactForceModel = contactForceModel;
using MotionModel = typename geometryMotionModel::MotionModel;
using ModelStorage = typename ContactForceModel::contactForceStorage;
using IdType = typename interaction::IdType;
using IndexType = typename interaction::IndexType;
using ExecutionSpace = typename interaction::ExecutionSpace;
using ContactListType =
contactListType<ModelStorage, ExecutionSpace, IdType>;
using PairsContainerType= typename contactSearch::PairContainerType;
protected:
const GeometryMotionModel& geometryMotion_;
const sphereParticles& sphParticles_;
uniquePtr<ContactForceModel> forceModel_ = nullptr;
uniquePtr<ContactListType> ppContactList_ = nullptr;
uniquePtr<ContactListType> pwContactList_ = nullptr;
Timer ppInteractionTimer_;
Timer pwInteractionTimer_;
bool createSphereInteraction();
bool managePPContactLists();
bool managePWContactLists();
using rpPPInteraction =
Kokkos::RangePolicy<Kokkos::IndexType<int32>, Kokkos::Schedule<Kokkos::Dynamic>>;
using rpPWInteraction = rpPPInteraction;
public:
TypeInfoTemplate3("sphereInteraction", ContactForceModel, MotionModel, ContactListType);
// constructor
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;
}
}
add_vCtor
(
interaction,
sphereInteraction,
systemControl
);
bool beforeIteration() override
{
return true;
}
bool iterate() override
{
//Info<<"before contact search"<<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();
};
}
#include "sphereInteraction.cpp"
#endif //__sphereInteraction_hpp__
pFlow::sphereInteraction::sphereWallInteraction
bool sphereWallInteraction()
Definition: sphereInteraction.cpp:95
pFlow::sphereInteraction::PairsContainerType
typename contactSearch::PairContainerType PairsContainerType
Definition: sphereInteraction.hpp:59
pFlow::sphereInteraction::beforeIteration
bool beforeIteration() override
Definition: sphereInteraction.hpp:129
pFlow::sphereInteraction::geometryMotion_
const GeometryMotionModel & geometryMotion_
const reference to geometry
Definition: sphereInteraction.hpp:64
fatalExit
#define fatalExit
Definition: error.hpp:57
pFlow::sphereInteraction::MotionModel
typename geometryMotionModel::MotionModel MotionModel
Definition: sphereInteraction.hpp:46
pFlow::sphereInteraction::afterIteration
bool afterIteration() override
Definition: sphereInteraction.hpp:203
pFlow::eventMessage
Definition: eventMessage.hpp:29
pFlow::demComponent::control
const auto & control() const
Definition: demComponent.hpp:57
pFlow::Timer::start
void start()
Definition: Timer.hpp:97
pFlow::sphereInteraction::createSphereInteraction
bool createSphereInteraction()
Definition: sphereInteraction.cpp:26
pFlow::sphereInteraction::managePWContactLists
bool managePWContactLists()
pFlow::sphereInteraction::GeometryMotionModel
geometryMotionModel GeometryMotionModel
Definition: sphereInteraction.hpp:42
pFlow::contactSearch::PairContainerType
unsortedPairs< ExecutionSpace, IdType > PairContainerType
Definition: contactSearch.hpp:46
pFlow::systemControl
Definition: systemControl.hpp:41
pFlow::interaction::ExecutionSpace
typename interactionBase::ExecutionSpace ExecutionSpace
Definition: interaction.hpp:46
pFlow::sphereInteraction::update
bool update(const eventMessage &msg) override
Definition: sphereInteraction.hpp:209
interaction.hpp
pFlow::sphereInteraction::rpPWInteraction
rpPPInteraction rpPWInteraction
range policy for p-w interaction execution
Definition: sphereInteraction.hpp:96
pFlow::sphereInteraction::sphereInteraction
sphereInteraction(systemControl &control, const particles &prtcl, const geometry &geom)
Definition: sphereInteraction.hpp:104
pFlow::sphereInteraction::ppInteractionTimer_
Timer ppInteractionTimer_
timer for particle-particle interaction computations
Definition: sphereInteraction.hpp:80
pFlow::sphereInteraction::pwContactList_
uniquePtr< ContactListType > pwContactList_
contact list for particle-wall interactions (keeps the history)
Definition: sphereInteraction.hpp:77
pFlow
Definition: demComponent.hpp:28
pFlow::sphereInteraction::ContactForceModel
contactForceModel ContactForceModel
Definition: sphereInteraction.hpp:44
pFlow::sphereParticles
Class for managing spherical particles.
Definition: sphereParticles.hpp:44
pFlow::sphereInteraction::ppContactList_
uniquePtr< ContactListType > ppContactList_
contact list for particle-particle interactoins (keeps the history)
Definition: sphereInteraction.hpp:74
pFlow::Timer::end
void end()
Definition: Timer.hpp:102
pFlow::particles
Definition: particles.hpp:33
pFlow::sphereInteraction::add_vCtor
add_vCtor(interaction, sphereInteraction, systemControl)
fatalErrorInFunction
#define fatalErrorInFunction
Definition: error.hpp:42
pFlow::sphereInteraction::sphParticles_
const sphereParticles & sphParticles_
const reference to particles
Definition: sphereInteraction.hpp:67
sphereInteractionKernels.hpp
sphereInteraction.cpp
pFlow::Timer
Definition: Timer.hpp:39
pFlow::sphereInteraction
Definition: sphereInteraction.hpp:36
pFlow::sphereInteraction::ModelStorage
typename ContactForceModel::contactForceStorage ModelStorage
Definition: sphereInteraction.hpp:48
pFlow::particles::numActive
auto numActive() const
Definition: particles.hpp:138
pFlow::interaction::IndexType
typename interactionBase::IndexType IndexType
Definition: interaction.hpp:44
pFlow::uniquePtr< ContactForceModel >
pFlow::geometry
Definition: geometry.hpp:37
pFlow::sphereInteraction::pwInteractionTimer_
Timer pwInteractionTimer_
timer for particle-wall interaction computations
Definition: sphereInteraction.hpp:83
pFlow::interaction::contactSearch_
uniquePtr< contactSearch > contactSearch_
contact search object for pp and pw interactions
Definition: interaction.hpp:54
pFlow::sphereInteraction::iterate
bool iterate() override
Definition: sphereInteraction.hpp:135
sphereParticles.hpp
pFlow::sphereInteraction::forceModel_
uniquePtr< ContactForceModel > forceModel_
contact force model
Definition: sphereInteraction.hpp:71
pFlow::interaction::IdType
typename interactionBase::IdType IdType
Definition: interaction.hpp:42
pFlow::sphereInteraction::managePPContactLists
bool managePPContactLists()
pFlow::sphereInteraction::rpPPInteraction
Kokkos::RangePolicy< Kokkos::IndexType< int32 >, Kokkos::Schedule< Kokkos::Dynamic > > rpPPInteraction
range policy for p-p interaction execution
Definition: sphereInteraction.hpp:93
pFlow::interaction
Definition: interaction.hpp:34
pFlow::demComponent::timers
auto & timers()
Definition: demComponent.hpp:79
pFlow::sphereInteraction::TypeInfoTemplate3
TypeInfoTemplate3("sphereInteraction", ContactForceModel, MotionModel, ContactListType)
pFlow::sphereInteraction::sphereSphereInteraction
bool sphereSphereInteraction()
Definition: sphereInteraction.cpp:56
pFlow::sphereInteraction::ContactListType
contactListType< ModelStorage, ExecutionSpace, IdType > ContactListType
Definition: sphereInteraction.hpp:57