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.
node_configure_for_node_search.h
Go to the documentation of this file.
1 // KRATOS ___| | | |
2 // \___ \ __| __| | | __| __| | | __| _` | |
3 // | | | | | ( | | | | ( | |
4 // _____/ \__|_| \__,_|\___|\__|\__,_|_| \__,_|_| MECHANICS
5 //
6 // License: BSD License
7 // license: StructuralMechanicsApplication/license.txt
8 //
9 // Main authors: Manuel Messmer
10 //
11 
12 #pragma once
13 
14 // System includes
15 #include <string>
16 #include <iostream>
17 #include <cmath>
18 
19 // Kratos includes
21 
22 namespace Kratos {
25 
28 
38 class KRATOS_API(STRUCTURAL_MECHANICS_APPLICATION) NodeConfigureForNodeSearch {
39 public:
42 
48  static constexpr auto Epsilon = std::numeric_limits<double>::epsilon();
49  static constexpr auto Dimension = 3;
50 
54 
58 
60  typedef ContainerType::value_type PointerType;
61  typedef ContainerType::iterator IteratorType;
62 
64 
65  typedef ResultContainerType::iterator ResultIteratorType;
66  typedef std::vector<double>::iterator DistanceIteratorType;
67 
71 
74 
77 
81 
88  static inline void CalculateBoundingBox(const PointerType& rObject, PointType& rLowPoint, PointType& rHighPoint)
89  {
90  rHighPoint = rLowPoint = *rObject;
91  }
92 
100  static inline void CalculateBoundingBox(const PointerType& rObject, PointType& rLowPoint, PointType& rHighPoint, const double Radius)
101  {
102  auto radiusExtension = PointType(Radius, Radius, Radius);
103 
104  rLowPoint = PointType{*rObject - radiusExtension};
105  rHighPoint = PointType{*rObject + radiusExtension};
106  }
107 
112  static inline void CalculateCenter(const PointerType& rObject, PointType& rCenter)
113  {
114  rCenter = *rObject;
115  }
116 
125  static inline bool Intersection(const PointerType& rObj_1, const PointerType& rObj_2, const double Radius)
126  {
127  double distance;
128  Distance(rObj_1, rObj_2, distance);
129 
130  if( distance > Epsilon + Radius){
131  return false;
132  }
133 
134  return true;
135  }
136 
145  static inline bool IntersectionBox(const PointerType& rObject, const PointType& rLowPoint, const PointType& rHighPoint)
146  {
147  for(std::size_t i = 0; i < Dimension; i++) {
148  if( (*rObject)[i] < rLowPoint[i] - Epsilon || (*rObject)[i] > rHighPoint[i] + Epsilon) {
149  return false;
150  }
151  }
152 
153  return true;
154  }
155 
165  static inline bool IntersectionBox(const PointerType& rObject, const PointType& rLowPoint, const PointType& rHighPoint, const double Radius)
166  {
167  for(std::size_t i = 0; i < Dimension; i++) {
168  if( ((*rObject)[i] + Radius) < rLowPoint[i] - Epsilon || ((*rObject)[i] - Radius) > rHighPoint[i] + Epsilon) {
169  return false;
170  }
171  }
172 
173  return true;
174  }
175 
181  static inline void Distance(const PointerType& rObj_1, const PointerType& rObj_2, double& distance)
182  {
183  double pwdDistance = 0.0f;
184 
185  for(std::size_t i = 0; i < Dimension; i++) {
186  pwdDistance += std::pow((*rObj_1)[i] - (*rObj_2)[i], 2);
187  }
188 
189  distance = std::sqrt(pwdDistance);
190  }
191 
193  virtual std::string Info() const {return " Spatial Containers Configure for Nodes to perform a Node Search"; }
194 
196  virtual void PrintInfo(std::ostream& rOStream) const {}
197 
199  virtual void PrintData(std::ostream& rOStream) const {}
200 
202 private:
203 
206 
209 
212 
214 
215  }; // Class NodeConfigureForNodeSearch
216 
218 
221 
223 
224  inline std::istream& operator >> (std::istream& rIStream, NodeConfigureForNodeSearch& rThis){
225  return rIStream;
226  }
227 
229  inline std::ostream& operator << (std::ostream& rOStream, const NodeConfigureForNodeSearch& rThis){
230  rThis.PrintInfo(rOStream);
231  rOStream << std::endl;
232  rThis.PrintData(rOStream);
233 
234  return rOStream;
235  }
236 
238 
240 
241 } // namespace Kratos.
PeriodicInterfaceProcess & operator=(const PeriodicInterfaceProcess &)=delete
Configuration file for nodes.
Definition: node_configure_for_node_search.h:38
virtual void PrintData(std::ostream &rOStream) const
Print object's data.
Definition: node_configure_for_node_search.h:199
static void CalculateCenter(const PointerType &rObject, PointType &rCenter)
Calculates the Center of the object.
Definition: node_configure_for_node_search.h:112
SearchType::NodeType NodeType
Definition: node_configure_for_node_search.h:59
SearchType::NodesContainerType::ContainerType ResultContainerType
Definition: node_configure_for_node_search.h:63
std::vector< double >::iterator DistanceIteratorType
Definition: node_configure_for_node_search.h:66
ContainerType::value_type PointerType
Definition: node_configure_for_node_search.h:60
ResultContainerType::iterator ResultIteratorType
Definition: node_configure_for_node_search.h:65
SearchType::PointType PointType
Definition: node_configure_for_node_search.h:55
SearchType::NodesContainerType::ContainerType ContainerType
Definition: node_configure_for_node_search.h:56
static void CalculateBoundingBox(const PointerType &rObject, PointType &rLowPoint, PointType &rHighPoint)
Calculates the bounding box for the given object.
Definition: node_configure_for_node_search.h:88
static bool IntersectionBox(const PointerType &rObject, const PointType &rLowPoint, const PointType &rHighPoint)
Tests the intersection of one object with a boundingbox described by 'rLowPoint' and 'rHighPoint'.
Definition: node_configure_for_node_search.h:145
static bool Intersection(const PointerType &rObj_1, const PointerType &rObj_2, const double Radius)
Tests the intersection of two objects extended with a given radius.
Definition: node_configure_for_node_search.h:125
static void CalculateBoundingBox(const PointerType &rObject, PointType &rLowPoint, PointType &rHighPoint, const double Radius)
Calculates the bounding box for the given object extended with a Radius.
Definition: node_configure_for_node_search.h:100
ContainerType::iterator IteratorType
Definition: node_configure_for_node_search.h:61
static bool IntersectionBox(const PointerType &rObject, const PointType &rLowPoint, const PointType &rHighPoint, const double Radius)
Tests the intersection of one object with a boundingbox described by 'rLowPoint' and 'rHighPoint'.
Definition: node_configure_for_node_search.h:165
static void Distance(const PointerType &rObj_1, const PointerType &rObj_2, double &distance)
Calculates the distance between two objects.
Definition: node_configure_for_node_search.h:181
virtual std::string Info() const
Turn back information as a string.
Definition: node_configure_for_node_search.h:193
SpatialSearch SearchType
Definition: node_configure_for_node_search.h:53
KRATOS_CLASS_POINTER_DEFINITION(NodeConfigureForNodeSearch)
Pointer definition of NodeConfigureForNodeSearch.
virtual void PrintInfo(std::ostream &rOStream) const
Print information about this object.
Definition: node_configure_for_node_search.h:196
virtual ~NodeConfigureForNodeSearch()
Default destructor.
Definition: node_configure_for_node_search.h:76
SearchType::NodesContainerType NodesContainerType
Definition: node_configure_for_node_search.h:57
NodeConfigureForNodeSearch()
Default constructor.
Definition: node_configure_for_node_search.h:73
This class defines the node.
Definition: node.h:65
Point class.
Definition: point.h:59
This class is used to search for elements, conditions and nodes in a given model part.
Definition: spatial_search.h:50
ModelPart::NodesContainerType NodesContainerType
Nodes classes.
Definition: spatial_search.h:80
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
Point PointType
Geometric definitions.
Definition: mortar_classes.h:36
integer i
Definition: TensorModule.f:17
Configure::ContainerType ContainerType
Definition: transfer_utility.h:247