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.
dem_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: clabra
11 //
12 
13 #pragma once
14 
15 // include kratos definitions
16 #include "includes/define.h"
17 
18 // System includes
19 #include <string>
20 #include <iostream>
21 
22 // External includes
24 
25 namespace Kratos
26 {
27 
30 
34 
38 
42 
46 
48 
51 template<std::size_t dim, class T>
53 {
54  public:
55  inline double operator()( T const& p1, T const& p2 )
56  {
57  double dist = 0.0;
58 
59  double tmp1 = p1[0] - p2[0];
60  double tmp2 = p1[1] - p2[1];
61  double tmp3 = p1[2] - p2[2];
62 
63  dist += tmp1*tmp1 + tmp2*tmp2 + tmp3*tmp3;
64 
65 // dist = sqrt(dist) - p2.radius - p1.radius;
66 
67  return dist;
68  }
69 };
70 
71 template<std::size_t Dimension>
73 {
74  public:
76  virtual ~RadiusPoint(){}
77 
78  void Initialize(Element::Pointer baseElem)
79  {
80  for(std::size_t i = 0; i < Dimension; i++)
81  coord[i] = baseElem->GetGeometry()[0][i];
82 
83  pNaseElem = baseElem;
84 
85 // mRadius = baseElem->GetGeometry()[0].FastGetSolutionStepValue(RADIUS);
86  }
87 
88  void Initialize(Element::Pointer baseElem, double Radius)
89  {
90  for(std::size_t i = 0; i < Dimension; i++)
91  coord[i] = baseElem->GetGeometry()[0][i];
92 
93  pNaseElem = baseElem;
94 
95 // mRadius = Radius;
96  }
97 
98  public:
99 
100  double mRadius;
101 
102  double coord[Dimension];
103 
104  double & operator[](std::size_t i) {return coord[i];}
105  double const & operator[](std::size_t i) const {return coord[i];}
106 
107  Element::Pointer pNaseElem;
108 
109  void operator=(Point const& Other){
110  for(std::size_t i = 0; i < Dimension; i++)
111  coord[i] = Other[i];
112  }
113 };
114 
115 template< std::size_t Dimension >
116 std::ostream & operator<<( std::ostream& rOut, RadiusPoint<Dimension> & rPoint){
117  for(std::size_t i = 0 ; i < Dimension ; i++)
118  rOut << rPoint[i] << " ";
119  return rOut;
120 }
121 
122 template< std::size_t Dimension >
123 std::istream & operator>>( std::istream& rIn, RadiusPoint<Dimension> & rPoint){
124  for(std::size_t i = 0 ; i < Dimension ; i++)
125  rIn >> rPoint[i];
126 
127  return rIn;
128 }
129 
130 template< class TDerived >
131 class DEMSearch : public SpatialSearch
132 {
133  public:
136 
139 
142  typedef std::vector<PtrPointType>* PointVector;
143 
145 
146  // Tell the compiler which overloaded functions are using so we can
147  // avoid "overloaded virtual function" warnings
148 
157 
161 
163  DEMSearch(const double domain_min_x = 0.0, const double domain_min_y = 0.0, const double domain_min_z = 0.0,
164  const double domain_max_x = -1.0, const double domain_max_y = -1.0, const double domain_max_z = -1.0)
165  {
166  mDomainMin[0] = domain_min_x;
167  mDomainMin[1] = domain_min_y;
168  mDomainMin[2] = domain_min_z;
169  mDomainMax[0] = domain_max_x;
170  mDomainMax[1] = domain_max_y;
171  mDomainMax[2] = domain_max_z;
172  TDerived::ElementConfigureType::SetDomain(domain_min_x, domain_min_y, domain_min_z, domain_max_x, domain_max_y, domain_max_z);
173  TDerived::NodeConfigureType::SetDomain(domain_min_x, domain_min_y, domain_min_z, domain_max_x, domain_max_y, domain_max_z);
174  mDomainPeriodicity = TDerived::ElementConfigureType::GetDomainPeriodicity();
175  searchPoints = new std::vector<PtrPointType>(0);
176  }
177 
179  virtual ~DEMSearch(){
180  delete searchPoints;
181  }
182 
186 
190 
192  ElementsContainerType const& StructureElements,
193  ElementsContainerType const& InputElements,
194  const RadiusArrayType & Radius,
196  VectorDistanceType& rResultsDistance ) override
197  {
198  static_cast<TDerived*>(this)->SearchElementsInRadiusExclusiveImplementation(StructureElements,InputElements,Radius,rResults,rResultsDistance);
199  }
200 
202  ElementsContainerType const& StructureElements,
203  ElementsContainerType const& InputElements,
204  const RadiusArrayType & Radius,
206  VectorDistanceType& rResultsDistance )
207  {
208  static_cast<TDerived*>(this)->SearchElementsInRadiusInclusiveImplementation(StructureElements,InputElements,Radius,rResults,rResultsDistance);
209  }
210 
212  ElementsContainerType const& StructureElements,
213  ElementsContainerType const& InputElements,
214  const RadiusArrayType & Radius,
215  VectorResultElementsContainerType& rResults ) override
216  {
217  static_cast<TDerived*>(this)->SearchElementsInRadiusExclusiveImplementation(StructureElements,InputElements,Radius,rResults);
218  }
219 
221  ElementsContainerType const& StructureElements,
222  ElementsContainerType const& InputElements,
223  const RadiusArrayType & Radius,
225  {
226  static_cast<TDerived*>(this)->SearchElementsInRadiusInclusiveImplementation(StructureElements,InputElements,Radius,rResults);
227  }
228 
230  NodesContainerType const& StructureNodes,
231  NodesContainerType const& InputNodes,
232  const RadiusArrayType & Radius,
234  VectorDistanceType& rResultsDistance ) override
235  {
236  static_cast<TDerived*>(this)->SearchNodesInRadiusExclusiveImplementation(StructureNodes,InputNodes,Radius,rResults,rResultsDistance);
237  }
238 
240  NodesContainerType const& StructureNodes,
241  NodesContainerType const& InputNodes,
242  const RadiusArrayType & Radius,
244  VectorDistanceType& rResultsDistance ) override
245  {
246  static_cast<TDerived*>(this)->SearchNodesInRadiusInclusiveImplementation(StructureNodes,InputNodes,Radius,rResults,rResultsDistance);
247  }
248 
250  NodesContainerType const& StructureNodes,
251  NodesContainerType const& InputNodes,
252  const RadiusArrayType & Radius,
253  VectorResultNodesContainerType& rResults ) override
254  {
255  static_cast<TDerived*>(this)->SearchNodesInRadiusExclusiveImplementation(StructureNodes,InputNodes,Radius,rResults);
256  }
257 
259  NodesContainerType const& StructureNodes,
260  NodesContainerType const& InputNodes,
261  const RadiusArrayType & Radius,
262  VectorResultNodesContainerType& rResults ) override
263  {
264  static_cast<TDerived*>(this)->SearchNodesInRadiusInclusiveImplementation(StructureNodes,InputNodes,Radius,rResults);
265  }
266 
268  ElementsContainerType const& StructureElements,
269  ConditionsContainerType const& InputConditions,
270  const RadiusArrayType & Radius,
272  VectorDistanceType& rResultsDistance )
273  {
274  static_cast<TDerived*>(this)->SearchGeometricalInRadiusExclusiveImplementation(StructureElements,InputConditions,Radius,rResults,rResultsDistance);
275  }
276 
278  ElementsContainerType const& StructureElements,
279  ConditionsContainerType const& InputConditions,
280  const RadiusArrayType & Radius,
282  VectorDistanceType& rResultsDistance )
283  {
284  static_cast<TDerived*>(this)->SearchGeometricalInRadiusInclusiveImplementation(StructureElements,InputConditions,Radius,rResults,rResultsDistance);
285  }
286 
288  ConditionsContainerType const& StructureElements,
289  ElementsContainerType const& InputElements,
290  const RadiusArrayType & Radius,
292  VectorDistanceType& rResultsDistance ) override
293  {
294  static_cast<TDerived*>(this)->SearchGeometricalInRadiusExclusiveImplementation(StructureElements,InputElements,Radius,rResults,rResultsDistance);
295  }
296 
298  ConditionsContainerType const& StructureElements,
299  ElementsContainerType const& InputElements,
300  const RadiusArrayType & Radius,
302  VectorDistanceType& rResultsDistance ) override
303  {
304  static_cast<TDerived*>(this)->SearchGeometricalInRadiusInclusiveImplementation(StructureElements,InputElements,Radius,rResults,rResultsDistance);
305  }
306 
310 
311 
315 
316 
320 
322  virtual std::string Info() const override
323  {
324  std::stringstream buffer;
325  buffer << "DemSearch" ;
326 
327  return buffer.str();
328  }
329 
331  virtual void PrintInfo(std::ostream& rOStream) const override {rOStream << "DemSearch";}
332 
334  virtual void PrintData(std::ostream& rOStream) const override {}
335 
336 
340 
341 
343 
344  protected:
347 
348 
352 
353 
357 
358 
362 
363 
370 
374 
378 
379 
381 
382  private:
385 
389 
390 
394 
395 
399 
400 
404 
405 
409 
410 
414 
416  DEMSearch& operator=(DEMSearch const& rOther)
417  {
418  return *this;
419  }
420 
422  DEMSearch(DEMSearch const& rOther)
423  {
424  *this = rOther;
425  }
426 
427 
429 
430  }; // Class DEMSearch
431 
433 
436 
437 
441 
442 
443 // /// input stream function
444 // inline std::istream& operator >> (std::istream& rIStream,
445 // DEMSearch& rThis){return rIStream;}
446 //
447 // /// output stream function
448 // inline std::ostream& operator << (std::ostream& rOStream,
449 // const DEMSearch& rThis)
450 // {
451 // rThis.PrintInfo(rOStream);
452 // rOStream << std::endl;
453 // rThis.PrintData(rOStream);
454 //
455 // return rOStream;
456 // }
457 
459 
461 
462 } // namespace Kratos.
Definition: dem_search.h:132
void SearchElementsOverConditionsInRadiusInclusive(ConditionsContainerType const &StructureElements, ElementsContainerType const &InputElements, const RadiusArrayType &Radius, VectorResultElementsContainerType &rResults, VectorDistanceType &rResultsDistance) override
Definition: dem_search.h:297
bool mDomainPeriodicity
Definition: dem_search.h:367
void SearchNodesInRadiusInclusive(NodesContainerType const &StructureNodes, NodesContainerType const &InputNodes, const RadiusArrayType &Radius, VectorResultNodesContainerType &rResults) override
Definition: dem_search.h:258
std::vector< PtrPointType > * PointVector
Definition: dem_search.h:142
RadiusPoint< Dimension > PointType
Definition: dem_search.h:140
void SearchNodesInRadiusInclusive(NodesContainerType const &StructureNodes, NodesContainerType const &InputNodes, const RadiusArrayType &Radius, VectorResultNodesContainerType &rResults, VectorDistanceType &rResultsDistance) override
Definition: dem_search.h:239
void SearchElementsInRadiusExclusive(ElementsContainerType const &StructureElements, ElementsContainerType const &InputElements, const RadiusArrayType &Radius, VectorResultElementsContainerType &rResults) override
Definition: dem_search.h:211
PointType * PtrPointType
Definition: dem_search.h:141
KRATOS_CLASS_POINTER_DEFINITION(DEMSearch)
Pointer definition of DEMSearch.
void SearchElementsInRadiusExclusive(ElementsContainerType const &StructureElements, ElementsContainerType const &InputElements, const RadiusArrayType &Radius, VectorResultElementsContainerType &rResults, VectorDistanceType &rResultsDistance) override
Definition: dem_search.h:191
array_1d< double, 3 > mDomainMax
Definition: dem_search.h:369
PointVector searchPoints
Definition: dem_search.h:144
virtual ~DEMSearch()
Destructor.
Definition: dem_search.h:179
void SearchNodesInRadiusExclusive(NodesContainerType const &StructureNodes, NodesContainerType const &InputNodes, const RadiusArrayType &Radius, VectorResultNodesContainerType &rResults, VectorDistanceType &rResultsDistance) override
Definition: dem_search.h:229
void SearchConditionsOverElementsInRadiusExclusive(ElementsContainerType const &StructureElements, ConditionsContainerType const &InputConditions, const RadiusArrayType &Radius, VectorResultConditionsContainerType &rResults, VectorDistanceType &rResultsDistance)
Definition: dem_search.h:267
void SearchElementsInRadiusInclusive(ElementsContainerType const &StructureElements, ElementsContainerType const &InputElements, const RadiusArrayType &Radius, VectorResultElementsContainerType &rResults)
Definition: dem_search.h:220
array_1d< double, 3 > mDomainMin
Definition: dem_search.h:368
virtual std::string Info() const override
Turn back information as a string.
Definition: dem_search.h:322
void SearchNodesInRadiusExclusive(NodesContainerType const &StructureNodes, NodesContainerType const &InputNodes, const RadiusArrayType &Radius, VectorResultNodesContainerType &rResults) override
Definition: dem_search.h:249
DEMSearch(const double domain_min_x=0.0, const double domain_min_y=0.0, const double domain_min_z=0.0, const double domain_max_x=-1.0, const double domain_max_y=-1.0, const double domain_max_z=-1.0)
Default constructor.
Definition: dem_search.h:163
virtual void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: dem_search.h:334
void SearchElementsInRadiusInclusive(ElementsContainerType const &StructureElements, ElementsContainerType const &InputElements, const RadiusArrayType &Radius, VectorResultElementsContainerType &rResults, VectorDistanceType &rResultsDistance)
Definition: dem_search.h:201
void SearchElementsOverConditionsInRadiusExclusive(ConditionsContainerType const &StructureElements, ElementsContainerType const &InputElements, const RadiusArrayType &Radius, VectorResultElementsContainerType &rResults, VectorDistanceType &rResultsDistance) override
Definition: dem_search.h:287
void SearchConditionsOverElementsInRadiusInclusive(ElementsContainerType const &StructureElements, ConditionsContainerType const &InputConditions, const RadiusArrayType &Radius, VectorResultConditionsContainerType &rResults, VectorDistanceType &rResultsDistance)
Definition: dem_search.h:277
virtual void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: dem_search.h:331
Short class definition.
Definition: dem_search.h:53
double operator()(T const &p1, T const &p2)
Definition: dem_search.h:55
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
Definition: dem_search.h:73
double mRadius
Definition: dem_search.h:100
void Initialize(Element::Pointer baseElem)
Definition: dem_search.h:78
Element::Pointer pNaseElem
Definition: dem_search.h:107
void Initialize(Element::Pointer baseElem, double Radius)
Definition: dem_search.h:88
double coord[Dimension]
Definition: dem_search.h:102
double const & operator[](std::size_t i) const
Definition: dem_search.h:105
void operator=(Point const &Other)
Definition: dem_search.h:109
virtual ~RadiusPoint()
Definition: dem_search.h:76
double & operator[](std::size_t i)
Definition: dem_search.h:104
RadiusPoint()
Definition: dem_search.h:75
This class is used to search for elements, conditions and nodes in a given model part.
Definition: spatial_search.h:50
virtual void SearchNodesInRadiusInclusive(ModelPart &rModelPart, const RadiusArrayType &rRadius, VectorResultNodesContainerType &rResults, VectorDistanceType &rResultsDistance)
Search neighbours for every node in "rModelpart" including itself.
Definition: spatial_search.cpp:315
std::vector< ResultConditionsContainerType > VectorResultConditionsContainerType
Definition: spatial_search.h:92
std::vector< double > RadiusArrayType
Input/output types.
Definition: spatial_search.h:95
std::vector< DistanceType > VectorDistanceType
Definition: spatial_search.h:97
std::vector< ResultNodesContainerType > VectorResultNodesContainerType
Definition: spatial_search.h:82
std::vector< ResultElementsContainerType > VectorResultElementsContainerType
Definition: spatial_search.h:87
virtual void SearchElementsOverConditionsInRadiusExclusive(ModelPart &rModelPart, const RadiusArrayType &rRadius, VectorResultElementsContainerType &rResults, VectorDistanceType &rResultsDistance)
Search neighbours for every element in "rModelpart" excluding itself.
Definition: spatial_search.cpp:809
virtual void SearchElementsOverConditionsInRadiusInclusive(ModelPart &rModelPart, const RadiusArrayType &rRadius, VectorResultElementsContainerType &rResults, VectorDistanceType &rResultsDistance)
Search neighbours for every element in "rModelpart" excluding itself.
Definition: spatial_search.cpp:854
virtual void SearchNodesInRadiusExclusive(ModelPart &rModelPart, const RadiusArrayType &rRadius, VectorResultNodesContainerType &rResults, VectorDistanceType &rResultsDistance)
Search neighbours for every node in "rModelpart" excluding itself.
Definition: spatial_search.cpp:255
virtual void SearchElementsInRadiusInclusive(ModelPart &rModelPart, const RadiusArrayType &rRadius, VectorResultNodesContainerType &rResults, VectorDistanceType &rResultsDistance)
Search neighbours for every element in "rModelpart" including itself.
Definition: spatial_search.cpp:83
virtual void SearchConditionsOverElementsInRadiusExclusive(ModelPart &rModelPart, const RadiusArrayType &rRadius, VectorResultElementsContainerType &rResults, VectorDistanceType &rResultsDistance)
Search neighbours for every element in "rModelpart" excluding itself.
Definition: spatial_search.cpp:719
virtual void SearchElementsInRadiusExclusive(ModelPart &rModelPart, const RadiusArrayType &rRadius, VectorResultElementsContainerType &rResults, VectorDistanceType &rResultsDistance)
Search neighbours for every element in "rModelpart" excluding itself.
Definition: spatial_search.cpp:23
virtual void SearchConditionsOverElementsInRadiusInclusive(ModelPart &rModelPart, const RadiusArrayType &rRadius, VectorResultElementsContainerType &rResults, VectorDistanceType &rResultsDistance)
Search neighbours for every element in "rModelpart" excluding itself.
Definition: spatial_search.cpp:764
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
float dist
Definition: edgebased_PureConvection.py:89
integer i
Definition: TensorModule.f:17