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.
line_2d_2.h
Go to the documentation of this file.
1 // | / |
2 // ' / __| _` | __| _ \ __|
3 // . \ | ( | | ( |\__ `
4 // _|\_\_| \__,_|\__|\___/ ____/
5 // Multi-Physics
6 //
7 // License: BSD License
8 // Kratos default license: kratos/license.txt
9 //
10 // Main authors: Riccardo Rossi
11 // Janosch Stascheit
12 // Felix Nagel
13 // Contributors: Hoang Giang Bui
14 // Josep Maria Carbonell
15 // Vicente Mataix Ferrandiz
16 //
17 
18 #pragma once
19 
20 // System includes
21 
22 // External includes
23 
24 // Project includes
25 #include "geometries/geometry.h"
29 
30 namespace Kratos
31 {
32 
35 
39 
43 
47 
51 
62 template<class TPointType>
63 
64 class Line2D2 : public Geometry<TPointType>
65 {
66 public:
70 
74 
77 
80 
84 
89 
92  typedef TPointType PointType;
93 
98  typedef typename BaseType::IndexType IndexType;
99 
100 
105  typedef typename BaseType::SizeType SizeType;
106 
111 
117 
124 
130 
135 
140 
146 
152 
156 
161 
165 
166 
167 
168 // Line2D2( const PointType& FirstPoint, const PointType& SecondPoint )
169 // : BaseType( PointsArrayType(), &msGeometryData )
170 // {
171 // BaseType::Points().push_back( typename PointType::Pointer( new PointType( FirstPoint ) ) );
172 // BaseType::Points().push_back( typename PointType::Pointer( new PointType( SecondPoint ) ) );
173 // }
174 
175  Line2D2( typename PointType::Pointer pFirstPoint, typename PointType::Pointer pSecondPoint )
176  : BaseType( PointsArrayType(), &msGeometryData )
177  {
178  BaseType::Points().push_back( pFirstPoint );
179  BaseType::Points().push_back( pSecondPoint );
180  }
181 
182 
183  explicit Line2D2( const PointsArrayType& ThisPoints )
184  : BaseType( ThisPoints, &msGeometryData )
185  {
186  if ( BaseType::PointsNumber() != 2 )
187  KRATOS_ERROR << "Invalid points number. Expected 2, given " << BaseType::PointsNumber() << std::endl;
188  }
189 
191  explicit Line2D2(
192  const IndexType GeometryId,
193  const PointsArrayType& rThisPoints
194  ) : BaseType( GeometryId, rThisPoints, &msGeometryData)
195  {
196  KRATOS_ERROR_IF( this->PointsNumber() != 2 ) << "Invalid points number. Expected 2, given " << this->PointsNumber() << std::endl;
197  }
198 
200  explicit Line2D2(
201  const std::string& rGeometryName,
202  const PointsArrayType& rThisPoints
203  ) : BaseType(rGeometryName, rThisPoints, &msGeometryData)
204  {
205  KRATOS_ERROR_IF(this->PointsNumber() != 2) << "Invalid points number. Expected 2, given " << this->PointsNumber() << std::endl;
206  }
207 
216  Line2D2( Line2D2 const& rOther )
217  : BaseType( rOther )
218  {
219  }
220 
221 
233  template<class TOtherPointType> explicit Line2D2( Line2D2<TOtherPointType> const& rOther )
234  : BaseType( rOther )
235  {
236  }
237 
239  ~Line2D2() override {}
240 
242  {
244  }
245 
247  {
249  }
250 
254 
265  Line2D2& operator=( const Line2D2& rOther )
266  {
267  BaseType::operator=( rOther );
268 
269  return *this;
270  }
271 
282  template<class TOtherPointType>
284  {
285  BaseType::operator=( rOther );
286 
287  return *this;
288  }
289 
293 
300  typename BaseType::Pointer Create(
301  const IndexType NewGeometryId,
302  PointsArrayType const& rThisPoints
303  ) const override
304  {
305  return typename BaseType::Pointer( new Line2D2( NewGeometryId, rThisPoints ) );
306  }
307 
314  typename BaseType::Pointer Create(
315  const IndexType NewGeometryId,
316  const BaseType& rGeometry
317  ) const override
318  {
319  auto p_geometry = typename BaseType::Pointer( new Line2D2( NewGeometryId, rGeometry.Points() ) );
320  p_geometry->SetData(rGeometry.GetData());
321  return p_geometry;
322  }
323 
333  Vector& rResult,
334  const typename BaseType::LumpingMethods LumpingMethod = BaseType::LumpingMethods::ROW_SUM
335  ) const override
336  {
337  if(rResult.size() != 2)
338  rResult.resize( 2, false );
339 
340  rResult[0] = 0.5;
341  rResult[1] = 0.5;
342  return rResult;
343  }
344 
348 
361  double Length() const override
362  {
363  const TPointType& FirstPoint = BaseType::GetPoint(0);
364  const TPointType& SecondPoint = BaseType::GetPoint(1);
365  const double lx = FirstPoint.X() - SecondPoint.X();
366  const double ly = FirstPoint.Y() - SecondPoint.Y();
367 
368  const double length = lx * lx + ly * ly;
369 
370  return std::sqrt( length );
371  }
372 
384  double Area() const override
385  {
386  return Length();
387  }
388 
389 
400  double DomainSize() const override
401  {
402  return Length();
403  }
404 
408 
423  JacobiansType& Jacobian( JacobiansType& rResult, IntegrationMethod ThisMethod ) const override
424  {
425  Matrix jacobian( 2, 1 );
426  jacobian( 0, 0 ) = ( BaseType::GetPoint( 1 ).X() - BaseType::GetPoint( 0 ).X() ) * 0.5; //on the Gauss points (J is constant at each element)
427  jacobian( 1, 0 ) = ( BaseType::GetPoint( 1 ).Y() - BaseType::GetPoint( 0 ).Y() ) * 0.5;
428 
429  if ( rResult.size() != BaseType::IntegrationPointsNumber( ThisMethod ) )
430  {
431  // KLUDGE: While there is a bug in ublas vector resize, I have to put this beside resizing!!
433  rResult.swap( temp );
434  }
435 
436  std::fill( rResult.begin(), rResult.end(), jacobian );
437 
438  return rResult;
439  }
440 
458  JacobiansType& Jacobian( JacobiansType& rResult, IntegrationMethod ThisMethod, Matrix & DeltaPosition ) const override
459  {
460  Matrix jacobian( 2, 1 );
461  jacobian( 0, 0 ) = ( (BaseType::GetPoint( 1 ).X() - DeltaPosition(1,0)) - (BaseType::GetPoint( 0 ).X() - DeltaPosition(0,0)) ) * 0.5; //on the Gauss points (J is constant at each element)
462  jacobian( 1, 0 ) = ( (BaseType::GetPoint( 1 ).Y() - DeltaPosition(1,1)) - (BaseType::GetPoint( 0 ).Y() - DeltaPosition(0,1)) ) * 0.5;
463 
464  if ( rResult.size() != BaseType::IntegrationPointsNumber( ThisMethod ) )
465  {
466  // KLUDGE: While there is a bug in ublas vector resize, I have to put this beside resizing!!
468  rResult.swap( temp );
469  }
470 
471  std::fill( rResult.begin(), rResult.end(), jacobian );
472 
473  return rResult;
474  }
475 
493  Matrix& Jacobian( Matrix& rResult, IndexType IntegrationPointIndex, IntegrationMethod ThisMethod ) const override
494  {
495  rResult.resize( 2, 1, false );
496  //on the Gauss points (J is constant at each element)
497  rResult( 0, 0 ) = ( BaseType::GetPoint( 1 ).X() - BaseType::GetPoint( 0 ).X() ) * 0.5;
498  rResult( 1, 0 ) = ( BaseType::GetPoint( 1 ).Y() - BaseType::GetPoint( 0 ).Y() ) * 0.5;
499  return rResult;
500  }
501 
513  Matrix& Jacobian( Matrix& rResult, const CoordinatesArrayType& rPoint ) const override
514  {
515  rResult.resize( 2, 1, false );
516  //on the Gauss points (J is constant at each element)
517  rResult( 0, 0 ) = ( BaseType::GetPoint( 1 ).X() - BaseType::GetPoint( 0 ).X() ) * 0.5;
518  rResult( 1, 0 ) = ( BaseType::GetPoint( 1 ).Y() - BaseType::GetPoint( 0 ).Y() ) * 0.5;
519  return rResult;
520  }
521 
533  Vector& DeterminantOfJacobian( Vector& rResult, IntegrationMethod ThisMethod ) const override
534  {
535  const unsigned int integration_points_number = msGeometryData.IntegrationPointsNumber( ThisMethod );
536  if(rResult.size() != integration_points_number)
537  {
538  rResult.resize(integration_points_number,false);
539  }
540 
541  const double detJ = 0.5*(this->Length());
542 
543  for ( unsigned int pnt = 0; pnt < integration_points_number; pnt++ )
544  {
545  rResult[pnt] = detJ;
546  }
547  return rResult;
548  }
549 
568  double DeterminantOfJacobian( IndexType IntegrationPointIndex, IntegrationMethod ThisMethod ) const override
569  {
570  return 0.5*(this->Length());
571  }
572 
585  double DeterminantOfJacobian( const CoordinatesArrayType& rPoint ) const override
586  {
587  return 0.5*(this->Length());
588  }
589 
590 
605  JacobiansType& InverseOfJacobian( JacobiansType& rResult, IntegrationMethod ThisMethod ) const override
606  {
607  rResult[0] = ZeroMatrix( 1, 1 );
608  rResult[0]( 0, 0 ) = 2.0 * MathUtils<double>::Norm3(( this->GetPoint( 1 ) ) - ( this->GetPoint( 0 ) ) );
609  return rResult;
610  }
611 
629  Matrix& InverseOfJacobian( Matrix& rResult, IndexType IntegrationPointIndex, IntegrationMethod ThisMethod ) const override
630  {
631  rResult = ZeroMatrix( 1, 1 );
632  rResult( 0, 0 ) = 2.0 * MathUtils<double>::Norm3(( this->GetPoint( 1 ) ) - ( this->GetPoint( 0 ) ) );
633  return( rResult );
634  }
635 
647  Matrix& InverseOfJacobian( Matrix& rResult, const CoordinatesArrayType& rPoint ) const override
648  {
649  rResult = ZeroMatrix( 1, 1 );
650  rResult( 0, 0 ) = 2.0 * MathUtils<double>::Norm3(( this->GetPoint( 1 ) ) - ( this->GetPoint( 0 ) ) );
651  return rResult;
652  }
653 
657 
669  SizeType EdgesNumber() const override
670  {
671  return 1;
672  }
673 
683  {
685  edges.push_back( Kratos::make_shared<EdgeType>( this->pGetPoint( 0 ), this->pGetPoint( 1 ) ) );
686  return edges;
687  }
688 
692 
700  SizeType FacesNumber() const override
701  {
702  return 0;
703  }
704 
705  //Connectivities of faces required
707  {
708  if(NumberNodesInFaces.size() != 2 )
709  NumberNodesInFaces.resize(2,false);
710 
711  // Lines have 1 node in edges/faces
712  NumberNodesInFaces[0]=1;
713  NumberNodesInFaces[1]=1;
714 
715  }
716 
718  {
719  // faces in columns
720  if(NodesInFaces.size1() != 2 || NodesInFaces.size2() != 2)
721  NodesInFaces.resize(2,2,false);
722 
723  //face 1
724  NodesInFaces(0,0)=0;//contrary node to the face
725  NodesInFaces(1,0)=1;
726 
727  //face 2
728  NodesInFaces(0,1)=1;//contrary node to the face
729  NodesInFaces(1,1)=0;
730  }
731 
735 
744  Vector& ShapeFunctionsValues (Vector &rResult, const CoordinatesArrayType& rCoordinates) const override
745  {
746  if(rResult.size() != 2)
747  {
748  rResult.resize(2, false);
749  }
750 
751  rResult[0] = 0.5 * ( 1.0 - rCoordinates[0]);
752  rResult[1] = 0.5 * ( 1.0 + rCoordinates[0]);
753 
754  return rResult;
755  }
756 
766  double ShapeFunctionValue( IndexType ShapeFunctionIndex,
767  const CoordinatesArrayType& rPoint ) const override
768  {
769  switch ( ShapeFunctionIndex )
770  {
771  case 0:
772  return( 0.5 * ( 1.0 - rPoint[0] ) );
773  case 1:
774  return( 0.5 * ( 1.0 + rPoint[0] ) );
775  default:
776  KRATOS_ERROR << "Wrong index of shape function!" << *this << std::endl;
777  }
778 
779  return 0;
780  }
781 
785 
792  std::string Info() const override
793  {
794  return "1 dimensional line in 2D space";
795  }
796 
803  void PrintInfo( std::ostream& rOStream ) const override
804  {
805  rOStream << "1 dimensional line in 2D space";
806  }
807 
816  void PrintData( std::ostream& rOStream ) const override
817  {
818  // Base Geometry class PrintData call
819  BaseType::PrintData( rOStream );
820  std::cout << std::endl;
821 
822  // If the geometry has valid points, calculate and output its data
823  if (this->AllPointsAreValid()) {
824  Matrix jacobian;
825  this->Jacobian( jacobian, PointType() );
826  rOStream << " Jacobian\t : " << jacobian;
827  }
828  }
829 
835  {
836  IntegrationMethod ThisMethod = msGeometryData.DefaultIntegrationMethod();
837  ShapeFunctionsGradientsType localGradients
838  = CalculateShapeFunctionsIntegrationPointsLocalGradients( ThisMethod );
839  const int integration_points_number
840  = msGeometryData.IntegrationPointsNumber( ThisMethod );
841  ShapeFunctionsGradientsType Result( integration_points_number );
842 
843  for ( int pnt = 0; pnt < integration_points_number; pnt++ )
844  {
845  Result[pnt] = localGradients[pnt];
846  }
847 
848  return Result;
849  }
850 
851 
861  const CoordinatesArrayType& rPoint ) const override
862  {
863  // Setting up result matrix
864  if(rResult.size1() != 2 || rResult.size2() != 1)
865  {
866  rResult.resize( 2, 1, false );
867  }
868  noalias( rResult ) = ZeroMatrix( 2, 1 );
869  rResult( 0, 0 ) = - 0.5;
870  rResult( 1, 0 ) = 0.5;
871 
872  return( rResult );
873  }
874 
880  array_1d<double, 3> Normal(const CoordinatesArrayType& rPointLocalCoordinates) const override
881  {
882  // We define the normal
883  array_1d<double,3> normal;
884 
885  // We get the local points
886  const TPointType& first_point = BaseType::GetPoint(0);
887  const TPointType& second_point = BaseType::GetPoint(1);
888 
889  // We compute the normal
890  normal[0] = second_point[1] - first_point[1];
891  normal[1] = first_point[0] - second_point[0];
892  normal[2] = 0.0;
893 
894  return normal;
895  }
896 
902  Matrix& PointsLocalCoordinates( Matrix& rResult ) const override
903  {
904  if(rResult.size1() != 2 || rResult.size2() != 1)
905  {
906  rResult.resize( 2, 1, false );
907  }
908  noalias( rResult ) = ZeroMatrix( 2, 1 );
909  rResult( 0, 0 ) = -1.0;
910  rResult( 1, 0 ) = 1.0;
911  return rResult;
912  }
913 
923  {
924  if(rResult.size1() != 2 || rResult.size2() != 1)
925  {
926  rResult.resize( 2, 1, false );
927  }
928  noalias( rResult ) = ZeroMatrix( 2, 1 );
929 
930  rResult( 0, 0 ) = - 0.5;
931  rResult( 1, 0 ) = 0.5;
932  return rResult;
933  }
934 
943  bool IsInside(
944  const CoordinatesArrayType& rPoint,
945  CoordinatesArrayType& rResult,
946  const double Tolerance = std::numeric_limits<double>::epsilon()
947  ) const override
948  {
949  // We compute the distance, if it is not in the plane we project
950  const Point point_to_project(rPoint);
951  Point point_projected;
952  const double distance = GeometricalProjectionUtilities::FastProjectOnLine2D(*this, point_to_project, point_projected);
953 
954  // We check if we are on the plane
955  if (std::abs(distance) > std::numeric_limits<double>::epsilon()) {
956  if (std::abs(distance) > 1.0e-6 * Length()) {
957  KRATOS_WARNING_FIRST_N("Line2D2", 10) << "The point of coordinates X: " << rPoint[0] << "\tY: " << rPoint[1] << " it is in a distance: " << std::abs(distance) << std::endl;
958  return false;
959  }
960  }
961 
962  PointLocalCoordinates( rResult, point_projected );
963 
964  if ( std::abs( rResult[0] ) <= (1.0 + Tolerance) ) {
965  return true;
966  }
967 
968  return false;
969  }
970 
977  bool HasIntersection(const BaseType& rOtherGeometry) const override
978  {
979  const double tolerance = std::numeric_limits<double>::epsilon();
980  // We get the local points
981  const TPointType& first_point = BaseType::GetPoint(0); //p1
982  const TPointType& second_point = BaseType::GetPoint(1); //p2
983 
984  // We get the other line's points
985  const TPointType& first_point_other = *rOtherGeometry(0); //p3
986  const TPointType& second_point_other = *rOtherGeometry(1); //p4
987 
988  // parametric coordinate of intersection on current line
989  const double numerator = ( (first_point[0]-first_point_other[0])*(first_point_other[1] - second_point_other[1]) - (first_point[1]-first_point_other[1])*(first_point_other[0]-second_point_other[0]) );
990  const double denominator = ( (first_point[0]-second_point[0])*(first_point_other[1] - second_point_other[1]) - (first_point[1]-second_point[1])*(first_point_other[0]-second_point_other[0]) );
991  if (std::abs(denominator) < tolerance) // this means parallel lines.
992  return false;
993  const double t = numerator / denominator;
994 
995  return (0.0-tolerance<=t) && (t<=1.0+tolerance);
996  }
997 
1006  bool HasIntersection(const Point& rLowPoint, const Point& rHighPoint) const override
1007  {
1008  const double tolerance = std::numeric_limits<double>::epsilon();
1009  // We get the local points
1010  const TPointType& first_point = BaseType::GetPoint(0);
1011  const TPointType& second_point = BaseType::GetPoint(1);
1012 
1013  if ( // If one of the point is inside the box then there is an intersection. If none is inside then we check further.
1014  ( (first_point[0] >= rLowPoint[0] && first_point[0] <= rHighPoint[0])
1015  && (first_point[1] >= rLowPoint[1] && first_point[1] <= rHighPoint[1]) ) // IF the first point is inside the box
1016  ||
1017  ( (second_point[0] >= rLowPoint[0] && second_point[0] <= rHighPoint[0])
1018  && (second_point[1] >= rLowPoint[1] && second_point[1] <= rHighPoint[1]) ) // IF the second point is inside the box
1019  )
1020  return true;
1021 
1022  const double high_x = rHighPoint[0];
1023  const double high_y = rHighPoint[1];
1024  const double low_x = rLowPoint[0];
1025  const double low_y = rLowPoint[1];
1026 
1027  const double denominator = ( second_point[0] - first_point[0] );
1028  const double numerator = (second_point[1] - first_point[1]);
1029  const double slope = std::abs(denominator) > tolerance ? std::abs(numerator) > tolerance ? numerator / denominator : 1.0e-12 : 1.0e12;
1030 
1031  // Intersection with left vertical line of the box that is x = low_x
1032  const double y_1 = slope*( low_x - first_point[0] ) + first_point[1];
1033  if(y_1 >= low_y - tolerance && y_1 <= high_y+tolerance) // If y intersection is between two y bounds there is an intersection
1034  return true;
1035  // Intersection with right vertical line of the box that is x = high_x
1036  const double y_2 = slope*( high_x - first_point[0] ) + first_point[1];
1037  if(y_2 >= low_y - tolerance && y_2 <= high_y+tolerance) // If y intersection is between two y bounds there is an intersection
1038  return true;
1039  // Intersection with bottom horizontal line of the box that is y = low_y
1040  const double x_1 = first_point[0] + ( (low_y - first_point[1]) / slope );
1041  if(x_1 >= low_x-tolerance && x_1 <= high_x+tolerance) // If x intersection is between two x bounds there is an intersection
1042  return true;
1043  // Intersection with top horizontal line of the box that is y = high_y
1044  const double x_2 = first_point[0] + ( (high_y - first_point[1]) / slope );
1045  if(x_2 >= low_x-tolerance && x_2 <= high_x+tolerance) // If x intersection is between two x bounds there is an intersection
1046  return true;
1047 
1048 
1049  return false;
1050  }
1051 
1052 
1060  CoordinatesArrayType& rResult,
1061  const CoordinatesArrayType& rPoint
1062  ) const override
1063  {
1064  rResult.clear();
1065 
1066  const TPointType& r_first_point = BaseType::GetPoint(0);
1067  const TPointType& r_second_point = BaseType::GetPoint(1);
1068 
1069  // Project point
1070  const double tolerance = 1e-14; // Tolerance
1071 
1072  const double length = Length();
1073 
1074  const double length_1 = std::sqrt( std::pow(rPoint[0] - r_first_point[0], 2)
1075  + std::pow(rPoint[1] - r_first_point[1], 2));
1076 
1077  const double length_2 = std::sqrt( std::pow(rPoint[0] - r_second_point[0], 2)
1078  + std::pow(rPoint[1] - r_second_point[1], 2));
1079 
1080  if (length_1 <= (length + tolerance) && length_2 <= (length + tolerance)) {
1081  rResult[0] = 2.0 * length_1/(length + tolerance) - 1.0;
1082  } else {
1083  if (length_1 > length_2) {
1084  rResult[0] = 2.0 * length_1/(length + tolerance) - 1.0;
1085  } else {
1086  rResult[0] = -2.0 * length_1/(length + tolerance) - 1.0;
1087  }
1088  }
1089 
1090  return rResult ;
1091  }
1092 
1096 
1126  KRATOS_DEPRECATED_MESSAGE("This method is deprecated. Use either \'ProjectionPointLocalToLocalSpace\' or \'ProjectionPointGlobalToLocalSpace\' instead.")
1128  const CoordinatesArrayType& rPointGlobalCoordinates,
1129  CoordinatesArrayType& rProjectedPointGlobalCoordinates,
1130  CoordinatesArrayType& rProjectedPointLocalCoordinates,
1131  const double Tolerance = std::numeric_limits<double>::epsilon()
1132  ) const override
1133  {
1134  KRATOS_WARNING("ProjectionPoint") << "This method is deprecated. Use either \'ProjectionPointLocalToLocalSpace\' or \'ProjectionPointGlobalToLocalSpace\' instead." << std::endl;
1135 
1136  ProjectionPointGlobalToLocalSpace(rPointGlobalCoordinates, rProjectedPointLocalCoordinates, Tolerance);
1137 
1138  this->GlobalCoordinates(rProjectedPointGlobalCoordinates, rProjectedPointLocalCoordinates);
1139 
1140  return 1;
1141  }
1142 
1144  const CoordinatesArrayType& rPointLocalCoordinates,
1145  CoordinatesArrayType& rProjectionPointLocalCoordinates,
1146  const double Tolerance = std::numeric_limits<double>::epsilon()
1147  ) const override
1148  {
1149  // Calculate the input point global coordinates
1150  CoordinatesArrayType pt_gl_coords;
1151  this->GlobalCoordinates(pt_gl_coords, rPointLocalCoordinates);
1152 
1153  // Calculate the projection point local coordinates
1154  return this->ProjectionPointGlobalToLocalSpace(pt_gl_coords, rProjectionPointLocalCoordinates, Tolerance);
1155  }
1156 
1158  const CoordinatesArrayType& rPointGlobalCoordinates,
1159  CoordinatesArrayType& rProjectionPointLocalCoordinates,
1160  const double Tolerance = std::numeric_limits<double>::epsilon()
1161  ) const override
1162  {
1163  // Calculate the projection point global coordinates from the input point global coordinates
1164  CoordinatesArrayType proj_pt_gl_coords;
1165  GeometricalProjectionUtilities::FastProjectOnLine2D(*this, rPointGlobalCoordinates, proj_pt_gl_coords);
1166 
1167  // Calculate the projection point of interest local coordinates
1168  // Note that rProjectionPointLocalCoordinates is used as initial guess
1169  PointLocalCoordinates( rProjectionPointLocalCoordinates, proj_pt_gl_coords );
1170 
1171  return 1;
1172  }
1173 
1177 
1179 protected:
1182 
1183 
1187 
1188 
1192 
1193 
1197 
1198 
1202 
1203 
1207 
1208 
1212 
1213 
1215 
1216 private:
1219 
1220  static const GeometryData msGeometryData;
1221 
1222  static const GeometryDimension msGeometryDimension;
1223 
1227 
1231 
1232  friend class Serializer;
1233 
1234  void save( Serializer& rSerializer ) const override
1235  {
1237  }
1238 
1239  void load( Serializer& rSerializer ) override
1240  {
1242  }
1243 
1244  Line2D2(): BaseType( PointsArrayType(), &msGeometryData ) {}
1245 
1249 
1250 
1254 
1255  static Matrix CalculateShapeFunctionsIntegrationPointsValues( typename BaseType::IntegrationMethod ThisMethod )
1256  {
1257  const IntegrationPointsContainerType& all_integration_points = AllIntegrationPoints();
1258  const IntegrationPointsArrayType& IntegrationPoints = all_integration_points[static_cast<int>(ThisMethod)];
1259  int integration_points_number = IntegrationPoints.size();
1260  Matrix N( integration_points_number, 2 );
1261 
1262  for ( int it_gp = 0; it_gp < integration_points_number; it_gp++ )
1263  {
1264  double e = IntegrationPoints[it_gp].X();
1265  N( it_gp, 0 ) = 0.5 * ( 1 - e );
1266  N( it_gp, 1 ) = 0.5 * ( 1 + e );
1267  }
1268 
1269  return N;
1270  }
1271 
1272  static ShapeFunctionsGradientsType CalculateShapeFunctionsIntegrationPointsLocalGradients( typename BaseType::IntegrationMethod ThisMethod )
1273  {
1274  const IntegrationPointsContainerType& all_integration_points = AllIntegrationPoints();
1275  const IntegrationPointsArrayType& IntegrationPoints = all_integration_points[static_cast<int>(ThisMethod)];
1277 
1278  for ( unsigned int it_gp = 0; it_gp < IntegrationPoints.size(); it_gp++ )
1279  {
1280  Matrix aux_mat = ZeroMatrix(2, 1);
1281  aux_mat(0, 0) = -0.5;
1282  aux_mat(1, 0) = 0.5;
1283  DN_De[it_gp] = aux_mat;
1284  }
1285 
1286  return DN_De;
1287 
1288  }
1289 
1290  static const IntegrationPointsContainerType AllIntegrationPoints()
1291  {
1292  IntegrationPointsContainerType integration_points = {{
1293  Quadrature<LineGaussLegendreIntegrationPoints1, 1, IntegrationPoint<3> >::GenerateIntegrationPoints(),
1294  Quadrature<LineGaussLegendreIntegrationPoints2, 1, IntegrationPoint<3> >::GenerateIntegrationPoints(),
1295  Quadrature<LineGaussLegendreIntegrationPoints3, 1, IntegrationPoint<3> >::GenerateIntegrationPoints(),
1296  Quadrature<LineGaussLegendreIntegrationPoints4, 1, IntegrationPoint<3> >::GenerateIntegrationPoints(),
1297  Quadrature<LineGaussLegendreIntegrationPoints5, 1, IntegrationPoint<3> >::GenerateIntegrationPoints(),
1298  Quadrature<LineCollocationIntegrationPoints1, 1, IntegrationPoint<3> >::GenerateIntegrationPoints(),
1299  Quadrature<LineCollocationIntegrationPoints2, 1, IntegrationPoint<3> >::GenerateIntegrationPoints(),
1300  Quadrature<LineCollocationIntegrationPoints3, 1, IntegrationPoint<3> >::GenerateIntegrationPoints(),
1301  Quadrature<LineCollocationIntegrationPoints4, 1, IntegrationPoint<3> >::GenerateIntegrationPoints(),
1302  Quadrature<LineCollocationIntegrationPoints5, 1, IntegrationPoint<3> >::GenerateIntegrationPoints()
1303  }
1304  };
1305  return integration_points;
1306  }
1307 
1308  static const ShapeFunctionsValuesContainerType AllShapeFunctionsValues()
1309  {
1310  ShapeFunctionsValuesContainerType shape_functions_values = {{
1311  Line2D2<TPointType>::CalculateShapeFunctionsIntegrationPointsValues( GeometryData::IntegrationMethod::GI_GAUSS_1 ),
1312  Line2D2<TPointType>::CalculateShapeFunctionsIntegrationPointsValues( GeometryData::IntegrationMethod::GI_GAUSS_2 ),
1313  Line2D2<TPointType>::CalculateShapeFunctionsIntegrationPointsValues( GeometryData::IntegrationMethod::GI_GAUSS_3 ),
1314  Line2D2<TPointType>::CalculateShapeFunctionsIntegrationPointsValues( GeometryData::IntegrationMethod::GI_GAUSS_4 ),
1315  Line2D2<TPointType>::CalculateShapeFunctionsIntegrationPointsValues( GeometryData::IntegrationMethod::GI_GAUSS_5 ),
1316  Line2D2<TPointType>::CalculateShapeFunctionsIntegrationPointsValues( GeometryData::IntegrationMethod::GI_EXTENDED_GAUSS_1 ),
1317  Line2D2<TPointType>::CalculateShapeFunctionsIntegrationPointsValues( GeometryData::IntegrationMethod::GI_EXTENDED_GAUSS_2 ),
1318  Line2D2<TPointType>::CalculateShapeFunctionsIntegrationPointsValues( GeometryData::IntegrationMethod::GI_EXTENDED_GAUSS_3 ),
1319  Line2D2<TPointType>::CalculateShapeFunctionsIntegrationPointsValues( GeometryData::IntegrationMethod::GI_EXTENDED_GAUSS_4 ),
1320  Line2D2<TPointType>::CalculateShapeFunctionsIntegrationPointsValues( GeometryData::IntegrationMethod::GI_EXTENDED_GAUSS_5 )
1321  }
1322  };
1323  return shape_functions_values;
1324  }
1325 
1326  static const ShapeFunctionsLocalGradientsContainerType AllShapeFunctionsLocalGradients()
1327  {
1328  ShapeFunctionsLocalGradientsContainerType shape_functions_local_gradients = {{
1329  Line2D2<TPointType>::CalculateShapeFunctionsIntegrationPointsLocalGradients( GeometryData::IntegrationMethod::GI_GAUSS_1 ),
1330  Line2D2<TPointType>::CalculateShapeFunctionsIntegrationPointsLocalGradients( GeometryData::IntegrationMethod::GI_GAUSS_2 ),
1331  Line2D2<TPointType>::CalculateShapeFunctionsIntegrationPointsLocalGradients( GeometryData::IntegrationMethod::GI_GAUSS_3 ),
1332  Line2D2<TPointType>::CalculateShapeFunctionsIntegrationPointsLocalGradients( GeometryData::IntegrationMethod::GI_GAUSS_4 ),
1333  Line2D2<TPointType>::CalculateShapeFunctionsIntegrationPointsLocalGradients( GeometryData::IntegrationMethod::GI_GAUSS_5 ),
1334  Line2D2<TPointType>::CalculateShapeFunctionsIntegrationPointsLocalGradients( GeometryData::IntegrationMethod::GI_EXTENDED_GAUSS_1 ),
1335  Line2D2<TPointType>::CalculateShapeFunctionsIntegrationPointsLocalGradients( GeometryData::IntegrationMethod::GI_EXTENDED_GAUSS_2 ),
1336  Line2D2<TPointType>::CalculateShapeFunctionsIntegrationPointsLocalGradients( GeometryData::IntegrationMethod::GI_EXTENDED_GAUSS_3 ),
1337  Line2D2<TPointType>::CalculateShapeFunctionsIntegrationPointsLocalGradients( GeometryData::IntegrationMethod::GI_EXTENDED_GAUSS_4 ),
1338  Line2D2<TPointType>::CalculateShapeFunctionsIntegrationPointsLocalGradients( GeometryData::IntegrationMethod::GI_EXTENDED_GAUSS_5 )
1339  }
1340  };
1341  return shape_functions_local_gradients;
1342  }
1343 
1347 
1348 
1352 
1353 
1357 
1358  template<class TOtherPointType> friend class Line2D2;
1359 
1363 
1364 
1365 
1367 
1368 }; // Class Geometry
1369 
1371 
1374 
1375 
1379 
1380 
1382 template<class TPointType>
1383 inline std::istream& operator >> ( std::istream& rIStream,
1384  Line2D2<TPointType>& rThis );
1385 
1387 template<class TPointType>
1388 inline std::ostream& operator << ( std::ostream& rOStream,
1389  const Line2D2<TPointType>& rThis )
1390 {
1391  rThis.PrintInfo( rOStream );
1392  rOStream << std::endl;
1393  rThis.PrintData( rOStream );
1394 
1395  return rOStream;
1396 }
1397 
1399 
1400 
1401 template<class TPointType>
1402 const GeometryData Line2D2<TPointType>::msGeometryData(
1405  Line2D2<TPointType>::AllIntegrationPoints(),
1406  Line2D2<TPointType>::AllShapeFunctionsValues(),
1407  AllShapeFunctionsLocalGradients() );
1408 
1409 template<class TPointType>
1410 const GeometryDimension Line2D2<TPointType>::msGeometryDimension(2, 1);
1411 
1412 } // namespace Kratos.
static double FastProjectOnLine2D(const TGeometryType &rGeometry, const TPointClass1 &rPointToProject, TPointClass2 &rPointProjected)
Project a point over a line (2D only)
Definition: geometrical_projection_utilities.h:267
Definition: geometry_data.h:60
KratosGeometryType
Definition: geometry_data.h:110
SizeType IntegrationPointsNumber() const
Definition: geometry_data.h:430
IntegrationMethod
Definition: geometry_data.h:76
KratosGeometryFamily
Definition: geometry_data.h:91
IntegrationMethod DefaultIntegrationMethod() const
Definition: geometry_data.h:425
Definition: geometry_dimension.h:42
Geometry base class.
Definition: geometry.h:71
SizeType PointsNumber() const
Definition: geometry.h:528
virtual void PrintData(std::ostream &rOStream) const
Print object's data.
Definition: geometry.h:3834
Geometry & operator=(const Geometry &rOther)
Definition: geometry.h:400
virtual CoordinatesArrayType & GlobalCoordinates(CoordinatesArrayType &rResult, CoordinatesArrayType const &LocalCoordinates) const
Definition: geometry.h:2377
std::vector< IntegrationPointType > IntegrationPointsArrayType
Definition: geometry.h:161
DataValueContainer & GetData()
Definition: geometry.h:591
KRATOS_DEPRECATED_MESSAGE("This is legacy version (use GenerateEdges instead)") virtual GeometriesArrayType Edges(void)
This method gives you all edges of this geometry.
Definition: geometry.h:2106
std::size_t SizeType
Definition: geometry.h:144
const TPointType::Pointer pGetPoint(const int Index) const
Definition: geometry.h:1790
std::size_t IndexType
Definition: geometry.h:137
std::array< Matrix, static_cast< int >GeometryData::IntegrationMethod::NumberOfIntegrationMethods)> ShapeFunctionsValuesContainerType
Definition: geometry.h:172
const PointsArrayType & Points() const
Definition: geometry.h:1768
bool AllPointsAreValid() const
Checks if the geometry points are valid Checks if the geometry points are valid from the pointer valu...
Definition: geometry.h:4093
std::array< IntegrationPointsArrayType, static_cast< int >GeometryData::IntegrationMethod::NumberOfIntegrationMethods)> IntegrationPointsContainerType
Definition: geometry.h:167
LumpingMethods
This defines the different methods to compute the lumping methods.
Definition: geometry.h:109
const IntegrationPointsArrayType & IntegrationPoints() const
Definition: geometry.h:2284
TPointType const & GetPoint(const int Index) const
Definition: geometry.h:1816
GeometryData::ShapeFunctionsLocalGradientsContainerType ShapeFunctionsLocalGradientsContainerType
Definition: geometry.h:177
SizeType IntegrationPointsNumber() const
Definition: geometry.h:2257
GeometryData::IntegrationMethod IntegrationMethod
Definition: geometry.h:122
Short class definition.
Definition: integration_point.h:52
Definition: amatrix_interface.h:41
void swap(Matrix &Other)
Definition: amatrix_interface.h:289
void resize(std::size_t NewSize1, std::size_t NewSize2, bool preserve=0)
Definition: amatrix_interface.h:224
iterator end()
Definition: amatrix_interface.h:243
iterator begin()
Definition: amatrix_interface.h:241
An two node 2D line geometry with linear shape functions.
Definition: line_2d_2.h:65
BaseType::IndexType IndexType
Definition: line_2d_2.h:98
double ShapeFunctionValue(IndexType ShapeFunctionIndex, const CoordinatesArrayType &rPoint) const override
This method gives value of given shape function evaluated in given point.
Definition: line_2d_2.h:766
GeometryData::KratosGeometryFamily GetGeometryFamily() const override
Definition: line_2d_2.h:241
Line2D2(const std::string &rGeometryName, const PointsArrayType &rThisPoints)
Constructor with Geometry Name.
Definition: line_2d_2.h:200
Matrix & InverseOfJacobian(Matrix &rResult, const CoordinatesArrayType &rPoint) const override
Definition: line_2d_2.h:647
double DomainSize() const override
Definition: line_2d_2.h:400
JacobiansType & Jacobian(JacobiansType &rResult, IntegrationMethod ThisMethod, Matrix &DeltaPosition) const override
Definition: line_2d_2.h:458
int ProjectionPoint(const CoordinatesArrayType &rPointGlobalCoordinates, CoordinatesArrayType &rProjectedPointGlobalCoordinates, CoordinatesArrayType &rProjectedPointLocalCoordinates, const double Tolerance=std::numeric_limits< double >::epsilon()) const override
Projects a certain point on the geometry, or finds the closest point, depending on the provided initi...
Definition: line_2d_2.h:1127
JacobiansType & Jacobian(JacobiansType &rResult, IntegrationMethod ThisMethod) const override
Definition: line_2d_2.h:423
double Length() const override
Definition: line_2d_2.h:361
Matrix & InverseOfJacobian(Matrix &rResult, IndexType IntegrationPointIndex, IntegrationMethod ThisMethod) const override
Definition: line_2d_2.h:629
void NodesInFaces(DenseMatrix< unsigned int > &NodesInFaces) const override
Definition: line_2d_2.h:717
BaseType::IntegrationPointsContainerType IntegrationPointsContainerType
Definition: line_2d_2.h:129
std::string Info() const override
Definition: line_2d_2.h:792
Vector & ShapeFunctionsValues(Vector &rResult, const CoordinatesArrayType &rCoordinates) const override
This method gives all non-zero shape functions values evaluated at the rCoordinates provided.
Definition: line_2d_2.h:744
SizeType FacesNumber() const override
Returns the number of faces of the current geometry.
Definition: line_2d_2.h:700
Line2D2(Line2D2< TOtherPointType > const &rOther)
Definition: line_2d_2.h:233
double Area() const override
Definition: line_2d_2.h:384
array_1d< double, 3 > Normal(const CoordinatesArrayType &rPointLocalCoordinates) const override
It returns a vector that is normal to its corresponding geometry in the given local point.
Definition: line_2d_2.h:880
BaseType::JacobiansType JacobiansType
Definition: line_2d_2.h:145
friend class Line2D2
Definition: line_2d_2.h:1358
virtual Matrix & ShapeFunctionsGradients(Matrix &rResult, CoordinatesArrayType &rPoint)
Definition: line_2d_2.h:922
~Line2D2() override
Destructor. Do nothing!!!
Definition: line_2d_2.h:239
Line2D2(typename PointType::Pointer pFirstPoint, typename PointType::Pointer pSecondPoint)
Definition: line_2d_2.h:175
double DeterminantOfJacobian(IndexType IntegrationPointIndex, IntegrationMethod ThisMethod) const override
Definition: line_2d_2.h:568
BaseType::GeometriesArrayType GeometriesArrayType
Definition: line_2d_2.h:88
BaseType::NormalType NormalType
Definition: line_2d_2.h:155
BaseType::IntegrationPointsArrayType IntegrationPointsArrayType
Definition: line_2d_2.h:123
Line2D2 & operator=(Line2D2< TOtherPointType > const &rOther)
Definition: line_2d_2.h:283
int ProjectionPointLocalToLocalSpace(const CoordinatesArrayType &rPointLocalCoordinates, CoordinatesArrayType &rProjectionPointLocalCoordinates, const double Tolerance=std::numeric_limits< double >::epsilon()) const override
Projects a point onto the geometry Projects a certain point on the geometry, or finds the closest poi...
Definition: line_2d_2.h:1143
Line2D2 & operator=(const Line2D2 &rOther)
Definition: line_2d_2.h:265
bool HasIntersection(const BaseType &rOtherGeometry) const override
Definition: line_2d_2.h:977
void NumberNodesInFaces(DenseVector< unsigned int > &NumberNodesInFaces) const override
Definition: line_2d_2.h:706
Line2D2(const IndexType GeometryId, const PointsArrayType &rThisPoints)
Constructor with Geometry Id.
Definition: line_2d_2.h:191
int ProjectionPointGlobalToLocalSpace(const CoordinatesArrayType &rPointGlobalCoordinates, CoordinatesArrayType &rProjectionPointLocalCoordinates, const double Tolerance=std::numeric_limits< double >::epsilon()) const override
Projects a point onto the geometry Projects a certain point on the geometry, or finds the closest poi...
Definition: line_2d_2.h:1157
BaseType::CoordinatesArrayType CoordinatesArrayType
Definition: line_2d_2.h:160
BaseType::IntegrationPointType IntegrationPointType
Definition: line_2d_2.h:116
BaseType::PointsArrayType PointsArrayType
Definition: line_2d_2.h:110
void PrintInfo(std::ostream &rOStream) const override
Definition: line_2d_2.h:803
BaseType::SizeType SizeType
Definition: line_2d_2.h:105
virtual ShapeFunctionsGradientsType ShapeFunctionsLocalGradients()
Definition: line_2d_2.h:834
Vector & LumpingFactors(Vector &rResult, const typename BaseType::LumpingMethods LumpingMethod=BaseType::LumpingMethods::ROW_SUM) const override
Lumping factors for the calculation of the lumped mass matrix.
Definition: line_2d_2.h:332
Matrix & ShapeFunctionsLocalGradients(Matrix &rResult, const CoordinatesArrayType &rPoint) const override
Definition: line_2d_2.h:860
CoordinatesArrayType & PointLocalCoordinates(CoordinatesArrayType &rResult, const CoordinatesArrayType &rPoint) const override
Returns the local coordinates of a given arbitrary point.
Definition: line_2d_2.h:1059
BaseType::ShapeFunctionsLocalGradientsContainerType ShapeFunctionsLocalGradientsContainerType
Definition: line_2d_2.h:139
double DeterminantOfJacobian(const CoordinatesArrayType &rPoint) const override
Definition: line_2d_2.h:585
GeometryData::IntegrationMethod IntegrationMethod
Definition: line_2d_2.h:83
Line2D2(Line2D2 const &rOther)
Definition: line_2d_2.h:216
Geometry< TPointType > BaseType
Geometry as base class.
Definition: line_2d_2.h:72
BaseType::Pointer Create(const IndexType NewGeometryId, const BaseType &rGeometry) const override
Creates a new geometry pointer.
Definition: line_2d_2.h:314
Matrix & Jacobian(Matrix &rResult, const CoordinatesArrayType &rPoint) const override
Definition: line_2d_2.h:513
JacobiansType & InverseOfJacobian(JacobiansType &rResult, IntegrationMethod ThisMethod) const override
Definition: line_2d_2.h:605
BaseType::Pointer Create(const IndexType NewGeometryId, PointsArrayType const &rThisPoints) const override
Creates a new geometry pointer.
Definition: line_2d_2.h:300
GeometriesArrayType GenerateEdges() const override
This method gives you all edges of this geometry.
Definition: line_2d_2.h:682
BaseType::ShapeFunctionsGradientsType ShapeFunctionsGradientsType
Definition: line_2d_2.h:151
bool IsInside(const CoordinatesArrayType &rPoint, CoordinatesArrayType &rResult, const double Tolerance=std::numeric_limits< double >::epsilon()) const override
Returns whether given arbitrary point is inside the Geometry and the respective local point for the g...
Definition: line_2d_2.h:943
bool HasIntersection(const Point &rLowPoint, const Point &rHighPoint) const override
Definition: line_2d_2.h:1006
Line2D2(const PointsArrayType &ThisPoints)
Definition: line_2d_2.h:183
KRATOS_CLASS_POINTER_DEFINITION(Line2D2)
Pointer definition of Line2D2.
TPointType PointType
Definition: line_2d_2.h:92
Matrix & PointsLocalCoordinates(Matrix &rResult) const override
Definition: line_2d_2.h:902
Line2D2< TPointType > EdgeType
Type of edge geometry.
Definition: line_2d_2.h:79
SizeType EdgesNumber() const override
This method gives you number of all edges of this geometry.
Definition: line_2d_2.h:669
BaseType::ShapeFunctionsValuesContainerType ShapeFunctionsValuesContainerType
Definition: line_2d_2.h:134
Vector & DeterminantOfJacobian(Vector &rResult, IntegrationMethod ThisMethod) const override
Definition: line_2d_2.h:533
Matrix & Jacobian(Matrix &rResult, IndexType IntegrationPointIndex, IntegrationMethod ThisMethod) const override
Definition: line_2d_2.h:493
void PrintData(std::ostream &rOStream) const override
Definition: line_2d_2.h:816
GeometryData::KratosGeometryType GetGeometryType() const override
Definition: line_2d_2.h:246
Various mathematical utilitiy functions.
Definition: math_utils.h:62
static double Norm3(const TVectorType &a)
Calculates the norm of vector "a" which is assumed to be of size 3.
Definition: math_utils.h:691
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 push_back(const TPointerType &x)
Definition: pointer_vector.h:270
The serialization consists in storing the state of an object into a storage format like data file or ...
Definition: serializer.h:123
Short class definition.
Definition: array_1d.h:61
BOOST_UBLAS_INLINE void clear()
Definition: array_1d.h:325
#define KRATOS_SERIALIZE_SAVE_BASE_CLASS(Serializer, BaseType)
Definition: define.h:812
#define KRATOS_SERIALIZE_LOAD_BASE_CLASS(Serializer, BaseType)
Definition: define.h:815
#define KRATOS_ERROR
Definition: exception.h:161
#define KRATOS_ERROR_IF(conditional)
Definition: exception.h:162
#define KRATOS_WARNING(label)
Definition: logger.h:265
#define KRATOS_WARNING_FIRST_N(label, logger_count)
Definition: logger.h:272
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
const GeometryData Line2D2< TPointType >::msGeometryData & msGeometryDimension(), Line2D2< TPointType >::AllShapeFunctionsValues(), AllShapeFunctionsLocalGradients()
Definition: brep_curve.h:483
KratosZeroMatrix< double > ZeroMatrix
Definition: amatrix_interface.h:559
Internals::Matrix< double, AMatrix::dynamic, AMatrix::dynamic > Matrix
Definition: amatrix_interface.h:470
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
const GeometryData BrepCurve< TContainerPointType, TContainerPointEmbeddedType >::msGeometryData & msGeometryDimension
Definition: brep_curve.h:483
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
REACTION_CHECK_STIFFNESS_FACTOR int
Definition: contact_structural_mechanics_application_variables.h:75
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
def load(f)
Definition: ode_solve.py:307
tuple const
Definition: ode_solve.py:403
int t
Definition: ode_solve.py:392
float temp
Definition: rotating_cone.py:85
N
Definition: sensitivityMatrix.py:29
namespace
Definition: array_1d.h:793
e
Definition: run_cpp_mpi_tests.py:31