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.
spatial_search.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: Carlos Roig
11 //
12 
13 #pragma once
14 
15 // System includes
16 
17 // External includes
18 
19 // Project includes
20 #include "includes/model_part.h"
21 
22 namespace Kratos
23 {
26 
30 
34 
38 
42 
49 class KRATOS_API(KRATOS_CORE) SpatialSearch
50 {
51 public:
54 
57 
59  using SizeType = std::size_t;
60 
62  using IndexType = std::size_t;
63 
65  static constexpr std::size_t Dimension = 3;
66 
68  static constexpr std::size_t MAX_LEVEL = 16;
69 
71  static constexpr std::size_t MIN_LEVEL = 2;
72 
74  using PointType = Point;
75 
77  using NodeType = Node;
78 
82  using VectorResultNodesContainerType = std::vector<ResultNodesContainerType>;
83 
87  using VectorResultElementsContainerType = std::vector<ResultElementsContainerType>;
88 
92  using VectorResultConditionsContainerType = std::vector<ResultConditionsContainerType>;
93 
95  using RadiusArrayType = std::vector<double>;
96  using DistanceType = std::vector<double>;
97  using VectorDistanceType = std::vector<DistanceType>;
98 
102 
105 
107  virtual ~SpatialSearch(){}
108 
112 
116 
117  //************************************************************************
118  // Elemental Exclusive search with distance calculation
119  //************************************************************************
120 
128  virtual void SearchElementsInRadiusExclusive (
129  ModelPart& rModelPart,
130  const RadiusArrayType& rRadius,
131  VectorResultElementsContainerType& rResults,
132  VectorDistanceType& rResultsDistance
133  );
134 
143  virtual void SearchElementsInRadiusExclusive (
144  ModelPart& rModelPart,
145  const ElementsContainerType& rInputElements,
146  const RadiusArrayType& rRadius,
147  VectorResultElementsContainerType& rResults,
148  VectorDistanceType& rResultsDistance
149  );
150 
158  virtual void SearchElementsInRadiusExclusive (
159  const ElementsContainerType& rStructureElements,
160  const RadiusArrayType& rRadius,
161  VectorResultElementsContainerType& rResults,
162  VectorDistanceType& rResultsDistance
163  );
164 
173  virtual void SearchElementsInRadiusExclusive (
174  const ElementsContainerType& rStructureElements,
175  const ElementsContainerType& rInputElements,
176  const RadiusArrayType& rRadius,
177  VectorResultElementsContainerType& rResults,
178  VectorDistanceType& rResultsDistance
179  );
180 
181  //************************************************************************
182  // Elemental Inclusive search with distance calculation
183  //************************************************************************
184 
192  virtual void SearchElementsInRadiusInclusive (
193  ModelPart& rModelPart,
194  const RadiusArrayType& rRadius,
195  VectorResultNodesContainerType& rResults,
196  VectorDistanceType& rResultsDistance
197  );
198 
207  virtual void SearchElementsInRadiusInclusive (
208  ModelPart& rModelPart,
209  const ElementsContainerType& rInputElements,
210  const RadiusArrayType& rRadius,
211  VectorResultNodesContainerType& rResults,
212  VectorDistanceType& rResultsDistance
213  );
214 
222  virtual void SearchElementsInRadiusInclusive (
223  const ElementsContainerType& rStructureElements,
224  const RadiusArrayType& rRadius,
225  VectorResultNodesContainerType& rResults,
226  VectorDistanceType& rResultsDistance
227  );
228 
237  virtual void SearchElementsInRadiusInclusive (
238  const ElementsContainerType& rStructureElements,
239  const ElementsContainerType& rInputElements,
240  const RadiusArrayType& rRadius,
241  VectorResultNodesContainerType& rResults,
242  VectorDistanceType& rResultsDistance
243  );
244 
245  //************************************************************************
246  // Elemental Exclusive search without distance calculation
247  //************************************************************************
248 
255  virtual void SearchElementsInRadiusExclusive (
256  ModelPart& rModelPart,
257  const RadiusArrayType& rRadius,
258  VectorResultElementsContainerType& rResults
259  );
260 
268  virtual void SearchElementsInRadiusExclusive (
269  ModelPart& rModelPart,
270  const ElementsContainerType& rInputElements,
271  const RadiusArrayType& rRadius,
272  VectorResultElementsContainerType& rResults
273  );
274 
281  virtual void SearchElementsInRadiusExclusive (
282  const ElementsContainerType& rStructureElements,
283  const RadiusArrayType& rRadius,
284  VectorResultElementsContainerType& rResults
285  );
286 
294  virtual void SearchElementsInRadiusExclusive (
295  const ElementsContainerType& rStructureElements,
296  const ElementsContainerType& rInputElements,
297  const RadiusArrayType& rRadius,
298  VectorResultElementsContainerType& rResults
299  );
300 
301  //************************************************************************
302  // Elemental Inclusive search without distance calculation
303  //************************************************************************
304 
311  virtual void SearchElementsInRadiusInclusive (
312  ModelPart& rModelPart,
313  const RadiusArrayType& rRadius,
314  VectorResultNodesContainerType& rResults
315  );
316 
324  virtual void SearchElementsInRadiusInclusive (
325  ModelPart& rModelPart,
326  const ElementsContainerType& rInputElements,
327  const RadiusArrayType& rRadius,
328  VectorResultNodesContainerType& rResults
329  );
330 
337  virtual void SearchElementsInRadiusInclusive (
338  const ElementsContainerType& rStructureElements,
339  const RadiusArrayType& rRadius,
340  VectorResultNodesContainerType& rResults
341  );
342 
350  virtual void SearchElementsInRadiusInclusive (
351  const ElementsContainerType& rStructureElements,
352  const ElementsContainerType& rInputElements,
353  const RadiusArrayType& rRadius,
354  VectorResultNodesContainerType& rResults
355  );
356 
357  //************************************************************************
358  // Nodal Exclusive search with distance calculation
359  //************************************************************************
360 
368  virtual void SearchNodesInRadiusExclusive (
369  ModelPart& rModelPart,
370  const RadiusArrayType& rRadius,
371  VectorResultNodesContainerType& rResults,
372  VectorDistanceType& rResultsDistance
373  );
374 
383  virtual void SearchNodesInRadiusExclusive (
384  ModelPart& rModelPart,
385  const NodesContainerType& rInputNodes,
386  const RadiusArrayType& rRadius,
387  VectorResultNodesContainerType& rResults,
388  VectorDistanceType& rResultsDistance
389  );
390 
398  virtual void SearchNodesInRadiusExclusive (
399  const NodesContainerType& rStructureNodes,
400  const RadiusArrayType& rRadius,
401  VectorResultNodesContainerType& rResults,
402  VectorDistanceType& rResultsDistance
403  );
404 
413  virtual void SearchNodesInRadiusExclusive (
414  const NodesContainerType& rStructureNodes,
415  const NodesContainerType& rInputNodes,
416  const RadiusArrayType& rRadius,
417  VectorResultNodesContainerType& rResults,
418  VectorDistanceType& rResultsDistance
419  );
420 
421  //************************************************************************
422  // Nodal Inclusive search with distance calculation
423  //************************************************************************
424 
432  virtual void SearchNodesInRadiusInclusive (
433  ModelPart& rModelPart,
434  const RadiusArrayType& rRadius,
435  VectorResultNodesContainerType& rResults,
436  VectorDistanceType& rResultsDistance
437  );
438 
447  virtual void SearchNodesInRadiusInclusive (
448  ModelPart& rModelPart,
449  const NodesContainerType& rInputNodes,
450  const RadiusArrayType& rRadius,
451  VectorResultNodesContainerType& rResults,
452  VectorDistanceType& rResultsDistance
453  );
454 
462  virtual void SearchNodesInRadiusInclusive (
463  const NodesContainerType& rStructureNodes,
464  const RadiusArrayType& rRadius,
465  VectorResultNodesContainerType& rResults,
466  VectorDistanceType& rResultsDistance
467  );
468 
477  virtual void SearchNodesInRadiusInclusive (
478  const NodesContainerType& rStructureNodes,
479  const NodesContainerType& rInputNodes,
480  const RadiusArrayType& rRadius,
481  VectorResultNodesContainerType& rResults,
482  VectorDistanceType& rResultsDistance
483  );
484 
485  //************************************************************************
486  // Nodal Exclusive search without distance calculation
487  //************************************************************************
488 
495  virtual void SearchNodesInRadiusExclusive (
496  ModelPart& rModelPart,
497  const RadiusArrayType& rRadius,
498  VectorResultNodesContainerType& rResults
499  );
500 
508  virtual void SearchNodesInRadiusExclusive (
509  ModelPart& rModelPart,
510  const NodesContainerType& rInputNodes,
511  const RadiusArrayType& rRadius,
512  VectorResultNodesContainerType& rResults
513  );
514 
521  virtual void SearchNodesInRadiusExclusive (
522  const NodesContainerType& rStructureNodes,
523  const RadiusArrayType& rRadius,
524  VectorResultNodesContainerType& rResults
525  );
526 
534  virtual void SearchNodesInRadiusExclusive (
535  const NodesContainerType& rStructureNodes,
536  const NodesContainerType& rInputNodes,
537  const RadiusArrayType& rRadius,
538  VectorResultNodesContainerType& rResults
539  );
540 
541  //************************************************************************
542  // Nodal Inclusive search without distance calculation
543  //************************************************************************
544 
551  virtual void SearchNodesInRadiusInclusive (
552  ModelPart& rModelPart,
553  const RadiusArrayType& rRadius,
554  VectorResultNodesContainerType& rResults
555  );
556 
564  virtual void SearchNodesInRadiusInclusive (
565  ModelPart& rModelPart,
566  const NodesContainerType& rInputNodes,
567  const RadiusArrayType& rRadius,
568  VectorResultNodesContainerType& rResults
569  );
570 
577  virtual void SearchNodesInRadiusInclusive (
578  const NodesContainerType& rStructureNodes,
579  const RadiusArrayType& rRadius,
580  VectorResultNodesContainerType& rResults
581  );
582 
590  virtual void SearchNodesInRadiusInclusive (
591  const NodesContainerType& rStructureNodes,
592  const NodesContainerType& rInputNodes,
593  const RadiusArrayType& rRadius,
594  VectorResultNodesContainerType& rResults
595  );
596 
597  //************************************************************************
598  // Conditional Exclusive search with distance calculation
599  //************************************************************************
600 
608  virtual void SearchConditionsInRadiusExclusive (
609  ModelPart& rModelPart,
610  const RadiusArrayType& rRadius,
611  VectorResultConditionsContainerType& rResults,
612  VectorDistanceType& rResultsDistance
613  );
614 
623  virtual void SearchConditionsInRadiusExclusive (
624  ModelPart& rModelPart,
625  const ConditionsContainerType& rInputConditions,
626  const RadiusArrayType& rRadius,
627  VectorResultConditionsContainerType& rResults,
628  VectorDistanceType& rResultsDistance
629  );
630 
638  virtual void SearchConditionsInRadiusExclusive (
639  const ConditionsContainerType& rStructureConditions,
640  const RadiusArrayType& rRadius,
641  VectorResultConditionsContainerType& rResults,
642  VectorDistanceType& rResultsDistance
643  );
644 
653  virtual void SearchConditionsInRadiusExclusive (
654  const ConditionsContainerType& rStructureConditions,
655  const ConditionsContainerType& rInputConditions,
656  const RadiusArrayType& rRadius,
657  VectorResultConditionsContainerType& rResults,
658  VectorDistanceType& rResultsDistance
659  );
660 
661  //************************************************************************
662  // Conditional Inclusive search with distance calculation
663  //************************************************************************
664 
672  virtual void SearchConditionsInRadiusInclusive (
673  ModelPart& rModelPart,
674  const RadiusArrayType& rRadius,
675  VectorResultNodesContainerType& rResults,
676  VectorDistanceType& rResultsDistance
677  );
678 
687  virtual void SearchConditionsInRadiusInclusive (
688  ModelPart& rModelPart,
689  const ConditionsContainerType& rInputConditions,
690  const RadiusArrayType& rRadius,
691  VectorResultNodesContainerType& rResults,
692  VectorDistanceType& rResultsDistance
693  );
694 
702  virtual void SearchConditionsInRadiusInclusive (
703  const ConditionsContainerType& rStructureConditions,
704  const RadiusArrayType& rRadius,
705  VectorResultNodesContainerType& rResults,
706  VectorDistanceType& rResultsDistance
707  );
708 
717  virtual void SearchConditionsInRadiusInclusive (
718  const ConditionsContainerType& rStructureConditions,
719  const ConditionsContainerType& rInputConditions,
720  const RadiusArrayType& rRadius,
721  VectorResultNodesContainerType& rResults,
722  VectorDistanceType& rResultsDistance
723  );
724 
725  //************************************************************************
726  // Conditional Exclusive search without distance calculation
727  //************************************************************************
728 
735  virtual void SearchConditionsInRadiusExclusive (
736  ModelPart& rModelPart,
737  const RadiusArrayType& rRadius,
738  VectorResultConditionsContainerType& rResults
739  );
740 
748  virtual void SearchConditionsInRadiusExclusive (
749  ModelPart& rModelPart,
750  const ConditionsContainerType& rInputConditions,
751  const RadiusArrayType& rRadius,
752  VectorResultConditionsContainerType& rResults
753  );
754 
761  virtual void SearchConditionsInRadiusExclusive (
762  const ConditionsContainerType& rStructureConditions,
763  const RadiusArrayType& rRadius,
764  VectorResultConditionsContainerType& rResults
765  );
766 
774  virtual void SearchConditionsInRadiusExclusive (
775  const ConditionsContainerType& rStructureConditions,
776  const ConditionsContainerType& rInputConditions,
777  const RadiusArrayType& rRadius,
778  VectorResultConditionsContainerType& rResults
779  );
780 
781  //************************************************************************
782  // Conditional Inclusive search without distance calculation
783  //************************************************************************
784 
791  virtual void SearchConditionsInRadiusInclusive (
792  ModelPart& rModelPart,
793  const RadiusArrayType& rRadius,
794  VectorResultNodesContainerType& rResults
795  );
796 
804  virtual void SearchConditionsInRadiusInclusive (
805  ModelPart& rModelPart,
806  const ConditionsContainerType& rInputConditions,
807  const RadiusArrayType& rRadius,
808  VectorResultNodesContainerType& rResults
809  );
810 
817  virtual void SearchConditionsInRadiusInclusive (
818  const ConditionsContainerType& rStructureConditions,
819  const RadiusArrayType& rRadius,
820  VectorResultNodesContainerType& rResults
821  );
822 
830  virtual void SearchConditionsInRadiusInclusive (
831  const ConditionsContainerType& rStructureConditions,
832  const ConditionsContainerType& rInputConditions,
833  const RadiusArrayType& rRadius,
834  VectorResultNodesContainerType& rResults
835  );
836 
837  //************************************************************************
838  // Elemental vs Condition Exclusive search with distance calculation
839  //************************************************************************
840 
848  virtual void SearchConditionsOverElementsInRadiusExclusive (
849  ModelPart& rModelPart,
850  const RadiusArrayType& rRadius,
851  VectorResultElementsContainerType& rResults,
852  VectorDistanceType& rResultsDistance
853  );
854 
863  virtual void SearchConditionsOverElementsInRadiusExclusive (
864  ModelPart& rModelPart,
865  const ConditionsContainerType& rInputConditions,
866  const RadiusArrayType& rRadius,
867  VectorResultElementsContainerType& rResults,
868  VectorDistanceType& rResultsDistance
869  );
870 
879  virtual void SearchConditionsOverElementsInRadiusExclusive (
880  const ElementsContainerType& rStructureElements,
881  const ConditionsContainerType& rInputConditions,
882  const RadiusArrayType& rRadius,
883  VectorResultElementsContainerType& rResults,
884  VectorDistanceType& rResultsDistance
885  );
886 
887  //************************************************************************
888  // Elemental vs Condition Inclusive search with distance calculation
889  //************************************************************************
890 
898  virtual void SearchConditionsOverElementsInRadiusInclusive (
899  ModelPart& rModelPart,
900  const RadiusArrayType& rRadius,
901  VectorResultElementsContainerType& rResults,
902  VectorDistanceType& rResultsDistance
903  );
904 
913  virtual void SearchConditionsOverElementsInRadiusInclusive (
914  ModelPart& rModelPart,
915  const ConditionsContainerType& rInputConditions,
916  const RadiusArrayType& rRadius,
917  VectorResultElementsContainerType& rResults,
918  VectorDistanceType& rResultsDistance
919  );
920 
929  virtual void SearchConditionsOverElementsInRadiusInclusive (
930  const ElementsContainerType& rStructureElements,
931  const ConditionsContainerType& rInputConditions,
932  const RadiusArrayType& rRadius,
933  VectorResultElementsContainerType& rResults,
934  VectorDistanceType& rResultsDistance
935  );
936 
937  //************************************************************************
938  // Condition vs Elemental Exclusive search with distance calculation
939  //************************************************************************
940 
948  virtual void SearchElementsOverConditionsInRadiusExclusive (
949  ModelPart& rModelPart,
950  const RadiusArrayType& rRadius,
951  VectorResultElementsContainerType& rResults,
952  VectorDistanceType& rResultsDistance
953  );
954 
963  virtual void SearchElementsOverConditionsInRadiusExclusive (
964  ModelPart& rModelPart,
965  const ElementsContainerType& rInputElements,
966  const RadiusArrayType& rRadius,
967  VectorResultElementsContainerType& rResults,
968  VectorDistanceType& rResultsDistance
969  );
970 
979  virtual void SearchElementsOverConditionsInRadiusExclusive (
980  const ConditionsContainerType& rStructureConditions,
981  const ElementsContainerType& rInputElements,
982  const RadiusArrayType& rRadius,
983  VectorResultElementsContainerType& rResults,
984  VectorDistanceType& rResultsDistance
985  );
986 
987  //************************************************************************
988  // Condition vs Elemental Inclusive search with distance calculation
989  //************************************************************************
990 
998  virtual void SearchElementsOverConditionsInRadiusInclusive (
999  ModelPart& rModelPart,
1000  const RadiusArrayType& rRadius,
1001  VectorResultElementsContainerType& rResults,
1002  VectorDistanceType& rResultsDistance
1003  );
1004 
1013  virtual void SearchElementsOverConditionsInRadiusInclusive (
1014  ModelPart& rModelPart,
1015  const ElementsContainerType& rInputElements,
1016  const RadiusArrayType& rRadius,
1017  VectorResultElementsContainerType& rResults,
1018  VectorDistanceType& rResultsDistance
1019  );
1020 
1029  virtual void SearchElementsOverConditionsInRadiusInclusive (
1030  const ConditionsContainerType& rStructureConditions,
1031  const ElementsContainerType& rInputElements,
1032  const RadiusArrayType& rRadius,
1033  VectorResultElementsContainerType& rResults,
1034  VectorDistanceType& rResultsDistance
1035  );
1036 
1037  //************************************************************************
1038  // Bounding box methods
1039  //************************************************************************
1040 
1045  virtual void InitializeBoundingBox(const NodesContainerType& rStructureNodes);
1046 
1051  virtual void InitializeBoundingBox(const ElementsContainerType& rStructureElements);
1052 
1057  virtual void InitializeBoundingBox(const ConditionsContainerType& rStructureConditions);
1058 
1062 
1066 
1070 
1072  virtual std::string Info() const
1073  {
1074  std::stringstream buffer;
1075  buffer << "SpatialSearch" ;
1076 
1077  return buffer.str();
1078  }
1079 
1081  virtual void PrintInfo(std::ostream& rOStream) const {rOStream << "SpatialSearch";}
1082 
1084  virtual void PrintData(std::ostream& rOStream) const {}
1085 
1089 
1091 protected:
1094 
1098 
1102 
1106 
1110 
1114 
1118 
1120 private:
1123 
1127 
1131 
1135 
1139 
1143 
1147 
1149  SpatialSearch& operator=(SpatialSearch const& rOther)
1150  {
1151  return *this;
1152  }
1153 
1155  SpatialSearch(SpatialSearch const& rOther)
1156  {
1157  *this = rOther;
1158  }
1159 
1161 }; // Class SpatialSearch
1162 
1166 
1170 
1172 inline std::ostream& operator << (std::ostream& rOStream,
1173  const SpatialSearch& rThis)
1174 {
1175  rThis.PrintInfo(rOStream);
1176  rOStream << std::endl;
1177  rThis.PrintData(rOStream);
1178 
1179  return rOStream;
1180 }
1182 
1184 
1185 } // namespace Kratos.
PeriodicInterfaceProcess & operator=(const PeriodicInterfaceProcess &)=delete
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
MeshType::ConditionsContainerType ConditionsContainerType
Condintions container. A vector set of Conditions with their Id's as key.
Definition: model_part.h:183
MeshType::ElementsContainerType ElementsContainerType
Element container. A vector set of Elements with their Id's as key.
Definition: model_part.h:168
MeshType::NodesContainerType NodesContainerType
Nodes container. Which is a vector set of nodes with their Id's as key.
Definition: model_part.h:128
This class defines the node.
Definition: node.h:65
Point class.
Definition: point.h:59
A sorted associative container similar to an STL set, but uses a vector to store pointers to its data...
Definition: pointer_vector_set.h:72
This class is used to search for elements, conditions and nodes in a given model part.
Definition: spatial_search.h:50
virtual ~SpatialSearch()
Destructor.
Definition: spatial_search.h:107
std::vector< ResultConditionsContainerType > VectorResultConditionsContainerType
Definition: spatial_search.h:92
std::vector< double > RadiusArrayType
Input/output types.
Definition: spatial_search.h:95
ConditionsContainerType::ContainerType ResultConditionsContainerType
Definition: spatial_search.h:91
std::vector< DistanceType > VectorDistanceType
Definition: spatial_search.h:97
std::vector< ResultNodesContainerType > VectorResultNodesContainerType
Definition: spatial_search.h:82
NodesContainerType::ContainerType ResultNodesContainerType
Definition: spatial_search.h:81
std::vector< ResultElementsContainerType > VectorResultElementsContainerType
Definition: spatial_search.h:87
std::size_t SizeType
The size type definition.
Definition: spatial_search.h:59
virtual void PrintData(std::ostream &rOStream) const
Print object's data.
Definition: spatial_search.h:1084
virtual std::string Info() const
Turn back information as a string.
Definition: spatial_search.h:1072
std::size_t IndexType
The index type definition.
Definition: spatial_search.h:62
virtual void PrintInfo(std::ostream &rOStream) const
Print information about this object.
Definition: spatial_search.h:1081
ElementsContainerType::ContainerType ResultElementsContainerType
Definition: spatial_search.h:86
KRATOS_CLASS_POINTER_DEFINITION(SpatialSearch)
Pointer definition of SpatialSearch.
std::vector< double > DistanceType
Definition: spatial_search.h:96
SpatialSearch()
Default constructor.
Definition: spatial_search.h:104
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
ModelPart::NodesContainerType NodesContainerType
Definition: find_conditions_neighbours_process.h:44
ModelPart::ConditionsContainerType ConditionsContainerType
Definition: find_conditions_neighbours_process.h:45
ModelPart::ElementsContainerType ElementsContainerType
Definition: clear_contact_conditions_mesher_process.hpp:43
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
Configure::ContainerType ContainerType
Definition: transfer_utility.h:247