KratosMultiphysics
KRATOS Multiphysics (Kratos) is a framework for building parallel, multi-disciplinary simulation software, aiming at modularity, extensibility, and high performance. Kratos is written in C++, and counts with an extensive Python interface.
bucket.h
Go to the documentation of this file.
1 // | / |
2 // ' / __| _` | __| _ \ __|
3 // . \ | ( | | ( |\__ `
4 // _|\_\_| \__,_|\__|\___/ ____/
5 // Multi-Physics
6 //
7 // License: BSD License
8 // Kratos default license: kratos/license.txt
9 //
10 // Main authors: Pooyan Dadvand
11 //
12 
13 #pragma once
14 
15 // System includes
16 
17 // External includes
18 
19 // Project includes
20 #include "tree.h"
21 
22 namespace Kratos
23 {
24 
27 
31 
35 
39 
43 
45 
47 template<
48 std::size_t TDimension,
49  class TPointType,
50  class TContainerType,
51  class TPointerType = typename TContainerType::value_type,
52  class TIteratorType = typename TContainerType::iterator,
53  class TDistanceIteratorType = typename std::vector<double>::iterator,
55  >
56 class Bucket : public TreeNode<TDimension,TPointType,TPointerType,TIteratorType,TDistanceIteratorType>
57 {
58 public:
61 
64 
66 
67  typedef TPointType PointType;
68 
69  typedef TContainerType ContainerType;
70 
71  typedef TIteratorType IteratorType;
72 
73  typedef TDistanceIteratorType DistanceIteratorType;
74 
75  typedef TPointerType PointerType;
76 
77  typedef TDistanceFunction DistanceFunction;
78 
79  typedef typename BaseType::SizeType SizeType;
80 
81  typedef typename BaseType::IndexType IndexType;
82 
84 
85  enum { Dimension = TDimension };
86 
88 
92 
93 
97 
100  : mPointsBegin(this->NullIterator()), mPointsEnd(this->NullIterator())
101  {}
102 
103  Bucket(IteratorType PointsBegin,IteratorType PointsEnd)
104  : mPointsBegin(PointsBegin), mPointsEnd(PointsEnd)
105  {}
106 
108  virtual ~Bucket() {}
109 
110 
114 
115 
119 
120  /* SizeType const Dimension() const { return TDimension; } */
121 
123  {
124  return mPointsBegin;
125  }
126 
128  {
129  return mPointsEnd;
130  }
131 
132  void SearchNearestPoint(PointType const& ThisPoint, PointerType& rResult, CoordinateType& rResultDistance ) override
133  {
134  if(mPointsBegin == mPointsEnd)
135  return;
136  SearchNearestInRange()( mPointsBegin, mPointsEnd, ThisPoint, rResult, rResultDistance );
137  }
138 
139  void SearchNearestPoint(PointType const& ThisPoint, PointerType& Result, CoordinateType& ResultDistance, SearchStructureType& Auxiliar ) override
140  {
141  SearchNearestPoint(ThisPoint,Result,ResultDistance);
142  }
143 
144  void SearchInRadius(PointType const& ThisPoint, CoordinateType const& Radius, CoordinateType const& Radius2, IteratorType& Results,
145  DistanceIteratorType& ResultsDistances, SizeType& NumberOfResults, SizeType const& MaxNumberOfResults) override
146  {
147  if(mPointsBegin == mPointsEnd)
148  return;
149  SearchRadiusInRange()(mPointsBegin,mPointsEnd,ThisPoint,Radius2,Results,ResultsDistances,NumberOfResults,MaxNumberOfResults);
150  }
151 
152  void SearchInRadius(PointType const& ThisPoint, CoordinateType const& Radius, CoordinateType const& Radius2, IteratorType& Results,
153  DistanceIteratorType& ResultsDistances, SizeType& NumberOfResults, SizeType const& MaxNumberOfResults, SearchStructureType& Auxiliar) override
154  {
155  SearchInRadius(ThisPoint,Radius,Radius2,Results,ResultsDistances,NumberOfResults,MaxNumberOfResults);
156  }
157 
158 
159  void SearchInRadius(PointType const& ThisPoint, CoordinateType const& Radius, CoordinateType const& Radius2, IteratorType& Results,
160  SizeType& NumberOfResults, SizeType const& MaxNumberOfResults) override
161  {
162  if(mPointsBegin == mPointsEnd)
163  return;
164  SearchRadiusInRange()(mPointsBegin,mPointsEnd,ThisPoint,Radius2,Results,NumberOfResults,MaxNumberOfResults);
165  }
166 
167  void SearchInRadius(PointType const& ThisPoint, CoordinateType const& Radius, CoordinateType const& Radius2, IteratorType& Results,
168  SizeType& NumberOfResults, SizeType const& MaxNumberOfResults, SearchStructureType& Auxiliar) override
169  {
170  SearchInRadius(ThisPoint,Radius,Radius2,Results,NumberOfResults,MaxNumberOfResults);
171  }
172 
173  void SearchInBox(PointType const& SearchMinPoint, PointType const& SearchMaxPoint, IteratorType& Results, SizeType& NumberOfResults,
174  SizeType const& MaxNumberOfResults ) override
175  {
176  SearchBoxInRange()(SearchMinPoint,SearchMaxPoint,mPointsBegin,mPointsEnd,Results,NumberOfResults,MaxNumberOfResults);
177  }
178 
179 
183 
184 
188 
189 
193 
195  virtual std::string Info() const
196  {
197  return "Bucket";
198  }
199 
201  virtual void PrintInfo(std::ostream& rOStream) const
202  {
203  rOStream << "Bucket";
204  }
205 
207  void PrintData(std::ostream& rOStream, std::string const& Perfix = std::string()) const override
208  {
209  rOStream << Perfix << "Leaf[" << SearchUtils::PointerDistance(mPointsBegin, mPointsEnd) << "] : ";
210  for(IteratorType i = mPointsBegin ; i != mPointsEnd ; i++)
211  rOStream << **i << " ";
212  rOStream << std::endl;
213  }
214 
215 
219 
220 
222 
223 protected:
226 
227 
231 
232 
236 
237  /* bool PointInBox(PointType const& BoxMinPoint, PointType const& BoxMaxPoint, PointType const& ThisPoint) */
238  /* { */
239  /* for(SizeType i = 0 ; i < Dimension ; i++) */
240  /* if( ThisPoint[i] < BoxMinPoint[i] || ThisPoint[i] > BoxMaxPoint[i] ) */
241  /* return false; */
242  /* return true; */
243  /* } */
244 
248 
249 
253 
254 
258 
259 
263 
264 
266 
267 private:
270 
271 
275  IteratorType mPointsBegin;
276  IteratorType mPointsEnd;
277 
278 
282 
283 
287 
288 
292 
293 
297 
298 
302 
304  Bucket& operator=(Bucket const& rOther);
305 
307  Bucket(Bucket const& rOther);
308 
309 
311 
312 }; // Class Bucket
313 
315 
318 
319 
323 
324 
326 template<
327 std::size_t TDimension,
328  class TPointType,
329  class TContainerType,
330  class TPointerType,
331  class TIteratorType,
332  class TDistanceIteratorType,
333  class TDistanceFunction >
334 inline std::istream& operator >> (std::istream& rIStream,
336 
338 template<
339 std::size_t TDimension,
340  class TPointType,
341  class TContainerType,
342  class TPointerType,
343  class TIteratorType,
344  class TDistanceIteratorType,
345  class TDistanceFunction >
346 inline std::ostream& operator << (std::ostream& rOStream,
348 {
349  rThis.PrintInfo(rOStream);
350  rOStream << std::endl;
351  rThis.PrintData(rOStream);
352 
353  return rOStream;
354 }
356 
357 
358 } // namespace Kratos.
359 
360 
Short class definition.
Definition: bucket.h:57
TPointerType PointerType
Definition: bucket.h:75
Bucket()
Default constructor.
Definition: bucket.h:99
void SearchInRadius(PointType const &ThisPoint, CoordinateType const &Radius, CoordinateType const &Radius2, IteratorType &Results, DistanceIteratorType &ResultsDistances, SizeType &NumberOfResults, SizeType const &MaxNumberOfResults) override
Definition: bucket.h:144
BaseType::CoordinateType CoordinateType
Definition: bucket.h:83
void SearchInBox(PointType const &SearchMinPoint, PointType const &SearchMaxPoint, IteratorType &Results, SizeType &NumberOfResults, SizeType const &MaxNumberOfResults) override
Definition: bucket.h:173
TIteratorType IteratorType
Definition: bucket.h:71
virtual std::string Info() const
Turn back information as a string.
Definition: bucket.h:195
void SearchNearestPoint(PointType const &ThisPoint, PointerType &rResult, CoordinateType &rResultDistance) override
Definition: bucket.h:132
Kratos::SearchUtils::SearchRadiusInRange< PointType, IteratorType, DistanceIteratorType, DistanceFunction, SizeType, CoordinateType > SearchRadiusInRange
Definition: bucket.h:90
Kratos::SearchUtils::SearchNearestInRange< PointType, PointerType, IteratorType, DistanceFunction, CoordinateType > SearchNearestInRange
Definition: bucket.h:89
BaseType::SearchStructureType SearchStructureType
Definition: bucket.h:87
BaseType::IndexType IndexType
Definition: bucket.h:81
IteratorType Begin()
Definition: bucket.h:122
TDistanceFunction DistanceFunction
Definition: bucket.h:77
void SearchInRadius(PointType const &ThisPoint, CoordinateType const &Radius, CoordinateType const &Radius2, IteratorType &Results, SizeType &NumberOfResults, SizeType const &MaxNumberOfResults) override
Definition: bucket.h:159
TDistanceIteratorType DistanceIteratorType
Definition: bucket.h:73
void SearchNearestPoint(PointType const &ThisPoint, PointerType &Result, CoordinateType &ResultDistance, SearchStructureType &Auxiliar) override
Definition: bucket.h:139
KRATOS_CLASS_POINTER_DEFINITION(Bucket)
Pointer definition of Bucket.
TreeNode< TDimension, TPointType, TPointerType, TIteratorType, TDistanceIteratorType > BaseType
Definition: bucket.h:65
Bucket(IteratorType PointsBegin, IteratorType PointsEnd)
Definition: bucket.h:103
BaseType::SizeType SizeType
Definition: bucket.h:79
Kratos::SearchUtils::SearchBoxInRange< PointType, IteratorType, SizeType, TDimension > SearchBoxInRange
Definition: bucket.h:91
void SearchInRadius(PointType const &ThisPoint, CoordinateType const &Radius, CoordinateType const &Radius2, IteratorType &Results, DistanceIteratorType &ResultsDistances, SizeType &NumberOfResults, SizeType const &MaxNumberOfResults, SearchStructureType &Auxiliar) override
Definition: bucket.h:152
virtual void PrintInfo(std::ostream &rOStream) const
Print information about this object.
Definition: bucket.h:201
IteratorType End()
Definition: bucket.h:127
TContainerType ContainerType
Definition: bucket.h:69
TPointType PointType
Definition: bucket.h:67
@ Dimension
Definition: bucket.h:85
void SearchInRadius(PointType const &ThisPoint, CoordinateType const &Radius, CoordinateType const &Radius2, IteratorType &Results, SizeType &NumberOfResults, SizeType const &MaxNumberOfResults, SearchStructureType &Auxiliar) override
Definition: bucket.h:167
void PrintData(std::ostream &rOStream, std::string const &Perfix=std::string()) const override
Print object's data.
Definition: bucket.h:207
virtual ~Bucket()
Destructor.
Definition: bucket.h:108
Definition: search_structure.h:309
Definition: search_structure.h:142
Definition: search_structure.h:160
Definition: search_structure.h:194
Definition: search_structure.h:109
Short class definition.
Definition: tree.h:61
double CoordinateType
Define CoordinateType as double.
Definition: tree.h:76
std::size_t IndexType
Define IndexType as std::size_t.
Definition: tree.h:73
std::size_t SizeType
Define SizeType as std::size_t.
Definition: tree.h:70
std::size_t PointerDistance(TPointerType const &PointerBegin, TPointerType const &PointerEnd)
Definition: search_structure.h:91
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
integer i
Definition: TensorModule.f:17
Configure::IteratorType IteratorType
Definition: transfer_utility.h:249