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.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 A. Roig
11 //
12 
13 #pragma once
14 
15 // System includes
16 #include <string>
17 #include <iostream>
18 #include <limits>
19 #include <cmath>
20 
21 // External includes
22 
23 // Project includes
24 #include "includes/define.h"
25 #include "geometries/point.h"
30 
31 namespace Kratos {
32 
35 
39 
43 
47 
51 
57 public:
60 
65  static constexpr auto Epsilon = std::numeric_limits<double>::epsilon();
66  static constexpr auto Dimension = 3;
67 
72  typedef Point PointType;
73  typedef Node ObjectType;
74  typedef ObjectType::Pointer PointerType;
75 
87 
90  typedef ContactPair<PointerType> ContactPairType;
91 
92  typedef ContainerType::iterator IteratorType;
93  typedef ResultContainerType::iterator ResultIteratorType;
94  typedef std::vector<double>::iterator DistanceIteratorType;
95 
96  typedef double CoordinateType;
98 
102 
105 
107  virtual ~NodeConfigure(){}
108 
112 
116 
123  static inline void CalculateBoundingBox(
124  const PointerType& rObject,
125  PointType& rLowPoint,
126  PointType& rHighPoint
127  )
128  {
129  rHighPoint = rLowPoint = *rObject;
130  }
131 
139  static inline void CalculateBoundingBox(
140  const PointerType& rObject,
141  PointType& rLowPoint,
142  PointType& rHighPoint,
143  const double Radius
144  )
145  {
146  auto radiusExtension = PointType(Radius, Radius, Radius);
147 
148  rLowPoint = PointType{*rObject - radiusExtension};
149  rHighPoint = PointType{*rObject + radiusExtension};
150  }
151 
156  static inline void CalculateCenter(
157  const PointerType& rObject,
158  PointType& rCentralPoint
159  )
160  {
161  rCentralPoint = *rObject;
162  }
163 
170  static inline bool Intersection(
171  const PointerType& rObj_1,
172  const PointerType& rObj_2
173  )
174  {
175  for(std::size_t i = 0; i < Dimension; i++) {
176  if(std::fabs((*rObj_1)[i] - (*rObj_2)[i]) > Epsilon) {
177  return false;
178  }
179  }
180 
181  return true;
182  }
183 
192  static inline bool Intersection(
193  const PointerType& rObj_1,
194  const PointerType& rObj_2,
195  double Radius
196  )
197  {
198  for(std::size_t i = 0; i < Dimension; i++) {
199  if(std::fabs((*rObj_1)[i] - (*rObj_2)[i]) > Epsilon + Radius) {
200  return false;
201  }
202  }
203 
204  return true;
205  }
206 
215  static inline bool IntersectionBox(
216  const PointerType& rObject,
217  const PointType& rLowPoint,
218  const PointType& rHighPoint
219  )
220  {
221  for(std::size_t i = 0; i < Dimension; i++) {
222  if( (*rObject)[i] < rLowPoint[i] - Epsilon || (*rObject)[i] > rHighPoint[i] + Epsilon) {
223  return false;
224  }
225  }
226 
227  return true;
228  }
229 
239  static inline bool IntersectionBox(
240  const PointerType& rObject,
241  const PointType& rLowPoint,
242  const PointType& rHighPoint,
243  const double Radius
244  )
245  {
246  for(std::size_t i = 0; i < Dimension; i++) {
247  if( ((*rObject)[i] + Radius) < rLowPoint[i] - Epsilon || ((*rObject)[i] - Radius) > rHighPoint[i] + Epsilon) {
248  return false;
249  }
250  }
251 
252  return true;
253  }
254 
266  static inline void Distance(
267  const PointerType& rObj_1,
268  const PointerType& rObj_2,
269  double& distance
270  )
271  {
272  double pwdDistance = 0.0f;
273 
274  for(std::size_t i = 0; i < Dimension; i++) {
275  pwdDistance += std::pow((*rObj_1)[i] - (*rObj_2)[i], 2);
276  }
277 
278  distance = std::sqrt(pwdDistance);
279  }
280 
287  static inline double GetObjectRadius(
288  const PointerType& rObject,
289  const double Radius
290  )
291  {
292  return 0.0f;
293  }
294 
298 
302 
306 
308  virtual std::string Info() const {
309  return "Spatial Containers Configure for 'Points'";
310  }
311 
313  virtual std::string Data() const {
314  return "Dimension: " + std::to_string(Dimension);
315  }
316 
318  virtual void PrintInfo(std::ostream& rOStream) const {
319  rOStream << Info() << std::endl;
320  }
321 
323  virtual void PrintData(std::ostream& rOStream) const {
324  rOStream << Data() << Dimension << std::endl;
325  }
326 
330 
332 
333 protected:
336 
340 
344 
348 
352 
356 
360 
362 private:
365 
369 
373 
377 
381 
385 
389 
391  NodeConfigure& operator=(NodeConfigure const& rOther);
392 
394  NodeConfigure(NodeConfigure const& rOther);
395 
397 
398 }; // Class NodeConfigure
399 
401 
404 
408 
410 inline std::istream& operator >> (std::istream& rIStream, NodeConfigure& rThis){
411  return rIStream;
412 }
413 
415 inline std::ostream& operator << (std::ostream& rOStream, const NodeConfigure& rThis){
416  rThis.PrintInfo(rOStream);
417  rOStream << std::endl;
418  rThis.PrintData(rOStream);
419 
420  return rOStream;
421 }
422 
424 
425 } // namespace Kratos.
Configuration file for Nodes.
Definition: node_configure.h:56
Tvector< CoordinateType, Dimension > CoordinateArray
Definition: node_configure.h:97
ObjectContainerType::ContainerType ResultContainerType
Definition: node_configure.h:89
ContainerType::iterator IteratorType
Definition: node_configure.h:92
Point PointType
Point and Pointer Types.
Definition: node_configure.h:72
static bool IntersectionBox(const PointerType &rObject, const PointType &rLowPoint, const PointType &rHighPoint, const double Radius)
Tests the intersection of one object with a boundingbox descrived by 'rLowPoint' and 'rHighPoint'.
Definition: node_configure.h:239
static void CalculateCenter(const PointerType &rObject, PointType &rCentralPoint)
Calculates the Center of the object.
Definition: node_configure.h:156
static constexpr auto Dimension
Definition: node_configure.h:66
KRATOS_CLASS_POINTER_DEFINITION(NodeConfigure)
Pointer definition of NodeConfigure.
PointerVectorSet< ObjectType, IndexedObject > ObjectContainerType
Definition: node_configure.h:86
static constexpr auto Epsilon
Compile time definitions.
Definition: node_configure.h:65
virtual void PrintData(std::ostream &rOStream) const
Prints object's data.
Definition: node_configure.h:323
ObjectType::Pointer PointerType
Definition: node_configure.h:74
ResultContainerType::iterator ResultIteratorType
Definition: node_configure.h:93
NodeConfigure()
Default consturctor.
Definition: node_configure.h:104
static bool Intersection(const PointerType &rObj_1, const PointerType &rObj_2, double Radius)
Tests the intersection of two objects extended with a given radius.
Definition: node_configure.h:192
virtual std::string Info() const
Turns back information as a string.
Definition: node_configure.h:308
Node ObjectType
Definition: node_configure.h:73
virtual std::string Data() const
Turns back data as a string.
Definition: node_configure.h:313
ObjectContainerType::ContainerType ContainerType
Definition: node_configure.h:88
static void Distance(const PointerType &rObj_1, const PointerType &rObj_2, double &distance)
Calculates the distance betwen two objects.
Definition: node_configure.h:266
static void CalculateBoundingBox(const PointerType &rObject, PointType &rLowPoint, PointType &rHighPoint)
Calculates the bounding box for the given object.
Definition: node_configure.h:123
virtual ~NodeConfigure()
Default destructor.
Definition: node_configure.h:107
std::vector< double >::iterator DistanceIteratorType
Definition: node_configure.h:94
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.h:139
double CoordinateType
Definition: node_configure.h:96
static bool Intersection(const PointerType &rObj_1, const PointerType &rObj_2)
Tests the intersection of two objects.
Definition: node_configure.h:170
virtual void PrintInfo(std::ostream &rOStream) const
Prints object's information.
Definition: node_configure.h:318
static double GetObjectRadius(const PointerType &rObject, const double Radius)
Returns a radius associated to the object.
Definition: node_configure.h:287
static bool IntersectionBox(const PointerType &rObject, const PointType &rLowPoint, const PointType &rHighPoint)
Tests the intersection of one object with a boundingbox descrived by 'rLowPoint' and 'rHighPoint'.
Definition: node_configure.h:215
ContactPair< PointerType > ContactPairType
Definition: node_configure.h:90
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
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