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.
rigid_face_geometrical_object_configure.h
Go to the documentation of this file.
1 //
2 // Author: Miquel Santasusana msantasusana@cimne.upc.edu
3 //
4 
5 
6 
7 #if !defined(KRATOS_RIGID_FACE_GEOMETRICAL_OBJECT_CONFIGURE_INCLUDED)
8 #define KRATOS_RIGID_FACE_GEOMETRICAL_OBJECT_CONFIGURE_INCLUDED
9 
10 // System includes
11 #include <string>
12 #include <iostream>
13 #include <cmath>
14 
15 // Kratos includes
16 #include "includes/variables.h"
18 #include "GeometryFunctions.h"
19 #include "geometries/geometry.h"
20 
21 namespace Kratos
22 {
23 
24 
25  typedef Geometry<Node > GeometryType;
28 
32 
36 
40 
44 
45 
46 template <std::size_t TDimension>
48 {
49 
50 public:
51 
52  enum {
53  Dimension = TDimension,
54  DIMENSION = TDimension,
55  MAX_LEVEL = 16,
56  MIN_LEVEL = 2
57  };
58 
59 
60 
63 
64 
66 
68 
69  //typedef PointerVectorSet<GeometricalObject, IndexedObject> ElementsContainerType;
72  std::less<typename IndexedObject::result_type>,
73  std::equal_to<typename IndexedObject::result_type>,
74  typename GeometricalObject::Pointer,
75  std::vector< typename GeometricalObject::Pointer >
77 
78  //typedef PointerVectorSet<GeometricalObject, IndexedObject>::ContainerType ContainerType;
80 
81  typedef ContainerType::value_type PointerType;
82  typedef ContainerType::iterator IteratorType;
83 
84  //typedef PointerVectorSet<GeometricalObject, IndexedObject>::ContainerType ResultContainerType;
86 
87 
88  typedef ResultContainerType::iterator ResultIteratorType;
89  typedef std::vector<double>::iterator DistanceIteratorType;
90 
94 
97 
101 
102 
106 
107  //******************************************************************************************************************
108 
110  static inline void CalculateBoundingBox(const PointerType& rObject, PointType& rLowPoint, PointType& rHighPoint, const double& Radius)
111  {
112  noalias(rHighPoint) = rObject->GetGeometry()[0];
113  noalias(rLowPoint) = rObject->GetGeometry()[0];
114 
115  for(std::size_t i = 0; i < 3; i++)
116  {
117  rLowPoint[i] += -Radius;
118  rHighPoint[i] += Radius;
119  }
120 
121  }
122 
124  static inline void CalculateBoundingBox(const PointerType& rObject, PointType& rLowPoint, PointType& rHighPoint)
125  {
127 
128 
129 
130  double xyz_min[3] = { 1e20, 1e20, 1e20};
131  double xyz_max[3] = {-1e20, -1e20, -1e20};
132 
133  for (std::size_t inode = 0; inode < rObject->GetGeometry().size(); inode++)
134  {
135  const array_1d<double, 3>& Coord = rObject->GetGeometry()[inode].Coordinates();
136 
137  xyz_min[0] = (xyz_min[0] > Coord[0]) ? Coord[0] : xyz_min[0];
138  xyz_min[1] = (xyz_min[1] > Coord[1]) ? Coord[1] : xyz_min[1];
139  xyz_min[2] = (xyz_min[2] > Coord[2]) ? Coord[2] : xyz_min[2];
140 
141  xyz_max[0] = (xyz_max[0] < Coord[0]) ? Coord[0] : xyz_max[0];
142  xyz_max[1] = (xyz_max[1] < Coord[1]) ? Coord[1] : xyz_max[1];
143  xyz_max[2] = (xyz_max[2] < Coord[2]) ? Coord[2] : xyz_max[2];
144  }
145 
146  for(std::size_t i = 0; i < 3; i++)
147  {
148  rLowPoint [i] = xyz_min[i];
149  rHighPoint[i] = xyz_max[i];
150  }
151 
152  const double domain_size = rObject->GetGeometry().DomainSize();
153 
154  for(std::size_t i = 0; i < 3; i++)
155  {
156  if( (rHighPoint[i]-rLowPoint[i]) < 1e-10 * domain_size) //altura no area
157  {
158  rHighPoint[i] = rLowPoint[i] + domain_size;
159  //rLowPoint [i];// + domain_size;
160  }
161  }
162 
163  }
164 
165 
166  static inline bool IntersectionBox(const PointerType& rObject, const PointType& rLowPoint, const PointType& rHighPoint) {
167 
168  double xyz_min[3] = { 1e20, 1e20, 1e20};
169  double xyz_max[3] = {-1e20, -1e20, -1e20};
170 
171  for (std::size_t inode = 0; inode < rObject->GetGeometry().size(); inode++) {
172  const array_1d<double, 3>& Coord = rObject->GetGeometry()[inode].Coordinates();
173  xyz_min[0] = (xyz_min[0] > Coord[0]) ? Coord[0] : xyz_min[0];
174  xyz_min[1] = (xyz_min[1] > Coord[1]) ? Coord[1] : xyz_min[1];
175  xyz_min[2] = (xyz_min[2] > Coord[2]) ? Coord[2] : xyz_min[2];
176 
177  xyz_max[0] = (xyz_max[0] < Coord[0]) ? Coord[0] : xyz_max[0];
178  xyz_max[1] = (xyz_max[1] < Coord[1]) ? Coord[1] : xyz_max[1];
179  xyz_max[2] = (xyz_max[2] < Coord[2]) ? Coord[2] : xyz_max[2];
180  }
181 
182  bool intersect = (rLowPoint [0] <= xyz_max[0] && rLowPoint [1] <= xyz_max[1] && rLowPoint [2] <= xyz_max[2] &&
183  rHighPoint[0] >= xyz_min[0] && rHighPoint[1] >= xyz_min[1] && rHighPoint[2] >= xyz_min[2]);
184 
185  return intersect;
186  }
187 
188  static inline bool IntersectionBox(const PointerType& rObject, const PointType& rLowPoint, const PointType& rHighPoint, const double& Radius)
189  {
190  const array_1d<double, 3>& center_of_particle = rObject->GetGeometry()[0];
191  double radius = Radius;//Cambien el radi del objecte de cerca per el gran, aixi no tindria que petar res
192 
193  bool intersect = (
194  floatle(rLowPoint[0] - radius,center_of_particle[0]) &&
195  floatle(rLowPoint[1] - radius,center_of_particle[1]) &&
196  floatle(rLowPoint[2] - radius,center_of_particle[2]) &&
197  floatge(rHighPoint[0] + radius,center_of_particle[0]) &&
198  floatge(rHighPoint[1] + radius,center_of_particle[1]) &&
199  floatge(rHighPoint[2] + radius,center_of_particle[2]));
200 
201  return intersect;
202  }
203 
204  static inline bool FastIntersection2D(const GeometryType& DE_Geom, const GeometryType& FE_Geom, const double& Radius)
205  {
206  //rObj_1 is particle, and rObj_2 is condition
207 
208  std::vector< array_1d<double,3> > Coord(2);
209 
210  for (unsigned int i = 0; i<2; i++) {
211  for (unsigned int j = 0; j<3; j++) {
212  Coord[i][j] = FE_Geom[i].Coordinates()[j];
213  }
214  }
215 
216  return GeometryFunctions::FastEdgeVertexCheck( Coord[0], Coord[1], DE_Geom[0].Coordinates(), Radius );
217  }//FastIntersection2D
218 
219  static inline bool FastIntersection3D(const GeometryType& DE_Geom,const GeometryType& FE_Geom, const double& Radius)
220  {
221  //rObj_1 is particle, and rObj_2 is condition
222  bool ContactExists = false;
223 
224  unsigned int FE_size = FE_Geom.size();
225  std::vector< array_1d<double,3> > Coord(FE_size);
226  //Coord.resize(FE_size); //, array_1d<double,3>(3,0.0) );
227 
228  for (unsigned int i = 0; i<FE_size; i++) {
229  for (unsigned int j = 0; j<3; j++) {
230  Coord[i][j] = FE_Geom[i].Coordinates()[j];
231  }
232  }
233 
234  double distance_point_to_plane = 0.0;
235  unsigned int current_edge_index = 0;
236 
237  ContactExists = GeometryFunctions::FastFacetCheck( Coord, DE_Geom[0].Coordinates(), Radius, distance_point_to_plane, current_edge_index);
238 
239  if (ContactExists){return true;}
240 
241  //The key here is to see that we only need to check for further contact if, when not having contact with plane, the distance_point_to_plane is lower than the radius.
242  //In this case it might have contact with edges or vertices, otherwise no contact is possible.
243 
244  else if (distance_point_to_plane < Radius) {
245  bool local_contact_exists = false;
246  for (unsigned int e = current_edge_index; e < FE_size; e++ ) {
247  local_contact_exists = GeometryFunctions::FastEdgeVertexCheck( Coord[e], Coord[(e+1)%FE_size], DE_Geom[0].Coordinates(), Radius );
248  if (local_contact_exists) {return true;}
249  }//for every edge
250  }//no plane contact found
251 
252  return false;
253  }//FastIntersection3D
254 
255  static inline bool Intersection(const PointerType& rObj_1, const PointerType& rObj_2) //rObj_1 is sphere, rObj_2 is FE
256  {
257  const GeometryType& DE_Geom = rObj_1->GetGeometry();
258  const GeometryType& FE_Geom = rObj_2->GetGeometry();
259  SphericParticle* p_particle = static_cast<SphericParticle*>(&*rObj_2);
260  const double Radius = p_particle->GetSearchRadius();
261 
262  const int facet_size = FE_Geom.size();
263 
264  if (facet_size==1) return GeometryFunctions::FastVertexCheck(FE_Geom[0].Coordinates(),DE_Geom[0].Coordinates(), Radius);
265  else if (facet_size==2) {
266  return FastIntersection2D(DE_Geom, FE_Geom, Radius);//, NewContactType);
267  }
268  else {
269  return FastIntersection3D(DE_Geom, FE_Geom, Radius);//, NewContactType);
270  }
271  }
272 
273  static inline bool Intersection(const PointerType& rObj_1, const PointerType& rObj_2, const double& Radius)
274  {
275  const GeometryType& DE_Geom = rObj_1->GetGeometry();
276  const GeometryType& FE_Geom = rObj_2->GetGeometry();
277 
278  const int facet_size = FE_Geom.size();
279 
280  if (facet_size==1) return GeometryFunctions::FastVertexCheck(FE_Geom[0].Coordinates(),DE_Geom[0].Coordinates(), Radius);
281  else if (facet_size==2) {
282  return FastIntersection2D(DE_Geom, FE_Geom, Radius);//, NewContactType);
283  }
284  else {
285  return FastIntersection3D(DE_Geom, FE_Geom, Radius);//, NewContactType);
286  }
287  }
288 
289  //Copy of the Intersection function accessible with geometry
290  static inline bool FastIntersection(const GeometryType& DE_Geom, const GeometryType& FE_Geom, const double& Radius) { //rObj_1 is sphere, rObj_2 is FE
291 
292  int facet_size = FE_Geom.size();
293 
294  if (facet_size==1) return GeometryFunctions::FastVertexCheck(FE_Geom[0].Coordinates(),DE_Geom[0].Coordinates(), Radius);
295  else if (facet_size==2) {
296  return FastIntersection2D(DE_Geom, FE_Geom, Radius);//, NewContactType);
297  }
298  else {
299  return FastIntersection3D(DE_Geom, FE_Geom, Radius);//, NewContactType);
300  }
301  }
302 
303 
304 
305  //needed for bins
306  static inline void Distance(const PointerType& rObj_1, const PointerType& rObj_2, double& distance) {
307  const array_1d<double, 3>& center_of_particle1 = rObj_1->GetGeometry()[0];
308  const array_1d<double, 3>& center_of_particle2 = rObj_2->GetGeometry()[0];
309 
310  distance = std::sqrt((center_of_particle1[0] - center_of_particle2[0]) * (center_of_particle1[0] - center_of_particle2[0]) +
311  (center_of_particle1[1] - center_of_particle2[1]) * (center_of_particle1[1] - center_of_particle2[1]) +
312  (center_of_particle1[2] - center_of_particle2[2]) * (center_of_particle1[2] - center_of_particle2[2]) );
313  }
314 
315 
316  static inline bool DistanceHierarchy(SphericParticle* rObj_1,
317  DEMWall* rObj_2,
318  const double LocalCoordSystem[3][3],
319  const double DistPToB,
320  std::vector<double> Weight,
321  int ContactType,
322  std::vector< double > & Distance_Array,
323  std::vector< array_1d<double,3> >& Normal_Array,
324  std::vector< array_1d<double,4> >& Weight_Array,
325  std::vector<int> & Id_Array,
326  std::vector<int> & ContactTypes
327  )
328  {
329 
330  int new_ID = rObj_2->Id();
331  std::size_t i_current = Normal_Array.size();
332  std::size_t neighbor_size = Normal_Array.size();
333 
334  bool substitute = false;
335  int position = i_current;
336 
337  for (std::size_t i_old_neigh = 0; i_old_neigh < neighbor_size; i_old_neigh++)
338  {
339  //int i_Old_RF_position = i_old_neigh * 16;
340 
341  double Old_Normal_Vector[3] = {0.0};
342  Old_Normal_Vector[0] = Normal_Array[i_old_neigh][0];
343  Old_Normal_Vector[1] = Normal_Array[i_old_neigh][1];
344  Old_Normal_Vector[2] = Normal_Array[i_old_neigh][2];
345 
346  double New_Dist = DistPToB;
347  double Old_dist = Distance_Array[i_old_neigh];
348 
349  double New_projected_on_old = DEM_INNER_PRODUCT_3(LocalCoordSystem[2], Old_Normal_Vector);
350  double New_projected_distance = New_projected_on_old * New_Dist;
351  double Old_projected_distance = New_projected_on_old * Old_dist;
352 
353  if (New_projected_distance - Old_dist > -1.0e-6 * std::abs(Old_dist)) {//old has hierarchy over new //DO NOT SAVE NEW NEIGH
354  return false;
355  }
356 
357  if (Old_projected_distance - New_Dist > -1.0e-6 * std::abs(New_Dist)) { //new has hierarchy over old
358 
359  int old_ID = Id_Array[i_old_neigh];
360  if (new_ID == old_ID) {//SUBSTITUTE
361  position = i_old_neigh;
362  substitute = true;
363  }
364 
365  else { //DISABLE THE OLD ONE
366  ContactTypes[i_old_neigh] = -1;
367  }
368 
369  } //new has hierarchy over
370 
371  }//Loop over Old Neigh
372 
373  std::vector<DEMWall*>& neighbour_rigid_faces = rObj_1->mNeighbourRigidFaces;
374 
375  if(!substitute) { //if substitute we wont resize or pushback
376  Distance_Array.resize(neighbor_size+1);
377  Weight_Array.resize(neighbor_size+1);
378  Normal_Array.resize(neighbor_size+1);
379  Id_Array.resize(neighbor_size+1);
380  ContactTypes.resize(neighbor_size+1);
381 
382  neighbour_rigid_faces.push_back(rObj_2);
383  }
384 
385  Normal_Array[position][0] = LocalCoordSystem[2][0];
386  Normal_Array[position][1] = LocalCoordSystem[2][1];
387  Normal_Array[position][2] = LocalCoordSystem[2][2];
388  Weight_Array[position][0] = Weight[0];
389  Weight_Array[position][1] = Weight[1];
390  Weight_Array[position][2] = Weight[2];
391  Weight_Array[position][3] = Weight[3];
392  Distance_Array[position] = DistPToB;
393 
394  Id_Array[position] = new_ID;
395  ContactTypes[position] = ContactType;
396 
397 
398  return true;
399  }//DistanceHierarchy
400 
401 
402  static inline void DoubleHierarchyMethod(SphericParticle* rObj_1,
403  DEMWall* rObj_2,
404  std::vector< double > & Distance_Array,
405  std::vector< array_1d<double,3> >& Normal_Array,
406  std::vector< array_1d<double,4> >& Weight_Array,
407  std::vector< int >& Id_Array,
408  std::vector<int> & ContactType_Array
409  )
410  {
411  const GeometryType& FE_Geom = rObj_2->GetGeometry();
412  unsigned int FE_size = FE_Geom.size();
413 
414  if (FE_size==1) {
415  DoubleHierarchyMethod1D(rObj_1,rObj_2, Distance_Array, Normal_Array,Weight_Array, Id_Array,ContactType_Array);
416  }
417  else if (FE_size==2) {
418  DoubleHierarchyMethod2D(rObj_1,rObj_2, Distance_Array, Normal_Array,Weight_Array, Id_Array,ContactType_Array);
419  }
420  else {
421  DoubleHierarchyMethod3D(rObj_1,rObj_2, Distance_Array, Normal_Array,Weight_Array, Id_Array,ContactType_Array);
422  }
423 
424  }
425 
426  static inline void DoubleHierarchyMethod3D(SphericParticle* rObj_1,
427  DEMWall* rObj_2,
428  std::vector< double > & Distance_Array,
429  std::vector< array_1d<double,3> >& Normal_Array,
430  std::vector< array_1d<double,4> >& Weight_Array,
431  std::vector< int >& Id_Array,
432  std::vector< int >& ContactType_Array
433  )
434 
435  {
436  //rObj_1 is particle, and rObj_2 is condition
437  //TYPE HIERARCHY
438  int ContactType = -1;
439  //-1: No contact;
440  // 1: Plane;
441  // 2: Edge;
442  // 3: Point.
443  // 4: Edge or Point
444 
445  bool ContactExists = false;
446  const GeometryType& DE_Geom = rObj_1->GetGeometry();
447 
448  double Radius = rObj_1->GetInteractionRadius();
449 
450  const GeometryType& FE_Geom = rObj_2->GetGeometry();
451  unsigned int FE_size = FE_Geom.size();
452 
453  double local_coord_system[3][3] = { {0.0},{0.0},{0.0} };
454  std::vector<double> Weight(4,0.0);
455 
456  double distance_point_to_plane = 0.0;
457  unsigned int current_edge_index = 0;
458  bool inside = false;
459  ContactExists = GeometryFunctions::FacetCheck(FE_Geom, DE_Geom[0].Coordinates(), Radius, local_coord_system,
460  distance_point_to_plane, Weight, current_edge_index, inside);
461  if (ContactExists == true) {
462  ContactType = 1;
463  ContactExists = DistanceHierarchy(rObj_1,rObj_2, local_coord_system, distance_point_to_plane, Weight, ContactType, Distance_Array, Normal_Array,Weight_Array, Id_Array, ContactType_Array);
464  return;
465  }
466  //The key here is to see that we only need to check for further contact if, when not having contact with plane, the distance_point_to_plane is lower than the radius.
467  //In this case it might have contact with edges or vertices, otherwise no contact is possible.
468 
469  //The check should avoid the edges which yielded a OUTSIDE value in the inside-outside check. i.e. we will check from the current edge to the last.
470 
471  if (!ContactExists) {
472 
474  if (distance_point_to_plane < Radius) {
475  bool local_contact_exists = false;
476  for (unsigned int e = current_edge_index; e < FE_size; e++) {
477  double eta = 0.5; // dummy initialize
478  double distance_point_to_edge = 2.0 * Radius; //dummy big initialization
479 
480  local_contact_exists = GeometryFunctions::EdgeCheck(FE_Geom[e], FE_Geom[(e + 1) % FE_size], DE_Geom[0].Coordinates(), Radius, local_coord_system,
481  distance_point_to_edge, eta);
482  if (local_contact_exists) {
483  //save data
484  ContactType = 2;
485  Weight[e] = 1 - eta;
486  Weight[(e + 1) % FE_size] = eta; //the rest remain 0 (valid for triangles and quadrilateral)
487  if (FE_size > 4) { KRATOS_WATCH("WEIGHTS ALONG EDGE CANT BE CALCULATED WITH SUKUMAR FORMULAE") }
488  ContactExists = DistanceHierarchy(rObj_1, rObj_2, local_coord_system, distance_point_to_edge, Weight, ContactType, Distance_Array, Normal_Array, Weight_Array, Id_Array, ContactType_Array);
489  continue; //skip vertex check
490  }
491  if ((local_contact_exists == false) && (distance_point_to_edge < Radius)) {
492  unsigned int vertex_to_check = -1;
493  if (eta < 0.0) { vertex_to_check = e; }
494  else if (eta > 1.0) { vertex_to_check = (e + 1) % FE_size; }
495  else { continue; }
496  double distance_point_to_vertex = 0.0;
497  local_contact_exists = GeometryFunctions::VertexCheck(FE_Geom[vertex_to_check], DE_Geom[0].Coordinates(), Radius, local_coord_system, distance_point_to_vertex);
498 
499  if (local_contact_exists) {
500  ContactType = 3;
501  Weight[vertex_to_check] = 1.0; //the rest weights stay 0.0;
502  ContactExists = DistanceHierarchy(rObj_1, rObj_2, local_coord_system, distance_point_to_vertex, Weight, ContactType, Distance_Array, Normal_Array, Weight_Array, Id_Array, ContactType_Array);
503  }
504  } // (ContactExists == false) && (distance_point_to_edge < Radius )
505  }//for every edge
506  }
507 
508  // Add to non contact list the faces intersected by the normal direction between the particle and the FE
509  else {
510  if (inside)
511  rObj_1->mNeighbourNonContactRigidFaces.push_back(rObj_2);
512  }
513  }
514 
515  return;
516  } //DoubleHierarchyMethod3D
517 
518 
519  static inline void DoubleHierarchyMethod2D(SphericParticle* rObj_1,
520  DEMWall* rObj_2,
521  std::vector< double > & Distance_Array,
522  std::vector< array_1d<double,3> >& Normal_Array,
523  std::vector< array_1d<double,4> >& Weight_Array,
524  std::vector< int > & Id_Array,
525  std::vector< int > & ContactType_Array
526  )
527  {
528  //rObj_1 is particle, and rObj_2 is condition
529  int ContactType = -1;
530  //-1: No contact;
531  // 2: Edge;
532  // 3: Vertex.
533 
534  bool ContactExists = false;
535 
536  const GeometryType& DE_Geom = rObj_1->GetGeometry();
537 
538  double Radius = rObj_1->GetInteractionRadius();
539 
540  const GeometryType& FE_Geom = rObj_2->GetGeometry();
541 
542  double local_coord_system[3][3] = { {0.0},{0.0},{0.0} };
543  std::vector<double> Weight(4,0.0);
544  std::vector< array_1d<double,3> > Coord(2);
545 
546  for (unsigned int i = 0; i<2; i++) {
547  for (unsigned int j = 0; j<3; j++) {
548  Coord[i][j] = FE_Geom[i].Coordinates()[j];
549  }
550  }
551 
552  double eta = 0.5; // dummy initialize
553  double distance_point_to_edge = 2*Radius; //dummy big initialization
554 
555  ContactExists = GeometryFunctions::EdgeCheck( Coord[0], Coord[1], DE_Geom[0].Coordinates(), Radius, local_coord_system,
556  distance_point_to_edge, eta);
557  if (ContactExists) { //save data
558  ContactType = 2;
559  Weight[0] = 1-eta;
560  Weight[1] = eta; //the rest remain 0 (valid for triangles and quadrilateral)
561 
562  ContactExists = DistanceHierarchy(rObj_1,rObj_2, local_coord_system, distance_point_to_edge, Weight, ContactType, Distance_Array, Normal_Array, Weight_Array, Id_Array, ContactType_Array);
563  return;
564  }
565 
566  if (ContactExists == false) {
567  if (distance_point_to_edge < Radius) {
568  unsigned int vertex_to_check = -1;
569  if (eta < 0.0) { vertex_to_check = 0; }
570  else if (eta > 1.0) { vertex_to_check = 1; }
571  double distance_point_to_vertex = 0.0;
572  ContactExists = GeometryFunctions::VertexCheck(Coord[vertex_to_check], DE_Geom[0].Coordinates(), Radius, local_coord_system, distance_point_to_vertex);
573 
574  if (ContactExists) {
575  ContactType = 3;
576  Weight[vertex_to_check] = 1.0; //the rest weights stay 0.0;
577  ContactExists = DistanceHierarchy(rObj_1, rObj_2, local_coord_system, distance_point_to_vertex, Weight, ContactType, Distance_Array, Normal_Array, Weight_Array, Id_Array, ContactType_Array);
578  return;
579  }
580  }
581  else { // noncontact rigid face (distance_point_to_edge >= Radius)
582  if ((eta >= 0.0) && (eta <= 1.0))
583  rObj_1->mNeighbourNonContactRigidFaces.push_back(rObj_2);
584  }
585  }
586 
587  return;
588  }//DoubleHierarchyMethod2D
589 
590  static inline void DoubleHierarchyMethod1D(SphericParticle* rObj_1,
591  DEMWall* rObj_2,
592  std::vector< double > & Distance_Array,
593  std::vector< array_1d<double,3> >& Normal_Array,
594  std::vector< array_1d<double,4> >& Weight_Array,
595  std::vector< int > & Id_Array,
596  std::vector< int > & ContactType_Array
597  )
598  {
599  //rObj_1 is particle, and rObj_2 is condition
600  int ContactType = -1;
601  //-1: No contact;
602  // 3: Vertex.
603 
604  bool ContactExists = false;
605 
606  const GeometryType& DE_Geom = rObj_1->GetGeometry();
607 
608  double Radius = rObj_1->GetInteractionRadius();
609 
610  const GeometryType& FE_Geom = rObj_2->GetGeometry();
611 
612  double local_coord_system[3][3] = { {0.0},{0.0},{0.0} };
613  std::vector<double> Weight(4,0.0);
614 
615  double distance_point_to_vertex = 0.0;
616  ContactExists = GeometryFunctions::VertexCheck(FE_Geom[0].Coordinates(),
617  DE_Geom[0].Coordinates(), Radius, local_coord_system,
618  distance_point_to_vertex);
619 
620  if (ContactExists) {
621  ContactType = 3;
622  Weight[0] = 1.0; //the rest weights stay 0.0;
623  ContactExists = DistanceHierarchy(rObj_1,rObj_2, local_coord_system,
624  distance_point_to_vertex, Weight, ContactType, Distance_Array,
625  Normal_Array, Weight_Array, Id_Array, ContactType_Array);
626  return;
627  }
628  return;
629  }//DoubleHierarchyMethod2D
630 
631 
632 
636 
637 
641 
642 
646 
648  virtual std::string Info() const {return " Spatial Containers Configure for RigidFace"; }
649 
651  virtual void PrintInfo(std::ostream& rOStream) const {}
652 
654  virtual void PrintData(std::ostream& rOStream) const {}
655 
659 
660 
662 
663 protected:
666 
670 
674 
678 
682 
686 
690 
692 
693 private:
696 
700 
704 
708 
709  static inline bool floateq(double a, double b) {
710  return std::fabs(a - b) < std::numeric_limits<double>::epsilon();
711  }
712 
713  static inline bool floatle(double a, double b) {
714  return std::fabs(a - b) < std::numeric_limits<double>::epsilon() || a < b;
715  }
716 
717  static inline bool floatge(double a, double b) {
718  return std::fabs(a - b) < std::numeric_limits<double>::epsilon() || a > b;
719  }
720 
724 
728 
732 
735 
738 
740 
741  }; // Class ParticleConfigure
742 
744 
747 
751 
753  template <std::size_t TDimension>
754  inline std::istream& operator >> (std::istream& rIStream, RigidFaceGeometricalObjectConfigure<TDimension> & rThis){
755  return rIStream;
756  }
757 
759  template <std::size_t TDimension>
760  inline std::ostream& operator << (std::ostream& rOStream, const RigidFaceGeometricalObjectConfigure<TDimension>& rThis){
761  rThis.PrintInfo(rOStream);
762  rOStream << std::endl;
763  rThis.PrintData(rOStream);
764 
765  return rOStream;
766  }
767 
769 
770 } // namespace Kratos.
771 #endif /* rigid_face_geometrical_object_configure.h */
#define DEM_INNER_PRODUCT_3(a, b)
Definition: DEM_application_variables.h:31
Definition: dem_wall.h:29
This defines the geometrical object, base definition of the element and condition entities.
Definition: geometrical_object.h:58
GeometryType & GetGeometry()
Returns the reference of the geometry.
Definition: geometrical_object.h:158
Geometry base class.
Definition: geometry.h:71
SizeType size() const
Definition: geometry.h:518
This object defines an indexed object.
Definition: indexed_object.h:54
IndexType Id() const
Definition: indexed_object.h:107
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
Definition: rigid_face_geometrical_object_configure.h:48
static void Distance(const PointerType &rObj_1, const PointerType &rObj_2, double &distance)
Definition: rigid_face_geometrical_object_configure.h:306
static bool FastIntersection3D(const GeometryType &DE_Geom, const GeometryType &FE_Geom, const double &Radius)
Definition: rigid_face_geometrical_object_configure.h:219
static void DoubleHierarchyMethod2D(SphericParticle *rObj_1, DEMWall *rObj_2, std::vector< double > &Distance_Array, std::vector< array_1d< double, 3 > > &Normal_Array, std::vector< array_1d< double, 4 > > &Weight_Array, std::vector< int > &Id_Array, std::vector< int > &ContactType_Array)
Definition: rigid_face_geometrical_object_configure.h:519
KRATOS_CLASS_POINTER_DEFINITION(RigidFaceGeometricalObjectConfigure)
Pointer definition of SpatialContainersConfigure.
static void CalculateBoundingBox(const PointerType &rObject, PointType &rLowPoint, PointType &rHighPoint)
Cfeng: For FEM conditions.
Definition: rigid_face_geometrical_object_configure.h:124
static bool Intersection(const PointerType &rObj_1, const PointerType &rObj_2)
Definition: rigid_face_geometrical_object_configure.h:255
static bool FastIntersection(const GeometryType &DE_Geom, const GeometryType &FE_Geom, const double &Radius)
Definition: rigid_face_geometrical_object_configure.h:290
std::vector< double >::iterator DistanceIteratorType
Definition: rigid_face_geometrical_object_configure.h:89
static bool DistanceHierarchy(SphericParticle *rObj_1, DEMWall *rObj_2, const double LocalCoordSystem[3][3], const double DistPToB, std::vector< double > Weight, int ContactType, std::vector< double > &Distance_Array, std::vector< array_1d< double, 3 > > &Normal_Array, std::vector< array_1d< double, 4 > > &Weight_Array, std::vector< int > &Id_Array, std::vector< int > &ContactTypes)
Definition: rigid_face_geometrical_object_configure.h:316
PointerVectorSet< GeometricalObject, IndexedObject, std::less< typename IndexedObject::result_type >, std::equal_to< typename IndexedObject::result_type >, typename GeometricalObject::Pointer, std::vector< typename GeometricalObject::Pointer > > ElementsContainerType
Definition: rigid_face_geometrical_object_configure.h:76
virtual void PrintInfo(std::ostream &rOStream) const
Print information about this object.
Definition: rigid_face_geometrical_object_configure.h:651
static bool IntersectionBox(const PointerType &rObject, const PointType &rLowPoint, const PointType &rHighPoint, const double &Radius)
Definition: rigid_face_geometrical_object_configure.h:188
static bool IntersectionBox(const PointerType &rObject, const PointType &rLowPoint, const PointType &rHighPoint)
Definition: rigid_face_geometrical_object_configure.h:166
static void DoubleHierarchyMethod(SphericParticle *rObj_1, DEMWall *rObj_2, std::vector< double > &Distance_Array, std::vector< array_1d< double, 3 > > &Normal_Array, std::vector< array_1d< double, 4 > > &Weight_Array, std::vector< int > &Id_Array, std::vector< int > &ContactType_Array)
Definition: rigid_face_geometrical_object_configure.h:402
ContainerType::iterator IteratorType
Definition: rigid_face_geometrical_object_configure.h:82
virtual std::string Info() const
Turn back information as a string.
Definition: rigid_face_geometrical_object_configure.h:648
static bool Intersection(const PointerType &rObj_1, const PointerType &rObj_2, const double &Radius)
Definition: rigid_face_geometrical_object_configure.h:273
static void DoubleHierarchyMethod3D(SphericParticle *rObj_1, DEMWall *rObj_2, std::vector< double > &Distance_Array, std::vector< array_1d< double, 3 > > &Normal_Array, std::vector< array_1d< double, 4 > > &Weight_Array, std::vector< int > &Id_Array, std::vector< int > &ContactType_Array)
Definition: rigid_face_geometrical_object_configure.h:426
ContainerType::value_type PointerType
Definition: rigid_face_geometrical_object_configure.h:81
SearchType::PointType PointType
Definition: rigid_face_geometrical_object_configure.h:67
@ DIMENSION
Definition: rigid_face_geometrical_object_configure.h:54
@ MIN_LEVEL
Definition: rigid_face_geometrical_object_configure.h:56
@ MAX_LEVEL
Definition: rigid_face_geometrical_object_configure.h:55
@ Dimension
Definition: rigid_face_geometrical_object_configure.h:53
virtual ~RigidFaceGeometricalObjectConfigure()
Definition: rigid_face_geometrical_object_configure.h:96
static void DoubleHierarchyMethod1D(SphericParticle *rObj_1, DEMWall *rObj_2, std::vector< double > &Distance_Array, std::vector< array_1d< double, 3 > > &Normal_Array, std::vector< array_1d< double, 4 > > &Weight_Array, std::vector< int > &Id_Array, std::vector< int > &ContactType_Array)
Definition: rigid_face_geometrical_object_configure.h:590
static bool FastIntersection2D(const GeometryType &DE_Geom, const GeometryType &FE_Geom, const double &Radius)
Definition: rigid_face_geometrical_object_configure.h:204
ContainerType ResultContainerType
Definition: rigid_face_geometrical_object_configure.h:85
SpatialSearch SearchType
Definition: rigid_face_geometrical_object_configure.h:65
virtual void PrintData(std::ostream &rOStream) const
Print object's data.
Definition: rigid_face_geometrical_object_configure.h:654
ElementsContainerType::ContainerType ContainerType
Definition: rigid_face_geometrical_object_configure.h:79
static void CalculateBoundingBox(const PointerType &rObject, PointType &rLowPoint, PointType &rHighPoint, const double &Radius)
Definition: rigid_face_geometrical_object_configure.h:110
RigidFaceGeometricalObjectConfigure()
Definition: rigid_face_geometrical_object_configure.h:95
ResultContainerType::iterator ResultIteratorType
Definition: rigid_face_geometrical_object_configure.h:88
This class is used to search for elements, conditions and nodes in a given model part.
Definition: spatial_search.h:50
Definition: spheric_particle.h:31
std::vector< DEMWall * > mNeighbourNonContactRigidFaces
Definition: spheric_particle.h:252
virtual double GetInteractionRadius(const int radius_index=0)
Definition: spheric_particle.cpp:2199
virtual double GetSearchRadius()
Definition: spheric_particle.cpp:2201
std::vector< DEMWall * > mNeighbourRigidFaces
Definition: spheric_particle.h:251
#define KRATOS_WATCH(variable)
Definition: define.h:806
static bool FastFacetCheck(const std::vector< array_1d< double, 3 > > &Coord, const array_1d< double, 3 > &Particle_Coord, double rad, double &DistPToB, unsigned int &current_edge_index)
Definition: GeometryFunctions.h:1053
static bool FastVertexCheck(const array_1d< double, 3 > &Coord, const array_1d< double, 3 > &Particle_Coord, double Radius)
Definition: GeometryFunctions.h:1359
static bool EdgeCheck(const array_1d< double, 3 > &Coord1, const array_1d< double, 3 > &Coord2, const array_1d< double, 3 > &Particle_Coord, double Radius, double LocalCoordSystem[3][3], double &DistParticleToEdge, double &eta)
Definition: GeometryFunctions.h:1288
static bool FastEdgeVertexCheck(const array_1d< double, 3 > &Coord1, const array_1d< double, 3 > &Coord2, const array_1d< double, 3 > &Particle_Coord, double Radius)
Definition: GeometryFunctions.h:1215
static bool VertexCheck(const array_1d< double, 3 > &Coord, const array_1d< double, 3 > &Particle_Coord, double Radius, double LocalCoordSystem[3][3], double &DistParticleToVertex)
Definition: GeometryFunctions.h:1340
static bool FacetCheck(const GeometryType &Coord, const array_1d< double, 3 > &Particle_Coord, double rad, double LocalCoordSystem[3][3], double &DistPToB, std::vector< double > &Weight, unsigned int &current_edge_index, bool &inside)
Definition: GeometryFunctions.h:1118
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
Geometry< Node > GeometryType
The definition of the geometry.
Definition: mortar_classes.h:37
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
int domain_size
Definition: face_heat.py:4
a
Definition: generate_stokes_twofluid_element.py:77
b
Definition: generate_total_lagrangian_mixed_volumetric_strain_element.py:31
float radius
Definition: mesh_to_mdpa_converter.py:18
int j
Definition: quadrature.py:648
integer i
Definition: TensorModule.f:17
e
Definition: run_cpp_mpi_tests.py:31