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.
compound_noses_bounding_box.hpp
Go to the documentation of this file.
1 //
2 // Project Name: KratosContactMechanicsApplication $
3 // Created by: $Author: JMCarbonell $
4 // Last modified by: $Co-Author: $
5 // Date: $Date: July 2016 $
6 // Revision: $Revision: 0.0 $
7 //
8 //
9 
10 #if !defined(KRATOS_COMPOUND_NOSES_BOUNDING_BOX_H_INCLUDED )
11 #define KRATOS_COMPOUND_NOSES_BOUNDING_BOX_H_INCLUDED
12 
13 // External includes
14 
15 // System includes
16 
17 // Project includes
19 #include "geometries/line_2d_2.h"
21 
22 namespace Kratos
23 {
24 
27 
31 
35 
39 
43 
45 
60  : public SpatialBoundingBox
61 {
62 public:
63 
64  //typedef BoundedVector<double, 3> PointType;
68  typedef NodesContainerType::Pointer NodesContainerTypePointer;
73 
74 private:
75 
76  enum ContactFace{ FreeSurface=0, RakeSurface=1, TipSurface=2, ClearanceSurface=3 };
77 
78 protected:
79 
81  {
82  int Convexity; //1 or -1 if "in" is inside or outside respectively
83 
84  double Radius; //nose radius
85  double RakeAngle; //top angle, from vertical axis --> #RakeAngle = (90-RakeAngle)
86  double ClearanceAngle; //bottom angle, from the horizontal axis --> #ClearanceAngle = (180-ClearanceAngle)
87 
88  double TangentRakeAngle; //tan((pi/2)-#RakeAngle)
89  double TangentClearanceAngle; //tan((pi/2)-#ClearanceAngle)
90 
91  PointType InitialCenter; // center original position
92  PointType Center; // center current position
93 
94 
95  public:
96 
97  void Initialize()
98  {
99  Convexity = 1;
100  Radius = 0;
101  RakeAngle = 0;
102  ClearanceAngle = 0;
103 
104  TangentRakeAngle = 0;
106 
108  Center.clear();
109  }
110 
112  {
114  }
115 
116  void UpdatePosition( PointType& Displacement )
117  {
118  Center = InitialCenter + Displacement;
119  }
120 
121 
122  };
123 
124 
125 public:
128 
131 
135 
138  {
139  KRATOS_TRY
140 
141  std::cout<< "Calling Rigid Nose Wall BBX empty constructor" <<std::endl;
142 
143  KRATOS_CATCH("")
144  }
145 
146  //**************************************************************************
147  //**************************************************************************
148 
150  {
151 
152  KRATOS_TRY
153 
154  Parameters DefaultParameters( R"(
155  {
156  "parameters_list": [],
157  "velocity": [0.0, 0.0, 0.0],
158  "angular_velocity": [0.0, 0.0, 0.0],
159  "plane_size": 1.0,
160  "local_axes":[ [1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0] ]
161  } )" );
162 
163 
164  //items in the parameters_list:
165  //{"radius": 0.0,
166  // "center": [0.0, 0.0, 0.0],
167  // "rake_angle": 0.0,
168  // "clearance_angle": 0.0,
169  // "convexity": 0}
170 
171  //validate against defaults -- this also ensures no type mismatch
172  CustomParameters.ValidateAndAssignDefaults(DefaultParameters);
173 
174  unsigned int list_size = CustomParameters["parameters_list"].size();
175 
176  Vector Radius (list_size);
177  Matrix Centers (list_size,3);
178  Vector RakeAngles (list_size);
179  Vector ClearanceAngles(list_size);
180  Vector Convexities (list_size);
181 
182  for( unsigned int i=0; i<list_size; i++ )
183  {
184  Parameters NoseParameters = CustomParameters["parameters_list"][i];
185 
186  Radius[i] = NoseParameters["radius"].GetDouble();
187 
188  Centers(i,0) = NoseParameters["center"][0].GetDouble();
189  Centers(i,1) = NoseParameters["center"][1].GetDouble();
190  Centers(i,2) = NoseParameters["center"][2].GetDouble();
191 
192  RakeAngles[i] = NoseParameters["rake_angle"].GetDouble();
193  ClearanceAngles[i] = NoseParameters["clearance_angle"].GetDouble();
194  Convexities[i] = NoseParameters["convexity"].GetInt();
195  }
196 
197  Vector Velocity(3);
198  Velocity[0] = CustomParameters["velocity"][0].GetDouble();
199  Velocity[1] = CustomParameters["velocity"][1].GetDouble();
200  Velocity[2] = CustomParameters["velocity"][2].GetDouble();
201 
202  Vector AngularVelocity(3);
203  AngularVelocity[0] = CustomParameters["angular_velocity"][0].GetDouble();
204  AngularVelocity[1] = CustomParameters["angular_velocity"][1].GetDouble();
205  AngularVelocity[2] = CustomParameters["angular_velocity"][2].GetDouble();
206 
207  mBox.Radius = CustomParameters["plane_size"].GetDouble();
208 
209  Vector UpperPoint(3);
210  Vector LowerPoint(3);
211 
212  for(unsigned int i=0; i<3; i++)
213  {
214  UpperPoint[i] = 1.0;
215  LowerPoint[i] = -1.0;
216  }
217 
218  UpperPoint *= mBox.Radius/sqrt(3.0);
219  LowerPoint *= mBox.Radius/sqrt(3.0);
220 
221  //check higher and lower center: (y coordinate as reference)
222  int v_axis = 1;
223  if( list_size == 1 ){
224  for(unsigned int i=0; i<3; i++)
225  {
226  UpperPoint[i] += Centers(0,i);
227  LowerPoint[i] += Centers(0,i);
228  }
229  }
230  else if( Centers(0, v_axis) > Centers(list_size-1, v_axis) ){
231  for(unsigned int i=0; i<3; i++)
232  {
233  UpperPoint[i] += Centers(0,i);
234  LowerPoint[i] += Centers(list_size-1,i);
235  }
236  }
237  else{
238  for(unsigned int i=0; i<3; i++)
239  {
240  UpperPoint[i] += Centers(list_size-1,i);
241  LowerPoint[i] += Centers(0,i);
242  }
243  }
244 
245 
246  Matrix InitialLocalMatrix = IdentityMatrix(3);
247 
248  unsigned int size = CustomParameters["local_axes"].size();
249 
250  for( unsigned int i=0; i<size; i++ )
251  {
252  Parameters LocalAxesRow = CustomParameters["local_axes"][i];
253 
254  InitialLocalMatrix(0,i) = LocalAxesRow[0].GetDouble(); //column disposition
255  InitialLocalMatrix(1,i) = LocalAxesRow[1].GetDouble();
256  InitialLocalMatrix(2,i) = LocalAxesRow[2].GetDouble();
257  }
258 
259  this->CreateCompoundNosesBox(Radius,RakeAngles,ClearanceAngles,Centers,Convexities,
260  Velocity, AngularVelocity, UpperPoint, LowerPoint, InitialLocalMatrix);
261 
262  KRATOS_CATCH("")
263 
264  }
265 
266 
267  //**************************************************************************
268  //**************************************************************************
269 
270  // General Wall constructor
272  Vector RakeAngles,
273  Vector ClearanceAngles,
274  Matrix Centers,
275  Vector Convexities,
276  Vector Velocity,
277  Vector AngularVelocity,
278  Vector UpperPoint,
279  Vector LowerPoint,
280  Matrix InitialLocalMatrix) //column disposition of the local_axes matrix
281  {
282 
283  KRATOS_TRY
284 
285  this->CreateCompoundNosesBox(Radius,RakeAngles,ClearanceAngles,Centers,Convexities,
286  Velocity, AngularVelocity, UpperPoint, LowerPoint, InitialLocalMatrix);
287 
288  KRATOS_CATCH("")
289 
290  }
291 
292  //**************************************************************************
293  //**************************************************************************
294 
297  {
299  mBoxNoses = rOther.mBoxNoses;
300  return *this;
301  }
302 
303  //**************************************************************************
304  //**************************************************************************
305 
308  :SpatialBoundingBox(rOther)
309  ,mBoxNoses(rOther.mBoxNoses)
310  {
311  }
312 
313  //**************************************************************************
314  //**************************************************************************
315 
318 
319 
323 
324 
328 
329  //**************************************************************************
330  //**************************************************************************
331 
332  double GetRadius(const PointType& rPoint) override
333  {
334  PointType LocalPoint = rPoint;
337 
338  LocalPoint[2] = 0; //2D
339 
340  return GetNearerRadius(LocalPoint);
341  }
342 
343  //**************************************************************************
344  //**************************************************************************
345 
346  PointType GetCenter(const PointType& rPoint) override
347  {
348  PointType LocalPoint = rPoint;
351 
352  LocalPoint[2] = 0; //2D
353 
354  PointType LocalNearerPoint = GetNearerCenter(LocalPoint);
357 
358  return LocalNearerPoint;
359  }
360 
361 
362  //**************************************************************************
363  //**************************************************************************
364 
365  void UpdateBoxPosition(const double & rCurrentTime) override
366  {
367 
368  PointType Displacement = this->GetBoxDisplacement(rCurrentTime);
369 
370  mBox.UpdatePosition(Displacement);
371 
373 
374  for(unsigned int i=0; i<mBoxNoses.size(); i++)
375  {
376  mBoxNoses[i].Center = mBoxNoses[i].InitialCenter + Displacement;
378 
379  //std::cout<<" BOX NOSE center position "<<mBoxNoses[i].Center<<std::endl;
380  }
381  }
382 
383  //************************************************************************************
384  //************************************************************************************
385 
386 
387  bool IsInside (const PointType& rPoint, double& rCurrentTime, double Radius = 0) override
388  {
389 
390  KRATOS_TRY
391 
392  bool is_inside = SpatialBoundingBox::IsInside(rPoint);
393 
394  //std::cout<< " IS INSIDE "<<is_inside<<std::endl;
395 
396  if( is_inside ){
397 
398  //std::cout<<" Local Point A "<<rPoint<<std::endl;
399 
400  PointType LocalPoint = rPoint;
403 
404  LocalPoint[2] = 0; //2D
405 
406  //std::cout<<" Local Point B "<<rPoint<<std::endl;
407 
408  unsigned int SelectedNose = BoxNoseSearch(LocalPoint);
409 
410  BoxNoseVariables& rWallNose = mBoxNoses[SelectedNose];
411 
412  double NoseRadius = rWallNose.Radius;
413 
414  if( rWallNose.Convexity == 1)
415  NoseRadius *= 2; //increase the bounding box
416 
417  if( rWallNose.Convexity == -1)
418  NoseRadius *= 0.1; //decrease the bounding box
419 
420  // bool node_in =false;
421  // if( rWallNose.Convexity == 1 && (LocalPoint[0]>=95 && LocalPoint[1]>=6.9) )
422  // node_in = true;
423 
424  switch( ContactSearch(LocalPoint, NoseRadius, rWallNose) )
425  {
426  case FreeSurface:
427  is_inside = false;
428  // ContactFace = 0;
429  // if( node_in )
430  // std::cout<<" Nose "<<SelectedNose<<" [ FreeSurface :"<<rPoint<<"]"<<std::endl;
431  break;
432  case RakeSurface:
433  is_inside = true;
434  // ContactFace = 1;
435  // if( node_in )
436  // std::cout<<" Nose "<<SelectedNose<<" [ RakeSurface :"<<rPoint<<"]"<<std::endl;
437  break;
438  case TipSurface:
439  is_inside = true;
440  // ContactFace = 2;
441  // if( node_in )
442  // std::cout<<" Nose "<<SelectedNose<<" [ TipSurface :"<<rPoint<<"]"<<std::endl;
443  break;
444  case ClearanceSurface:
445  is_inside = true;
446  // ContactFace = 3;
447  // if( node_in )
448  // std::cout<<" Nose "<<SelectedNose<<" [ ClearanceSurface :"<<rPoint<<"]"<<std::endl;
449  break;
450  default:
451  is_inside = false;
452  break;
453  }
454 
455  }
456 
457  return is_inside;
458 
459  KRATOS_CATCH("")
460 
461  }
462 
463 
464  //************************************************************************************
465  //************************************************************************************
466 
467  bool IsInside(BoundingBoxParameters& rValues, const ProcessInfo& rCurrentProcessInfo) override
468  {
469  KRATOS_TRY
470 
471  const PointType& rPoint = rValues.GetPoint();
472  PointType& rNormal = rValues.GetNormal();
473  double& rGapNormal = rValues.GetGapNormal();
474 
475  bool is_inside = SpatialBoundingBox::IsInside(rPoint);
476 
477  //std::cout<<" [is inside :"<<is_inside<<"]"<<std::endl;
478 
479  if( is_inside ){
480 
481  PointType LocalPoint = rPoint;
484 
485  LocalPoint[2] = 0; //2D
486 
487  unsigned int SelectedNose = BoxNoseSearch(LocalPoint);
488 
489  BoxNoseVariables& rWallNose = mBoxNoses[SelectedNose];
490 
491  double NoseRadius = rWallNose.Radius;
492 
493  //std::cout<<" Convexity ["<<SelectedNose<<" ]: "<< rWallNose.Convexity <<std::endl;
494 
495  switch( ContactSearch(LocalPoint, NoseRadius, rWallNose) )
496  {
497  case FreeSurface:
498  is_inside = false;
499  rValues.SetContactFace(0);
500  break;
501  case RakeSurface:
502  is_inside = CalculateRakeSurface(LocalPoint, rGapNormal, rNormal, rWallNose);
503  rValues.SetContactFace(1);
504  break;
505  case TipSurface:
506  is_inside = CalculateTipSurface(LocalPoint, rGapNormal, rNormal, rWallNose);
507  rValues.SetContactFace(2);
508  break;
509  case ClearanceSurface:
510  is_inside = CalculateClearanceSurface(LocalPoint, rGapNormal, rNormal, rWallNose);
511  rValues.SetContactFace(3);
512  break;
513  default:
514  is_inside = false;
515  break;
516  }
517 
518  // if(rWallNose.Convexity == -1 && ContactFace == 3 && rGapNormal<1.0){
519  // std::cout<<" [ ContactFace: "<<ContactFace<<"; Normal: "<<rNormal<<"; GapNormal: "<< rGapNormal <<" ] "<<rPoint<<std::endl;
520  // }
521 
524 
525  if( is_inside )
526  this->ComputeContactTangent(rValues,rCurrentProcessInfo);
527 
528  }
529 
530  //std::cout<<" ["<<is_inside<<"][ ContactFace: "<<rValues.GetContactFace()<<"; Normal: "<<rNormal<<"; GapNormal: "<< rGapNormal <<" ] "<<rPoint<<std::endl;
531 
532  return is_inside;
533 
534  KRATOS_CATCH("")
535 
536  }
537 
538 
539  //************************************************************************************
540  //************************************************************************************
541 
542  //Compound Noses
543  void CreateBoundingBoxBoundaryMesh(ModelPart& rModelPart, int linear_partitions = 4, int angular_partitions = 4 ) override
544  {
545  KRATOS_TRY
546 
547  unsigned int NodeId = 0;
548  if( rModelPart.IsSubModelPart() )
549  NodeId = this->GetMaxNodeId( rModelPart.GetParentModelPart());
550  else
551  NodeId = this->GetMaxNodeId( rModelPart );
552 
553  unsigned int InitialNodeId = NodeId;
554 
555  //get boundary model parts and computing model part ( temporary implementation )
556  std::vector<std::string> BoundaryModelPartsName;
557 
558  ModelPart* pMainModelPart = &rModelPart;
559  if( rModelPart.IsSubModelPart() )
560  pMainModelPart = &rModelPart.GetParentModelPart();
561 
562  for(ModelPart::SubModelPartIterator i_mp= pMainModelPart->SubModelPartsBegin() ; i_mp!=pMainModelPart->SubModelPartsEnd(); i_mp++)
563  {
564  if( i_mp->Is(BOUNDARY) || i_mp->Is(ACTIVE) ){
565  for(ModelPart::NodesContainerType::iterator i_node = i_mp->NodesBegin() ; i_node != i_mp->NodesEnd() ; ++i_node)
566  {
567  if( i_node->Id() == rModelPart.Nodes().front().Id() ){
568  BoundaryModelPartsName.push_back(i_mp->Name());
569  break;
570  }
571  }
572  }
573  }
574  //get boundary model parts ( temporary implementation )
575 
576  PointType DirectionX(3);
577  noalias(DirectionX) = ZeroVector(3);
578  DirectionX[0] = 0;
579  DirectionX[1] = 0;
580  DirectionX[2] = 1; //2D only temporary
581  PointType DirectionY(3);
582  noalias(DirectionY) = ZeroVector(3);
583  PointType DirectionZ(3);
584  noalias(DirectionZ) = ZeroVector(3);
585 
586  this->CalculateOrthonormalBase(DirectionX, DirectionY, DirectionZ);
587 
588  PointType BasePoint(3);
589  PointType RotationAxis(3);
590  PointType RotatedDirectionY(3);
591 
592  PointType Normal(3);
593  PointType Tangent(3);
594  PointType TipPoint(3);
595  PointType RakePoint(3);
596  PointType ClearancePoint(3);
597 
598  std::vector<PointType> FacePoints;
599 
600  double alpha = 0;
602 
603  PointType FirstPoint(3);
604  bool order_changed = false;
605  for(unsigned int i=0; i<mBoxNoses.size(); i++)
606  {
607  this->GetNosePoints(mBoxNoses[i],RakePoint,ClearancePoint,TipPoint);
608 
609  order_changed = false;
610 
611  if( i == 0 ){
612 
613  this->GetRakeNormal(mBoxNoses[i],Normal);
614 
615  this->GetPlaneTangent(Normal,RakePoint,TipPoint,Tangent);
616 
617  //point 1
618  noalias(FirstPoint) = RakePoint + mBox.Radius * Tangent;
619 
620  }
621  else{
622 
623  if( norm_2(RakePoint-FirstPoint) > norm_2(ClearancePoint-FirstPoint) ){
624 
625  //change the Rake and the Clearance Order
626  order_changed = true;
627  BasePoint = ClearancePoint; //temporary
628  ClearancePoint = RakePoint;
629  RakePoint = BasePoint;
630 
631  }
632  }
633 
634  BasePoint = FirstPoint;
635  BasePoint[2] += mBoxNoses[i].Center[2];
636  FacePoints.push_back(BasePoint);
637 
638 
639  //next first point
640  FirstPoint = ClearancePoint;
641 
642 
643  //rake point
644  BasePoint = RakePoint;
645  BasePoint[2] += mBoxNoses[i].Center[2];
646  FacePoints.push_back(BasePoint);
647 
648  //tip angle:
649  double length1 = inner_prod( (RakePoint-mBoxNoses[i].Center), (RakePoint-mBoxNoses[i].Center) );
650  double length2 = inner_prod( (ClearancePoint-mBoxNoses[i].Center), (ClearancePoint-mBoxNoses[i].Center) );
651  length1 = sqrt(length1);
652  length2 = sqrt(length2);
653  double tip_alpha = acos(inner_prod( (RakePoint-mBoxNoses[i].Center), (ClearancePoint-mBoxNoses[i].Center) ) / (length1*length2) );
654 
655  for(int k=1; k<=angular_partitions; k++)
656  {
657 
658  alpha = (tip_alpha * double(k) )/(double)(angular_partitions-1);
659 
660  //vector of rotation
661  RotationAxis = DirectionX * alpha;
663 
664  RotatedDirectionY = RakePoint - mBoxNoses[i].Center;
665 
666  Quaternion.RotateVector3(RotatedDirectionY);
667 
668  noalias(BasePoint) = mBoxNoses[i].Center + RotatedDirectionY;
669 
670  BasePoint[2] += mBoxNoses[i].Center[2];
671  FacePoints.push_back(BasePoint);
672  }
673 
674 
675 
676 
677  if( i == mBoxNoses.size()-1 ){
678  //clearance point
679  BasePoint = ClearancePoint;
680  BasePoint[2] += mBoxNoses[i].Center[2];
681  FacePoints.push_back(BasePoint);
682 
683  if(order_changed)
684  this->GetRakeNormal(mBoxNoses[i],Normal);
685  else
686  this->GetClearanceNormal(mBoxNoses[i],Normal);
687 
688 
689  this->GetPlaneTangent(Normal,FirstPoint,TipPoint,Tangent);
690 
691  //point n
692  noalias(BasePoint) = FirstPoint + mBox.Radius * Tangent;
693 
694  BasePoint[2] += mBoxNoses[i].Center[2];
695  FacePoints.push_back(BasePoint);
696 
697  }
698 
699  }
700 
701 
702  //std::cout<<" Nodes Added "<<NodeId-InitialNodeId<<std::endl;
703  if( rModelPart.GetMesh().WorkingSpaceDimension() == 2 || rModelPart.GetProcessInfo()[SPACE_DIMENSION]==2 ){
704 
705  //create modelpart nodes
706  for(unsigned int i=0; i<FacePoints.size(); i++)
707  {
708 
709  NodeId += 1;
710 
711  NodeType::Pointer pNode = this->CreateNode(rModelPart, FacePoints[i], NodeId);
712 
713  pNode->Set(RIGID,true);
714 
715  rModelPart.AddNode( pNode );
716 
717  //get boundary model parts ( temporary implementation )
718  for(unsigned int j=0; j<BoundaryModelPartsName.size(); j++)
719  (pMainModelPart->GetSubModelPart(BoundaryModelPartsName[j])).AddNode( pNode );
720  //get boundary model parts ( temporary implementation )
721 
722  }
723 
724  this->CreateLinearBoundaryMesh(rModelPart, InitialNodeId);
725  }
726  else{
727 
728  //3D case: rotate to local axis
729 
730  //create modelpart nodes first row
731  for(unsigned int i=0; i<FacePoints.size(); i++)
732  {
733  NodeId += 1;
734 
736 
737  mBox.LocalQuaternion.RotateVector3(FacePoints[i]);
738 
739  NodeType::Pointer pNode = this->CreateNode(rModelPart, FacePoints[i], NodeId);
740 
741  pNode->Set(RIGID,true);
742 
743  rModelPart.AddNode( pNode );
744 
745  //get boundary model parts ( temporary implementation )
746  for(unsigned int j=0; j<BoundaryModelPartsName.size(); j++)
747  (pMainModelPart->GetSubModelPart(BoundaryModelPartsName[j])).AddNode( pNode );
748  //get boundary model parts ( temporary implementation )
749 
750  }
751 
752  double FinalNodeId = NodeId;
753 
754  //3D case: translate to axis length
755 
756  PointType Axis(3);
757  Matrix RotationMatrix(3,3);
758  mBox.LocalQuaternion.ToRotationMatrix(RotationMatrix);
759  Axis[0] = RotationMatrix(2,0);
760  Axis[1] = RotationMatrix(2,1);
761  Axis[2] = RotationMatrix(2,2);
762 
763  Axis *= mBox.Radius;
764 
765  //create modelpart nodes second row
766  for(unsigned int i=0; i<FacePoints.size(); i++)
767  {
768  NodeId += 1;
769 
770  FacePoints[i] += Axis;
771 
772  NodeType::Pointer pNode = this->CreateNode(rModelPart, FacePoints[i], NodeId);
773 
774  pNode->Set(RIGID,true);
775 
776  rModelPart.AddNode( pNode );
777 
778  //get boundary model parts ( temporary implementation )
779  for(unsigned int j=0; j<BoundaryModelPartsName.size(); j++)
780  (pMainModelPart->GetSubModelPart(BoundaryModelPartsName[j])).AddNode( pNode );
781  //get boundary model parts ( temporary implementation )
782 
783  }
784 
785  this->CreateQuadrilateralBoundaryMesh(rModelPart, InitialNodeId, FinalNodeId);
786 
787  }
788 
789  KRATOS_CATCH( "" )
790  }
791 
792 
796 
797 
798 
802 
803 
807 
809  std::string Info() const override
810  {
811  return "CompoundNosesBoundingBox";
812  }
813 
815  void PrintInfo(std::ostream& rOStream) const override
816  {
817  rOStream << Info();
818  }
819 
821  void PrintData(std::ostream& rOStream) const override
822  {
823  rOStream << this->mBox.UpperPoint << " , " << this->mBox.LowerPoint;
824  }
825 
829 
830 
832 
833 protected:
836 
837 
841 
842  std::vector<BoxNoseVariables> mBoxNoses;
843 
847 
848 
852 
853  //************************************************************************************
854  //************************************************************************************
855 
856  void CreateLinearBoundaryMesh(ModelPart& rModelPart, const unsigned int& rInitialNodeId)
857  {
858 
859  KRATOS_TRY
860 
861  //add elements to computing model part: (in order to be written)
862  ModelPart* pComputingModelPart = NULL;
863  if( rModelPart.IsSubModelPart() )
864  for(ModelPart::SubModelPartIterator i_mp= rModelPart.GetParentModelPart().SubModelPartsBegin() ; i_mp!=rModelPart.GetParentModelPart().SubModelPartsEnd(); i_mp++)
865  {
866  if( i_mp->Is(ACTIVE) ) //computing_domain
867  pComputingModelPart = &rModelPart.GetParentModelPart().GetSubModelPart(i_mp->Name());
868  }
869  else{
870  for(ModelPart::SubModelPartIterator i_mp= rModelPart.SubModelPartsBegin() ; i_mp!=rModelPart.SubModelPartsEnd(); i_mp++)
871  {
872  if( i_mp->Is(ACTIVE) ) //computing_domain
873  pComputingModelPart = &rModelPart.GetSubModelPart(i_mp->Name());
874  }
875  }
876 
877  // Create surface of the cylinder/tube with quadrilateral shell conditions
878  unsigned int ElementId = 0;
879  if( rModelPart.IsSubModelPart() )
880  ElementId = this->GetMaxElementId( rModelPart.GetParentModelPart());
881  else
882  ElementId = this->GetMaxElementId( rModelPart );
883 
884  unsigned int NodeId = 0;
885  if( rModelPart.IsSubModelPart() )
886  NodeId = this->GetMaxNodeId( rModelPart.GetParentModelPart());
887  else
888  NodeId = this->GetMaxNodeId( rModelPart );
889 
890 
891  //GEOMETRY:
892  GeometryType::Pointer pFace;
893  ElementType::Pointer pElement;
894 
895  //PROPERTIES:
896  int number_of_properties = rModelPart.NumberOfProperties();
897  Properties::Pointer pProperties = Kratos::make_shared<Properties>(number_of_properties);
898 
899  int counter = 0;
900  unsigned int Id = rInitialNodeId;
901 
902  Vector FaceNodesIds(2);
903  noalias( FaceNodesIds ) = ZeroVector(2);
904 
905  while(Id < NodeId){
906 
907  counter += 1;
908  ElementId += 1;
909 
910  FaceNodesIds[0] = rInitialNodeId + counter ;
911  FaceNodesIds[1] = rInitialNodeId + counter + 1;
912 
914  FaceNodes.reserve(2);
915 
916  //NOTE: when creating a PointsArrayType
917  //important ask for pGetNode, if you ask for GetNode a copy is created
918  //if a copy is created a segmentation fault occurs when the node destructor is called
919 
920  for(unsigned int j=0; j<2; j++)
921  FaceNodes.push_back(rModelPart.pGetNode(FaceNodesIds[j]));
922 
923  pFace = Kratos::make_shared<Line2D2<NodeType> >(FaceNodes);
924  pElement = Kratos::make_intrusive<Element>(ElementId, pFace, pProperties);
925 
926  rModelPart.AddElement(pElement);
927  pElement->Set(ACTIVE,false);
928  pComputingModelPart->AddElement(pElement);
929 
930  Id = rInitialNodeId + counter + 1;
931 
932  }
933 
934  KRATOS_CATCH( "" )
935 
936  }
937 
938 
939  //************************************************************************************
940  //************************************************************************************
941 
942  void CreateQuadrilateralBoundaryMesh(ModelPart& rModelPart, const unsigned int& rFirstInitialNodeId , const unsigned int& rSecondInitialNodeId)
943  {
944 
945  KRATOS_TRY
946 
947  //add elements to computing model part: (in order to be written)
948  ModelPart* pComputingModelPart = NULL;
949  if( rModelPart.IsSubModelPart() )
950  for(ModelPart::SubModelPartIterator i_mp= rModelPart.GetParentModelPart().SubModelPartsBegin() ; i_mp!=rModelPart.GetParentModelPart().SubModelPartsEnd(); i_mp++)
951  {
952  if( i_mp->Is(ACTIVE) ) //computing_domain
953  pComputingModelPart = &rModelPart.GetParentModelPart().GetSubModelPart(i_mp->Name());
954  }
955  else{
956  for(ModelPart::SubModelPartIterator i_mp= rModelPart.SubModelPartsBegin() ; i_mp!=rModelPart.SubModelPartsEnd(); i_mp++)
957  {
958  if( i_mp->Is(ACTIVE) ) //computing_domain
959  pComputingModelPart = &rModelPart.GetSubModelPart(i_mp->Name());
960  }
961  }
962 
963  // Create surface of the cylinder/tube with quadrilateral shell conditions
964  unsigned int ElementId = 0;
965  if( rModelPart.IsSubModelPart() )
966  ElementId = this->GetMaxElementId( rModelPart.GetParentModelPart());
967  else
968  ElementId = this->GetMaxElementId( rModelPart );
969 
970  unsigned int NodeId = 0;
971  if( rModelPart.IsSubModelPart() )
972  NodeId = this->GetMaxNodeId( rModelPart.GetParentModelPart());
973  else
974  NodeId = this->GetMaxNodeId( rModelPart );
975 
976 
977  //GEOMETRY:
978  GeometryType::Pointer pFace;
979  ElementType::Pointer pElement;
980 
981  //PROPERTIES:
982  int number_of_properties = rModelPart.NumberOfProperties();
983  Properties::Pointer pProperties = Kratos::make_shared<Properties>(number_of_properties);
984 
985  int counter = 0;
986  unsigned int Id = rSecondInitialNodeId;
987 
988  Vector FaceNodesIds(4);
989  noalias( FaceNodesIds ) = ZeroVector(4);
990 
991  while(Id < NodeId){
992 
993  counter += 1;
994  ElementId += 1;
995 
996  FaceNodesIds[0] = rFirstInitialNodeId + counter + 1;
997  FaceNodesIds[1] = rFirstInitialNodeId + counter;
998  FaceNodesIds[2] = rSecondInitialNodeId + counter;
999  FaceNodesIds[3] = rSecondInitialNodeId + counter + 1;
1000 
1001  //std::cout<<" FaceNodesIds "<<FaceNodesIds<<" element id "<<ElementId<<std::endl;
1002 
1004  FaceNodes.reserve(4);
1005 
1006  //NOTE: when creating a PointsArrayType
1007  //important ask for pGetNode, if you ask for GetNode a copy is created
1008  //if a copy is created a segmentation fault occurs when the node destructor is called
1009 
1010  for(unsigned int j=0; j<4; j++)
1011  FaceNodes.push_back(rModelPart.pGetNode(FaceNodesIds[j]));
1012 
1013  pFace = Kratos::make_shared<Quadrilateral3D4<NodeType> >(FaceNodes);
1014  pElement = Kratos::make_intrusive<Element>(ElementId, pFace, pProperties);
1015 
1016  rModelPart.AddElement(pElement);
1017  pElement->Set(ACTIVE,false);
1018  pComputingModelPart->AddElement(pElement);
1019 
1020  Id = rSecondInitialNodeId + counter + 1;
1021 
1022  }
1023 
1024  KRATOS_CATCH( "" )
1025 
1026  }
1027 
1031 
1032 
1036 
1037 
1041 
1042 
1044 
1045 private:
1048 
1049 
1053 
1054 
1058 
1059 
1063 
1064  //************************************************************************************
1065  //************************************************************************************
1066 
1067  PointType GetNearerCenter(const PointType& rPoint)
1068  {
1069 
1070  unsigned int SelectedNose = BoxNoseSearch(rPoint);
1071 
1072  BoxNoseVariables& rWallNose = mBoxNoses[SelectedNose];
1073 
1074  return rWallNose.Center;
1075  }
1076 
1077  //************************************************************************************
1078  //************************************************************************************
1079 
1080  double GetNearerRadius(const PointType& rPoint)
1081  {
1082  unsigned int SelectedNose = BoxNoseSearch(rPoint);
1083 
1084  BoxNoseVariables& rWallNose = mBoxNoses[SelectedNose];
1085 
1086  return rWallNose.Radius;
1087 
1088  }
1089 
1090  //************************************************************************************
1091  //************************************************************************************
1092 
1093  bool CheckValidAngle( double& rAngle )
1094  {
1095  bool valid_angle = true;
1096  double tol = 1e-3;
1097  for( int i = 0; i<=360; i+=90 ){
1098  if( fabs(rAngle) < double(i + tol) && fabs(rAngle) > double(i - tol) ){
1099  valid_angle = false;
1100  break;
1101  }
1102  }
1103 
1104  return valid_angle;
1105  }
1106 
1107  //************************************************************************************
1108  //************************************************************************************
1109 
1110  // General Wall creator
1111  void CreateCompoundNosesBox(Vector& rRadius, Vector& rRakeAngles, Vector& rClearanceAngles, Matrix& rCenters, Vector& rConvexities,
1112  Vector& rVelocity, Vector& rAngularVelocity, Vector& rUpperPoint, Vector& rLowerPoint, Matrix& rInitialLocalMatrix)
1113  {
1114 
1115  KRATOS_TRY
1116 
1117  if( rRadius.size() != rRakeAngles.size() || rRakeAngles.size() != rClearanceAngles.size() )
1118  std::cout<<" Introduced walls are not consistent in sizes "<<std::endl;
1119 
1120  double pi = 3.141592654;
1121 
1122  std::cout<<" [--NOSE-WALL--] "<<std::endl;
1123  std::cout<<" [NOSES:"<<rRadius.size()<<"]"<<std::endl;
1124 
1125  mBox.Initialize();
1126 
1127  for(unsigned int i=0; i<rRadius.size(); i++)
1128  {
1129  BoxNoseVariables WallNose;
1130  WallNose.Initialize();
1131 
1132  WallNose.Convexity = rConvexities[i];
1133  WallNose.Radius = rRadius[i];
1134 
1135  // RakeAngle :: Angle given respect to the vertical axis (is positive line, represents the nose upper part)
1136  // changed to be expressed respect to the horitzontal axis, represents positive (increasing) line
1137  WallNose.RakeAngle = ( 90 - rRakeAngles[i] );
1138 
1139  // ClearanceAngle :: Angle given respect to the vertical axis (is negative line, represents the nose down part)
1140  // changed to represent a negative (decreasing) line
1141  WallNose.ClearanceAngle = ( 180 + rClearanceAngles[i] );
1142 
1143  bool valid_angle = CheckValidAngle( WallNose.RakeAngle );
1144 
1145  //check if the angle is 0 or 180 before performing this operation
1146  if( valid_angle ){
1147  WallNose.RakeAngle *= pi / 180.0;
1148  WallNose.TangentRakeAngle = tan(0.5*pi-WallNose.RakeAngle);
1149  }
1150  else{
1151  WallNose.RakeAngle *= pi / 180.0;
1152  WallNose.TangentRakeAngle = 0;
1153  }
1154 
1155  valid_angle = CheckValidAngle( WallNose.ClearanceAngle );
1156 
1157  //check if the angle is 0 or 180 before performing this operation
1158  if( valid_angle ){
1159  WallNose.ClearanceAngle *= pi / 180.0;
1160  WallNose.TangentClearanceAngle = tan(0.5*pi-WallNose.ClearanceAngle);
1161  }
1162  else{
1163  WallNose.ClearanceAngle *= pi / 180.0;
1164  WallNose.TangentClearanceAngle = 0;
1165  }
1166 
1167  for(unsigned int j=0; j<rCenters.size2(); j++)
1168  {
1169  WallNose.Center[j] = rCenters(i,j);
1170  }
1171 
1172  WallNose.SetInitialValues();
1173 
1174  //set to local frame
1177 
1178  std::cout<<" [COMPONENT]["<<i<<"]"<<std::endl;
1179  std::cout<<" [Convexity:"<<WallNose.Convexity<<std::endl;
1180  std::cout<<" [Radius:"<<WallNose.Radius<<std::endl;
1181  std::cout<<" [Center:"<<WallNose.Center<<std::endl;
1182  std::cout<<" [Rake:"<<WallNose.RakeAngle<<std::endl;
1183  std::cout<<" [Clearance:"<<WallNose.ClearanceAngle<<std::endl;
1184  std::cout<<" [TangentRakeAngle:"<<WallNose.TangentRakeAngle<<std::endl;
1185  std::cout<<" [TangentClearanceAngle:"<<WallNose.TangentClearanceAngle<<std::endl;
1186 
1187  mBoxNoses.push_back(WallNose);
1188 
1189  }
1190 
1191  std::cout<<" [--------] "<<std::endl;
1192 
1194 
1195  mBox.UpperPoint = rUpperPoint;
1196  mBox.LowerPoint = rLowerPoint;
1197 
1198  mBox.Center = 0.5 * ( rUpperPoint + rLowerPoint );
1199  mBox.Radius = 0.5 * norm_2(rUpperPoint-rLowerPoint);
1200 
1201  mBox.Velocity = rVelocity;
1202  mBox.AngularVelocity = rAngularVelocity;
1203 
1204  //set to local frame
1206 
1209 
1211 
1212  mBox.Print();
1213 
1214  mRigidBodyCenterSupplied = false;
1215 
1216  KRATOS_CATCH("")
1217  }
1218 
1219  //************************************************************************************
1220  //************************************************************************************
1221 
1222  unsigned int BoxNoseSearch(const PointType& rPoint)
1223  {
1224 
1225  KRATOS_TRY
1226 
1227  double MinimumDistance =std::numeric_limits<double>::max();
1228  double MinimumDistanceRadius =std::numeric_limits<double>::max();
1229 
1230  //std::cout<<" Minimum Distance "<<MinimumDistance<<std::endl;
1231 
1232  unsigned int NumberBoxNoses = mBoxNoses.size();
1233 
1234  unsigned int SelectedNose = 0;
1235  unsigned int SelectedNoseDistance = 0;
1236  unsigned int SelectedNoseRadius = 0;
1237 
1238  std::vector<double> NoseDistanceVector (NumberBoxNoses);
1239 
1240  for(unsigned int i=0; i<NumberBoxNoses; i++)
1241  {
1242 
1243  //based on distance
1244  PointType Distance = (mBoxNoses[i].Center - rPoint);
1245  Distance[2] = 0; //2D
1246  double NoseDistance = norm_2( Distance );
1247  double NoseDistanceRadius = norm_2( Distance );
1248 
1249  if( NoseDistance > 0 ){
1250 
1251  // //CORRECTION START: add a correction by velocity component for critical points
1252 
1253  // //based on center movement
1254  // PointType VelocityProjection = this->mMovement.Velocity;
1255  // double NormVelocity = norm_2(VelocityProjection);
1256  // if( NormVelocity > 0 )
1257  // VelocityProjection /= NormVelocity;
1258 
1259  // Distance += (NoseDistance * 0.01) * VelocityProjection;
1260  // NoseDistance = norm_2( Distance );
1261 
1262  // //CORRECTION END
1263 
1264  //CORRECTION START: add a correction by radius component for critical points
1265  Distance = ( 1.0 - (mBoxNoses[i].Radius)/NoseDistance ) * Distance;
1266  NoseDistanceRadius = norm_2( Distance );
1267 
1268  //CORRECTION END
1269 
1270  }
1271 
1272  NoseDistanceVector[i] = NoseDistance;
1273 
1274 
1275  if( NoseDistance < MinimumDistance ){
1276  MinimumDistance = NoseDistance;
1277  SelectedNoseDistance = i;
1278  //std::cout<<" SelectedNoseDistance: "<<SelectedNoseDistance<<" MinimumDistance "<<MinimumDistance<<std::endl;
1279  }
1280 
1281  if( NoseDistanceRadius < MinimumDistanceRadius ){
1282  MinimumDistanceRadius = NoseDistanceRadius;
1283  SelectedNoseRadius = i;
1284  //std::cout<<" SelectedNoseDistanceRadiius: "<<SelectedNoseRadius<<" MinimumDistanceRadius "<<MinimumDistanceRadius<<std::endl;
1285  }
1286 
1287 
1288  }
1289 
1290 
1291  if( SelectedNoseDistance == SelectedNoseRadius ){
1292 
1293  SelectedNose = SelectedNoseRadius;
1294 
1295  }
1296  else{
1297 
1298  if( mBoxNoses[SelectedNoseDistance].Convexity > mBoxNoses[SelectedNoseRadius].Convexity ){
1299 
1300 
1301  if( NoseDistanceVector[SelectedNoseDistance] > mBoxNoses[SelectedNoseDistance].Radius ){
1302 
1303 
1304  PointType TipPoint(3);
1305  this->GetTipPoint(mBoxNoses[SelectedNoseRadius],TipPoint); //slave point : convexity -
1306 
1307  double sign = GetOrientation( rPoint, mBoxNoses[SelectedNoseDistance].Center, mBoxNoses[SelectedNoseRadius].Center, TipPoint );
1308 
1309  if( sign > 0 )
1310  SelectedNose = SelectedNoseRadius;
1311  else
1312  SelectedNose = SelectedNoseDistance;
1313 
1314  //std::cout<<" SELECTED NOSE A "<<SelectedNose<<" sign "<<sign<<std::endl;
1315 
1316  // if ( NoseDistanceVector[SelectedNoseRadius] > mBoxNoses[SelectedNoseRadius].Radius + (mBoxNoses[SelectedNoseDistance].Radius * 0.02) ){
1317  // SelectedNose = SelectedNoseDistance;
1318  // }
1319  // else{
1320  // SelectedNose = SelectedNoseRadius;
1321  // }
1322 
1323  }
1324  else{
1325 
1326  SelectedNose = SelectedNoseDistance;
1327  }
1328 
1329 
1330  }
1331  else if( mBoxNoses[SelectedNoseDistance].Convexity < mBoxNoses[SelectedNoseRadius].Convexity ){
1332 
1333 
1334  if( mBoxNoses[SelectedNoseDistance].Radius < mBoxNoses[SelectedNoseRadius].Radius ){
1335 
1336 
1337  PointType TipPoint(3);
1338  this->GetTipPoint(mBoxNoses[SelectedNoseRadius],TipPoint); //slave point : convexity +
1339 
1340  double sign = GetOrientation( rPoint, mBoxNoses[SelectedNoseDistance].Center, mBoxNoses[SelectedNoseRadius].Center, TipPoint );
1341 
1342  if( sign > 0 )
1343  SelectedNose = SelectedNoseRadius;
1344  else
1345  SelectedNose = SelectedNoseDistance;
1346 
1347  //std::cout<<" SELECTED NOSE B "<<SelectedNose<<" sign "<<sign<<std::endl;
1348 
1349  // if ( NoseDistanceVector[SelectedNoseDistance] < mBoxNoses[SelectedNoseDistance].Radius + (mBoxNoses[SelectedNoseDistance].Radius * 0.01) ){
1350  // SelectedNose = SelectedNoseDistance;
1351  // }
1352  // else{
1353  // SelectedNose = SelectedNoseRadius;
1354  // }
1355 
1356 
1357  }
1358  else{
1359 
1360  SelectedNose = SelectedNoseDistance;
1361 
1362  }
1363 
1364 
1365  }
1366  else{
1367 
1368  SelectedNose = SelectedNoseRadius;
1369  }
1370 
1371  }
1372 
1373  return SelectedNose;
1374 
1375  KRATOS_CATCH("")
1376 
1377  }
1378 
1379 
1380  //************************************************************************************
1381  //************************************************************************************
1382 
1383  double GetOrientation(const PointType& rPoint, const PointType& rMasterCenter, const PointType& rSlaveCenter, const PointType& rSlaveTipPoint )
1384  {
1385 
1386  PointType DistanceToPoint = (rPoint - rMasterCenter);
1387  DistanceToPoint[2] = 0; //2D
1388  PointType DistanceToCenter = (rSlaveCenter - rMasterCenter);
1389  DistanceToCenter[2] = 0; //2D
1390  PointType DistanceToTip = (rSlaveTipPoint - rMasterCenter);
1391  DistanceToTip[2] = 0; //2D
1392 
1393  PointType ReferenceOrientation;
1394  MathUtils<double>::CrossProduct( ReferenceOrientation, DistanceToTip, DistanceToCenter );
1395  PointType Orientation;
1396  MathUtils<double>::CrossProduct( Orientation, DistanceToPoint, DistanceToCenter );
1397 
1398  double sign = (Orientation[2] * ReferenceOrientation[2]);
1399 
1400  return sign;
1401  }
1402 
1403 
1404 
1405  //************************************************************************************
1406  //************************************************************************************
1407 
1408 
1409  ContactFace ContactSearch(const PointType& rPoint, const double& rRadius, const BoxNoseVariables& rWallNose)
1410  {
1411 
1412  KRATOS_TRY
1413 
1414  ContactFace Face = FreeSurface;
1415 
1416  double FaceR = CalculateRakeFace( FaceR, rPoint, rRadius, rWallNose );
1417  double FaceT = CalculateTipFace( FaceT, rPoint, rRadius, rWallNose );
1418  double FaceC = CalculateClearanceFace( FaceC, rPoint, rRadius, rWallNose );
1419 
1420  double Face1=0, Face2=0, Face3=0;
1421  CalculateAuxiliarFaces( Face1, Face2, Face3, rPoint, rRadius, rWallNose );
1422 
1423 
1424  // bool node_in =false;
1425  // if( rWallNose.Convexity == 1 && (rPoint[0]>=95 && rPoint[1]>=6.9) )
1426  // node_in = true;
1427 
1428  // if( node_in ){
1429  // std::cout<<" Point : "<<rPoint<<" Center "<<rWallNose.Center<<std::endl;
1430  // std::cout<<" [ FaceR: "<<FaceR<<"; FaceT: "<<FaceT<<"; FaceC: "<<FaceC<<" ] "<<std::endl;
1431  // std::cout<<" [ Face1: "<<Face1<<"; Face2: "<<Face2<<"; Face3: "<<Face3<<" ] "<<std::endl;
1432  // }
1433 
1434 
1435  if(rWallNose.Convexity == 1){
1436 
1437  if(FaceR>0 && Face3<0 && Face1<0){
1438  Face = RakeSurface;
1439  }
1440  else if(FaceT>0 && Face1>0 && Face2>0){
1441  Face = TipSurface;
1442  }
1443  else if(FaceC>0 && Face3>0 && Face2<0){
1444  Face = ClearanceSurface;
1445  }
1446  else{
1447  Face = FreeSurface;
1448  }
1449 
1450  }
1451  else{
1452 
1453  if(FaceR<0 && Face3<0 && Face1<0){
1454  Face = RakeSurface;
1455  }
1456  else if(FaceT<0 && Face1>0 && Face2>0){
1457  Face = TipSurface;
1458  }
1459  else if(FaceC<0 && Face3>0 && Face2<0){
1460  Face = ClearanceSurface;
1461  }
1462  else{
1463  Face = FreeSurface;
1464  }
1465 
1466 
1467  }
1468 
1469  return Face;
1470 
1471  KRATOS_CATCH( "" )
1472 
1473  }
1474 
1475 
1476  //************************************************************************************
1477  //************************************************************************************
1478 
1479 
1480  void PointFaceEvaluation(const PointType& rPoint, const PointType& rLinePoint, const double& rTangentAngle, PointType& rPointFace)
1481  {
1482  KRATOS_TRY
1483 
1484  // if( rTangentAngle != 0 ){
1485 
1486  // rPointFace[0] = rPoint[0] - ( 1.0/rTangentAngle ) * ( rPoint[1] - rLinePoint[1] ) - rLinePoint[0];
1487  // rPointFace[1] = rPoint[1] - ( rTangentAngle ) * ( rPoint[0] - rLinePoint[0] ) - rLinePoint[1];
1488 
1489  // }
1490  // else{
1491 
1492  rPointFace[0] = rPoint[0] - rLinePoint[0];
1493  rPointFace[1] = rPoint[1] - rLinePoint[1];
1494  // }
1495 
1496  rPointFace [2] = 0;
1497 
1498  KRATOS_CATCH( "" )
1499  }
1500 
1501  //************************************************************************************
1502  //************************************************************************************
1503 
1504 
1505  double& CalculateRakeFace(double& Face, const PointType& rPoint, const double& rRadius, const BoxNoseVariables& rWallNose)
1506  {
1507  KRATOS_TRY
1508 
1509 
1510  PointType PointFace(3);
1511 
1512  PointType CenterFace(3);
1513 
1514  PointType RakePoint(3);
1515 
1516  RakePoint[0] = rWallNose.Center[0] - rRadius * sin(rWallNose.RakeAngle);
1517  RakePoint[1] = rWallNose.Center[1] + rRadius * cos(rWallNose.RakeAngle);
1518  RakePoint[2] = 0;
1519 
1520 
1521  // bool node_in =false;
1522  // if( rWallNose.Convexity == 1 && (rPoint[0]>=95 && rPoint[1]>=6.9) )
1523  // node_in = true;
1524 
1525  // if( node_in )
1526  // std::cout<<" RakePoint "<<RakePoint<<" Radius "<<rWallNose.Radius<<" Angle "<<rWallNose.RakeAngle<<" Center "<<rWallNose.Center<<std::endl;
1527 
1528 
1529  PointFaceEvaluation(rPoint, RakePoint, rWallNose.TangentRakeAngle, PointFace);
1530  PointFaceEvaluation(rWallNose.Center, RakePoint, rWallNose.TangentRakeAngle, CenterFace);
1531 
1532  Face = inner_prod(PointFace,CenterFace);
1533 
1534  // PointFace[0] *= CenterFace[0];
1535  // PointFace[1] *= CenterFace[1];
1536 
1537  // double MaximumDistance=-1;
1538 
1539  // for(unsigned int i=0; i<2; i++)
1540  // {
1541  // double Distance = fabs( PointFace[i] );
1542  // if( Distance > MaximumDistance ){
1543  // MaximumDistance = Distance;
1544  // }
1545  // }
1546 
1547  // double zero_tol = MaximumDistance * 1e-3;
1548 
1549 
1550  // //the sign is evaluated (+) accepted and (-) rejected
1551  // if( fabs(PointFace[0]) > zero_tol && fabs(PointFace[1]) > zero_tol ){
1552  // Face = PointFace[0] * PointFace[1];
1553  // }
1554  // else if( fabs(PointFace[0]) > zero_tol && fabs(PointFace[1]) < zero_tol ){
1555  // Face = PointFace[0];
1556  // }
1557  // else if( fabs(PointFace[0]) < zero_tol && fabs(PointFace[1]) > zero_tol ){
1558  // Face = PointFace[1];
1559  // }
1560  // else{
1561  // std::cout<<" Critical point reached and accepted on Rake Face: "<<PointFace<<std::endl;
1562  // Face = +1;
1563  // }
1564 
1565  //Face (+) rPoint is "in" :: (-) rPoint is "out" the rake part of the nose
1566  return Face;
1567 
1568  KRATOS_CATCH( "" )
1569 
1570  }
1571 
1572 
1573  //************************************************************************************
1574  //************************************************************************************
1575 
1576  double& CalculateClearanceFace(double& Face, const PointType& rPoint, const double& rRadius, const BoxNoseVariables& rWallNose)
1577  {
1578  KRATOS_TRY
1579 
1580  PointType PointFace(3);
1581 
1582  PointType CenterFace(3);
1583 
1584  PointType ClearancePoint(3);
1585 
1586  ClearancePoint[0] = rWallNose.Center[0] - rRadius * sin(rWallNose.ClearanceAngle);
1587  ClearancePoint[1] = rWallNose.Center[1] + rRadius * cos(rWallNose.ClearanceAngle);
1588  ClearancePoint[2] = 0;
1589 
1590  // bool node_in =false;
1591  // if( rWallNose.Convexity == 1 && (rPoint[0]>=95 && rPoint[1]>=6.9) )
1592  // node_in = true;
1593 
1594  // if( node_in )
1595  // std::cout<<" ClearancePoint "<<ClearancePoint<<" Radius "<<rWallNose.Radius<<" Angle "<<rWallNose.ClearanceAngle<<" Center "<<rWallNose.Center<<std::endl;
1596 
1597  PointFaceEvaluation(rPoint, ClearancePoint, rWallNose.TangentClearanceAngle, PointFace);
1598  PointFaceEvaluation(rWallNose.Center, ClearancePoint, rWallNose.TangentClearanceAngle, CenterFace);
1599 
1600  Face = inner_prod(PointFace,CenterFace);
1601 
1602  // PointFace[0] *= CenterFace[0];
1603  // PointFace[1] *= CenterFace[1];
1604 
1605  // double MaximumDistance=-1;
1606 
1607  // for(unsigned int i=0; i<2; i++)
1608  // {
1609  // double Distance = fabs( PointFace[i] );
1610  // if( Distance > MaximumDistance ){
1611  // MaximumDistance = Distance;
1612  // }
1613  // }
1614 
1615  // double zero_tol = MaximumDistance * 1e-3;
1616 
1617  // //the sign is evaluated (+) accepted and (-) rejected
1618  // if( fabs(PointFace[0]) > zero_tol && fabs(PointFace[1]) > zero_tol ){
1619  // Face = PointFace[0] * PointFace[1];
1620  // }
1621  // else if( fabs(PointFace[0]) > zero_tol && fabs(PointFace[1]) < zero_tol ){
1622  // Face = PointFace[0];
1623  // }
1624  // else if( fabs(PointFace[0]) < zero_tol && fabs(PointFace[1]) > zero_tol ){
1625  // Face = PointFace[1];
1626  // }
1627  // else{
1628  // std::cout<<" Critical point reached and accepted on Clearance Face :"<<PointFace<<std::endl;
1629  // Face = +1;
1630  // }
1631 
1632 
1633  //Face (+) rPoint is "in" :: (-) rPoint is "out" the clearance part of the nose
1634  return Face;
1635 
1636 
1637  KRATOS_CATCH( "" )
1638  }
1639 
1640  //************************************************************************************
1641  //************************************************************************************
1642 
1643 
1644  double& CalculateTipFace(double& Face, const PointType& rPoint, const double& rRadius, const BoxNoseVariables& rWallNose)
1645  {
1646  KRATOS_TRY
1647 
1648  Face = ( rRadius * rRadius ) - pow( (rPoint[0] - rWallNose.Center[0]), 2 ) - pow( (rPoint[1] - rWallNose.Center[1]), 2 );
1649 
1650  //Face (+) rPoint is "in" :: (-) rPoint is "out" the nose tip
1651  return Face;
1652 
1653  KRATOS_CATCH( "" )
1654  }
1655 
1656 
1657  //************************************************************************************
1658  //************************************************************************************
1659 
1660  void CalculateLineProjection(double& rFace, const PointType& rPoint, const PointType& rReferencePoint, const PointType& rCenterPoint, const PointType& rLinePoint )
1661  {
1662 
1663  PointType Line(3);
1664 
1665  PointType NormalLine(3);
1666 
1667  //rCenterPoint and rLinePoint define the line:
1668  Line[0] = (rLinePoint[0] - rCenterPoint[0]);
1669  Line[1] = (rLinePoint[1] - rCenterPoint[1]);
1670  Line[2] = 0;
1671  Line *= (1.0/norm_2(Line));
1672 
1673  //normal to the line
1674  NormalLine[0] = -Line[1];
1675  NormalLine[1] = Line[0];
1676  NormalLine[2] = 0;
1677 
1678  //compare the sense of the direction of Line1 and Line2
1679  PointType Line1(3);
1680  Line1[0] = (rReferencePoint[0] - rCenterPoint[0]);
1681  Line1[1] = (rReferencePoint[1] - rCenterPoint[1]);
1682  Line1[2] = 0;
1683  PointType Line2(3);
1684  Line2[0] = (rPoint[0] - rCenterPoint[0]);
1685  Line2[1] = (rPoint[1] - rCenterPoint[1]);
1686  Line2[2] = 0;
1687 
1688  //check the Projection with the Line
1689  double ReferenceDirection = inner_prod(Line1,NormalLine);
1690  double PointDirection = inner_prod(Line2,NormalLine);
1691 
1692  //the sign is evaluated (+) accepted and (-) rejected
1693  if( PointDirection != 0 ){
1694  rFace = PointDirection * ReferenceDirection;
1695  }
1696  else{
1697  std::cout<<" Critical point reached and accepted on a Face "<<std::endl;
1698  std::cout<<" LINE "<<rLinePoint<<" CENTER "<<rCenterPoint<<" REFERENCE "<<rReferencePoint<<" POINT "<<rPoint<<std::endl;
1699  rFace = +1;
1700  }
1701 
1702  }
1703 
1704 
1705  //************************************************************************************
1706  //************************************************************************************
1707 
1708 
1709  void CalculateAuxiliarFaces(double& rFace1, double& rFace2, double& rFace3, const PointType& rPoint, const double& rRadius, const BoxNoseVariables& rWallNose)
1710  {
1711  KRATOS_TRY
1712 
1713  double pi = 3.141592654;
1714 
1715  //-----------
1716 
1717  PointType RakePoint(3);
1718 
1719  RakePoint[0] = rWallNose.Center[0] - rRadius * sin(rWallNose.RakeAngle);
1720  RakePoint[1] = rWallNose.Center[1] + rRadius * cos(rWallNose.RakeAngle);
1721  RakePoint[2] = 0;
1722 
1723  PointType ClearancePoint(3);
1724 
1725  ClearancePoint[0] = rWallNose.Center[0] - rRadius * sin(rWallNose.ClearanceAngle);
1726  ClearancePoint[1] = rWallNose.Center[1] + rRadius * cos(rWallNose.ClearanceAngle);
1727  ClearancePoint[2] = 0;
1728 
1729  PointType TipPoint(3);
1730 
1731  TipPoint[0] = ( RakePoint[0] - rWallNose.Center[0] ) + ( ClearancePoint[0] - rWallNose.Center[0] );
1732  TipPoint[1] = ( RakePoint[1] - rWallNose.Center[1] ) + ( ClearancePoint[1] - rWallNose.Center[1] );
1733  TipPoint[2] = 0;
1734  TipPoint *= ( rRadius/norm_2(TipPoint) );
1735 
1736  //open angle to get the correct tip direction
1737  double OpenAngle = ( rWallNose.ClearanceAngle - rWallNose.RakeAngle ) * ( 180.0 / pi ) - 90;
1738 
1739  if( OpenAngle < 90 )
1740  TipPoint = rWallNose.Center + TipPoint;
1741  else
1742  TipPoint = rWallNose.Center - TipPoint;
1743 
1744  TipPoint[2] = 0;
1745 
1746  // std::cout<<" Center "<<rWallNose.Center<<" Radius "<<rRadius<<std::endl;
1747  // std::cout<<" RakePoint "<<RakePoint<<" x "<<-sin(rWallNose.RakeAngle)<<" y "<<cos(rWallNose.RakeAngle)<<std::endl;
1748  // std::cout<<" ClearancePoint "<<ClearancePoint<<" x "<<-sin(rWallNose.ClearanceAngle)<<" y "<<cos(rWallNose.ClearanceAngle)<<std::endl;
1749  // std::cout<<" TipPoint "<<TipPoint<<std::endl;
1750 
1751 
1752  //-----------
1753 
1754 
1755  //Center to RakePoint line (TipPoint:= NoseCenter) (rFace1)
1756 
1757  CalculateLineProjection(rFace1, rPoint, TipPoint, rWallNose.Center, RakePoint);
1758 
1759  //Face1 (+) rPoint is "in" the same part as the TipPoint :: (-) rPoint is "out" of the nose tip
1760 
1761 
1762  //-----------
1763 
1764 
1765  //Center to ClearancePoint line (TipPoint:= NoseCenter) (rFace2)
1766 
1767  CalculateLineProjection(rFace2, rPoint, TipPoint, rWallNose.Center, ClearancePoint);
1768 
1769  //Face2 (+) rPoint is "in" the same part as the TipPoint :: (-) rPoint is "out" of the same part of the ClearancePoint
1770 
1771 
1772 
1773  //-----------
1774 
1775  //Center to TipPoint line (ClearancePoint:= NoseCenter) (rFace3)
1776 
1777  CalculateLineProjection(rFace3, rPoint, ClearancePoint, rWallNose.Center, TipPoint);
1778 
1779  //Face3 (+) rPoint is "in" the same part as the ClearancePoint :: (-) rPoint is "in" the same part of the RakePoint
1780 
1781 
1782  KRATOS_CATCH( "" )
1783  }
1784 
1785 
1786  //************************************************************************************
1787  //************************************************************************************
1788 
1789  void GetRakePoint(const BoxNoseVariables& rWallNose, PointType& rRakePoint)
1790  {
1791  KRATOS_TRY
1792 
1793 
1794  rRakePoint[0] = rWallNose.Center[0] - rWallNose.Radius * sin(rWallNose.RakeAngle);
1795  rRakePoint[1] = rWallNose.Center[1] + rWallNose.Radius * cos(rWallNose.RakeAngle);
1796  rRakePoint[2] = 0;
1797 
1798 
1799  KRATOS_CATCH(" ")
1800  }
1801 
1802 
1803  //************************************************************************************
1804  //************************************************************************************
1805 
1806  void GetClearancePoint(const BoxNoseVariables& rWallNose, PointType& rClearancePoint)
1807  {
1808  KRATOS_TRY
1809 
1810  rClearancePoint[0] = rWallNose.Center[0] - rWallNose.Radius * sin(rWallNose.ClearanceAngle);
1811  rClearancePoint[1] = rWallNose.Center[1] + rWallNose.Radius * cos(rWallNose.ClearanceAngle);
1812  rClearancePoint[2] = 0;
1813 
1814  KRATOS_CATCH(" ")
1815  }
1816 
1817  //************************************************************************************
1818  //************************************************************************************
1819 
1820  void GetTipPoint(const BoxNoseVariables& rWallNose, PointType& rTipPoint)
1821  {
1822  KRATOS_TRY
1823 
1824  PointType RakePoint(3);
1825  PointType ClearancePoint(3);
1826 
1827  this->GetNosePoints(rWallNose, RakePoint, ClearancePoint, rTipPoint);
1828 
1829  KRATOS_CATCH(" ")
1830  }
1831 
1832  //************************************************************************************
1833  //************************************************************************************
1834 
1835 
1836  void GetNosePoints(const BoxNoseVariables& rWallNose, PointType& rRakePoint, PointType& rClearancePoint, PointType& rTipPoint )
1837  {
1838 
1839  KRATOS_TRY
1840 
1841  double pi = 3.141592654;
1842 
1843  //-----------
1844 
1845  this->GetRakePoint(rWallNose,rRakePoint);
1846 
1847  this->GetClearancePoint(rWallNose,rClearancePoint);
1848 
1849  rTipPoint = ( rRakePoint - rWallNose.Center ) + ( rClearancePoint - rWallNose.Center );
1850  rTipPoint[2] = 0; //2D
1851  rTipPoint *= ( rWallNose.Radius/norm_2(rTipPoint) );
1852 
1853  //open angle to get the correct tip direction
1854  double OpenAngle = ( rWallNose.ClearanceAngle - rWallNose.RakeAngle ) * ( 180.0 / pi ) - 90;
1855 
1856  if( OpenAngle < 90 )
1857  rTipPoint = rWallNose.Center + rTipPoint;
1858  else
1859  rTipPoint = rWallNose.Center - rTipPoint;
1860 
1861  rTipPoint[2] = 0; //2D
1862 
1863  KRATOS_CATCH(" ")
1864  }
1865 
1866 
1867  //************************************************************************************
1868  //************************************************************************************
1869 
1870  void GetRakeNormal(const BoxNoseVariables& rWallNose, PointType& rNormal)
1871  {
1872  KRATOS_TRY
1873 
1874  rNormal[0] = -sin(rWallNose.RakeAngle);
1875  rNormal[1] = cos(rWallNose.RakeAngle);
1876  rNormal[2] = 0;
1877 
1878  rNormal *= rWallNose.Convexity;
1879 
1880  KRATOS_CATCH(" ")
1881  }
1882 
1883 
1884  //************************************************************************************
1885  //************************************************************************************
1886 
1887  void GetClearanceNormal(const BoxNoseVariables& rWallNose, PointType& rNormal)
1888  {
1889  KRATOS_TRY
1890 
1891  rNormal[0] = -sin(rWallNose.ClearanceAngle);
1892  rNormal[1] = cos(rWallNose.ClearanceAngle);
1893  rNormal[2] = 0;
1894 
1895  rNormal *= rWallNose.Convexity;
1896 
1897  KRATOS_CATCH(" ")
1898  }
1899 
1900 
1901  //************************************************************************************
1902  //************************************************************************************
1903 
1904  void GetPlaneTangent(const PointType& rNormal, const PointType& rPoint, const PointType& rTipPoint, PointType& rTangent)
1905  {
1906  KRATOS_TRY
1907 
1908  rTangent = (rTipPoint-rPoint);
1909  rTangent -= inner_prod((rTipPoint-rPoint),rNormal) * rNormal;
1910 
1911  if( norm_2(rTangent) )
1912  rTangent *= (-1.0/norm_2(rTangent));
1913 
1914  KRATOS_CATCH(" ")
1915  }
1916 
1917 
1918  //************************************************************************************
1919  //************************************************************************************
1920 
1921 
1922  bool CalculateRakeSurface(const PointType& rPoint, double& rGapNormal, PointType& rNormal, const BoxNoseVariables& rWallNose)
1923  {
1924  KRATOS_TRY
1925 
1926  rNormal = ZeroVector(3);
1927 
1928  //1.-compute contact normal
1929  this->GetRakeNormal(rWallNose,rNormal);
1930 
1931  //2.-compute point projection
1932  PointType RakePoint(3);
1933 
1934  this->GetRakePoint(rWallNose,RakePoint);
1935 
1936  //3.-compute gap
1937  rGapNormal = inner_prod((rPoint - RakePoint), rNormal);
1938 
1939 
1940  if(rGapNormal<0)
1941  return true;
1942  else
1943  return false;
1944 
1945  KRATOS_CATCH( "" )
1946  }
1947 
1948  //************************************************************************************
1949  //************************************************************************************
1950 
1951  bool CalculateTipSurface(const PointType& rPoint, double& rGapNormal, PointType& rNormal, const BoxNoseVariables& rWallNose)
1952  {
1953  KRATOS_TRY
1954 
1955  rNormal = ZeroVector(3);
1956 
1957  //1.-compute point projection
1958  PointType Projection(3);
1959  Projection[0] = (rPoint[0]-rWallNose.Center[0]);
1960  Projection[1] = (rPoint[1]-rWallNose.Center[1]);
1961  Projection[2] = 0;
1962  if( norm_2(Projection) )
1963  Projection /= norm_2(Projection);
1964 
1965  Projection[0] = rWallNose.Radius * Projection[0] + rWallNose.Center[0];
1966  Projection[1] = rWallNose.Radius * Projection[1] + rWallNose.Center[1];
1967  Projection[2] = 0;
1968 
1969  //2.-compute contact normal
1970  rNormal[0] = (Projection[0]-rWallNose.Center[0])/rWallNose.Radius;
1971  rNormal[1] = (Projection[1]-rWallNose.Center[1])/rWallNose.Radius;
1972  rNormal[2] = 0;
1973 
1974  rNormal *= rWallNose.Convexity;
1975 
1976  //3.-compute gap
1977  PointType Distance(3);
1978  Distance[0] = rWallNose.Center[0]-rPoint[0];
1979  Distance[1] = rWallNose.Center[1]-rPoint[1];
1980  Distance[2] = 0;
1981 
1982  if( norm_2(Distance) <= rWallNose.Radius ){
1983  rGapNormal = (-1) * norm_2(rPoint - Projection);
1984  }
1985  else{
1986  rGapNormal = norm_2(Projection - rPoint);
1987  }
1988 
1989  rGapNormal *= rWallNose.Convexity;
1990 
1991  if(rGapNormal<0)
1992  return true;
1993  else
1994  return false;
1995 
1996 
1997  KRATOS_CATCH( "" )
1998  }
1999 
2000 
2001  //************************************************************************************
2002  //************************************************************************************
2003 
2004 
2005  bool CalculateClearanceSurface(const PointType& rPoint, double& rGapNormal, PointType& rNormal, const BoxNoseVariables& rWallNose)
2006  {
2007  KRATOS_TRY
2008 
2009  rNormal = ZeroVector(3);
2010 
2011  //1.-compute contact normal
2012  this->GetClearanceNormal(rWallNose,rNormal);
2013 
2014  //2.-compute point projection
2015  PointType ClearancePoint(3);
2016 
2017  this->GetClearancePoint(rWallNose,ClearancePoint);
2018 
2019  //3.-compute gap
2020  rGapNormal = inner_prod((rPoint - ClearancePoint), rNormal);
2021 
2022  if(rGapNormal<0)
2023  return true;
2024  else
2025  return false;
2026 
2027  KRATOS_CATCH( "" )
2028  }
2029 
2030 
2034 
2035 
2039 
2040 
2044 
2045 
2047 
2048 
2049 }; // Class CompoundNosesBoundingBox
2050 
2052 
2055 
2056 
2060 
2062 
2063 
2064 } // namespace Kratos.
2065 
2066 #endif // KRATOS_COMPOUND_NOSES_BOUNDING_BOX_H_INCLUDED defined
Definition: beam_math_utilities.hpp:31
static TVector3 & MapToCurrentLocalFrame(QuaternionType &rQuaternion, TVector3 &rVector)
Definition: beam_math_utilities.hpp:57
static TVector3 & MapToReferenceLocalFrame(QuaternionType &rQuaternion, TVector3 &rVector)
Definition: beam_math_utilities.hpp:88
Short class definition.
Definition: compound_noses_bounding_box.hpp:61
void CreateQuadrilateralBoundaryMesh(ModelPart &rModelPart, const unsigned int &rFirstInitialNodeId, const unsigned int &rSecondInitialNodeId)
Definition: compound_noses_bounding_box.hpp:942
ModelPart::ElementType ElementType
Definition: compound_noses_bounding_box.hpp:71
array_1d< double, 3 > PointType
Definition: compound_noses_bounding_box.hpp:65
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: compound_noses_bounding_box.hpp:821
void CreateBoundingBoxBoundaryMesh(ModelPart &rModelPart, int linear_partitions=4, int angular_partitions=4) override
Definition: compound_noses_bounding_box.hpp:543
CompoundNosesBoundingBox & operator=(CompoundNosesBoundingBox const &rOther)
Assignment operator.
Definition: compound_noses_bounding_box.hpp:296
void UpdateBoxPosition(const double &rCurrentTime) override
Definition: compound_noses_bounding_box.hpp:365
std::vector< BoxNoseVariables > mBoxNoses
Definition: compound_noses_bounding_box.hpp:842
CompoundNosesBoundingBox(CompoundNosesBoundingBox const &rOther)
Copy constructor.
Definition: compound_noses_bounding_box.hpp:307
std::string Info() const override
Turn back information as a string.
Definition: compound_noses_bounding_box.hpp:809
bool IsInside(BoundingBoxParameters &rValues, const ProcessInfo &rCurrentProcessInfo) override
Definition: compound_noses_bounding_box.hpp:467
virtual ~CompoundNosesBoundingBox()
Destructor.
Definition: compound_noses_bounding_box.hpp:317
NodesContainerType::Pointer NodesContainerTypePointer
Definition: compound_noses_bounding_box.hpp:68
KRATOS_CLASS_POINTER_DEFINITION(CompoundNosesBoundingBox)
Pointer definition of CompoundNosesBoundingBox.
CompoundNosesBoundingBox()
Default constructor.
Definition: compound_noses_bounding_box.hpp:137
ModelPart::NodesContainerType NodesContainerType
Definition: compound_noses_bounding_box.hpp:67
ModelPart::NodeType NodeType
Definition: compound_noses_bounding_box.hpp:66
double GetRadius(const PointType &rPoint) override
Definition: compound_noses_bounding_box.hpp:332
BeamMathUtils< double > BeamMathUtilsType
Definition: compound_noses_bounding_box.hpp:69
Quaternion< double > QuaternionType
Definition: compound_noses_bounding_box.hpp:70
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: compound_noses_bounding_box.hpp:815
CompoundNosesBoundingBox(Parameters CustomParameters)
Definition: compound_noses_bounding_box.hpp:149
ElementType::GeometryType GeometryType
Definition: compound_noses_bounding_box.hpp:72
bool IsInside(const PointType &rPoint, double &rCurrentTime, double Radius=0) override
Definition: compound_noses_bounding_box.hpp:387
PointType GetCenter(const PointType &rPoint) override
Definition: compound_noses_bounding_box.hpp:346
CompoundNosesBoundingBox(Vector Radius, Vector RakeAngles, Vector ClearanceAngles, Matrix Centers, Vector Convexities, Vector Velocity, Vector AngularVelocity, Vector UpperPoint, Vector LowerPoint, Matrix InitialLocalMatrix)
Definition: compound_noses_bounding_box.hpp:271
void CreateLinearBoundaryMesh(ModelPart &rModelPart, const unsigned int &rInitialNodeId)
Definition: compound_noses_bounding_box.hpp:856
Base class for all Elements.
Definition: element.h:60
Geometry base class.
Definition: geometry.h:71
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
SizeType WorkingSpaceDimension() const
Definition: mesh.h:237
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
SubModelPartIterator SubModelPartsEnd()
Definition: model_part.h:1708
SubModelPartIterator SubModelPartsBegin()
Definition: model_part.h:1698
void AddNode(NodeType::Pointer pNewNode, IndexType ThisIndex=0)
Definition: model_part.cpp:211
SizeType NumberOfProperties(IndexType ThisIndex=0) const
Returns the number of properties of the mesh.
Definition: model_part.cpp:575
bool IsSubModelPart() const
Definition: model_part.h:1893
SubModelPartsContainerType::iterator SubModelPartIterator
Iterator over the sub model parts of this model part.
Definition: model_part.h:258
ProcessInfo & GetProcessInfo()
Definition: model_part.h:1746
NodeType::Pointer pGetNode(IndexType NodeId, IndexType ThisIndex=0)
Definition: model_part.h:421
MeshType::NodesContainerType NodesContainerType
Nodes container. Which is a vector set of nodes with their Id's as key.
Definition: model_part.h:128
ModelPart & GetSubModelPart(std::string const &SubModelPartName)
Definition: model_part.cpp:2029
void AddElement(ElementType::Pointer pNewElement, IndexType ThisIndex=0)
Definition: model_part.cpp:917
ModelPart & GetParentModelPart()
Definition: model_part.cpp:2124
MeshType & GetMesh(IndexType ThisIndex=0)
Definition: model_part.h:1791
NodesContainerType & Nodes(IndexType ThisIndex=0)
Definition: model_part.h:507
This class defines the node.
Definition: node.h:65
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
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
PointerVector is a container like stl vector but using a vector to store pointers to its data.
Definition: pointer_vector.h:72
void reserve(size_type dim)
Definition: pointer_vector.h:319
void push_back(const TPointerType &x)
Definition: pointer_vector.h:270
ProcessInfo holds the current value of different solution parameters.
Definition: process_info.h:59
static Quaternion FromRotationMatrix(const TMatrix3x3 &m)
Definition: quaternion.h:475
void ToRotationMatrix(TMatrix3x3 &R) const
Definition: quaternion.h:213
void RotateVector3(const TVector3_A &a, TVector3_B &b) const
Definition: quaternion.h:325
static Quaternion FromRotationVector(double rx, double ry, double rz)
Definition: quaternion.h:427
Short class definition.
Definition: spatial_bounding_box.hpp:48
bool mRigidBodyCenterSupplied
Definition: spatial_bounding_box.hpp:1150
PointType GetBoxDisplacement(const double &rCurrentTime)
Definition: spatial_bounding_box.hpp:1181
void CalculateOrthonormalBase(PointType &rDirectionVectorX, PointType &rDirectionVectorY, PointType &rDirectionVectorZ)
Definition: spatial_bounding_box.hpp:1408
void ComputeContactTangent(BoundingBoxParameters &rValues, const ProcessInfo &rCurrentProcessInfo)
Definition: spatial_bounding_box.hpp:1274
NodeType::Pointer CreateNode(ModelPart &rModelPart, PointType &rPoint, const unsigned int &rNodeId)
Definition: spatial_bounding_box.hpp:1357
static unsigned int GetMaxNodeId(ModelPart &rModelPart)
Definition: spatial_bounding_box.hpp:1314
static unsigned int GetMaxElementId(ModelPart &rModelPart)
Definition: spatial_bounding_box.hpp:1334
BoundingBoxVariables mBox
Definition: spatial_bounding_box.hpp:1152
void MapToLocalFrame(QuaternionType &rQuaternion, BoundingBoxVariables &rBox)
Definition: spatial_bounding_box.hpp:1166
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
BOOST_UBLAS_INLINE void clear()
Definition: array_1d.h:325
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
static double max(double a, double b)
Definition: GeometryFunctions.h:79
static int sign(const double a)
Definition: GeometryFunctions.h:61
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
Internals::Matrix< double, AMatrix::dynamic, 1 > Vector
Definition: amatrix_interface.h:472
Internals::Matrix< double, AMatrix::dynamic, AMatrix::dynamic > Matrix
Definition: amatrix_interface.h:470
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
TABLE_NUMBER_ANGULAR_VELOCITY TABLE_NUMBER_MOMENT I33 BEAM_INERTIA_ROT_UNIT_LENGHT_Y KRATOS_DEFINE_APPLICATION_VARIABLE(DEM_APPLICATION, double, BEAM_INERTIA_ROT_UNIT_LENGHT_Z) typedef std double
Definition: DEM_application_variables.h:182
alpha
Definition: generate_convection_diffusion_explicit_element.py:113
int tol
Definition: hinsberg_optimization.py:138
int k
Definition: quadrature.py:595
int j
Definition: quadrature.py:648
int counter
Definition: script_THERMAL_CORRECT.py:218
integer i
Definition: TensorModule.f:17
double precision, public pi
Definition: TensorModule.f:16
e
Definition: run_cpp_mpi_tests.py:31
Definition: compound_noses_bounding_box.hpp:81
double TangentClearanceAngle
Definition: compound_noses_bounding_box.hpp:89
double TangentRakeAngle
Definition: compound_noses_bounding_box.hpp:88
PointType Center
Definition: compound_noses_bounding_box.hpp:92
void UpdatePosition(PointType &Displacement)
Definition: compound_noses_bounding_box.hpp:116
PointType InitialCenter
Definition: compound_noses_bounding_box.hpp:91
double ClearanceAngle
Definition: compound_noses_bounding_box.hpp:86
int Convexity
Definition: compound_noses_bounding_box.hpp:82
double Radius
Definition: compound_noses_bounding_box.hpp:84
void SetInitialValues()
Definition: compound_noses_bounding_box.hpp:111
double RakeAngle
Definition: compound_noses_bounding_box.hpp:85
void Initialize()
Definition: compound_noses_bounding_box.hpp:97
Definition: spatial_bounding_box.hpp:61
void SetContactFace(int ContactFace)
Definition: spatial_bounding_box.hpp:178
double & GetGapNormal()
Definition: spatial_bounding_box.hpp:193
const PointType & GetPoint()
Definition: spatial_bounding_box.hpp:181
PointType & GetNormal()
Definition: spatial_bounding_box.hpp:188
PointType AngularVelocity
Definition: spatial_bounding_box.hpp:222
QuaternionType InitialLocalQuaternion
Definition: spatial_bounding_box.hpp:224
void UpdatePosition(PointType &Displacement)
Definition: spatial_bounding_box.hpp:260
PointType Velocity
Definition: spatial_bounding_box.hpp:221
PointType LowerPoint
Definition: spatial_bounding_box.hpp:218
double Radius
Definition: spatial_bounding_box.hpp:211
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
Configure::PointType PointType
Definition: transfer_utility.h:245