51 template<
class TLeafType >
53 typename TLeafType::PointType,
54 typename TLeafType::PointerType,
55 typename TLeafType::IteratorType,
56 typename TLeafType::DistanceIteratorType >
101 : mCutingDimension(CutingDimension), mPosition(Position), mLeftEnd(LeftEnd), mRightEnd(RightEnd)
103 mpChilds[0] = pLeftChild;
104 mpChilds[1] = pRightChild;
107 void PrintData(std::ostream& rOStream, std::string
const& Perfix = std::string())
const override
109 rOStream << Perfix <<
"Partition at ";
110 switch(mCutingDimension)
122 rOStream << mCutingDimension <<
" in";
125 rOStream << mPosition <<
" from " << mLeftEnd <<
" to " << mRightEnd << std::endl;
127 mpChilds[0]->
PrintData(rOStream, Perfix +
" ");
128 mpChilds[1]->
PrintData(rOStream, Perfix +
" ");
152 Auxiliar.residual_distance[
i] = 0.00;
164 CoordinateType distance_to_partition = rThisPoint[mCutingDimension] - mPosition;
166 if( distance_to_partition < 0.0 )
172 Auxiliar.residual_distance[mCutingDimension] = distance_to_partition * distance_to_partition;
173 Auxiliar.distance_to_partition2 = Auxiliar.residual_distance[0];
175 Auxiliar.distance_to_partition2 += Auxiliar.residual_distance[
i];
176 if( rResultDistance > Auxiliar.distance_to_partition2 )
186 Auxiliar.residual_distance[mCutingDimension] = distance_to_partition * distance_to_partition;
187 Auxiliar.distance_to_partition2 = Auxiliar.residual_distance[0];
189 Auxiliar.distance_to_partition2 += Auxiliar.residual_distance[
i];
190 if( rResultDistance > Auxiliar.distance_to_partition2 )
193 Auxiliar.residual_distance[mCutingDimension] =
temp;
209 Auxiliar.residual_distance[
i] = 0.00;
210 SearchInRadius(ThisPoint, Radius, Radius2, Results, ResultsDistances, NumberOfResults, MaxNumberOfResults, Auxiliar );
225 const CoordinateType distance_to_partition = ThisPoint[mCutingDimension] - mPosition;
227 if(distance_to_partition < 0)
230 mpChilds[0]->
SearchInRadius(ThisPoint, Radius, Radius2, Results, ResultsDistances, NumberOfResults, MaxNumberOfResults, Auxiliar );
232 Auxiliar.residual_distance[mCutingDimension] = distance_to_partition * distance_to_partition;
233 Auxiliar.distance_to_partition2 = Auxiliar.residual_distance[0];
235 Auxiliar.distance_to_partition2 += Auxiliar.residual_distance[
i];
237 if( Radius2 >= Auxiliar.distance_to_partition2 )
238 mpChilds[1]->
SearchInRadius(ThisPoint, Radius, Radius2, Results, ResultsDistances, NumberOfResults, MaxNumberOfResults, Auxiliar );
243 mpChilds[1]->
SearchInRadius(ThisPoint, Radius, Radius2, Results, ResultsDistances, NumberOfResults, MaxNumberOfResults, Auxiliar );
245 Auxiliar.residual_distance[mCutingDimension] = distance_to_partition * distance_to_partition;
246 Auxiliar.distance_to_partition2 = Auxiliar.residual_distance[0];
248 Auxiliar.distance_to_partition2 += Auxiliar.residual_distance[
i];
250 if( Radius2 >= Auxiliar.distance_to_partition2 )
251 mpChilds[0]->
SearchInRadius(ThisPoint, Radius, Radius2, Results, ResultsDistances, NumberOfResults, MaxNumberOfResults, Auxiliar );
253 Auxiliar.residual_distance[mCutingDimension] =
temp;
268 Auxiliar.residual_distance[
i] = 0.00;
269 SearchInRadius(ThisPoint, Radius, Radius2, Results, NumberOfResults, MaxNumberOfResults, Auxiliar );
283 CoordinateType distance_to_partition = ThisPoint[mCutingDimension] - mPosition;
285 if(distance_to_partition < 0)
288 mpChilds[0]->
SearchInRadius(ThisPoint, Radius, Radius2, Results, NumberOfResults, MaxNumberOfResults, Auxiliar );
290 Auxiliar.residual_distance[mCutingDimension] = distance_to_partition * distance_to_partition;
291 Auxiliar.distance_to_partition2 = Auxiliar.residual_distance[0];
293 Auxiliar.distance_to_partition2 += Auxiliar.residual_distance[
i];
295 if( Radius2 >= Auxiliar.distance_to_partition2 )
296 mpChilds[1]->
SearchInRadius(ThisPoint, Radius, Radius2, Results, NumberOfResults, MaxNumberOfResults, Auxiliar );
297 Auxiliar.residual_distance[mCutingDimension] =
temp;
302 mpChilds[1]->
SearchInRadius(ThisPoint, Radius, Radius2, Results, NumberOfResults, MaxNumberOfResults, Auxiliar );
304 Auxiliar.residual_distance[mCutingDimension] = distance_to_partition * distance_to_partition;
305 Auxiliar.distance_to_partition2 = Auxiliar.residual_distance[0];
307 Auxiliar.distance_to_partition2 += Auxiliar.residual_distance[
i];
309 if( Radius2 >= Auxiliar.distance_to_partition2 )
310 mpChilds[0]->
SearchInRadius(ThisPoint, Radius, Radius2, Results, NumberOfResults, MaxNumberOfResults, Auxiliar );
311 Auxiliar.residual_distance[mCutingDimension] =
temp;
324 if( SearchMinPoint[mCutingDimension] <= mPosition )
325 mpChilds[0]->
SearchInBox(SearchMinPoint,SearchMaxPoint,Results,NumberOfResults,MaxNumberOfResults);
326 if( SearchMaxPoint[mCutingDimension] >= mPosition )
327 mpChilds[1]->
SearchInBox(SearchMinPoint,SearchMaxPoint,Results,NumberOfResults,MaxNumberOfResults);
360 template<
class TLeafType >
407 :
BaseType(CutingDimension,Position,LeftEnd,RightEnd,pLeftChild,pRightChild) {}
428 rCuttingDimension =
MaxSpread(PointsBegin, PointsEnd);
431 MedianSplit(PointsBegin, partition, PointsEnd, rCuttingDimension, rCuttingValue);
451 min[
d] = (**PointsBegin)[
d];
452 max[
d] = (**PointsBegin)[
d];
454 for (
IteratorType i_point = PointsBegin; i_point != PointsEnd; i_point++)
466 max_spread =
max[0] -
min[0];
470 if (spread > max_spread)
477 return max_dimension;
494 if ((**
i)[CuttingDimension] > (**right)[CuttingDimension])
495 std::swap(*
i,*right);
501 while ((**(++
i))[CuttingDimension] < value)
504 while ((**(--
j))[CuttingDimension] > value)
506 if (
i <
j) std::swap(*
i,*
j);
511 if (
j > PartitionPosition)
513 else if (
j < PartitionPosition)
523 if((**
i)[CuttingDimension] >
max)
525 max = (**i)[CuttingDimension];
530 std::swap(--last,
k);
532 rCuttingValue = ((**last)[CuttingDimension] + (**PartitionPosition)[CuttingDimension])/2.0;
547 if (number_of_points == 0)
549 else if (number_of_points <= BucketSize)
551 return new LeafType(PointsBegin, PointsEnd);
563 partition_high_point.Coordinates() = HighPoint.Coordinates();
565 partition_low_point.Coordinates() = LowPoint.Coordinates();
567 partition_high_point[cutting_dimension] = cutting_value;
568 partition_low_point[cutting_dimension] = cutting_value;
571 HighPoint[cutting_dimension], LowPoint[cutting_dimension],
572 Construct(PointsBegin, partition, partition_high_point, LowPoint, BucketSize),
573 Construct(partition, PointsEnd, HighPoint, partition_low_point, BucketSize) );
590 template<
class TLeafType >
643 :
BaseType(CutingDimension,Position,LeftEnd,RightEnd,pLeftChild,pRightChild)
665 rCuttingDimension =
MaxSpread( PointsBegin, PointsEnd, rCuttingValue );
668 AverageSplit(PointsBegin, partition, PointsEnd, rCuttingDimension, rCuttingValue);
692 min[
d] = (**PointsBegin)[
d];
693 max[
d] = (**PointsBegin)[
d];
695 for (
IteratorType i_point = PointsBegin; i_point != PointsEnd; i_point++)
708 max_spread =
max[0] -
min[0];
709 AverageValue =
Average[0] / size;
713 if (spread > max_spread)
721 return max_dimension;
738 while(
left < PointsEnd && (**
left)[CuttingDimension] < rCuttingValue )
left++;
739 while( right > PointsBegin && (**right)[CuttingDimension] >= rCuttingValue ) right--;
740 if (
left <= right) std::swap(*
left,*right);
744 PartitionPosition =
left;
757 if (number_of_points == 0)
759 else if (number_of_points <= BucketSize)
761 return new LeafType(PointsBegin, PointsEnd);
770 PointType partition_high_point = HighPoint;
771 PointType partition_low_point = LowPoint;
773 partition_high_point[cutting_dimension] = cutting_value;
774 partition_low_point[cutting_dimension] = cutting_value;
777 HighPoint[cutting_dimension], LowPoint[cutting_dimension],
778 Construct(PointsBegin, partition, partition_high_point, LowPoint, BucketSize),
779 Construct(partition, PointsEnd, HighPoint, partition_low_point, BucketSize) );
795 template<
class TLeafType >
841 :
BaseType(CutingDimension,Position,LeftEnd,RightEnd,pLeftChild,pRightChild) {}
861 rCuttingDimension =
MaxSpread( PointsBegin, PointsEnd, HighPoint, LowPoint, rCuttingValue );
877 return Split(PointsBegin, PointsEnd, rCuttingDimension, rCuttingValue);
895 min[
d] = (**PointsBegin)[
d];
896 max[
d] = (**PointsBegin)[
d];
898 for (
IteratorType i_point = PointsBegin; i_point != PointsEnd; i_point++)
912 if (spread > max_spread)
918 CuttingValue = (
max[max_dimension]+
min[max_dimension]) / 2.00;
920 return max_dimension;
935 while( (**
left)[CuttingDimension] < rCuttingValue )
left++;
936 while( (**right)[CuttingDimension] >= rCuttingValue ) right--;
937 if (
left < right) std::swap(*
left,*right);
954 if (number_of_points == 0)
956 else if (number_of_points <= BucketSize)
958 return new LeafType(PointsBegin, PointsEnd);
965 IteratorType partition =
Partition(PointsBegin, PointsEnd, HighPoint, LowPoint, cutting_dimension, cutting_value);
967 PointType partition_high_point = HighPoint;
968 PointType partition_low_point = LowPoint;
970 partition_high_point[cutting_dimension] = cutting_value;
971 partition_low_point[cutting_dimension] = cutting_value;
974 HighPoint[cutting_dimension], LowPoint[cutting_dimension],
975 Construct(PointsBegin, partition, partition_high_point, LowPoint, BucketSize),
976 Construct(partition, PointsEnd, HighPoint, partition_low_point, BucketSize) );
Definition: kd_tree.h:592
static void AverageSplit(IteratorType PointsBegin, IteratorType &PartitionPosition, IteratorType PointsEnd, IndexType &CuttingDimension, CoordinateType &rCuttingValue)
Definition: kd_tree.h:725
static IteratorType Partition(IteratorType PointsBegin, IteratorType PointsEnd, IndexType &rCuttingDimension, CoordinateType &rCuttingValue)
Definition: kd_tree.h:657
static SizeType MaxSpread(IteratorType PointsBegin, IteratorType PointsEnd, CoordinateType &AverageValue)
Definition: kd_tree.h:674
virtual ~KDTreePartitionAverageSplit()
Destructor.
Definition: kd_tree.h:648
TLeafType LeafType
Definition: kd_tree.h:602
TreeNodeType::SizeType SizeType
Definition: kd_tree.h:622
@ Dimension
Definition: kd_tree.h:616
static TreeNodeType * Construct(IteratorType PointsBegin, IteratorType PointsEnd, PointType HighPoint, PointType LowPoint, SizeType BucketSize)
Definition: kd_tree.h:748
LeafType::PointerType PointerType
Definition: kd_tree.h:612
LeafType::PointType PointType
Definition: kd_tree.h:604
LeafType::SearchStructureType SearchStructureType
Definition: kd_tree.h:627
LeafType::DistanceFunction DistanceFunction
Definition: kd_tree.h:614
LeafType::ContainerType ContainerType
Definition: kd_tree.h:606
TreeNode< Dimension, PointType, PointerType, IteratorType, DistanceIteratorType > TreeNodeType
Definition: kd_tree.h:618
KRATOS_CLASS_POINTER_DEFINITION(KDTreePartitionAverageSplit)
Pointer definition of KDTree.
TreeNodeType::CoordinateType CoordinateType
Definition: kd_tree.h:620
TreeNodeType::IndexType IndexType
Definition: kd_tree.h:624
KDTreePartitionAverageSplit(IndexType CutingDimension, CoordinateType Position, CoordinateType LeftEnd, CoordinateType RightEnd, TreeNodeType *pLeftChild=NULL, TreeNodeType *pRightChild=NULL)
Partition constructor.
Definition: kd_tree.h:635
KDTreePartitionBase< TLeafType > BaseType
Definition: kd_tree.h:600
LeafType::IteratorType IteratorType
Definition: kd_tree.h:608
LeafType::DistanceIteratorType DistanceIteratorType
Definition: kd_tree.h:610
Short class definition.
Definition: kd_tree.h:57
TreeNodeType::IndexType IndexType
Definition: kd_tree.h:87
LeafType::ContainerType ContainerType
Definition: kd_tree.h:69
void SearchInRadius(PointType const &ThisPoint, CoordinateType const &Radius, CoordinateType const &Radius2, IteratorType &Results, DistanceIteratorType &ResultsDistances, SizeType &NumberOfResults, SizeType const &MaxNumberOfResults) override
Definition: kd_tree.h:197
void SearchInRadius(PointType const &ThisPoint, CoordinateType const &Radius, CoordinateType const &Radius2, IteratorType &Results, SizeType &NumberOfResults, SizeType const &MaxNumberOfResults) override
Definition: kd_tree.h:257
LeafType::PointerType PointerType
Definition: kd_tree.h:75
void SearchInBox(PointType const &SearchMinPoint, PointType const &SearchMaxPoint, IteratorType &Results, SizeType &NumberOfResults, SizeType const &MaxNumberOfResults) override
Definition: kd_tree.h:316
TreeNode< Dimension, PointType, PointerType, IteratorType, DistanceIteratorType > TreeNodeType
Definition: kd_tree.h:81
TLeafType LeafType
Definition: kd_tree.h:65
void SearchInRadius(PointType const &ThisPoint, CoordinateType const &Radius, CoordinateType const &Radius2, IteratorType &Results, SizeType &NumberOfResults, SizeType const &MaxNumberOfResults, SearchStructureType &Auxiliar) override
Definition: kd_tree.h:272
void SearchNearestPoint(PointType const &rThisPoint, PointerType &rResult, CoordinateType &rResultDistance) override
Definition: kd_tree.h:144
KRATOS_CLASS_POINTER_DEFINITION(KDTreePartitionBase)
Pointer definition of KDTree.
LeafType::PointType PointType
Definition: kd_tree.h:67
@ Dimension
Definition: kd_tree.h:79
LeafType::DistanceFunction DistanceFunction
Definition: kd_tree.h:77
KDTreePartitionBase(IndexType CutingDimension, CoordinateType Position, CoordinateType LeftEnd, CoordinateType RightEnd, TreeNodeType *pLeftChild=NULL, TreeNodeType *pRightChild=NULL)
Partition constructor.
Definition: kd_tree.h:98
void PrintData(std::ostream &rOStream, std::string const &Perfix=std::string()) const override
Definition: kd_tree.h:107
void SearchInRadius(PointType const &ThisPoint, CoordinateType const &Radius, CoordinateType const &Radius2, IteratorType &Results, DistanceIteratorType &ResultsDistances, SizeType &NumberOfResults, SizeType const &MaxNumberOfResults, SearchStructureType &Auxiliar) override
Definition: kd_tree.h:213
void SearchNearestPoint(PointType const &rThisPoint, PointerType &rResult, CoordinateType &rResultDistance, SearchStructureType &Auxiliar) override
Definition: kd_tree.h:156
LeafType::DistanceIteratorType DistanceIteratorType
Definition: kd_tree.h:73
LeafType::IteratorType IteratorType
Definition: kd_tree.h:71
TreeNodeType::CoordinateType CoordinateType
Definition: kd_tree.h:83
virtual ~KDTreePartitionBase()
Destructor.
Definition: kd_tree.h:133
TreeNodeType::SizeType SizeType
Definition: kd_tree.h:85
LeafType::SearchStructureType SearchStructureType
Definition: kd_tree.h:90
Definition: kd_tree.h:362
static IteratorType Partition(IteratorType PointsBegin, IteratorType PointsEnd, IndexType &rCuttingDimension, CoordinateType &rCuttingValue)
Definition: kd_tree.h:419
static void MedianSplit(IteratorType PointsBegin, IteratorType PartitionPosition, IteratorType PointsEnd, IndexType CuttingDimension, CoordinateType &rCuttingValue)
Definition: kd_tree.h:480
LeafType::IteratorType IteratorType
Definition: kd_tree.h:378
KDTreePartitionBase< TLeafType > BaseType
Definition: kd_tree.h:370
LeafType::PointType PointType
Definition: kd_tree.h:374
KRATOS_CLASS_POINTER_DEFINITION(KDTreePartition)
Pointer definition of KDTree.
TreeNodeType::CoordinateType CoordinateType
Definition: kd_tree.h:390
KDTreePartition(IndexType CutingDimension, CoordinateType Position, CoordinateType LeftEnd, CoordinateType RightEnd, TreeNodeType *pLeftChild=NULL, TreeNodeType *pRightChild=NULL)
Partition constructor.
Definition: kd_tree.h:405
LeafType::ContainerType ContainerType
Definition: kd_tree.h:376
LeafType::DistanceIteratorType DistanceIteratorType
Definition: kd_tree.h:380
TreeNode< Dimension, PointType, PointerType, IteratorType, DistanceIteratorType > TreeNodeType
Definition: kd_tree.h:388
~KDTreePartition()
Destructor.
Definition: kd_tree.h:410
LeafType::DistanceFunction DistanceFunction
Definition: kd_tree.h:384
TreeNodeType::SizeType SizeType
Definition: kd_tree.h:392
@ Dimension
Definition: kd_tree.h:386
static TreeNodeType * Construct(IteratorType PointsBegin, IteratorType PointsEnd, const PointType &HighPoint, const PointType &LowPoint, SizeType BucketSize)
Definition: kd_tree.h:538
TLeafType LeafType
Definition: kd_tree.h:372
TreeNodeType::IndexType IndexType
Definition: kd_tree.h:394
LeafType::SearchStructureType SearchStructureType
Definition: kd_tree.h:397
LeafType::PointerType PointerType
Definition: kd_tree.h:382
static SizeType MaxSpread(IteratorType PointsBegin, IteratorType PointsEnd)
Definition: kd_tree.h:436
Definition: kd_tree.h:797
TreeNodeType::IndexType IndexType
Definition: kd_tree.h:829
LeafType::PointType PointType
Definition: kd_tree.h:809
KDTreePartitionBase< TLeafType > BaseType
Definition: kd_tree.h:805
TLeafType LeafType
Definition: kd_tree.h:807
LeafType::DistanceIteratorType DistanceIteratorType
Definition: kd_tree.h:815
LeafType::SearchStructureType SearchStructureType
Definition: kd_tree.h:832
KRATOS_CLASS_POINTER_DEFINITION(KDTreePartitionMidPointSplit)
Pointer definition of KDTree.
static IteratorType Split(IteratorType PointsBegin, IteratorType PointsEnd, IndexType &CuttingDimension, CoordinateType &rCuttingValue)
Definition: kd_tree.h:923
TreeNodeType::SizeType SizeType
Definition: kd_tree.h:827
static IteratorType Partition(IteratorType PointsBegin, IteratorType PointsEnd, PointType const &HighPoint, PointType const &LowPoint, IndexType &rCuttingDimension, CoordinateType &rCuttingValue)
Definition: kd_tree.h:852
LeafType::IteratorType IteratorType
Definition: kd_tree.h:813
TreeNode< Dimension, PointType, PointerType, IteratorType, DistanceIteratorType > TreeNodeType
Definition: kd_tree.h:823
virtual ~KDTreePartitionMidPointSplit()
Destructor.
Definition: kd_tree.h:844
TreeNodeType::CoordinateType CoordinateType
Definition: kd_tree.h:825
static SizeType MaxSpread(IteratorType PointsBegin, IteratorType PointsEnd, PointType const &HighPoint, PointType const &LowPoint, CoordinateType &CuttingValue)
Definition: kd_tree.h:880
LeafType::PointerType PointerType
Definition: kd_tree.h:817
LeafType::ContainerType ContainerType
Definition: kd_tree.h:811
LeafType::DistanceFunction DistanceFunction
Definition: kd_tree.h:819
static TreeNodeType * Construct(IteratorType PointsBegin, IteratorType PointsEnd, PointType HighPoint, PointType LowPoint, SizeType BucketSize)
Definition: kd_tree.h:945
KDTreePartitionMidPointSplit(IndexType CutingDimension, CoordinateType Position, CoordinateType LeftEnd, CoordinateType RightEnd, TreeNodeType *pLeftChild=NULL, TreeNodeType *pRightChild=NULL)
Partition constructor.
Definition: kd_tree.h:839
@ Dimension
Definition: kd_tree.h:821
Short class definition.
Definition: tree.h:61
virtual void SearchInBox(PointType const &SearchMinPoint, PointType const &SearchMaxPoint, IteratorType &Results, SizeType &NumberOfResults, SizeType const &MaxNumberOfResults)
Definition: tree.h:138
virtual void SearchNearestPoint(PointType const &ThisPoint, PointerType &rResult, CoordinateType &rResultDistance)
Definition: tree.h:105
virtual void SearchInRadius(PointType const &ThisPoint, CoordinateType const &Radius, CoordinateType const &Radius2, IteratorType &Results, DistanceIteratorType &ResultsDistances, SizeType &NumberOfResults, SizeType const &MaxNumberOfResults)
Definition: tree.h:110
double CoordinateType
Define CoordinateType as double.
Definition: tree.h:76
virtual void PrintData(std::ostream &rOStream, std::string const &Perfix=std::string()) const
Definition: tree.h:99
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 IndexType
The definition of the index type.
Definition: key_hash.h:35
static double max(double a, double b)
Definition: GeometryFunctions.h:79
static double min(double a, double b)
Definition: GeometryFunctions.h:71
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
left
Definition: exact_hinsberg_test.py:140
c
Definition: generate_weakly_compressible_navier_stokes_element.py:108
def Average(vector_container, current_values, k_calc, pp)
Definition: initial_time_bounds.py:102
int d
Definition: ode_solve.py:397
int n
manufactured solution and derivatives (u=0 at z=0 dudz=0 at z=domain_height)
Definition: ode_solve.py:402
int k
Definition: quadrature.py:595
int j
Definition: quadrature.py:648
float temp
Definition: rotating_cone.py:85
integer i
Definition: TensorModule.f:17
Configure::IteratorType IteratorType
Definition: transfer_utility.h:249
Configure::PointType PointType
Definition: transfer_utility.h:245
Configure::ContainerType ContainerType
Definition: transfer_utility.h:247