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.
spatial_bounding_box.hpp
Go to the documentation of this file.
1 //
2 // Project Name: KratosDelaunayMeshingApplication $
3 // Created by: $Author: JMCarbonell $
4 // Last modified by: $Co-Author: $
5 // Date: $Date: April 2018 $
6 // Revision: $Revision: 0.0 $
7 //
8 //
9 
10 #if !defined(KRATOS_SPATIAL_BOUNDING_BOX_H_INCLUDED )
11 #define KRATOS_SPATIAL_BOUNDING_BOX_H_INCLUDED
12 
13 
14 // System includes
15 #include <limits>
16 
18 #include "includes/model_part.h"
20 
21 namespace Kratos
22 {
23 
26 
30 
34 
38 
42 
44 
47 class KRATOS_API(DELAUNAY_MESHING_APPLICATION) SpatialBoundingBox
48 {
49 public:
50 
51  //typedef bounded_vector<double, 3> PointType;
55  typedef NodesContainerType::Pointer NodesContainerTypePointer;
58 
59 
61  {
63 
64  private:
65 
66  const PointType* mpPoint;
67  const PointType* mpVelocity;
68 
69  const PointType* mpCurrentDisplacement;
70  const PointType* mpPreviousDisplacement;
71 
72  PointType* mpNormal;
73  PointType* mpTangent;
74  PointType* mpRelativeDisplacement;
75 
76  double* mpGapNormal;
77  double* mpGapTangent;
78 
79  double mRadius;
80  int mContactFace;
81 
82  public:
83 
88  {
89  //Initialize pointers to NULL
90  mpPoint=NULL;
91  mpVelocity=NULL;
92 
93  mpCurrentDisplacement=NULL;
94  mpPreviousDisplacement=NULL;
95 
96  mpNormal=NULL;
97  mpTangent=NULL;
98  mpRelativeDisplacement=NULL;
99 
100  mpGapNormal=NULL;
101  mpGapTangent=NULL;
102 
103  mRadius = 0.0;
104  mContactFace = 0;
105 
106  };
107 
112  {
113 
114  mpPoint = &(rNode.Coordinates());
115  mpVelocity = &(rNode.FastGetSolutionStepValue(VELOCITY));
116 
117  mpCurrentDisplacement = &(rNode.FastGetSolutionStepValue(DISPLACEMENT,0));
118  mpPreviousDisplacement = &(rNode.FastGetSolutionStepValue(DISPLACEMENT,1));
119 
120  mpNormal=NULL;
121  mpTangent=NULL;
122 
123  mpRelativeDisplacement=NULL;
124 
125  mpGapNormal=NULL;
126  mpGapTangent=NULL;
127 
128  mRadius = 0.0;
129  mContactFace = 0;
130 
131  };
132 
136  BoundingBoxParameters(const NodeType& rNode, double& rGapNormal, double& rGapTangent, PointType& rNormal, PointType& rTangent, PointType& rDisplacement)
137  {
138  mpPoint = &(rNode.Coordinates());
139  mpVelocity = &(rNode.FastGetSolutionStepValue(VELOCITY));
140 
141  mpCurrentDisplacement = &(rNode.FastGetSolutionStepValue(DISPLACEMENT,0));
142  mpPreviousDisplacement = &(rNode.FastGetSolutionStepValue(DISPLACEMENT,1));
143 
144  mpNormal = &rNormal;
145  mpTangent = &rTangent;
146 
147  mpRelativeDisplacement = &rDisplacement;
148 
149  mpGapNormal = &rGapNormal;
150  mpGapTangent = &rGapTangent;
151 
152  mRadius = 0.0;
153  mContactFace = 0;
154  };
155 
156  //set parameters
157  void SetNode(const NodeType& rNode){
158  mpPoint = &(rNode.Coordinates());
159  mpVelocity = &(rNode.FastGetSolutionStepValue(VELOCITY));
160 
161  mpCurrentDisplacement = &(rNode.FastGetSolutionStepValue(DISPLACEMENT,0));
162  mpPreviousDisplacement = &(rNode.FastGetSolutionStepValue(DISPLACEMENT,1));
163  };
164 
165  void SetPoint(const PointType& rPoint) {mpPoint = &rPoint;};
166  void SetVelocity(const PointType& rVelocity) {mpVelocity = &rVelocity;};
167  void SetCurrentDisplacement(const PointType& rDisplacement) {mpCurrentDisplacement = &rDisplacement;};
168  void SetPreviousDisplacement(const PointType& rDisplacement) {mpPreviousDisplacement = &rDisplacement;};
169 
170  void SetNormal(PointType& rNormal) {mpNormal = &rNormal;};
171  void SetTangent(PointType& rTangent) {mpTangent = &rTangent;};
172  void SetRelativeDisplacement(PointType& rDisplacement) {mpRelativeDisplacement = &rDisplacement;};
173 
174  void SetGapNormal(double& rGapNormal) {mpGapNormal = &rGapNormal;};
175  void SetGapTangent(double& rGapTangent) {mpGapTangent = &rGapTangent;};
176 
177  void SetRadius(double Radius) {mRadius = Radius;};
178  void SetContactFace(int ContactFace) {mContactFace = ContactFace;};
179 
180  //get parameters
181  const PointType& GetPoint() {return *mpPoint;};
182  const PointType& GetVelocity() {return *mpVelocity;};
183  const PointType& GetCurrentDisplacement() {return *mpCurrentDisplacement;};
184  const PointType& GetPreviousDisplacement() {return *mpPreviousDisplacement;};
185 
186  PointType GetDeltaDisplacement() {return ((*mpCurrentDisplacement)-(*mpPreviousDisplacement));};
187 
188  PointType& GetNormal() {return *mpNormal;};
189  PointType& GetTangent() {return *mpTangent;};
190  PointType& GetRelativeDisplacement() {return *mpRelativeDisplacement;};
191 
192 
193  double& GetGapNormal() {return *mpGapNormal;};
194  double& GetGapTangent() {return *mpGapTangent;};
195 
196  double& GetRadius() {return mRadius;};
197  int& GetContactFace() {return mContactFace;};
198 
199  };// struct BoundingBoxParameters end
200 
201 
202 protected:
203 
204 
206  {
207 
208  int Dimension; // 2D or 3D
209  bool Axisymmetric; // true or false
210  int Convexity; // 1 or -1 if "in" is inside or outside respectively
211  double Radius; // box radius
212 
213  PointType InitialUpperPoint; // box highest point
214  PointType InitialLowerPoint; // box lowest point
215  PointType InitialCenter; // center current position
216 
217  PointType UpperPoint; // box highest point
218  PointType LowerPoint; // box lowest point
219  PointType Center; // center current position
220 
221  PointType Velocity; // box velocity
222  PointType AngularVelocity; // box rotation
223 
224  QuaternionType InitialLocalQuaternion; //initial local axes for the box
225  QuaternionType LocalQuaternion; //local axes for the box
226 
227  public:
228 
229  void Initialize()
230  {
231  Dimension = 3;
232  Axisymmetric = false;
233  Convexity = 1;
234  Radius = 0;
235 
236  UpperPoint.clear();
237  LowerPoint.clear();
238  Center.clear();
239 
240  InitialUpperPoint.clear();
241  InitialLowerPoint.clear();
242  InitialCenter.clear();
243 
244  Velocity.clear();
245  AngularVelocity.clear();
246 
247  Matrix InitialLocalMatrix = IdentityMatrix(3);
248  InitialLocalQuaternion = QuaternionType::FromRotationMatrix( InitialLocalMatrix );
249  LocalQuaternion = QuaternionType::FromRotationMatrix( InitialLocalMatrix );
250 
251  }
252 
254  {
255  InitialUpperPoint = UpperPoint;
256  InitialLowerPoint = LowerPoint;
257  InitialCenter = Center;
258  }
259 
260  void UpdatePosition( PointType& Displacement )
261  {
262  UpperPoint = InitialUpperPoint + Displacement;
263  LowerPoint = InitialLowerPoint + Displacement;
264  Center = InitialCenter + Displacement;
265  }
266 
267  void Print()
268  {
269  std::cout<<" [--SPATIAL-BOX--] "<<std::endl;
270  std::cout<<" [Center:"<<Center<<std::endl;
271  std::cout<<" [UpperPoint:"<<UpperPoint<<std::endl;
272  std::cout<<" [LowerPoint:"<<LowerPoint<<std::endl;
273  std::cout<<" [--------] "<<std::endl;
274  }
275 
276 
277  };
278 
279 
280 
281 public:
282 
285 
288 
289 
290 
294 
297  {
298  KRATOS_TRY
299 
300  mBox.Initialize();
301  mRigidBodyCenterSupplied = false;
302  //std::cout<< " Calling Bounding Box empty constructor" <<std::endl;
303 
304  KRATOS_CATCH("")
305  }
306 
307 
308  //**************************************************************************
309  //**************************************************************************
310 
311  SpatialBoundingBox(Parameters CustomParameters)
312  {
313 
314  KRATOS_TRY
315 
316  Parameters DefaultParameters( R"(
317  {
318  "parameters_list":[{
319  "upper_point": [0.0, 0.0, 0.0],
320  "lower_point": [0.0, 0.0, 0.0],
321  "convexity": 1
322  }],
323  "velocity": [0.0, 0.0, 0.0],
324  "angular_velocity": [0.0, 0.0, 0.0],
325  "local_axes":[ [1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0] ]
326  } )" );
327 
328 
329  //validate against defaults -- this also ensures no type mismatch
330  CustomParameters.ValidateAndAssignDefaults(DefaultParameters);
331 
332  if(CustomParameters["parameters_list"].IsArray() == true && CustomParameters["parameters_list"].size() != 1)
333  {
334  KRATOS_THROW_ERROR(std::runtime_error,"paramters_list for the Spatial BBX must contain only one term",CustomParameters.PrettyPrintJsonString());
335  }
336 
337  mBox.Initialize();
338 
339  Parameters BoxParameters = CustomParameters["parameters_list"][0];
340 
341  mBox.UpperPoint[0] = BoxParameters["upper_point"][0].GetDouble();
342  mBox.UpperPoint[1] = BoxParameters["upper_point"][1].GetDouble();
343  mBox.UpperPoint[2] = BoxParameters["upper_point"][2].GetDouble();
344 
345  mBox.LowerPoint[0] = BoxParameters["lower_point"][0].GetDouble();
346  mBox.LowerPoint[1] = BoxParameters["lower_point"][1].GetDouble();
347  mBox.LowerPoint[2] = BoxParameters["lower_point"][2].GetDouble();
348 
349  mBox.Center = 0.5 * ( mBox.UpperPoint + mBox.LowerPoint );
350  mBox.Radius = 0.5 * norm_2(mBox.UpperPoint - mBox.LowerPoint);
351 
352  mBox.Velocity[0] = CustomParameters["velocity"][0].GetDouble();
353  mBox.Velocity[1] = CustomParameters["velocity"][1].GetDouble();
354  mBox.Velocity[2] = CustomParameters["velocity"][2].GetDouble();
355 
356  mBox.AngularVelocity[0] = CustomParameters["angular_velocity"][0].GetDouble();
357  mBox.AngularVelocity[1] = CustomParameters["angular_velocity"][1].GetDouble();
358  mBox.AngularVelocity[2] = CustomParameters["angular_velocity"][2].GetDouble();
359 
360  mBox.Convexity = BoxParameters["convexity"].GetInt();
361 
362  Matrix InitialLocalMatrix = IdentityMatrix(3);
363 
364  unsigned int size = CustomParameters["local_axes"].size();
365 
366  for( unsigned int i=0; i<size; i++ )
367  {
368  Parameters LocalAxesRow = CustomParameters["local_axes"][i];
369 
370  InitialLocalMatrix(0,i) = LocalAxesRow[0].GetDouble(); //column disposition
371  InitialLocalMatrix(1,i) = LocalAxesRow[1].GetDouble();
372  InitialLocalMatrix(2,i) = LocalAxesRow[2].GetDouble();
373  }
374 
375  //set to local frame
376  this->MapToLocalFrame(mBox.InitialLocalQuaternion,mBox);
377 
378  BeamMathUtilsType::MapToCurrentLocalFrame(mBox.InitialLocalQuaternion, mBox.Velocity);
379  BeamMathUtilsType::MapToCurrentLocalFrame(mBox.InitialLocalQuaternion, mBox.AngularVelocity);
380 
381  mBox.SetInitialValues();
382 
383  mRigidBodyCenterSupplied = false;
384 
385  KRATOS_CATCH("")
386  }
387 
388  //**************************************************************************
389  //**************************************************************************
390 
391  SpatialBoundingBox(const PointType& rLowerPoint, const PointType& rUpperPoint )
392  {
393  KRATOS_TRY
394 
395  mBox.Initialize();
396  mBox.UpperPoint = rUpperPoint;
397  mBox.LowerPoint = rLowerPoint;
398 
399  mBox.Center = 0.5 * ( rUpperPoint + rLowerPoint );
400  mBox.Radius = 0.5 * norm_2(rUpperPoint-rLowerPoint);
401 
402  //set to local frame
403  this->MapToLocalFrame(mBox.InitialLocalQuaternion,mBox);
404 
405  BeamMathUtilsType::MapToCurrentLocalFrame(mBox.InitialLocalQuaternion, mBox.Velocity);
406  BeamMathUtilsType::MapToCurrentLocalFrame(mBox.InitialLocalQuaternion, mBox.AngularVelocity);
407 
408  mBox.SetInitialValues();
409 
410  mRigidBodyCenterSupplied = false;
411 
412  KRATOS_CATCH("")
413  }
414 
415  //**************************************************************************
416  //**************************************************************************
417 
418  SpatialBoundingBox(const PointType& rCenter, const double& rRadius)
419  {
420  KRATOS_TRY
421 
422  mBox.Initialize();
423  mBox.Center = rCenter;
424  mBox.Radius = rRadius;
425 
426  PointType Side;
427  Side[0] = mBox.Radius;
428  Side[1] = mBox.Radius;
429  Side[2] = mBox.Radius;
430 
431  mBox.UpperPoint = mBox.Center + Side;
432  mBox.LowerPoint = mBox.Center - Side;
433 
434  //set to local frame
435  this->MapToLocalFrame(mBox.InitialLocalQuaternion,mBox);
436 
437  mBox.SetInitialValues();
438 
439  mRigidBodyCenterSupplied = false;
440 
441  KRATOS_CATCH("")
442  }
443 
444  //**************************************************************************
445  //**************************************************************************
446 
447  SpatialBoundingBox(ModelPart &rModelPart, const double& rRadius, double factor = 0)
448  {
449  KRATOS_TRY
450 
453 
454 
455  unsigned int dimension = 2;
456  if ( rModelPart.NumberOfElements() > 0)
457  dimension = rModelPart.ElementsBegin()->GetGeometry().WorkingSpaceDimension();
458  else if ( rModelPart.NumberOfConditions() > 0)
459  dimension = rModelPart.ConditionsBegin()->GetGeometry().WorkingSpaceDimension();
460  else
461  KRATOS_ERROR << " spatial_bounding_box: the supplied ModelPart does not have elements or conditions " << std::endl;
462 
463  PointType Maximum;
464  PointType Minimum;
465 
466  for(unsigned int i=0; i<3; ++i)
467  {
468  Maximum[i] = min;
469  Minimum[i] = max;
470  }
471 
472  //Get inside point of the subdomains
473 
474  for(ModelPart::NodesContainerType::iterator in = rModelPart.NodesBegin(); in!=rModelPart.NodesEnd(); ++in)
475  {
476  if(in->Is(BOUNDARY) ){
477 
478  //get maximum
479  if(Maximum[0]<in->X())
480  Maximum[0]=in->X();
481 
482  if(Maximum[1]<in->Y())
483  Maximum[1]=in->Y();
484 
485  if(Maximum[2]<in->Z())
486  Maximum[2]=in->Z();
487 
488  //get minimum
489  if(Minimum[0]>in->X())
490  Minimum[0]=in->X();
491 
492  if(Minimum[1]>in->Y())
493  Minimum[1]=in->Y();
494 
495  if(Minimum[2]>in->Z())
496  Minimum[2]=in->Z();
497  }
498 
499  }
500 
501  mBox.Initialize();
502 
503  mBox.Center = 0.5*(Maximum+Minimum);
504 
505  double MaxRadius = min;
506 
507  if(Maximum[0]-Minimum[0] > MaxRadius)
508  MaxRadius = Maximum[0]-Minimum[0];
509 
510  if(Maximum[1]-Minimum[1] > MaxRadius)
511  MaxRadius = Maximum[1]-Minimum[1];
512 
513  if(Maximum[2]-Minimum[2]>MaxRadius)
514  MaxRadius = Maximum[2]-Minimum[2];
515 
516 
517  mBox.Radius = rRadius + 0.5*(MaxRadius);
518 
519  PointType Side(dimension);
520  Side[0] = mBox.Radius + mBox.Radius * factor;
521  Side[1] = mBox.Radius + mBox.Radius * factor;
522  Side[2] = mBox.Radius + mBox.Radius * factor;
523 
524  mBox.UpperPoint = mBox.Center + Side;
525  mBox.LowerPoint = mBox.Center - Side;
526 
527  //set to local frame
528  this->MapToLocalFrame(mBox.InitialLocalQuaternion,mBox);
529 
530  mRigidBodyCenterSupplied = false;
531 
532  KRATOS_CATCH("")
533  }
534 
535  //**************************************************************************
536  //**************************************************************************
537 
538 
541  {
542  KRATOS_TRY
543 
544  mpRigidBodyCenter = rOther.mpRigidBodyCenter;
545  mRigidBodyCenterSupplied = rOther.mRigidBodyCenterSupplied;
546  mBox = rOther.mBox;
547 
548  return *this;
549 
550  KRATOS_CATCH("")
551  }
552 
553 
554  //**************************************************************************
555  //**************************************************************************
556 
559  :mpRigidBodyCenter(rOther.mpRigidBodyCenter)
560  ,mRigidBodyCenterSupplied(rOther.mRigidBodyCenterSupplied)
561  ,mBox(rOther.mBox)
562  {
563  }
564 
565  //**************************************************************************
566  //**************************************************************************
567 
568 
570  virtual ~SpatialBoundingBox() {};
571 
572 
576 
577 
581 
582  //**************************************************************************
583  //**************************************************************************
584 
585  virtual void UpdateBoxPosition(const double & rCurrentTime)
586  {
587 
588  KRATOS_TRY
589 
590  PointType Displacement = this->GetBoxDisplacement(rCurrentTime);
591 
592  mBox.UpdatePosition(Displacement);
593 
594  this->MapToLocalFrame(mBox.LocalQuaternion, mBox);
595 
596  KRATOS_CATCH("")
597 
598  }
599 
600  //**************************************************************************
601  //**************************************************************************
602 
603 
604  virtual bool IsInside (const PointType& rPoint, double& rCurrentTime, double Radius = 0)
605  {
606 
607  KRATOS_TRY
608 
609  bool inside = true;
610 
611  PointType Displacement = this->GetBoxDisplacement(rCurrentTime);
612 
613  mBox.UpdatePosition(Displacement);
614 
615  this->MapToLocalFrame(mBox.LocalQuaternion, mBox);
616 
617  PointType LocalPoint = rPoint;
618  BeamMathUtilsType::MapToCurrentLocalFrame(mBox.InitialLocalQuaternion, LocalPoint);
619 
620  if( (mBox.UpperPoint[0]>=LocalPoint[0] && mBox.LowerPoint[0]<=LocalPoint[0])
621  && (mBox.UpperPoint[1]>=LocalPoint[1] && mBox.LowerPoint[1]<=LocalPoint[1])
622  && (mBox.UpperPoint[2]>=LocalPoint[2] && mBox.LowerPoint[2]<=LocalPoint[2]) ){
623  inside = true;
624  }
625  else{
626  inside = false;
627  }
628 
629  QuaternionType LocaQuaternionlConjugate = mBox.LocalQuaternion.conjugate();
630  this->MapToLocalFrame(LocaQuaternionlConjugate, mBox);
631 
632  return inside;
633 
634  KRATOS_CATCH("")
635 
636  }
637 
638 
639  //**************************************************************************
640  //**************************************************************************
641 
642 
643  virtual bool IsInside (const PointType& rPoint)
644  {
645 
646  KRATOS_TRY
647 
648  bool inside = true;
649 
650  //check if the box is not set
651  unsigned int count = 0;
652  for(unsigned int i=0; i<mBox.Center.size(); ++i)
653  {
654  if( mBox.UpperPoint[i] == mBox.LowerPoint[i] )
655  {
656  count++;
657  }
658  }
659 
660  if( count == mBox.Center.size() ){
661  std::cout<<" IsInside:: warning spatial BOX not set "<<std::endl;
662  return true;
663  }
664  //check if the box is not set
665 
666 
667  PointType LocalPoint = rPoint;
668  BeamMathUtilsType::MapToCurrentLocalFrame(mBox.InitialLocalQuaternion, LocalPoint);
669 
670  // std::cout<<" Local Point "<<LocalPoint<<std::endl;
671  // std::cout<<" Upper "<<mBox.UpperPoint<<" Lower "<<mBox.LowerPoint<<std::endl;
672  // if(!(mBox.UpperPoint[0]>=LocalPoint[0] && mBox.LowerPoint[0]<=LocalPoint[0]) )
673  // std::cout<<" first not fit "<<std::endl;
674  // if(!(mBox.UpperPoint[1]>=LocalPoint[1] && mBox.LowerPoint[1]<=LocalPoint[1]) )
675  // std::cout<<" second not fit "<<std::endl;
676  // if(!(mBox.UpperPoint[2]>=LocalPoint[2] && mBox.LowerPoint[2]<=LocalPoint[2]) )
677  // std::cout<<" third not fit "<<std::endl;
678 
679 
680  if( (mBox.UpperPoint[0]>=LocalPoint[0] && mBox.LowerPoint[0]<=LocalPoint[0])
681  && (mBox.UpperPoint[1]>=LocalPoint[1] && mBox.LowerPoint[1]<=LocalPoint[1])
682  && (mBox.UpperPoint[2]>=LocalPoint[2] && mBox.LowerPoint[2]<=LocalPoint[2]) ){
683  inside = true;
684  }
685  else{
686  inside = false;
687  }
688 
689 
690  return inside;
691 
692  KRATOS_CATCH("")
693 
694  }
695 
696 
697 
698  //************************************************************************************
699  //************************************************************************************
700  virtual bool IsInside(BoundingBoxParameters& rValues, const ProcessInfo& rCurrentProcessInfo)
701  {
702  KRATOS_TRY
703 
704  std::cout<< "Calling empty method" <<std::endl;
705  return false;
706 
707  KRATOS_CATCH("")
708  }
709 
710 
711  virtual void GetParametricDirections(BoundingBoxParameters & rValues, Vector & rT1, Vector & rT2)
712  {
713  KRATOS_TRY
714 
715  //std::cout<< "Calling empty method directions" <<std::endl;
716 
717  KRATOS_CATCH("")
718  }
719 
723 
724 
725  // SET
726 
727  void SetUpperPoint(PointType& rUpperPoint)
728  {
729  mBox.UpperPoint = rUpperPoint;
730  mBox.InitialUpperPoint = rUpperPoint;
731  }
732 
733  //**************************************************************************
734  //**************************************************************************
735 
736  void SetLowerPoint(PointType& rLowerPoint)
737  {
738  mBox.LowerPoint = rLowerPoint;
739  mBox.InitialLowerPoint = rLowerPoint;
740 
741  }
742 
743  //**************************************************************************
744  //**************************************************************************
745 
746  void SetVelocity(PointType& rVelocity)
747  {
748  mBox.Velocity = rVelocity;
749  BeamMathUtilsType::MapToCurrentLocalFrame(mBox.InitialLocalQuaternion, mBox.Velocity);
750  }
751 
752  //**************************************************************************
753  //**************************************************************************
754 
755  void SetAngularVelocity(PointType& rAngularVelocity)
756  {
757  mBox.AngularVelocity = rAngularVelocity;
758  BeamMathUtilsType::MapToCurrentLocalFrame(mBox.InitialLocalQuaternion, mBox.AngularVelocity);
759  }
760 
761  //**************************************************************************
762  //**************************************************************************
763 
765  {
766  mBox.Dimension = dimension;
767  }
768 
769  //**************************************************************************
770  //**************************************************************************
771 
773  {
774  mBox.Axisymmetric = true;
775  }
776 
777  //**************************************************************************
778  //**************************************************************************
779 
780  void SetRigidBodyCenter(NodeType::Pointer pCenter)
781  {
782  mpRigidBodyCenter = pCenter;
783  mRigidBodyCenterSupplied = true;
784  }
785 
786  // GET
787 
788  //**************************************************************************
789  //**************************************************************************
790 
791  virtual double GetRadius()
792  {
793  return mBox.Radius;
794  }
795 
796  //**************************************************************************
797  //**************************************************************************
798 
799  virtual double GetRadius(const PointType& rPoint)
800  {
801  return mBox.Radius;
802  }
803 
804  //**************************************************************************
805  //**************************************************************************
806 
808  {
809  PointType Velocity;
810  if( mRigidBodyCenterSupplied ){
811  array_1d<double, 3>& rVelocity = mpRigidBodyCenter->FastGetSolutionStepValue(VELOCITY);
812  for(unsigned int i=0; i<3; ++i)
813  Velocity[i] = rVelocity[i];
814  }
815  else{
816  Velocity = mBox.Velocity;
817  BeamMathUtilsType::MapToReferenceLocalFrame(mBox.InitialLocalQuaternion, Velocity);
818  }
819  return Velocity;
820  }
821 
822  //**************************************************************************
823  //**************************************************************************
824 
826  {
827  BeamMathUtilsType::MapToReferenceLocalFrame(mBox.InitialLocalQuaternion, mBox.Center);
828  return mBox.Center;
829  }
830 
831  //**************************************************************************
832  //**************************************************************************
833 
834  virtual PointType GetCenter(const PointType& rPoint)
835  {
836  KRATOS_WARNING("") << "Calling spatial bounding box base class method "<<std::endl;
837  BeamMathUtilsType::MapToReferenceLocalFrame(mBox.InitialLocalQuaternion, mBox.Center);
838  return mBox.Center;
839  }
840 
841  //**************************************************************************
842  //**************************************************************************
843 
845  std::vector<PointType > GetHoles(ModelPart &rModelPart)
846  {
847  //Get inside point of the subdomains
848  ModelPart::ConditionsContainerType::iterator condition_begin = rModelPart.ConditionsBegin();
849  const unsigned int dimension = condition_begin->GetGeometry().WorkingSpaceDimension();
850 
851  std::vector<PointType > Holes;
853  for(ModelPart::NodesContainerType::iterator in = rModelPart.NodesBegin(); in!=rModelPart.NodesEnd(); ++in)
854  {
855  if(in->IsNot(BOUNDARY) ){
856  Point[0] = in->X();
857  Point[1] = in->Y();
858 
859  if(dimension>2)
860  Point[2] = in->Z();
861 
862  Holes.push_back(Point);
863  break;
864  }
865  else{
866  array_1d<double, 3>& Normal = in->FastGetSolutionStepValue(NORMAL);
867 
868  std::cout<<" Normal "<<Normal<<std::endl;
869  double tolerance = 0.25;
870 
871  Point[0] = in->X() - Normal[0] * tolerance;
872  Point[1] = in->Y() - Normal[1] * tolerance;
873  if(dimension>2)
874  Point[2] = in->Z() - Normal[2] * tolerance;
875 
876  Holes.push_back(Point);
877  break;
878  }
879  }
880 
881 
882  return Holes;
883  }
884 
885  //**************************************************************************
886  //**************************************************************************
887 
889  void GetVertices(std::vector<PointType >& rVertices, const double& rCurrentTime, const unsigned int& rDimension)
890  {
891 
892  PointType Displacement = this->GetBoxDisplacement( rCurrentTime );
893 
894  PointType Reference = mBox.UpperPoint + Displacement;
895 
896  PointType Side = mBox.UpperPoint - mBox.LowerPoint;
897 
898  Reference[1] -= Side[1];
899 
900  //point 0
901  rVertices.push_back(Reference);
902 
903  Reference[1] += Side[1];
904 
905  //point 1
906  rVertices.push_back(Reference);
907 
908  Reference[0] -= Side[0];
909 
910  //point 2
911  rVertices.push_back(Reference);
912 
913  Reference[1] -= Side[1];
914 
915  //point 3
916  rVertices.push_back(Reference);
917 
918 
919  if( rDimension == 3 ){
920 
921  Reference = mBox.LowerPoint + Displacement;
922 
923  Reference[0] += Side[0];
924 
925  //point 4
926  rVertices.push_back(Reference);
927 
928  Reference[0] -= Side[0];
929 
930  //point 5
931  rVertices.push_back(Reference);
932 
933  Reference[1] += Side[1];
934 
935  //point 6
936  rVertices.push_back(Reference);
937 
938  Reference[0] += Side[0];
939 
940  //point 7
941  rVertices.push_back(Reference);
942 
943  }
944 
945  }
946 
947  //************************************************************************************
948  //************************************************************************************
949 
950  void GetTriangularFaces(DenseMatrix<unsigned int>& rFaces, const unsigned int& rDimension)
951  {
952  KRATOS_TRY
953 
954  if( rDimension == 2 ){
955 
956  if(rFaces.size1() != 4 || rFaces.size2() != 2)
957  rFaces.resize(4,2,false);
958 
959  rFaces(0,0)=0;
960  rFaces(0,1)=1;
961 
962  rFaces(1,0)=1;
963  rFaces(1,1)=2;
964 
965  rFaces(2,0)=2;
966  rFaces(2,1)=3;
967 
968  rFaces(3,0)=3;
969  rFaces(3,1)=4;
970 
971  }
972  else if ( rDimension == 3 ){
973 
974  if(rFaces.size1() != 12 || rFaces.size2() != 3)
975  rFaces.resize(12,3,false);
976 
977  rFaces(0,0)=0;
978  rFaces(0,1)=1;
979  rFaces(0,2)=3;
980 
981  rFaces(1,0)=3;
982  rFaces(1,1)=1;
983  rFaces(1,2)=2;
984 
985  rFaces(2,0)=3;
986  rFaces(2,1)=2;
987  rFaces(2,2)=6;
988 
989  rFaces(3,0)=6;
990  rFaces(3,1)=5;
991  rFaces(3,2)=3;
992 
993  rFaces(4,0)=5;
994  rFaces(4,1)=6;
995  rFaces(4,2)=7;
996 
997  rFaces(5,0)=7;
998  rFaces(5,1)=4;
999  rFaces(5,2)=5;
1000 
1001  rFaces(6,0)=0;
1002  rFaces(6,1)=4;
1003  rFaces(6,2)=7;
1004 
1005  rFaces(7,0)=7;
1006  rFaces(7,1)=1;
1007  rFaces(7,2)=0;
1008 
1009  rFaces(8,0)=0;
1010  rFaces(8,1)=3;
1011  rFaces(8,2)=5;
1012 
1013  rFaces(9,0)=5;
1014  rFaces(9,1)=4;
1015  rFaces(9,2)=0;
1016 
1017  rFaces(10,0)=1;
1018  rFaces(10,1)=7;
1019  rFaces(10,2)=6;
1020 
1021  rFaces(11,0)=6;
1022  rFaces(11,1)=2;
1023  rFaces(11,2)=1;
1024 
1025  }
1026 
1027  KRATOS_CATCH("")
1028  }
1029 
1030 
1031  void GetQuadrilateralFaces(DenseMatrix<unsigned int>& rFaces, const unsigned int& rDimension)
1032  {
1033  KRATOS_TRY
1034 
1035  if( rDimension == 2 ){
1036 
1037  if(rFaces.size1() != 4 || rFaces.size2() != 2)
1038  rFaces.resize(4,2,false);
1039 
1040  rFaces(0,0)=0;
1041  rFaces(0,1)=1;
1042 
1043  rFaces(1,0)=1;
1044  rFaces(1,1)=2;
1045 
1046  rFaces(2,0)=2;
1047  rFaces(2,1)=3;
1048 
1049  rFaces(3,0)=3;
1050  rFaces(3,1)=4;
1051 
1052  }
1053  else if ( rDimension == 3 ){
1054 
1055  if(rFaces.size1() != 6 || rFaces.size2() != 4)
1056  rFaces.resize(6,4,false);
1057 
1058  rFaces(0,0)=0;
1059  rFaces(0,1)=1;
1060  rFaces(0,2)=2;
1061  rFaces(0,3)=3;
1062 
1063  rFaces(1,0)=3;
1064  rFaces(1,1)=2;
1065  rFaces(1,2)=6;
1066  rFaces(1,3)=5;
1067 
1068  rFaces(2,0)=5;
1069  rFaces(2,1)=6;
1070  rFaces(2,2)=7;
1071  rFaces(2,3)=4;
1072 
1073  rFaces(3,0)=4;
1074  rFaces(3,1)=7;
1075  rFaces(3,2)=1;
1076  rFaces(3,3)=0;
1077 
1078  rFaces(4,0)=0;
1079  rFaces(4,1)=3;
1080  rFaces(4,2)=5;
1081  rFaces(4,3)=4;
1082 
1083  rFaces(5,0)=1;
1084  rFaces(5,1)=7;
1085  rFaces(5,2)=6;
1086  rFaces(5,3)=2;
1087 
1088  }
1089 
1090  KRATOS_CATCH("")
1091  }
1092 
1093  //************************************************************************************
1094  //************************************************************************************
1095 
1096  virtual void CreateBoundingBoxBoundaryMesh(ModelPart& rModelPart, int linear_partitions = 4, int angular_partitions = 4 )
1097  {
1098  KRATOS_TRY
1099 
1100  std::cout<< " Calling Spatial Bounding Box empty boundary mesh creation" <<std::endl;
1101 
1102  KRATOS_CATCH("")
1103  }
1104 
1108 
1109 
1113 
1115  virtual std::string Info() const
1116  {
1117  return "SpatialBoundingBox";
1118  }
1119 
1121  virtual void PrintInfo(std::ostream& rOStream) const
1122  {
1123  rOStream << Info();
1124  }
1125 
1127  virtual void PrintData(std::ostream& rOStream) const
1128  {
1129  rOStream << mBox.UpperPoint << " , " << mBox.LowerPoint;
1130  }
1131 
1135 
1136 
1138 
1139 protected:
1142 
1143 
1147 
1148  NodeType::Pointer mpRigidBodyCenter;
1149 
1151 
1153 
1157 
1158 
1162 
1163  //**************************************************************************
1164  //**************************************************************************
1165 
1167  {
1168  KRATOS_TRY
1169 
1170  BeamMathUtilsType::MapToCurrentLocalFrame(rQuaternion, rBox.UpperPoint);
1171  BeamMathUtilsType::MapToCurrentLocalFrame(rQuaternion, rBox.LowerPoint);
1172  BeamMathUtilsType::MapToCurrentLocalFrame(rQuaternion, rBox.Center);
1173 
1174  KRATOS_CATCH("")
1175  }
1176 
1177 
1178  //**************************************************************************
1179  //**************************************************************************
1180 
1181  PointType GetBoxDisplacement(const double& rCurrentTime)
1182  {
1183 
1184  PointType Displacement = ZeroVector(3);
1185  PointType Rotation = ZeroVector(3);
1186 
1187  if( mRigidBodyCenterSupplied ){
1188 
1189  array_1d<double, 3 > & CurrentDisplacement = mpRigidBodyCenter->FastGetSolutionStepValue(DISPLACEMENT);
1190  for( int i=0; i<3; ++i )
1191  Displacement[i] = CurrentDisplacement[i];
1192 
1193  if( mpRigidBodyCenter->SolutionStepsDataHas(ROTATION) ){
1194  array_1d<double, 3 > & CurrentRotation = mpRigidBodyCenter->FastGetSolutionStepValue(ROTATION);
1195  for( int i=0; i<3; ++i )
1196  Rotation[i] = CurrentRotation[i];
1197  }
1198 
1199  //local base rotation
1200  BeamMathUtilsType::MapToCurrentLocalFrame(mBox.InitialLocalQuaternion, Rotation);
1201  mBox.LocalQuaternion = QuaternionType::FromRotationVector(Rotation);
1202 
1203  BeamMathUtilsType::MapToCurrentLocalFrame(mBox.InitialLocalQuaternion, Displacement);
1204 
1205  }
1206  else{
1207 
1208  Displacement = mBox.Velocity * rCurrentTime;
1209  Rotation = mBox.AngularVelocity * rCurrentTime;
1210 
1211  //local base rotation
1212  BeamMathUtilsType::MapToCurrentLocalFrame(mBox.InitialLocalQuaternion, Rotation);
1213  mBox.LocalQuaternion = QuaternionType::FromRotationVector(Rotation);
1214 
1215  }
1216 
1217  return Displacement;
1218  }
1219 
1220 
1221  //**************************************************************************
1222  //**************************************************************************
1223 
1224  PointType GetBoxDeltaDisplacement(const double& rCurrentTime, const double& rPreviousTime)
1225  {
1226 
1227  //Quaternion LocalQuaternion = mBox.LocalQuaternion;
1228 
1229  PointType Displacement = ZeroVector(3);
1230  //PointType Rotation = ZeroVector(3);
1231 
1232  if( mRigidBodyCenterSupplied ){
1233 
1234  array_1d<double, 3 > & CurrentDisplacement = mpRigidBodyCenter->FastGetSolutionStepValue(DISPLACEMENT,0);
1235  array_1d<double, 3 > & PreviousDisplacement = mpRigidBodyCenter->FastGetSolutionStepValue(DISPLACEMENT,1);
1236  for( int i=0; i<3; ++i )
1237  Displacement[i] = CurrentDisplacement[i]-PreviousDisplacement[i];
1238 
1239  // TODO: treatment of rotation in displacement calculation
1240  // if( mpRigidBodyCenter->SolutionStepsDataHas(ROTATION) ){
1241  // array_1d<double, 3 > & CurrentRotation = mpRigidBodyCenter->FastGetSolutionStepValue(ROTATION,0);
1242  // array_1d<double, 3 > & PreviousRotation = mpRigidBodyCenter->FastGetSolutionStepValue(ROTATION,1);
1243  // for( int i=0; i<3; ++i )
1244  // Rotation[i] = CurrentRotation[i]-PreviousRotation[i];
1245  // }
1246 
1247  // //local base rotation
1248  // BeamMathUtilsType::MapToCurrentLocalFrame(mBox.InitialLocalQuaternion, Rotation);
1249  // mBox.LocalQuaternion = QuaternionType::FromRotationVector(Rotation);
1250 
1251  BeamMathUtilsType::MapToCurrentLocalFrame(mBox.InitialLocalQuaternion, Displacement);
1252 
1253  }
1254  else{
1255 
1256  Displacement = mBox.Velocity * (rCurrentTime - rPreviousTime);
1257 
1258  // TODO: treatment of rotation in displacement calculation
1259  // Rotation = mBox.AngularVelocity * (rCurrentTime - rPreviousTime);
1260  // //local base rotation
1261  // BeamMathUtilsType::MapToCurrentLocalFrame(mBox.InitialLocalQuaternion, Rotation);
1262  // mBox.LocalQuaternion = QuaternionType::FromRotationVector(Rotation);
1263 
1264  }
1265 
1266  //mBox.LocalQuaternion = LocalQuaternion;
1267 
1268  return Displacement;
1269  }
1270 
1271  //**************************************************************************
1272  //**************************************************************************
1273 
1274  void ComputeContactTangent(BoundingBoxParameters& rValues, const ProcessInfo& rCurrentProcessInfo)
1275  {
1276  KRATOS_TRY
1277 
1278  PointType& rNormal = rValues.GetNormal();
1279  PointType& rTangent = rValues.GetTangent();
1280  double& rGapTangent = rValues.GetGapTangent();
1281 
1282  PointType& rRelativeDisplacement = rValues.GetRelativeDisplacement();
1283 
1284  noalias(rTangent) = ZeroVector(3);
1285 
1286  //1.-compute contact tangent (following relative movement)
1287  PointType PointDeltaDisplacement = rValues.GetDeltaDisplacement();
1288 
1289  //2.-compute tangent direction
1290  PointType BoxDeltaDisplacement = this->GetBoxDeltaDisplacement(rCurrentProcessInfo[TIME], rCurrentProcessInfo.GetPreviousTimeStepInfo()[TIME]);
1291 
1292  rRelativeDisplacement = BoxDeltaDisplacement-PointDeltaDisplacement;
1293 
1294  rTangent = (rRelativeDisplacement) - inner_prod(rRelativeDisplacement, rNormal) * rNormal;
1295 
1296  if( !norm_2(rNormal) )
1297  noalias(rTangent) = ZeroVector(3);
1298 
1299  //3.-compute normal gap
1300  rGapTangent = norm_2(rTangent);
1301 
1302  if(norm_2(rTangent))
1303  rTangent/= norm_2(rTangent);
1304 
1305  //std::cout<<" Normal "<<rNormal<<" Tangent "<<rTangent<<" gapT "<<rGapTangent<<std::endl;
1306 
1307  KRATOS_CATCH( "" )
1308 
1309  }
1310 
1311  //*******************************************************************************************
1312  //*******************************************************************************************
1313 
1314  static inline unsigned int GetMaxNodeId(ModelPart& rModelPart)
1315  {
1316  KRATOS_TRY
1317 
1318  unsigned int max_id = rModelPart.Nodes().back().Id();
1319 
1320  for(ModelPart::NodesContainerType::iterator i_node = rModelPart.NodesBegin(); i_node!= rModelPart.NodesEnd(); ++i_node)
1321  {
1322  if(i_node->Id() > max_id)
1323  max_id = i_node->Id();
1324  }
1325 
1326  return max_id;
1327 
1328  KRATOS_CATCH( "" )
1329  }
1330 
1331  //*******************************************************************************************
1332  //*******************************************************************************************
1333 
1334  static inline unsigned int GetMaxElementId(ModelPart& rModelPart)
1335  {
1336  KRATOS_TRY
1337 
1338  if( rModelPart.NumberOfElements() == 0 )
1339  return 0;
1340 
1341  unsigned int max_id = rModelPart.Elements().back().Id();
1342 
1343  for(ModelPart::ElementsContainerType::iterator i_elem = rModelPart.ElementsBegin(); i_elem!= rModelPart.ElementsEnd(); ++i_elem)
1344  {
1345  if(i_elem->Id() > max_id)
1346  max_id = i_elem->Id();
1347  }
1348 
1349  return max_id;
1350 
1351  KRATOS_CATCH( "" )
1352  }
1353 
1354  //************************************************************************************
1355  //************************************************************************************
1356 
1357  NodeType::Pointer CreateNode (ModelPart& rModelPart, PointType& rPoint, const unsigned int& rNodeId)
1358  {
1359 
1360  KRATOS_TRY
1361 
1362  NodeType::Pointer Node = rModelPart.CreateNewNode( rNodeId, rPoint[0], rPoint[1], rPoint[2]);
1363 
1364  //generating the dofs
1365  NodeType::DofsContainerType& reference_dofs = (rModelPart.NodesBegin())->GetDofs();
1366 
1367 
1368  for(NodeType::DofsContainerType::iterator iii = reference_dofs.begin(); iii != reference_dofs.end(); ++iii)
1369  {
1370  NodeType::DofType& rDof = **iii;
1371  Node->pAddDof( rDof );
1372  }
1373 
1374  //set fix dofs:
1375  NodeType::DofsContainerType& new_dofs = Node->GetDofs();
1376 
1377  for(NodeType::DofsContainerType::iterator iii = new_dofs.begin(); iii != new_dofs.end(); ++iii)
1378  {
1379  NodeType::DofType& rDof = **iii;
1380  rDof.FixDof(); // dofs free
1381  }
1382 
1383  //generating step data:
1384  // unsigned int buffer_size = (rModelPart.NodesBegin())->GetBufferSize();
1385  // unsigned int step_data_size = rModelPart.GetNodalSolutionStepDataSize();
1386  // for(unsigned int step = 0; step<buffer_size; ++step)
1387  // {
1388  // double* NodeData = Node->SolutionStepData().Data(step);
1389  // double* ReferenceData = (rModelPart.NodesBegin())->SolutionStepData().Data(step);
1390 
1391  // //copying this data in the position of the vector we are interested in
1392  // for(unsigned int j= 0; j<step_data_size; ++j)
1393  // {
1394  // NodeData[j] = ReferenceData[j];
1395  // }
1396  // }
1397 
1398  return Node;
1399 
1400  KRATOS_CATCH( "" )
1401 
1402  }
1403 
1404 
1405  //************************************************************************************
1406  //************************************************************************************
1407 
1408  void CalculateOrthonormalBase(PointType & rDirectionVectorX, PointType & rDirectionVectorY, PointType & rDirectionVectorZ)
1409  {
1410  KRATOS_TRY
1411 
1412  PointType GlobalY = ZeroVector(3);
1413  GlobalY[1]=1.0;
1414 
1415  PointType GlobalZ = ZeroVector(3);
1416  GlobalZ[2]=1.0;
1417 
1418 
1419  // local x-axis (e1_local) is the beam axis (in GID is e3_local)
1420  double VectorNorm = MathUtils<double>::Norm(rDirectionVectorX);
1421  if( VectorNorm != 0)
1422  rDirectionVectorX /= VectorNorm;
1423 
1424  // local y-axis (e2_local) (in GID is e1_local)
1425  rDirectionVectorY = ZeroVector(3);
1426 
1427  double tolerance = 1.0/64.0;
1428  if(fabs(rDirectionVectorX[0])< tolerance && fabs(rDirectionVectorX[1])< tolerance){
1429  MathUtils<double>::CrossProduct(rDirectionVectorY, GlobalY, rDirectionVectorX);
1430  }
1431  else{
1432  MathUtils<double>::CrossProduct(rDirectionVectorY, GlobalZ, rDirectionVectorX);
1433  }
1434 
1435 
1436  VectorNorm = MathUtils<double>::Norm(rDirectionVectorY);
1437  if( VectorNorm != 0)
1438  rDirectionVectorY /= VectorNorm;
1439 
1440  // local z-axis (e3_local) (in GID is e2_local)
1441  MathUtils<double>::CrossProduct(rDirectionVectorZ, rDirectionVectorX,rDirectionVectorY);
1442 
1443  VectorNorm = MathUtils<double>::Norm(rDirectionVectorZ);
1444  if( VectorNorm != 0 )
1445  rDirectionVectorZ /= VectorNorm;
1446 
1447  KRATOS_CATCH( "" )
1448 
1449  }
1450 
1454 
1455 
1459 
1460 
1464 
1465 
1467 
1468 private:
1471 
1472 
1476 
1480 
1481 
1485 
1486 
1490 
1491 
1495 
1496 
1500 
1501 
1502 
1504 
1505 
1506 }; // Class SpatialBoundingBox
1507 
1509 
1512 
1513 
1517 
1519 
1520 
1521 } // namespace Kratos.
1522 
1523 #endif // KRATOS_SPATIAL_BOUNDING_BOX_H_INCLUDED defined
std::string Info() const override
Turn back information as a string.
Definition: periodic_interface_process.hpp:93
Definition: beam_math_utilities.hpp:31
Dof represents a degree of freedom (DoF).
Definition: dof.h:86
void FixDof()
Definition: dof.h:338
void resize(std::size_t NewSize1, std::size_t NewSize2, bool preserve=0)
Definition: amatrix_interface.h:224
static T CrossProduct(const T &a, const T &b)
Performs the vector product of the two input vectors a,b.
Definition: math_utils.h:762
static double Norm(const Vector &a)
Calculates the norm of vector "a".
Definition: math_utils.h:703
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
ElementIterator ElementsBegin(IndexType ThisIndex=0)
Definition: model_part.h:1169
NodeType::Pointer CreateNewNode(int Id, double x, double y, double z, VariablesList::Pointer pNewVariablesList, IndexType ThisIndex=0)
Definition: model_part.cpp:270
ConditionIterator ConditionsBegin(IndexType ThisIndex=0)
Definition: model_part.h:1361
NodeIterator NodesBegin(IndexType ThisIndex=0)
Definition: model_part.h:487
SizeType NumberOfElements(IndexType ThisIndex=0) const
Definition: model_part.h:1027
ElementsContainerType & Elements(IndexType ThisIndex=0)
Definition: model_part.h:1189
MeshType::NodesContainerType NodesContainerType
Nodes container. Which is a vector set of nodes with their Id's as key.
Definition: model_part.h:128
SizeType NumberOfConditions(IndexType ThisIndex=0) const
Definition: model_part.h:1218
ElementIterator ElementsEnd(IndexType ThisIndex=0)
Definition: model_part.h:1179
NodeIterator NodesEnd(IndexType ThisIndex=0)
Definition: model_part.h:497
NodesContainerType & Nodes(IndexType ThisIndex=0)
Definition: model_part.h:507
This class defines the node.
Definition: node.h:65
TVariableType::Type & FastGetSolutionStepValue(const TVariableType &rThisVariable)
Definition: node.h:435
DofsContainerType & GetDofs()
Definition: node.h:694
std::vector< std::unique_ptr< Dof< double > >> DofsContainerType
The DoF container type definition.
Definition: node.h:92
DofType::Pointer pAddDof(TVariableType const &rDofVariable)
Definition: node.h:759
This class provides to Kratos a data structure for I/O based on the standard of JSON.
Definition: kratos_parameters.h:59
double GetDouble() const
This method returns the double contained in the current Parameter.
Definition: kratos_parameters.cpp:657
const std::string PrettyPrintJsonString() const
This method returns a string with the corresponding text to the equivalent *.json file (this version ...
Definition: kratos_parameters.cpp:415
int GetInt() const
This method returns the integer contained in the current Parameter.
Definition: kratos_parameters.cpp:666
void ValidateAndAssignDefaults(const Parameters &rDefaultParameters)
This function is designed to verify that the parameters under testing match the form prescribed by th...
Definition: kratos_parameters.cpp:1306
SizeType size() const
This method returns the total size of the current array parameter.
Definition: kratos_parameters.cpp:993
Point class.
Definition: point.h:59
CoordinatesArrayType const & Coordinates() const
Definition: point.h:215
double Y() const
Definition: point.h:187
double Z() const
Definition: point.h:193
double X() const
Definition: point.h:181
ProcessInfo holds the current value of different solution parameters.
Definition: process_info.h:59
ProcessInfo & GetPreviousTimeStepInfo(IndexType StepsBefore=1)
Definition: process_info.h:187
Quaternion conjugate() const
Definition: quaternion.h:195
Short class definition.
Definition: spatial_bounding_box.hpp:48
virtual void PrintInfo(std::ostream &rOStream) const
Print information about this object.
Definition: spatial_bounding_box.hpp:1121
void SetRigidBodyCenter(NodeType::Pointer pCenter)
Definition: spatial_bounding_box.hpp:780
virtual bool IsInside(const PointType &rPoint)
Definition: spatial_bounding_box.hpp:643
virtual bool IsInside(BoundingBoxParameters &rValues, const ProcessInfo &rCurrentProcessInfo)
Definition: spatial_bounding_box.hpp:700
virtual double GetRadius(const PointType &rPoint)
Definition: spatial_bounding_box.hpp:799
virtual void CreateBoundingBoxBoundaryMesh(ModelPart &rModelPart, int linear_partitions=4, int angular_partitions=4)
Definition: spatial_bounding_box.hpp:1096
void SetVelocity(PointType &rVelocity)
Definition: spatial_bounding_box.hpp:746
bool mRigidBodyCenterSupplied
Definition: spatial_bounding_box.hpp:1150
virtual double GetRadius()
Definition: spatial_bounding_box.hpp:791
SpatialBoundingBox(const PointType &rCenter, const double &rRadius)
Definition: spatial_bounding_box.hpp:418
virtual void UpdateBoxPosition(const double &rCurrentTime)
Definition: spatial_bounding_box.hpp:585
PointType GetBoxDisplacement(const double &rCurrentTime)
Definition: spatial_bounding_box.hpp:1181
void GetTriangularFaces(DenseMatrix< unsigned int > &rFaces, const unsigned int &rDimension)
Definition: spatial_bounding_box.hpp:950
void CalculateOrthonormalBase(PointType &rDirectionVectorX, PointType &rDirectionVectorY, PointType &rDirectionVectorZ)
Definition: spatial_bounding_box.hpp:1408
array_1d< double, 3 > PointType
Definition: spatial_bounding_box.hpp:52
BeamMathUtils< double > BeamMathUtilsType
Definition: spatial_bounding_box.hpp:56
void SetAxisymmetric()
Definition: spatial_bounding_box.hpp:772
SpatialBoundingBox(Parameters CustomParameters)
Definition: spatial_bounding_box.hpp:311
virtual std::string Info() const
Turn back information as a string.
Definition: spatial_bounding_box.hpp:1115
void ComputeContactTangent(BoundingBoxParameters &rValues, const ProcessInfo &rCurrentProcessInfo)
Definition: spatial_bounding_box.hpp:1274
Quaternion< double > QuaternionType
Definition: spatial_bounding_box.hpp:57
void SetAngularVelocity(PointType &rAngularVelocity)
Definition: spatial_bounding_box.hpp:755
void SetDimension(int dimension)
Definition: spatial_bounding_box.hpp:764
NodeType::Pointer CreateNode(ModelPart &rModelPart, PointType &rPoint, const unsigned int &rNodeId)
Definition: spatial_bounding_box.hpp:1357
SpatialBoundingBox(const PointType &rLowerPoint, const PointType &rUpperPoint)
Definition: spatial_bounding_box.hpp:391
static unsigned int GetMaxNodeId(ModelPart &rModelPart)
Definition: spatial_bounding_box.hpp:1314
virtual PointType GetCenter(const PointType &rPoint)
Definition: spatial_bounding_box.hpp:834
SpatialBoundingBox(SpatialBoundingBox const &rOther)
Copy constructor.
Definition: spatial_bounding_box.hpp:558
virtual void PrintData(std::ostream &rOStream) const
Print object's data.
Definition: spatial_bounding_box.hpp:1127
KRATOS_CLASS_POINTER_DEFINITION(SpatialBoundingBox)
Pointer definition of SpatialBoundingBox.
NodesContainerType::Pointer NodesContainerTypePointer
Definition: spatial_bounding_box.hpp:55
virtual PointType GetVelocity()
Definition: spatial_bounding_box.hpp:807
virtual void GetParametricDirections(BoundingBoxParameters &rValues, Vector &rT1, Vector &rT2)
Definition: spatial_bounding_box.hpp:711
void SetLowerPoint(PointType &rLowerPoint)
Definition: spatial_bounding_box.hpp:736
void GetQuadrilateralFaces(DenseMatrix< unsigned int > &rFaces, const unsigned int &rDimension)
Definition: spatial_bounding_box.hpp:1031
static unsigned int GetMaxElementId(ModelPart &rModelPart)
Definition: spatial_bounding_box.hpp:1334
virtual ~SpatialBoundingBox()
Destructor.
Definition: spatial_bounding_box.hpp:570
SpatialBoundingBox(ModelPart &rModelPart, const double &rRadius, double factor=0)
Definition: spatial_bounding_box.hpp:447
NodeType::Pointer mpRigidBodyCenter
Definition: spatial_bounding_box.hpp:1148
ModelPart::NodesContainerType NodesContainerType
Definition: spatial_bounding_box.hpp:54
SpatialBoundingBox()
Default constructor.
Definition: spatial_bounding_box.hpp:296
BoundingBoxVariables mBox
Definition: spatial_bounding_box.hpp:1152
void MapToLocalFrame(QuaternionType &rQuaternion, BoundingBoxVariables &rBox)
Definition: spatial_bounding_box.hpp:1166
PointType GetBoxDeltaDisplacement(const double &rCurrentTime, const double &rPreviousTime)
Definition: spatial_bounding_box.hpp:1224
void SetUpperPoint(PointType &rUpperPoint)
Definition: spatial_bounding_box.hpp:727
virtual SpatialBoundingBox & operator=(SpatialBoundingBox const &rOther)
Assignment operator.
Definition: spatial_bounding_box.hpp:540
virtual bool IsInside(const PointType &rPoint, double &rCurrentTime, double Radius=0)
Definition: spatial_bounding_box.hpp:604
ModelPart::NodeType NodeType
Definition: spatial_bounding_box.hpp:53
std::vector< PointType > GetHoles(ModelPart &rModelPart)
Compute inside holes.
Definition: spatial_bounding_box.hpp:845
void GetVertices(std::vector< PointType > &rVertices, const double &rCurrentTime, const unsigned int &rDimension)
Compute vertices.
Definition: spatial_bounding_box.hpp:889
virtual PointType GetCenter()
Definition: spatial_bounding_box.hpp:825
BOOST_UBLAS_INLINE void clear()
Definition: array_1d.h:325
#define KRATOS_THROW_ERROR(ExceptionType, ErrorMessage, MoreInfo)
Definition: define.h:77
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
#define KRATOS_ERROR
Definition: exception.h:161
#define KRATOS_WARNING(label)
Definition: logger.h:265
static double max(double a, double b)
Definition: GeometryFunctions.h:79
static double min(double a, double b)
Definition: GeometryFunctions.h:71
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
KratosZeroVector< double > ZeroVector
Definition: amatrix_interface.h:561
TExpressionType::data_type norm_2(AMatrix::MatrixExpression< TExpressionType, TCategory > const &TheExpression)
Definition: amatrix_interface.h:625
AMatrix::IdentityMatrix< double > IdentityMatrix
Definition: amatrix_interface.h:564
TExpression1Type::data_type inner_prod(AMatrix::MatrixExpression< TExpression1Type, TCategory1 > const &First, AMatrix::MatrixExpression< TExpression2Type, TCategory2 > const &Second)
Definition: amatrix_interface.h:592
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
int count
Definition: generate_frictional_mortar_condition.py:212
int dimension
Definition: isotropic_damage_automatic_differentiation.py:123
integer i
Definition: TensorModule.f:17
float factor
for node in (self.combined_model_part).Nodes: pold = node.GetSolutionStepValue(PRESSURE,...
Definition: ulf_PGLASS.py:254
Definition: spatial_bounding_box.hpp:61
void SetPreviousDisplacement(const PointType &rDisplacement)
Definition: spatial_bounding_box.hpp:168
BoundingBoxParameters(const NodeType &rNode, double &rGapNormal, double &rGapTangent, PointType &rNormal, PointType &rTangent, PointType &rDisplacement)
Definition: spatial_bounding_box.hpp:136
void SetNode(const NodeType &rNode)
Definition: spatial_bounding_box.hpp:157
void SetVelocity(const PointType &rVelocity)
Definition: spatial_bounding_box.hpp:166
PointType GetDeltaDisplacement()
Definition: spatial_bounding_box.hpp:186
const PointType & GetVelocity()
Definition: spatial_bounding_box.hpp:182
void SetNormal(PointType &rNormal)
Definition: spatial_bounding_box.hpp:170
void SetPoint(const PointType &rPoint)
Definition: spatial_bounding_box.hpp:165
void SetContactFace(int ContactFace)
Definition: spatial_bounding_box.hpp:178
void SetCurrentDisplacement(const PointType &rDisplacement)
Definition: spatial_bounding_box.hpp:167
void SetGapNormal(double &rGapNormal)
Definition: spatial_bounding_box.hpp:174
const PointType & GetPreviousDisplacement()
Definition: spatial_bounding_box.hpp:184
void SetTangent(PointType &rTangent)
Definition: spatial_bounding_box.hpp:171
void SetRelativeDisplacement(PointType &rDisplacement)
Definition: spatial_bounding_box.hpp:172
PointType & GetTangent()
Definition: spatial_bounding_box.hpp:189
double & GetGapNormal()
Definition: spatial_bounding_box.hpp:193
BoundingBoxParameters()
Definition: spatial_bounding_box.hpp:87
double & GetRadius()
Definition: spatial_bounding_box.hpp:196
PointType & GetRelativeDisplacement()
Definition: spatial_bounding_box.hpp:190
void SetGapTangent(double &rGapTangent)
Definition: spatial_bounding_box.hpp:175
int & GetContactFace()
Definition: spatial_bounding_box.hpp:197
double & GetGapTangent()
Definition: spatial_bounding_box.hpp:194
const PointType & GetPoint()
Definition: spatial_bounding_box.hpp:181
void SetRadius(double Radius)
Definition: spatial_bounding_box.hpp:177
const PointType & GetCurrentDisplacement()
Definition: spatial_bounding_box.hpp:183
PointType & GetNormal()
Definition: spatial_bounding_box.hpp:188
BoundingBoxParameters(const NodeType &rNode)
Definition: spatial_bounding_box.hpp:111
Definition: spatial_bounding_box.hpp:206
PointType InitialCenter
Definition: spatial_bounding_box.hpp:215
bool Axisymmetric
Definition: spatial_bounding_box.hpp:209
PointType AngularVelocity
Definition: spatial_bounding_box.hpp:222
PointType InitialLowerPoint
Definition: spatial_bounding_box.hpp:214
QuaternionType InitialLocalQuaternion
Definition: spatial_bounding_box.hpp:224
void UpdatePosition(PointType &Displacement)
Definition: spatial_bounding_box.hpp:260
int Dimension
Definition: spatial_bounding_box.hpp:208
int Convexity
Definition: spatial_bounding_box.hpp:210
PointType Velocity
Definition: spatial_bounding_box.hpp:221
PointType LowerPoint
Definition: spatial_bounding_box.hpp:218
double Radius
Definition: spatial_bounding_box.hpp:211
PointType InitialUpperPoint
Definition: spatial_bounding_box.hpp:213
void Initialize()
Definition: spatial_bounding_box.hpp:229
PointType Center
Definition: spatial_bounding_box.hpp:219
PointType UpperPoint
Definition: spatial_bounding_box.hpp:217
void SetInitialValues()
Definition: spatial_bounding_box.hpp:253
void Print()
Definition: spatial_bounding_box.hpp:267
QuaternionType LocalQuaternion
Definition: spatial_bounding_box.hpp:225