sphereInteraction.hpp
Go to the documentation of this file.
1 /*------------------------------- phasicFlow ---------------------------------
2  O C enter of
3  O O E ngineering and
4  O O M ultiscale modeling of
5  OOOOOOO F luid flow
6 ------------------------------------------------------------------------------
7  Copyright (C): www.cemf.ir
8  email: hamid.r.norouzi AT gmail.com
9 ------------------------------------------------------------------------------
10 Licence:
11  This file is part of phasicFlow code. It is a free software for simulating
12  granular and multiphase flows. You can redistribute it and/or modify it under
13  the terms of GNU General Public License v3 or any other later versions.
14 
15  phasicFlow is distributed to help others in their research in the field of
16  granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
17  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 
19 -----------------------------------------------------------------------------*/
20 
21 #ifndef __sphereInteraction_hpp__
22 #define __sphereInteraction_hpp__
23 
24 #include "interaction.hpp"
25 #include "sphereParticles.hpp"
26 
28 
29 namespace pFlow
30 {
31 
32 template<
33  typename contactForceModel,
34  typename geometryMotionModel,
35  template <class, class, class> class contactListType>
37 :
38  public interaction
39 {
40 public:
41 
42  using GeometryMotionModel = geometryMotionModel;
43 
44  using ContactForceModel = contactForceModel;
45 
46  using MotionModel = typename geometryMotionModel::MotionModel;
47 
48  using ModelStorage = typename ContactForceModel::contactForceStorage;
49 
50  using IdType = typename interaction::IdType;
51 
53 
55 
56  using ContactListType =
57  contactListType<ModelStorage, ExecutionSpace, IdType>;
58 
60 
61 protected:
62 
65 
68 
69 
72 
75 
78 
81 
84 
86 
87  bool managePPContactLists();
88 
89  bool managePWContactLists();
90 
92  using rpPPInteraction =
93  Kokkos::RangePolicy<Kokkos::IndexType<int32>, Kokkos::Schedule<Kokkos::Dynamic>>;
94 
97 
98 public:
99 
101 
102  // constructor
103 
106  const particles& prtcl,
107  const geometry& geom)
108  :
109  interaction(control, prtcl, geom),
110  geometryMotion_(dynamic_cast<const GeometryMotionModel&>(geom)),
111  sphParticles_(dynamic_cast<const sphereParticles&>(prtcl)),
112  ppInteractionTimer_("sphere-sphere interaction", &this->timers()),
113  pwInteractionTimer_("sphere-wall interaction", &this->timers())
114  {
116  {
117  fatalExit;
118  }
119  }
120 
121  add_vCtor
122  (
123  interaction,
126  );
127 
128 
129  bool beforeIteration() override
130  {
131  return true;
132  }
133 
134 
135  bool iterate() override
136  {
137 
138 //Info<<"before contact search"<<endInfo;
140  if(this->contactSearch_)
141  {
142 
143  if( this->contactSearch_().ppEnterBroadSearch())
144  {
145  //Info<<" before ppEnterBroadSearch"<<endInfo;
146  ppContactList_().beforeBroadSearch();
147  //Info<<" after ppEnterBroadSearch"<<endInfo;
148  }
149 
150  if(this->contactSearch_().pwEnterBroadSearch())
151  {
152  //Info<<" before pwEnterBroadSearch"<<endInfo;
153  pwContactList_().beforeBroadSearch();
154  //Info<<" after pwEnterBroadSearch"<<endInfo;
155  }
156 
157  //Info<<" before broadSearch"<<endInfo;
158  if( !contactSearch_().broadSearch(
159  ppContactList_(),
160  pwContactList_()) )
161  {
163  "unable to perform broadSearch.\n";
164  fatalExit;
165  }
166 
167  //Info<<" before broadSearch"<<endInfo;
168 
169 
170  if(this->contactSearch_().ppPerformedBroadSearch())
171  {
172  //Info<<" before afterBroadSearch"<<endInfo;
173  ppContactList_().afterBroadSearch();
174  //Info<<" after afterBroadSearch"<<endInfo;
175  }
176 
177  if(this->contactSearch_().pwPerformedBroadSearch())
178  {
179  //Info<<" before pwContactList_().afterBroadSearch()"<<endInfo;
180  pwContactList_().afterBroadSearch();
181  //Info<<" after pwContactList_().afterBroadSearch()"<<endInfo;
182  }
183  }
184 //Info<<"after contact search"<<endInfo;
185 
186  if( sphParticles_.numActive()<=0)return true;
187 //Info<<"before sphereSphereInteraction "<<endInfo;
191 //Info<<"after sphereSphereInteraction "<<endInfo;
192 
193 //Info<<"before sphereWallInteraction "<<endInfo;
197 //Info<<"after sphereWallInteraction "<<endInfo;
198 
199  return true;
200  }
201 
202 
203  bool afterIteration() override
204  {
205  return true;
206  }
207 
208 
209  bool update(const eventMessage& msg)override
210  {
211  // it requires not action regarding any changes in the
212  // point structure
213  return true;
214  }
215 
217 
218  bool sphereWallInteraction();
219 };
220 
221 
222 }
223 
224 #include "sphereInteraction.cpp"
225 
226 #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