ContactSearch.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 
22 #ifndef __ContactSearch_hpp__
23 #define __ContactSearch_hpp__
24 
25 
26 #include "contactSearch.hpp"
27 #include "box.hpp"
28 
29 namespace pFlow
30 {
31 
32 template<
33  template<class> class BaseMethod,
34  template<class> class WallMapping
35 >
37 :
38  public contactSearch
39 {
40 public:
41 
42  using IdType = typename contactSearch::IdType;
43 
45 
47 
49 
51  BaseMethod<
53 
54  using WallMappingType =
55  WallMapping<
57 
58 protected:
59 
60 
62 
64 
65 public:
66 
68 
70  const dictionary& csDict,
71  const box& domain,
72  const particles& prtcl,
73  const geometry& geom,
74  Timers& timers)
75  :
76  contactSearch(csDict, domain, prtcl, geom, timers)
77 
78  {
79 
80  auto method = dict().getVal<word>("method");
81  auto wmMethod = dict().getVal<word>("wallMapping");
82 
83  auto nbDict = dict().subDict(method+"Info");
84 
85  real minD, maxD;
86  this->Particles().boundingSphereMinMax(minD, maxD);
87 
88  const auto& position = this->Particles().pointPosition().deviceVectorAll();
89  const auto& diam = this->Particles().boundingSphere().deviceVectorAll();
90 
91  particleContactSearch_ =
92  makeUnique<ParticleContactSearchType>
93  (
94  nbDict,
95  this->domain(),
96  minD,
97  maxD,
98  position,
99  diam
100  );
101  REPORT(2)<<"Contact search algorithm for particle-particle is "<<
103 
104 
105  auto wmDict = dict().subDict(wmMethod+"Info");
106 
107  int32 wnPoints = this->Geometry().numPoints();
108  int32 wnTri = this->Geometry().size();
109 
110  const auto& wPoints = this->Geometry().points().deviceVectorAll();
111  const auto& wVertices = this->Geometry().vertices().deviceVectorAll();
112 
113  wallMapping_ =
114  makeUnique<WallMappingType>(
115  wmDict,
116  particleContactSearch_().numLevels(),
117  particleContactSearch_().getCellsLevels(),
118  wnPoints,
119  wnTri,
120  wPoints,
121  wVertices
122  );
123  REPORT(2)<<"Wall mapping algorithm for particle-wall is "<<
124  greenText(wallMapping_().typeName())<< endREPORT;
125 
126  }
127 
128 
129  add_vCtor(
132  dictionary);
133 
135  PairContainerType& ppPairs,
136  PairContainerType& pwPairs,
137  bool force = false) override
138  {
139 
140 
142  {
143  auto activeRange = this->Particles().activeRange();
144 
146 
147  if(this->Particles().allActive())
148  {
149  particleContactSearch_().broadSearch(ppPairs, activeRange, force);
150  }
151  else
152  {
153  particleContactSearch_().broadSearch(ppPairs, activeRange, this->Particles().activePointsMaskD(), force);
154  }
155 
157 
158  }
159  else
160  return false;
161 
162  if(wallMapping_)
163  {
165  wallMapping_().broadSearch(pwPairs, particleContactSearch_(), force);
167  }
168  else
169  return false;
170 
171 
172 
173  return true;
174  }
175 
176 
177  bool ppEnterBroadSearch()const override
178  {
180  {
181  return particleContactSearch_().enterBoadSearch();
182  }
183  return false;
184  }
185 
186  bool pwEnterBroadSearch()const override
187  {
188  if(wallMapping_)
189  {
190  return wallMapping_().enterBoadSearch();
191  }
192  return false;
193  }
194 
195 
196  bool ppPerformedBroadSearch()const override
197  {
199  {
200  return particleContactSearch_().performedSearch();
201  }
202  return false;
203  }
204 
205 
206  bool pwPerformedBroadSearch()const override
207  {
208  if(wallMapping_)
209  {
210  return wallMapping_().performedSearch();
211  }
212  return false;
213  }
214 
215  /*bool update(const eventMessage& msg)
216  {
217  if(msg.isSizeChanged() )
218  {
219  auto newSize = this->prtcl().size();
220  if(!particleContactSearch_().objectSizeChanged(newSize))
221  {
222  fatalErrorInFunction<<
223  "erro in changing the size for particleContactSearch_ \n";
224  return false;
225  }
226  }
227 
228  if(msg.isCapacityChanged() )
229  {
230  auto newSize = this->prtcl().capacity();
231  if(!particleContactSearch_().objectSizeChanged(newSize))
232  {
233  fatalErrorInFunction<<
234  "erro in changing the capacity for particleContactSearch_ \n";
235  return false;
236  }
237  }
238 
239  return true;
240  }*/
241 
242 
243 };
244 
245 }
246 
247 
248 #endif //__ContactSearch_hpp__
pFlow::ContactSearch::add_vCtor
add_vCtor(contactSearch, ContactSearch, dictionary)
endREPORT
#define endREPORT
Definition: streams.hpp:41
pFlow::real
float real
Definition: builtinTypes.hpp:46
pFlow::interactionBase::Particles
const auto & Particles() const
Definition: interactionBase.hpp:70
REPORT
#define REPORT(n)
Definition: streams.hpp:40
pFlow::Timer::start
void start()
Definition: Timer.hpp:97
pFlow::ContactSearch::WallMappingType
WallMapping< ExecutionSpace > WallMappingType
Definition: ContactSearch.hpp:56
pFlow::contactSearch::domain
const auto & domain() const
Definition: contactSearch.hpp:91
pFlow::ContactSearch::IdType
typename contactSearch::IdType IdType
Definition: ContactSearch.hpp:42
pFlow::interactionBase::Geometry
auto & Geometry() const
Definition: interactionBase.hpp:75
pFlow::contactSearch::PairContainerType
unsortedPairs< ExecutionSpace, IdType > PairContainerType
Definition: contactSearch.hpp:46
pFlow::word
std::string word
Definition: builtinTypes.hpp:63
box.hpp
pFlow::contactSearch::ExecutionSpace
typename interactionBase::ExecutionSpace ExecutionSpace
Definition: contactSearch.hpp:44
pFlow::ContactSearch::wallMapping_
uniquePtr< WallMappingType > wallMapping_
Definition: ContactSearch.hpp:63
pFlow::Timers
Definition: Timers.hpp:33
greenText
#define greenText(text)
Definition: streams.hpp:32
pFlow
Definition: demComponent.hpp:28
pFlow::ContactSearch::IndexType
typename contactSearch::IndexType IndexType
Definition: ContactSearch.hpp:44
pFlow::contactSearch::sphereWallTimer_
Timer sphereWallTimer_
Definition: contactSearch.hpp:56
pFlow::Timer::end
void end()
Definition: Timer.hpp:102
pFlow::ContactSearch::ParticleContactSearchType
BaseMethod< ExecutionSpace > ParticleContactSearchType
Definition: ContactSearch.hpp:52
pFlow::contactSearch::dict
auto & dict()
Definition: contactSearch.hpp:58
pFlow::particles
Definition: particles.hpp:33
pFlow::ContactSearch::ContactSearch
ContactSearch(const dictionary &csDict, const box &domain, const particles &prtcl, const geometry &geom, Timers &timers)
Definition: ContactSearch.hpp:69
pFlow::int32
int int32
Definition: builtinTypes.hpp:53
pFlow::ContactSearch::PairContainerType
typename contactSearch::PairContainerType PairContainerType
Definition: ContactSearch.hpp:48
pFlow::contactSearch::sphereSphereTimer_
Timer sphereSphereTimer_
Definition: contactSearch.hpp:54
pFlow::ContactSearch::particleContactSearch_
uniquePtr< ParticleContactSearchType > particleContactSearch_
Definition: ContactSearch.hpp:61
pFlow::contactSearch::IndexType
typename interactionBase::IndexType IndexType
Definition: contactSearch.hpp:42
pFlow::ContactSearch::TypeInfoTemplate2
TypeInfoTemplate2("ContactSearch", ParticleContactSearchType, WallMappingType)
pFlow::contactSearch::IdType
typename interactionBase::IdType IdType
Definition: contactSearch.hpp:40
pFlow::contactSearch
Definition: contactSearch.hpp:35
pFlow::box
Definition: box.hpp:32
pFlow::ContactSearch::pwPerformedBroadSearch
bool pwPerformedBroadSearch() const override
Definition: ContactSearch.hpp:206
pFlow::uniquePtr< ParticleContactSearchType >
pFlow::ContactSearch::ppEnterBroadSearch
bool ppEnterBroadSearch() const override
Definition: ContactSearch.hpp:177
pFlow::geometry
Definition: geometry.hpp:37
pFlow::ContactSearch::broadSearch
bool broadSearch(PairContainerType &ppPairs, PairContainerType &pwPairs, bool force=false) override
Definition: ContactSearch.hpp:134
pFlow::ContactSearch::ppPerformedBroadSearch
bool ppPerformedBroadSearch() const override
Definition: ContactSearch.hpp:196
pFlow::ContactSearch
Definition: ContactSearch.hpp:36
pFlow::ContactSearch::pwEnterBroadSearch
bool pwEnterBroadSearch() const override
Definition: ContactSearch.hpp:186
contactSearch.hpp
pFlow::ContactSearch::ExecutionSpace
typename contactSearch::ExecutionSpace ExecutionSpace
Definition: ContactSearch.hpp:46
pFlow::dictionary
Definition: dictionary.hpp:38