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.
search_structure_periodic.h
Go to the documentation of this file.
1 // $Author: Guillermo Casas $
2 
3 #if !defined(KRATOS_SEARCH_STRUCTURE_PERIODIC_H_INCLUDED )
4 #define KRATOS_SEARCH_STRUCTURE_PERIODIC_H_INCLUDED
5 // System includes
6 #include <vector>
7 #include <cfloat>
8 // External includes
9 
10 // Project includes
11 #include "includes/define.h"
13 
14 namespace Kratos
15 {
18 
22 
26 
30 
34 
35 
37 
38 template< class IndexType, class SizeType>
40 {
41 public:
46 
47  SubBinAxisPeriodic() : Min(0), Max(0), MaxSize(0), Block(1) {}
48 
49  SubBinAxisPeriodic(IndexType const& Min_, IndexType const& Max_, IndexType const& MaxSize_, IndexType const& Block_)
50  {
51  Set(Min_,Max_,MaxSize_,Block_);
52  }
53 
55 
56  void Set(IndexType const& iCell, IndexType const& MaxSize_, IndexType const& Block_)
57  {
58  Set(iCell,iCell,MaxSize_,Block_);
59  }
60  void Set(IndexType const& Min_, IndexType const& Max_, IndexType const& MaxSize_, IndexType const& Block_)
61  {
62  MaxSize = MaxSize_;
63  Block = Block_;
64  Min = Min_;
65  Max = Max_;
66 // Min = (Min_ >= 0) ? Min_ : Min_ + MaxSize_;
67 // Max = (Max_ < MaxSize_ - 1) ? Max_ : Max_ - MaxSize_ + 1;
68 // Min = std::max( Min_, static_cast<IndexType>(0) );
69 // Max = std::min( Max_, MaxSize-1 );
70  }
72  {
73  return Min*Block;
74  }
76  {
77  return Max*Block;
78  }
80  {
81  return Min;
82  }
84  {
85  return Max;
86  }
88  {
89  if (Max >= Min){
90  return static_cast<SizeType>(Max-Min);
91  }
92  else {
93  return static_cast<SizeType>(MaxSize + 1 + Max - Min);
94  }
95  }
97  {
98  if( Min > static_cast<IndexType>(0) ) Min--;
99  if( Max < MaxSize-1 ) Max++;
100  return *this;
101  }
103  {
104  Min++;
105  Max--;
106  return *this;
107  }
108 };
109 
110 
111 template<
112 class IndexType,
113 class SizeType,
114 class CoordinateType,
115 class IteratorType,
116 class IteratorIteratorType,
117 std::size_t Dimension >
119 {
120 public:
123 
126 
129 
131 
132 public:
133  // Bin
134  //SubBinAxis<IndexType,SizeType> Axis[Dimension];
136  IteratorIteratorType RowBegin;
137  IteratorIteratorType RowEnd;
138  IteratorIteratorType DataBegin;
139  // KDTree
140  CoordinateType distance_to_partition;
141  CoordinateType distance_to_partition2;
142  CoordinateType residual_distance[Dimension];
144 
145 public:
146 
148 
150  IndexVector const& Max_,
151  SizeVector const& MaxSize_,
152  IteratorIteratorType const& IteratorBegin)
153  {
154  Set(Min_,Max_,MaxSize_,IteratorBegin);
155  }
156 
158  SizeVector const& MaxSize_,
159  IteratorIteratorType const& IteratorBegin)
160  {
161  Set(IndexCell,IndexCell,MaxSize_,IteratorBegin);
162  }
163 
164  SearchStructurePeriodic(IndexVector const& Min_, IndexVector const& Max_, SizeVector const& MaxSize_ )
165  {
166  Set(Min_,Max_,MaxSize_);
167  }
168 
169  SearchStructurePeriodic( IndexVector const& IndexCell, SizeVector const& MaxSize_ )
170  {
171  Set(IndexCell,IndexCell,MaxSize_);
172  }
173 
175 
176  void Set(IndexVector const& IndexCell, SizeVector const& _MaxSize, IteratorIteratorType const& IteratorBegin )
177  {
178  Set(IndexCell, IndexCell, _MaxSize, IteratorBegin );
179  }
180 
181  void Set(IndexVector const& Min_,
182  IndexVector const& Max_,
183  SizeVector const& MaxSize_,
184  IteratorIteratorType const& IteratorBegin )
185  {
186  IndexType Block = 1;
187  Axis[0].Set(Min_[0], Max_[0], MaxSize_[0], Block);
188 
189  for (SizeType i = 1; i < Dimension; ++i){
190  Block *= MaxSize_[i-1];
191  Axis[i].Set(Min_[i],Max_[i],MaxSize_[i],Block);
192  }
193 
194  DataBegin = IteratorBegin;
195 
196  RowBegin = DataBegin + Axis[0].Min;
197  RowEnd = DataBegin + Axis[0].Max + 1;
198  }
199 
200  void Set( IndexVector const& IndexCell, SizeVector const& MaxSize_ )
201  {
202  Set(IndexCell,IndexCell,MaxSize_);
203  }
204 
205  void Set( IndexVector const& Min_, IndexVector const& Max_, SizeVector const& MaxSize_ )
206  {
207  IndexType Block = 1;
208  Axis[0].Set(Min_[0], Max_[0], MaxSize_[0], Block);
209 
210  for (SizeType i = 1; i < Dimension; ++i){
211  Block *= MaxSize_[i-1];
212  Axis[i].Set(Min_[i],Max_[i],MaxSize_[i],Block);
213  }
214  }
215 
217  {
218  return Idx + Axis[0].Min;
219  }
220 
222  {
223  return Idx + Axis[0].Max+1;
224  }
225 
227  {
228  for (SizeType i = 0; i < Dimension; ++i){
229  (Axis[i])++;
230  }
231 
232  RowBegin = DataBegin + Axis[0].Min;
233  RowEnd = DataBegin + Axis[0].Max + 1;
234 
235  return *this;
236  }
237 
239  {
240  for (SizeType i = 0; i < Dimension; ++i){
241  (Axis[i])--;
242  }
243 
244  RowBegin = DataBegin + Axis[0].Min;
245  RowEnd = DataBegin + Axis[0].Max + 1;
246 
247  return *this;
248  }
249 };
250 
251 } // namespace Kratos.
252 
253 #endif
Definition: search_structure_periodic.h:119
void Set(IndexVector const &IndexCell, SizeVector const &_MaxSize, IteratorIteratorType const &IteratorBegin)
Definition: search_structure_periodic.h:176
Tvector< IndexType, Dimension > IndexVector
Definition: search_structure_periodic.h:127
SearchStructurePeriodic(IndexVector const &IndexCell, SizeVector const &MaxSize_, IteratorIteratorType const &IteratorBegin)
Definition: search_structure_periodic.h:157
SearchStructurePeriodic()
Definition: search_structure_periodic.h:147
SearchStructurePeriodic< IndexType, SizeType, CoordinateType, IteratorType, IteratorIteratorType, Dimension > ThisType
Definition: search_structure_periodic.h:130
IteratorIteratorType RowEnd
Definition: search_structure_periodic.h:137
SearchStructurePeriodic(IndexVector const &Min_, IndexVector const &Max_, SizeVector const &MaxSize_)
Definition: search_structure_periodic.h:164
SearchStructurePeriodic(IndexVector const &Min_, IndexVector const &Max_, SizeVector const &MaxSize_, IteratorIteratorType const &IteratorBegin)
Definition: search_structure_periodic.h:149
void Set(IndexVector const &IndexCell, SizeVector const &MaxSize_)
Definition: search_structure_periodic.h:200
KRATOS_CLASS_POINTER_DEFINITION(SearchStructurePeriodic)
Pointer definition of SearchStructurePeriodic.
SizeType BucketCounter
Definition: search_structure_periodic.h:143
SearchStructurePeriodic const & operator++()
Definition: search_structure_periodic.h:226
SubBinAxisPeriodic< IndexType, SizeType > Axis[3]
Definition: search_structure_periodic.h:135
SearchStructurePeriodic(IndexVector const &IndexCell, SizeVector const &MaxSize_)
Definition: search_structure_periodic.h:169
void Set(IndexVector const &Min_, IndexVector const &Max_, SizeVector const &MaxSize_)
Definition: search_structure_periodic.h:205
Tvector< SizeType, Dimension > SizeVector
Definition: search_structure_periodic.h:128
CoordinateType residual_distance[Dimension]
Definition: search_structure_periodic.h:142
IndexType EndRow(IndexType const &Idx)
Definition: search_structure_periodic.h:221
IndexType BeginRow(IndexType const &Idx)
Definition: search_structure_periodic.h:216
CoordinateType distance_to_partition2
Definition: search_structure_periodic.h:141
IteratorIteratorType DataBegin
Definition: search_structure_periodic.h:138
~SearchStructurePeriodic()
Definition: search_structure_periodic.h:174
IteratorIteratorType RowBegin
Definition: search_structure_periodic.h:136
void Set(IndexVector const &Min_, IndexVector const &Max_, SizeVector const &MaxSize_, IteratorIteratorType const &IteratorBegin)
Definition: search_structure_periodic.h:181
CoordinateType distance_to_partition
Definition: search_structure_periodic.h:140
SearchStructurePeriodic const & operator--()
Definition: search_structure_periodic.h:238
TOOLS UTILS ///.
Definition: search_structure_periodic.h:40
IndexType EndIndex()
Definition: search_structure_periodic.h:83
SubBinAxisPeriodic(IndexType const &Min_, IndexType const &Max_, IndexType const &MaxSize_, IndexType const &Block_)
Definition: search_structure_periodic.h:49
SubBinAxisPeriodic const & operator++()
Definition: search_structure_periodic.h:96
IndexType MaxSize
Definition: search_structure_periodic.h:44
IndexType Max
Definition: search_structure_periodic.h:43
IndexType Min
Definition: search_structure_periodic.h:42
void Set(IndexType const &Min_, IndexType const &Max_, IndexType const &MaxSize_, IndexType const &Block_)
Definition: search_structure_periodic.h:60
void Set(IndexType const &iCell, IndexType const &MaxSize_, IndexType const &Block_)
Definition: search_structure_periodic.h:56
IndexType Block
Definition: search_structure_periodic.h:45
IndexType Begin()
Definition: search_structure_periodic.h:71
~SubBinAxisPeriodic()
Definition: search_structure_periodic.h:54
IndexType End()
Definition: search_structure_periodic.h:75
SubBinAxisPeriodic()
Definition: search_structure_periodic.h:47
SubBinAxisPeriodic const & operator--()
Definition: search_structure_periodic.h:102
SizeType Size()
Definition: search_structure_periodic.h:87
IndexType BeginIndex()
Definition: search_structure_periodic.h:79
Short class definition.
Definition: search_structure.h:53
std::size_t IndexType
The definition of the index type.
Definition: key_hash.h:35
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
std::size_t SizeType
The definition of the size type.
Definition: mortar_classes.h:43
integer i
Definition: TensorModule.f:17
Configure::IteratorType IteratorType
Definition: transfer_utility.h:249