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.
interface_object_configure.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: Philipp Bucher, Jordi Cotela
11 //
12 // See Master-Thesis P.Bucher
13 // "Development and Implementation of a Parallel
14 // Framework for Non-Matching Grid Mapping"
15 
16 #pragma once
17 
18 // System includes
19 
20 // Kratos includes
22 
23 namespace Kratos
24 {
25 
28 
35 {
36 public:
37 
40 
45  static constexpr auto Epsilon = std::numeric_limits<double>::epsilon();
46  static constexpr auto Dimension = 3;
47 
52  typedef Point PointType;
53 
64  typedef PointerVectorSet <
65  ObjectType,
68  typedef ObjectType::Pointer PointerType;
69 
72 
73  typedef ContainerType::iterator IteratorType;
74  typedef ResultContainerType::iterator ResultIteratorType;
75  typedef std::vector<double>::iterator DistanceIteratorType;
76 
77  typedef double CoordinateType;
79 
83 
86 
89 
93 
100  static inline void CalculateBoundingBox(const PointerType& rObject, PointType& rLowPoint, PointType& rHighPoint)
101  {
102  rHighPoint = rLowPoint = *rObject;
103  }
104 
112  static inline void CalculateBoundingBox(const PointerType& rObject, PointType& rLowPoint, PointType& rHighPoint, const double& Radius)
113  {
114  auto radiusExtension = PointType(Radius, Radius, Radius);
115 
116  rLowPoint = PointType{*rObject - radiusExtension};
117  rHighPoint = PointType{*rObject + radiusExtension};
118  }
119 
124  static inline void CalculateCenter(const PointerType& rObject, PointType& rCentralPoint)
125  {
126  rCentralPoint = *rObject;
127  }
128 
135  static inline bool Intersection(const PointerType& rObj_1, const PointerType& rObj_2)
136  {
137  for(std::size_t i = 0; i < Dimension; i++)
138  {
139  if(std::fabs((*rObj_1)[i] - (*rObj_2)[i]) > Epsilon)
140  {
141  return false;
142  }
143  }
144 
145  return true;
146  }
147 
156  static inline bool Intersection(const PointerType& rObj_1, const PointerType& rObj_2, double Radius)
157  {
158  // TODO change to squared distance function
159  // for(std::size_t i = 0; i < Dimension; i++) {
160  // if(std::fabs((*rObj_1)[i] - (*rObj_2)[i]) > Epsilon + Radius) {
161  // return false;
162  // }
163  // }
164  //
165  // return true;
166 
167  double pwdDistance = 0.0f;
168 
169  for(std::size_t i = 0; i < Dimension; i++)
170  {
171  pwdDistance += std::pow((*rObj_1)[i] - (*rObj_2)[i], 2);
172  }
173 
174  if (std::sqrt(pwdDistance) > Epsilon + Radius)
175  {
176  return false;
177  }
178  else
179  {
180  return true;
181  }
182  }
183 
192  static inline bool IntersectionBox(const PointerType& rObject, const PointType& rLowPoint, const PointType& rHighPoint)
193  {
194  for(std::size_t i = 0; i < Dimension; i++)
195  {
196  if( (*rObject)[i] < rLowPoint[i] - Epsilon || (*rObject)[i] > rHighPoint[i] + Epsilon)
197  {
198  return false;
199  }
200  }
201 
202  return true;
203  }
204 
214  static inline bool IntersectionBox(const PointerType& rObject, const PointType& rLowPoint, const PointType& rHighPoint, const double& Radius)
215  {
216  for(std::size_t i = 0; i < Dimension; i++)
217  {
218  if( ((*rObject)[i] + Radius) < rLowPoint[i] - Epsilon || ((*rObject)[i] - Radius) > rHighPoint[i] + Epsilon)
219  {
220  return false;
221  }
222  }
223 
224  return true;
225  }
226 
239  static inline void Distance(const PointerType& rObj_1, const PointerType& rObj_2, double& distance)
240  {
241  double pwdDistance = 0.0f;
242 
243  for(std::size_t i = 0; i < Dimension; i++)
244  {
245  pwdDistance += std::pow((*rObj_1)[i] - (*rObj_2)[i], 2);
246  }
247 
248  distance = std::sqrt(pwdDistance);
249  }
250 
257  static inline double GetObjectRadius(const PointerType& rObject, const double& Radius)
258  {
259  return 0.0f;
260  }
261 
265 
267  virtual std::string Info() const
268  {
269  return "Spatial Containers Configure for 'Points'";
270  }
271 
273  virtual std::string Data() const
274  {
275  return "Dimension: " + std::to_string(Dimension);
276  }
277 
279  virtual void PrintInfo(std::ostream& rOStream) const
280  {
281  rOStream << Info() << std::endl;
282  }
283 
285  virtual void PrintData(std::ostream& rOStream) const
286  {
287  rOStream << Data() << Dimension << std::endl;
288  }
289 
291 
292 private:
295 
297  InterfaceObjectConfigure& operator=(InterfaceObjectConfigure const& rOther);
298 
301 
303 
304 }; // Class InterfaceObjectConfigure
305 
307 
310 
312 inline std::istream& operator >> (std::istream& rIStream, InterfaceObjectConfigure& rThis)
313 {
314  return rIStream;
315 }
316 
318 inline std::ostream& operator << (std::ostream& rOStream, const InterfaceObjectConfigure& rThis)
319 {
320  rThis.PrintInfo(rOStream);
321  rOStream << std::endl;
322  rThis.PrintData(rOStream);
323 
324  return rOStream;
325 }
326 
328 
329 } // namespace Kratos.
This object defines an indexed object.
Definition: indexed_object.h:54
Definition: interface_object_configure.h:35
static bool IntersectionBox(const PointerType &rObject, const PointType &rLowPoint, const PointType &rHighPoint)
Definition: interface_object_configure.h:192
static void CalculateCenter(const PointerType &rObject, PointType &rCentralPoint)
Definition: interface_object_configure.h:124
PointerVectorSet< ObjectType, IndexedObject > ObjectContainerType
Definition: interface_object_configure.h:67
static constexpr auto Epsilon
Definition: interface_object_configure.h:45
KRATOS_CLASS_POINTER_DEFINITION(InterfaceObjectConfigure)
Pointer definition of InterfaceObjectConfigure.
virtual std::string Info() const
Turns back information as a string.
Definition: interface_object_configure.h:267
static void CalculateBoundingBox(const PointerType &rObject, PointType &rLowPoint, PointType &rHighPoint)
Definition: interface_object_configure.h:100
ObjectContainerType::ContainerType ContainerType
Definition: interface_object_configure.h:70
static constexpr auto Dimension
Definition: interface_object_configure.h:46
ObjectType::Pointer PointerType
Definition: interface_object_configure.h:68
ObjectContainerType::ContainerType ResultContainerType
Definition: interface_object_configure.h:71
virtual ~InterfaceObjectConfigure()
Default destructor.
Definition: interface_object_configure.h:88
static double GetObjectRadius(const PointerType &rObject, const double &Radius)
Definition: interface_object_configure.h:257
static bool Intersection(const PointerType &rObj_1, const PointerType &rObj_2)
Definition: interface_object_configure.h:135
static void CalculateBoundingBox(const PointerType &rObject, PointType &rLowPoint, PointType &rHighPoint, const double &Radius)
Definition: interface_object_configure.h:112
virtual void PrintInfo(std::ostream &rOStream) const
Prints object's information.
Definition: interface_object_configure.h:279
virtual std::string Data() const
Turns back data as a string.
Definition: interface_object_configure.h:273
InterfaceObjectConfigure()
Default consturctor.
Definition: interface_object_configure.h:85
ResultContainerType::iterator ResultIteratorType
Definition: interface_object_configure.h:74
Point PointType
Definition: interface_object_configure.h:52
static bool IntersectionBox(const PointerType &rObject, const PointType &rLowPoint, const PointType &rHighPoint, const double &Radius)
Definition: interface_object_configure.h:214
InterfaceObject ObjectType
Definition: interface_object_configure.h:63
Tvector< CoordinateType, Dimension > CoordinateArray
Definition: interface_object_configure.h:78
std::vector< double >::iterator DistanceIteratorType
Definition: interface_object_configure.h:75
static void Distance(const PointerType &rObj_1, const PointerType &rObj_2, double &distance)
Definition: interface_object_configure.h:239
ContainerType::iterator IteratorType
Definition: interface_object_configure.h:73
double CoordinateType
Definition: interface_object_configure.h:77
virtual void PrintData(std::ostream &rOStream) const
Prints object's data.
Definition: interface_object_configure.h:285
static bool Intersection(const PointerType &rObj_1, const PointerType &rObj_2, double Radius)
Definition: interface_object_configure.h:156
Object used by the bin-search.
Definition: interface_object.h:40
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
TContainerType ContainerType
Definition: pointer_vector_set.h:90
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
integer i
Definition: TensorModule.f:17