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.
find_intersected_geometrical_objects_process.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: Pooyan Davand
11 // Collaborators: Ruben Zorrilla Martinez
12 // Vicente Mataix Ferrandiz
13 //
14 
15 #if !defined(KRATOS_FIND_INTERSECTED_GEOMETRICAL_OBJECTS_PROCESS_H_INCLUDED )
16 #define KRATOS_FIND_INTERSECTED_GEOMETRICAL_OBJECTS_PROCESS_H_INCLUDED
17 
18 // System includes
19 #include <string>
20 #include <iostream>
21 
22 // External includes
23 
24 // Project includes
25 #include "processes/process.h"
26 #include "containers/model.h"
29 
30 namespace Kratos
31 {
32 namespace Internals {
33 
42  {
43  public:
51  {
52  double mDistance;
53  double mCoordinates[3];
54  std::size_t mId;
55  public:
56  double& Distance() { return mDistance; }
57  double& X() { return mCoordinates[0]; }
58  double& Y() { return mCoordinates[1]; }
59  double& Z() { return mCoordinates[2]; }
60  double& Coordinate(int i) { return mCoordinates[i]; }
61  std::size_t& Id() { return mId; }
62  };
63 
67 
68  enum {
69  Dimension = 3,
70  DIMENSION = 3,
71  MAX_LEVEL = 12,
72  MIN_LEVEL = 2 // this cannot be less than 2!!!
73  };
74 
78 
80  typedef std::size_t IndexType;
81 
83  typedef Point PointType;
84 
86  typedef std::vector<double>::iterator DistanceIteratorType;
87 
90 
93 
95  typedef typename ContainerType::value_type PointerType;
96 
99 
101  typedef std::vector<CellNodeData*> data_type;
102 
105 
108 
112 
115 
118 
119 
123 
124 
128 
133  return new data_type(27, (CellNodeData*)NULL);
134  }
135 
141  static void CopyData(
142  data_type* pSource,
143  data_type* pDestination
144  )
145  {
146  *pDestination = *pSource;
147  }
148 
153  static void DeleteData(data_type* pData) {
154  delete pData;
155  }
156 
163  static inline void CalculateBoundingBox(
164  const PointerType& pObject,
165  PointType& rLowPoint,
166  PointType& rHighPoint
167  )
168  {
169  // Getting the geoemtry
170  auto& r_geometry = pObject->GetGeometry();
171 
172  // Initializing the highest and lowest point
173  rHighPoint = r_geometry.GetPoint(0);
174  rLowPoint = r_geometry.GetPoint(0);
175 
176  // Iterating over the nodes
177  for (IndexType point = 1; point< r_geometry.PointsNumber(); ++point) {
178  const auto& r_point = r_geometry.GetPoint(point);
179  for (IndexType i = 0; i < 3; ++i) {
180  rLowPoint[i] = (rLowPoint[i] > r_point[i]) ? r_point[i] : rLowPoint[i];
181  rHighPoint[i] = (rHighPoint[i] < r_point[i]) ? r_point[i] : rHighPoint[i];
182  }
183  }
184  }
185 
192  static inline void GetBoundingBox(
193  const typename GeometricalObject::Pointer pObject,
194  double* rLowPoint,
195  double* rHighPoint
196  )
197  {
198  // Getting the geoemtry
199  auto& r_geometry = pObject->GetGeometry();
200 
201  // Initializing the highest and lowest point
202  for (IndexType i = 0; i<3; ++i) {
203  rLowPoint[i] = r_geometry.GetPoint(0)[i];
204  rHighPoint[i] = r_geometry.GetPoint(0)[i];
205  }
206 
207  // Iterating over the nodes
208  for (IndexType point = 1; point< r_geometry.PointsNumber(); ++point) {
209  const auto& r_point = r_geometry.GetPoint(point);
210  for (IndexType i = 0; i < 3; ++i) {
211  rLowPoint[i] = (rLowPoint[i] > r_point[i]) ? r_point[i] : rLowPoint[i];
212  rHighPoint[i] = (rHighPoint[i] < r_point[i]) ? r_point[i] : rHighPoint[i];
213  }
214  }
215  }
216 
223  static inline bool Intersection(
224  const typename GeometricalObject::Pointer pObj1,
225  const typename GeometricalObject::Pointer pObj2
226  )
227  {
228  auto& r_geom_1 = pObj1->GetGeometry();
229  auto& r_geom_2 = pObj2->GetGeometry();
230  return r_geom_1.HasIntersection(r_geom_2);
231  }
232 
240  static inline bool IntersectionBox(
241  const typename GeometricalObject::Pointer pObject,
242  const PointType& rLowPoint,
243  const PointType& rHighPoint
244  )
245  {
246  return pObject->GetGeometry().HasIntersection(rLowPoint, rHighPoint);
247  }
248 
256  static inline bool IsIntersected(
257  const typename GeometricalObject::Pointer pObject,
258  double Tolerance,
259  const double* rLowPoint,
260  const double* rHighPoint
261  )
262  {
263  PointType low_point(rLowPoint[0] - Tolerance, rLowPoint[1] - Tolerance, rLowPoint[2] - Tolerance);
264  PointType high_point(rHighPoint[0] + Tolerance, rHighPoint[1] + Tolerance, rHighPoint[2] + Tolerance);
265 
266  KRATOS_ERROR << "Not Implemented method" << std::endl;
267 // return HasIntersection(pObject->GetGeometry(), low_point, high_point);
268  }
269 
273 
275  virtual std::string Info() const
276  {
277  return " Spatial Containers Configure";
278  }
279 
281  virtual void PrintInfo(std::ostream& rOStream) const {}
282 
284  virtual void PrintData(std::ostream& rOStream) const {}
285 
287 
288  protected:
289 
290  private:
291 
294 
297 
298 
299  }; // Class DistanceSpatialContainersConfigure
300 
301 
302 } // manespace Internals
303 
306 
309 
319 class KRATOS_API(KRATOS_CORE) FindIntersectedGeometricalObjectsProcess
320  : public Process
321 {
322 public:
325 
328 
330  KRATOS_DEFINE_LOCAL_FLAG( INTERSECTING_CONDITIONS );
331  KRATOS_DEFINE_LOCAL_FLAG( INTERSECTING_ELEMENTS );
332  KRATOS_DEFINE_LOCAL_FLAG( INTERSECTED_CONDITIONS );
333  KRATOS_DEFINE_LOCAL_FLAG( INTERSECTED_ELEMENTS );
334 
341  typedef std::vector<typename OctreeType::cell_type*> OtreeCellVectorType;
342 
344  typedef std::size_t IndexType;
345 
347  typedef std::size_t SizeType;
348 
350  typedef Point PointType;
351 
353  using NodeType = Node;
354 
357 
361 
367 
374  ModelPart& rModelPartIntersected,
375  ModelPart& rModelPartIntersecting,
376  const Flags Options = INTERSECTING_CONDITIONS|INTERSECTING_ELEMENTS|INTERSECTED_CONDITIONS|INTERSECTED_ELEMENTS
377  );
378 
385  Model& rModel,
386  Parameters ThisParameters
387  );
388 
391 
394 
397 
398  std::vector<PointerVector<GeometricalObject>> mIntersectedObjects;
399 
403 
408  KRATOS_DEPRECATED_MESSAGE("Please do not use this method - Use ExecuteInitialize instead\"")
409  virtual void Initialize();
410 
415  virtual void FindIntersectedSkinObjects(std::vector<PointerVector<GeometricalObject>>& rResults);
416 
420  virtual void FindIntersections();
421 
426  virtual std::vector<PointerVector<GeometricalObject>>& GetIntersections();
427 
432  virtual ModelPart& GetModelPart1();
433 
438  virtual ModelPart& GetModelPart2();
439 
444  virtual OctreePointerType& GetOctreePointer();
445 
450  void Clear() override;
451 
455  void Execute() override;
456 
460  void ExecuteInitialize() override;
461 
467  virtual void IdentifyNearEntitiesAndCheckEntityForIntersection(
468  GeometricalObject::Pointer pGeometricalObject,
469  OtreeCellVectorType& rLeaves
470  );
471 
475  const Parameters GetDefaultParameters() const override;
476 
480 
482  std::string Info() const override {
483  return "FindIntersectedGeometricalObjectsProcess";
484  }
485 
487  void PrintInfo(std::ostream& rOStream) const override {
488  rOStream << Info();
489  }
490 
492  void PrintData(std::ostream& rOStream) const override {
493 
494  }
495 
497 protected:
500 
504 
509 
513 
517 
521  virtual void SetOctreeBoundingBox();
522 
528  virtual void MarkIfIntersected(
529  GeometricalObject& rIntersectedGeometricalObject,
530  OtreeCellVectorType& rLeaves
531  );
532 
538  virtual bool HasIntersection(
539  GeometryType& rFirstGeometry,
540  GeometryType& rSecondGeometry
541  );
542 
546 
550 
554 
556 private:
559 
560 
564 
568 
573  std::size_t WorkingSpaceDimension();
574 
578  void GenerateOctree();
579 
586  virtual void FindIntersectedSkinObjects(
587  GeometricalObject& rIntersectedEntity,
588  OtreeCellVectorType& rLeaves,
590  );
591 
595 
598 
599 
601 
602 }; // Class FindIntersectedGeometricalObjectsProcess
603 
605 
606 } // namespace Kratos.
607 
608 #endif // KRATOS_FIND_INTERSECTED_GEOMETRICAL_OBJECTS_PROCESS_H_INCLUDED defined
PeriodicInterfaceProcess & operator=(const PeriodicInterfaceProcess &)=delete
void ExecuteInitialize() override
Definition: periodic_interface_process.hpp:37
std::string Info() const override
Turn back information as a string.
Definition: periodic_interface_process.hpp:93
This class takes two modelparts and marks the intersected ones with SELECTED flag.
Definition: find_intersected_geometrical_objects_process.h:321
KRATOS_DEFINE_LOCAL_FLAG(INTERSECTING_CONDITIONS)
Local Flags.
OctreePointerType mpOctree
Local flags.
Definition: find_intersected_geometrical_objects_process.h:508
FindIntersectedGeometricalObjectsProcess(FindIntersectedGeometricalObjectsProcess const &rOther)=delete
Copy constructor.
~FindIntersectedGeometricalObjectsProcess() override=default
Destructor.
KRATOS_CLASS_POINTER_DEFINITION(FindIntersectedGeometricalObjectsProcess)
Pointer definition of FindIntersectedGeometricalObjectsProcess.
Flags mOptions
Model part intersecting.
Definition: find_intersected_geometrical_objects_process.h:507
std::size_t IndexType
Definition of the index type.
Definition: find_intersected_geometrical_objects_process.h:344
ModelPart & mrModelPartIntersected
Definition: find_intersected_geometrical_objects_process.h:505
typename ConfigurationType::cell_node_data_type CellNodeDataType
Definition: find_intersected_geometrical_objects_process.h:340
std::vector< typename OctreeType::cell_type * > OtreeCellVectorType
Definition: find_intersected_geometrical_objects_process.h:341
unique_ptr< OctreeType > OctreePointerType
Definition: find_intersected_geometrical_objects_process.h:339
ModelPart & mrModelPartIntersecting
Model part intersected.
Definition: find_intersected_geometrical_objects_process.h:506
std::vector< PointerVector< GeometricalObject > > mIntersectedObjects
Definition: find_intersected_geometrical_objects_process.h:398
std::size_t SizeType
Definition of the size type.
Definition: find_intersected_geometrical_objects_process.h:347
Point PointType
Definition of the point type.
Definition: find_intersected_geometrical_objects_process.h:350
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: find_intersected_geometrical_objects_process.h:487
FindIntersectedGeometricalObjectsProcess()=delete
Default constructor.
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: find_intersected_geometrical_objects_process.h:492
Definition: flags.h:58
This defines the geometrical object, base definition of the element and condition entities.
Definition: geometrical_object.h:58
Geometry base class.
Definition: geometry.h:71
This class contains the cell node data.
Definition: find_intersected_geometrical_objects_process.h:51
double & Z()
Definition: find_intersected_geometrical_objects_process.h:59
double & Y()
Definition: find_intersected_geometrical_objects_process.h:58
double & Distance()
Definition: find_intersected_geometrical_objects_process.h:56
double & Coordinate(int i)
Definition: find_intersected_geometrical_objects_process.h:60
std::size_t & Id()
Definition: find_intersected_geometrical_objects_process.h:61
double & X()
Definition: find_intersected_geometrical_objects_process.h:57
This class contains the tools related with the distance spatial container cell data.
Definition: find_intersected_geometrical_objects_process.h:42
DistanceSpatialContainersConfigure()
Default constructor.
Definition: find_intersected_geometrical_objects_process.h:114
KRATOS_CLASS_POINTER_DEFINITION(DistanceSpatialContainersConfigure)
Pointer definition of DistanceSpatialContainersConfigure.
static bool Intersection(const typename GeometricalObject::Pointer pObj1, const typename GeometricalObject::Pointer pObj2)
This method computes if there is an intersection between two objects.
Definition: find_intersected_geometrical_objects_process.h:223
static void CopyData(data_type *pSource, data_type *pDestination)
This method copies the data from a cell.
Definition: find_intersected_geometrical_objects_process.h:141
static void GetBoundingBox(const typename GeometricalObject::Pointer pObject, double *rLowPoint, double *rHighPoint)
This method computes the bounding box of an object (using C arrays)
Definition: find_intersected_geometrical_objects_process.h:192
static bool IntersectionBox(const typename GeometricalObject::Pointer pObject, const PointType &rLowPoint, const PointType &rHighPoint)
This computes the intersection between an object and a box.
Definition: find_intersected_geometrical_objects_process.h:240
PointerVectorSet< GeometricalObject, IndexedObject > EntityContainerType
Definition of the entity container type.
Definition: find_intersected_geometrical_objects_process.h:89
EntityContainerType::ContainerType ContainerType
Definition of the container type.
Definition: find_intersected_geometrical_objects_process.h:92
PointerType pointer_type
The definition of the pointer type.
Definition: find_intersected_geometrical_objects_process.h:104
virtual void PrintInfo(std::ostream &rOStream) const
Print information about this object.
Definition: find_intersected_geometrical_objects_process.h:281
virtual void PrintData(std::ostream &rOStream) const
Print object's data.
Definition: find_intersected_geometrical_objects_process.h:284
@ MIN_LEVEL
Definition: find_intersected_geometrical_objects_process.h:72
@ MAX_LEVEL
Definition: find_intersected_geometrical_objects_process.h:71
@ DIMENSION
Definition: find_intersected_geometrical_objects_process.h:70
@ Dimension
Definition: find_intersected_geometrical_objects_process.h:69
static data_type * AllocateData()
This method allocates the cell data.
Definition: find_intersected_geometrical_objects_process.h:132
static bool IsIntersected(const typename GeometricalObject::Pointer pObject, double Tolerance, const double *rLowPoint, const double *rHighPoint)
This method checks if the objects intersects the low and hight points provided.
Definition: find_intersected_geometrical_objects_process.h:256
Point PointType
Definition of the point type.
Definition: find_intersected_geometrical_objects_process.h:83
ContainerType::value_type PointerType
Defintion of the pointer type.
Definition: find_intersected_geometrical_objects_process.h:95
static void CalculateBoundingBox(const PointerType &pObject, PointType &rLowPoint, PointType &rHighPoint)
This method computes the bounding box of an object.
Definition: find_intersected_geometrical_objects_process.h:163
static void DeleteData(data_type *pData)
This method deletes the data from a cell data.
Definition: find_intersected_geometrical_objects_process.h:153
std::vector< double >::iterator DistanceIteratorType
Definition of the distance iterator type.
Definition: find_intersected_geometrical_objects_process.h:86
std::vector< CellNodeData * > data_type
Definition of the cell data type.
Definition: find_intersected_geometrical_objects_process.h:101
std::size_t IndexType
Definition of the index type.
Definition: find_intersected_geometrical_objects_process.h:80
virtual ~DistanceSpatialContainersConfigure()
Destructor.
Definition: find_intersected_geometrical_objects_process.h:117
CellNodeData cell_node_data_type
Definition of the cell node data.
Definition: find_intersected_geometrical_objects_process.h:98
virtual std::string Info() const
Turn back information as a string.
Definition: find_intersected_geometrical_objects_process.h:275
This class aims to manage different model parts across multi-physics simulations.
Definition: model.h:60
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
This class defines the node.
Definition: node.h:65
This class represents a cell in an octree to be used with Octree class.
Definition: octree_binary_cell.h:70
This class provides to Kratos a data structure for I/O based on the standard of JSON.
Definition: kratos_parameters.h:59
Point class.
Definition: point.h:59
PointerVector is a container like stl vector but using a vector to store pointers to its data.
Definition: pointer_vector.h:72
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
The base class for all processes in Kratos.
Definition: process.h:49
#define KRATOS_ERROR
Definition: exception.h:161
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
std::unique_ptr< T > unique_ptr
Definition: smart_pointers.h:33
namespace KRATOS_DEPRECATED_MESSAGE("Please use std::filesystem directly") filesystem
Definition: kratos_filesystem.h:33
tuple const
Definition: ode_solve.py:403
namespace
Definition: array_1d.h:793
integer i
Definition: TensorModule.f:17