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_5.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: Mohamed Nabi
11 //
12 //
13 // Contributors:
14 //
15 //
16 
17 #pragma once
18 
19 // System includes
20 
21 // External includes
22 
23 // Project includes
24 #include "geometries/geometry.h"
27 
28 namespace Kratos
29 {
30 
33 
37 
41 
45 
49 
60  template<class TPointType>
61  class Line2D5 : public Geometry<TPointType>
62  {
63  public:
67 
70 
73 
77 
82 
85  typedef TPointType PointType;
86 
91  typedef typename BaseType::IndexType IndexType;
92 
97  typedef typename BaseType::SizeType SizeType;
98 
103 
109 
116 
122 
127 
132 
138 
144 
148 
153 
157 
158  Line2D5(const PointType& Point01, const PointType& Point02, const PointType& Point03,
159  const PointType& Point04, const PointType& Point05)
160  : BaseType(PointsArrayType(), &msGeometryData)
161  {
162  BaseType::Points().push_back(typename PointType::Pointer(new PointType(Point01)));
163  BaseType::Points().push_back(typename PointType::Pointer(new PointType(Point02)));
164  BaseType::Points().push_back(typename PointType::Pointer(new PointType(Point03)));
165  BaseType::Points().push_back(typename PointType::Pointer(new PointType(Point04)));
166  BaseType::Points().push_back(typename PointType::Pointer(new PointType(Point05)));
167  }
168 
169  Line2D5(typename PointType::Pointer pPoint01, typename PointType::Pointer pPoint02,
170  typename PointType::Pointer pPoint03, typename PointType::Pointer pPoint04,
171  typename PointType::Pointer pPoint05) : BaseType(PointsArrayType(), &msGeometryData)
172  {
173  BaseType::Points().push_back(pPoint01);
174  BaseType::Points().push_back(pPoint02);
175  BaseType::Points().push_back(pPoint03);
176  BaseType::Points().push_back(pPoint04);
177  BaseType::Points().push_back(pPoint05);
178  }
179 
180  explicit Line2D5(const PointsArrayType& rThisPoints) : BaseType(rThisPoints, &msGeometryData)
181  {
182  KRATOS_ERROR_IF(BaseType::PointsNumber() != 5) << "Invalid points number. Expected 5, given "
183  << BaseType::PointsNumber() << std::endl;
184  }
185 
187  explicit Line2D5(const IndexType GeometryId, const PointsArrayType& rThisPoints)
188  : BaseType(GeometryId, rThisPoints, &msGeometryData)
189  {
190  KRATOS_ERROR_IF(this->PointsNumber() != 5) << "Invalid points number. Expected 5, given "
191  << this->PointsNumber() << std::endl;
192  }
193 
195  explicit Line2D5(const std::string& rGeometryName, const PointsArrayType& rThisPoints)
196  : BaseType(rGeometryName, rThisPoints, &msGeometryData)
197  {
198  KRATOS_ERROR_IF(this->PointsNumber() != 5) << "Invalid points number. Expected 5, given "
199  << this->PointsNumber() << std::endl;
200  }
201 
209  Line2D5(Line2D5 const& rOther) : BaseType(rOther)
210  {
211  }
212 
223  template<class TOtherPointType> explicit Line2D5(Line2D5<TOtherPointType> const& rOther)
224  : BaseType(rOther)
225  {
226  }
227 
229  ~Line2D5() override {}
230 
232  {
234  }
235 
237  {
239  }
240 
244 
253  Line2D5& operator=(const Line2D5& rOther)
254  {
255  BaseType::operator=(rOther);
256  return *this;
257  }
258 
267  template<class TOtherPointType>
269  {
270  BaseType::operator=(rOther);
271  return *this;
272  }
273 
277 
284  typename BaseType::Pointer Create(const IndexType NewGeometryId, PointsArrayType const& rThisPoints)
285  const override
286  {
287  return typename BaseType::Pointer(new Line2D5(NewGeometryId, rThisPoints));
288  }
289 
296  typename BaseType::Pointer Create(const IndexType NewGeometryId, const BaseType& rGeometry) const override
297  {
298  auto p_geometry = typename BaseType::Pointer(new Line2D5(NewGeometryId, rGeometry.Points()));
299  p_geometry->SetData(rGeometry.GetData());
300  return p_geometry;
301  }
302 
312  Vector& LumpingFactors(Vector& rResult, const typename BaseType::LumpingMethods LumpingMethod
313  = BaseType::LumpingMethods::ROW_SUM) const override
314  {
315  if (rResult.size() != 5) rResult.resize(5, false);
316  rResult[0] = 7.0 / 90.0;
317  rResult[1] = 7.0 / 90.0;
318  rResult[2] = 32.0 / 90.0;
319  rResult[3] = 12.0 / 90.0;
320  rResult[4] = 32.0 / 90.0;
321  return rResult;
322  }
323 
327 
338  double Length() const override
339  {
340  Vector temp;
342  this->DeterminantOfJacobian(temp, integration_method);
343  const IntegrationPointsArrayType& r_integration_points = this->IntegrationPoints(integration_method);
344  double length = 0.0;
345 
346  for (std::size_t i = 0; i < r_integration_points.size(); ++i) {
347  length += temp[i] * r_integration_points[i].Weight();
348  }
349 
350  return length;
351  }
352 
363  double Area() const override
364  {
365  return Length();
366  }
367 
378  double DomainSize() const override
379  {
380  return Length();
381  }
382 
391  bool IsInside(const CoordinatesArrayType& rPoint, CoordinatesArrayType& rResult,
392  const double Tolerance = std::numeric_limits<double>::epsilon()) const override
393  {
394  PointLocalCoordinates(rResult, rPoint);
395  if (std::abs(rResult[0]) <= (1.0 + Tolerance)) {
396  return true;
397  }
398  return false;
399  }
400 
408  const CoordinatesArrayType& rPoint) const override
409  {
412  for (IndexType i = 0; i < this->size(); ++i)
413  {
414  const auto& r_node = this->GetPoint(i);
415  X(0, i) = r_node.X();
416  X(1, i) = r_node.Y();
417  X(2, i) = r_node.Z();
418  }
419 
420  static constexpr double MaxNormPointLocalCoordinates = 300.0;
421  static constexpr std::size_t MaxIteratioNumberPointLocalCoordinates = 500;
422  static constexpr double MaxTolerancePointLocalCoordinates = 1.0e-8;
423 
424  Matrix J = ZeroMatrix(1, 1);
425  Matrix invJ = ZeroMatrix(1, 1);
426 
427  // Starting with xi = 0
428  if (rResult.size() != 3) rResult.resize(3, false);
429  noalias(rResult) = ZeroVector(3);
430  double delta_xi = 0.0;
431  const array_1d<double, 3> zero_array = ZeroVector(3);
432  array_1d<double, 3> current_global_coords;
434 
435  //Newton iteration:
436  for (IndexType k = 0; k < MaxIteratioNumberPointLocalCoordinates; ++k) {
437  noalias(current_global_coords) = zero_array;
438  this->GlobalCoordinates(current_global_coords, rResult);
439 
440  noalias(current_global_coords) = rPoint - current_global_coords;
441 
442  // Derivatives of shape functions
443  Matrix shape_functions_gradients;
444  shape_functions_gradients = ShapeFunctionsLocalGradients(shape_functions_gradients, rResult);
445  noalias(DN) = prod(X, shape_functions_gradients);
446  noalias(J) = prod(trans(DN), DN);
447  noalias(res) = prod(trans(DN), current_global_coords);
448 
449  // The inverted jacobian matrix
450  invJ(0, 0) = 1.0 / J(0, 0);
451 
452  delta_xi = invJ(0, 0) * res[0];
453 
454  rResult[0] += delta_xi;
455 
456  if (delta_xi > MaxNormPointLocalCoordinates) {
457  KRATOS_WARNING_IF("Line2D5", k > 0) << "detJ =\t" << J(0, 0) << " DeltaX =\t" << delta_xi << " stopping calculation. Iteration:\t" << k << std::endl;
458  break;
459  }
460 
461  if (delta_xi < MaxTolerancePointLocalCoordinates)
462  break;
463  }
464  return rResult;
465  }
466 
470 
485  JacobiansType& Jacobian(JacobiansType& rResult, IntegrationMethod ThisMethod) const override
486  {
487  // Getting derivatives of shape functions
488  const ShapeFunctionsGradientsType shape_functions_gradients
489  = CalculateShapeFunctionsIntegrationPointsLocalGradients(ThisMethod);
490  const std::size_t number_of_integration_points = this->IntegrationPointsNumber(ThisMethod);
491  if (rResult.size() != number_of_integration_points) {
492  JacobiansType temp(number_of_integration_points);
493  rResult.swap(temp);
494  }
495  // Loop over all integration points
496  for (std::size_t pnt = 0; pnt < number_of_integration_points; ++pnt) {
497  // Initializing jacobian matrix
498  noalias(rResult[pnt]) = ZeroMatrix(2, 1);
499  // Loop over all nodes
500  for (std::size_t i = 0; i < this->PointsNumber(); ++i) {
501  const auto& r_node = this->GetPoint(i);
502  rResult[pnt](0, 0) += r_node.X() * shape_functions_gradients[pnt](i, 0);
503  rResult[pnt](1, 0) += r_node.Y() * shape_functions_gradients[pnt](i, 0);
504  }
505  } // End of loop over all integration points
506  return rResult;
507  }
508 
527  Matrix& rDeltaPosition) const override
528  {
529  // Getting derivatives of shape functions
530  ShapeFunctionsGradientsType shape_functions_gradients
531  = CalculateShapeFunctionsIntegrationPointsLocalGradients(ThisMethod);
532  const std::size_t number_of_integration_points = this->IntegrationPointsNumber(ThisMethod);
533  // Getting values of shape functions
534  Matrix shape_functions_values = CalculateShapeFunctionsIntegrationPointsValues(ThisMethod);
535  if (rResult.size() != number_of_integration_points) {
536  JacobiansType temp(number_of_integration_points);
537  rResult.swap(temp);
538  }
539  // Loop over all integration points
540  for (std::size_t pnt = 0; pnt < number_of_integration_points; ++pnt) {
541  // Initializing jacobian matrix
542  noalias(rResult[pnt]) = ZeroMatrix(2, 1);
543  // Loop over all nodes
544  for (std::size_t i = 0; i < this->PointsNumber(); ++i) {
545  const auto& r_node = this->GetPoint(i);
546  rResult[pnt](0, 0) += (r_node.X() - rDeltaPosition(i, 0)) * shape_functions_gradients[pnt](i, 0);
547  rResult[pnt](1, 0) += (r_node.Y() - rDeltaPosition(i, 1)) * shape_functions_gradients[pnt](i, 0);
548  }
549  }// End of loop over all integration points
550  return rResult;
551  }
552 
569  Matrix& Jacobian(Matrix& rResult, IndexType IntegrationPointIndex, IntegrationMethod ThisMethod)
570  const override
571  {
572  // Setting up size of jacobian matrix
573  rResult.resize(2, 1, false);
574  noalias(rResult) = ZeroMatrix(2, 1);
575  // Derivatives of shape functions
576  ShapeFunctionsGradientsType shape_functions_gradients
577  = CalculateShapeFunctionsIntegrationPointsLocalGradients(ThisMethod);
578  Matrix shape_function_gradient_in_integration_point = shape_functions_gradients(IntegrationPointIndex);
579  // Values of shape functions in integration points
580  DenseVector<double> ShapeFunctionsValuesInIntegrationPoint = ZeroVector(3);
581  ShapeFunctionsValuesInIntegrationPoint = row(CalculateShapeFunctionsIntegrationPointsValues(ThisMethod), IntegrationPointIndex);
582  // Elements of jacobian matrix (e.g. J(1,1) = dX1/dXi1)
583  // Loop over all nodes
584  for (std::size_t i = 0; i < this->PointsNumber(); ++i) {
585  const auto& r_node = this->GetPoint(i);
586  rResult(0, 0) += r_node.X() * shape_function_gradient_in_integration_point(i, 0);
587  rResult(1, 0) += r_node.Y() * shape_function_gradient_in_integration_point(i, 0);
588  }
589  return rResult;
590  }
591 
599  Matrix& Jacobian(Matrix& rResult, const CoordinatesArrayType& rPoint) const override
600  {
601  // Setting up size of jacobian matrix
602  rResult.resize(2, 1, false);
603  noalias(rResult) = ZeroMatrix(2, 1);
604  // Derivatives of shape functions
605  Matrix shape_functions_gradients;
606  shape_functions_gradients = ShapeFunctionsLocalGradients(shape_functions_gradients, rPoint);
607  // Elements of jacobian matrix (e.g. J(1,1) = dX1/dXi1)
608  // Loop over all nodes
609  for (std::size_t i = 0; i < this->PointsNumber(); ++i) {
610  const auto& r_node = this->GetPoint(i);
611  rResult(0, 0) += r_node.X() * shape_functions_gradients(i, 0);
612  rResult(1, 0) += r_node.Y() * shape_functions_gradients(i, 0);
613  }
614  return rResult;
615  }
616 
624  Vector& DeterminantOfJacobian(Vector& rResult, IntegrationMethod ThisMethod) const override
625  {
626  const std::size_t number_of_integration_points = this->IntegrationPointsNumber(ThisMethod);
627  if (rResult.size() != number_of_integration_points)
628  rResult.resize(number_of_integration_points, false);
629  Matrix J(2, 1);
630  for (std::size_t pnt = 0; pnt < number_of_integration_points; ++pnt) {
631  this->Jacobian(J, pnt, ThisMethod);
632  rResult[pnt] = std::sqrt(std::pow(J(0, 0), 2) + std::pow(J(1, 0), 2));
633  }
634  return rResult;
635  }
636 
645  double DeterminantOfJacobian(IndexType IntegrationPointIndex, IntegrationMethod ThisMethod)
646  const override
647  {
648  Matrix J(2, 1);
649  this->Jacobian(J, IntegrationPointIndex, ThisMethod);
650  return std::sqrt(std::pow(J(0, 0), 2) + std::pow(J(1, 0), 2));
651  }
652 
660  double DeterminantOfJacobian(const CoordinatesArrayType& rPoint) const override
661  {
662  Matrix J(2, 1);
663  this->Jacobian(J, rPoint);
664  return std::sqrt(std::pow(J(0, 0), 2) + std::pow(J(1, 0), 2));
665  }
666 
670  SizeType EdgesNumber() const override
671  {
672  return 2;
673  }
674 
678  SizeType FacesNumber() const override
679  {
680  return EdgesNumber();
681  }
682 
686 
695  Vector& ShapeFunctionsValues(Vector& rResult, const CoordinatesArrayType& rCoordinates) const override
696  {
697  if (rResult.size() != 5) rResult.resize(5, false);
698  //
699  const double xi = rCoordinates[0];
700  const double fx1 = xi - 1.0;
701  const double fx2 = xi + 1.0;
702  const double fx3 = fx1 * fx2;
703  const double gx1 = 2.0 * xi - 1.0;
704  const double gx2 = 2.0 * xi + 1.0;
705  const double gx3 = gx1 * gx2;
706  const double cof1 = 1.0 / 6.0;
707  const double cof2 = 8.0 * cof1;
708  //
709  rResult[0] = xi * fx1 * gx3 * cof1;
710  rResult[1] = xi * fx2 * gx3 * cof1;
711  rResult[2] = -xi * fx3 * gx1 * cof2;
712  rResult[3] = fx3 * gx3;
713  rResult[4] = -xi * fx3 * gx2 * cof2;
714  //
715  return rResult;
716  }
717 
727  double ShapeFunctionValue(const IndexType ShapeFunctionIndex, const CoordinatesArrayType& rPoint) const override
728  {
729  const double xi = rPoint[0];
730  const double fx1 = xi - 1.0;
731  const double fx2 = xi + 1.0;
732  const double fx3 = fx1 * fx2;
733  const double gx1 = 2.0 * xi - 1.0;
734  const double gx2 = 2.0 * xi + 1.0;
735  const double gx3 = gx1 * gx2;
736  const double cof1 = 1.0 / 6.0;
737  const double cof2 = 8.0 * cof1;
738  double shape = 0.0;
739  //
740  switch (ShapeFunctionIndex)
741  {
742  case 0:
743  shape = xi * fx1 * gx3 * cof1;
744  break;
745  case 1:
746  shape = xi * fx2 * gx3 * cof1;
747  break;
748  case 2:
749  shape = -xi * fx3 * gx1 * cof2;
750  break;
751  case 3:
752  shape = fx3 * gx3;
753  break;
754  case 4:
755  shape = -xi * fx3 * gx2 * cof2;
756  break;
757  default:
758  KRATOS_ERROR << "Wrong index of shape function!" << *this << std::endl;
759  break;
760  }
761  //
762  return shape;
763  }
764 
768 
770  IntegrationMethod ThisMethod) const override
771  {
772  KRATOS_ERROR << "Jacobian is not square" << std::endl;
773  }
774 
776  Vector& rDeterminantsOfJacobian, IntegrationMethod ThisMethod) const override
777  {
778  KRATOS_ERROR << "Jacobian is not square" << std::endl;
779  }
780 
784 
791  std::string Info() const override
792  {
793  return "1 dimensional line with 5 nodes in 2D space";
794  }
795 
801  void PrintInfo(std::ostream& rOStream) const override
802  {
803  rOStream << "1 dimensional line with 5 nodes in 2D space";
804  }
805 
812  void PrintData( std::ostream& rOStream ) const override
813  {
814  // Base Geometry class PrintData call
815  BaseType::PrintData( rOStream );
816  std::cout << std::endl;
817 
818  // If the geometry has valid points, calculate and output its data
819  if (this->AllPointsAreValid()) {
820  Matrix jacobian;
821  this->Jacobian( jacobian, PointType() );
822  rOStream << " Jacobian\t : " << jacobian;
823  }
824  }
825 
829  {
830  ShapeFunctionsGradientsType localGradients
831  = CalculateShapeFunctionsIntegrationPointsLocalGradients(ThisMethod);
832  const int integration_points_number = msGeometryData.IntegrationPointsNumber(ThisMethod);
833  ShapeFunctionsGradientsType Result(integration_points_number);
834  //
835  for (int pnt = 0; pnt < integration_points_number; ++pnt)
836  {
837  Result[pnt] = localGradients[pnt];
838  }
839  return Result;
840  }
841 
846  {
847  IntegrationMethod ThisMethod = msGeometryData.DefaultIntegrationMethod();
848  ShapeFunctionsGradientsType localGradients
849  = CalculateShapeFunctionsIntegrationPointsLocalGradients(ThisMethod);
850  const int integration_points_number = msGeometryData.IntegrationPointsNumber(ThisMethod);
851  ShapeFunctionsGradientsType Result(integration_points_number);
852  //
853  for (int pnt = 0; pnt < integration_points_number; ++pnt)
854  {
855  Result[pnt] = localGradients[pnt];
856  }
857  return Result;
858  }
859 
868  Matrix& ShapeFunctionsLocalGradients(Matrix& rResult, const CoordinatesArrayType& rPoint) const override
869  {
870  // Setting up result matrix
871  if (rResult.size1() != 5 || rResult.size2() != 1) rResult.resize(5, 1, false);
872  noalias(rResult) = ZeroMatrix(5, 1);
873  //
874  const double xi = rPoint[0];
875  const double fx1 = xi - 1.0;
876  const double fx2 = xi + 1.0;
877  const double fx3 = fx1 * fx2;
878  const double gx1 = 2.0 * xi - 1.0;
879  const double gx2 = 2.0 * xi + 1.0;
880  const double gx3 = gx1 * gx2;
881  const double cof1 = 1.0 / 6.0;
882  const double cof2 = 8.0 * cof1;
883  //
884  rResult(0, 0) = gx3 * gx1 * cof1 + xi * xi * fx1 * cof2;
885  rResult(1, 0) = gx3 * gx2 * cof1 + xi * xi * fx2 * cof2;
886  rResult(2, 0) = -(gx1 * (gx3 - fx3 - 1.0) + 2.0 * xi * fx3) * cof2;
887  rResult(3, 0) = 2.0 * xi * (gx3 + 4.0 * fx3);
888  rResult(4, 0) = -(gx2 * (gx3 - fx3 - 1.0) + 2.0 * xi * fx3) * cof2;
889  return rResult;
890  }
891 
897  Matrix& PointsLocalCoordinates(Matrix& rResult) const override
898  {
899  if (rResult.size1() != 5 || rResult.size2() != 1) rResult.resize(5, 1, false);
900  noalias(rResult) = ZeroMatrix(5, 1);
901  //
902  rResult(0, 0) = -1.0;
903  rResult(1, 0) = 1.0;
904  rResult(2, 0) = -0.5;
905  rResult(3, 0) = 0.0;
906  rResult(4, 0) = 0.5;
907  //
908  return rResult;
909  }
910 
919  virtual Matrix& ShapeFunctionsGradients(Matrix& rResult, const CoordinatesArrayType& rPoint)
920  {
921  if (rResult.size1() != 5 || rResult.size2() != 1) rResult.resize(5, 1, false);
922  noalias(rResult) = ZeroMatrix(5, 1);
923  //
924  const double xi = rPoint[0];
925  const double fx1 = xi - 1.0;
926  const double fx2 = xi + 1.0;
927  const double fx3 = fx1 * fx2;
928  const double gx1 = 2.0 * xi - 1.0;
929  const double gx2 = 2.0 * xi + 1.0;
930  const double gx3 = gx1 * gx2;
931  const double cof1 = 1.0 / 6.0;
932  const double cof2 = 8.0 * cof1;
933  //
934  rResult(0, 0) = gx3 * gx1 * cof1 + xi * xi * fx1 * cof2;
935  rResult(1, 0) = gx3 * gx2 * cof1 + xi * xi * fx2 * cof2;
936  rResult(2, 0) = -(gx1 * (gx3 - fx3 - 1.0) + 2.0 * xi * fx3) * cof2;
937  rResult(3, 0) = 2.0 * xi * (gx3 + 4.0 * fx3);
938  rResult(4, 0) = -(gx2 * (gx3 - fx3 - 1.0) + 2.0 * xi * fx3) * cof2;
939  //
940  return rResult;
941  }
942 
946 
948 
949  protected:
952 
956 
960 
964 
968 
972 
976 
978 
979  private:
982 
983  static const GeometryData msGeometryData;
984 
985  static const GeometryDimension msGeometryDimension;
986 
990 
994 
995  friend class Serializer;
996 
997  void save(Serializer& rSerializer) const override
998  {
1000  }
1001 
1002  void load(Serializer& rSerializer) override
1003  {
1005  }
1006 
1007  Line2D5() : BaseType(PointsArrayType(), &msGeometryData) {}
1008 
1012 
1016 
1017  static Matrix CalculateShapeFunctionsIntegrationPointsValues(typename BaseType::IntegrationMethod ThisMethod)
1018  {
1019  const IntegrationPointsContainerType& all_integration_points = AllIntegrationPoints();
1020  const IntegrationPointsArrayType& IntegrationPoints = all_integration_points[static_cast<int>(ThisMethod)];
1021  const int integration_points_number = IntegrationPoints.size();
1022  Matrix shape_function_values(integration_points_number, 5);
1023  //
1024  const double cof1 = 1.0 / 6.0;
1025  const double cof2 = 8.0 * cof1;
1026  //
1027  for (int pnt = 0; pnt < integration_points_number; ++pnt)
1028  {
1029  const double xi = IntegrationPoints[pnt].X();
1030  const double fx1 = xi - 1.0;
1031  const double fx2 = xi + 1.0;
1032  const double fx3 = fx1 * fx2;
1033  const double gx1 = 2.0 * xi - 1.0;
1034  const double gx2 = 2.0 * xi + 1.0;
1035  const double gx3 = gx1 * gx2;
1036  //
1037  shape_function_values(pnt, 0) = xi * fx1 * gx3 * cof1;
1038  shape_function_values(pnt, 1) = xi * fx2 * gx3 * cof1;
1039  shape_function_values(pnt, 2) = -xi * fx3 * gx1 * cof2;
1040  shape_function_values(pnt, 3) = fx3 * gx3;
1041  shape_function_values(pnt, 4) = -xi * fx3 * gx2 * cof2;
1042  }
1043  return shape_function_values;
1044  }
1045 
1046  static ShapeFunctionsGradientsType CalculateShapeFunctionsIntegrationPointsLocalGradients(
1047  typename BaseType::IntegrationMethod ThisMethod)
1048  {
1049  const IntegrationPointsContainerType& all_integration_points = AllIntegrationPoints();
1050  const IntegrationPointsArrayType& IntegrationPoints = all_integration_points[static_cast<int>(ThisMethod)];
1052  std::fill(DN_De.begin(), DN_De.end(), Matrix(5, 1));
1053  //
1054  const double cof1 = 1.0 / 6.0;
1055  const double cof2 = 8.0 * cof1;
1056  //
1057  for (unsigned int pnt = 0; pnt < IntegrationPoints.size(); ++pnt)
1058  {
1059  const double xi = IntegrationPoints[pnt].X();
1060  const double fx1 = xi - 1.0;
1061  const double fx2 = xi + 1.0;
1062  const double fx3 = fx1 * fx2;
1063  const double gx1 = 2.0 * xi - 1.0;
1064  const double gx2 = 2.0 * xi + 1.0;
1065  const double gx3 = gx1 * gx2;
1066  //
1067  DN_De[pnt](0, 0) = gx3 * gx1 * cof1 + xi * xi * fx1 * cof2;
1068  DN_De[pnt](1, 0) = gx3 * gx2 * cof1 + xi * xi * fx2 * cof2;
1069  DN_De[pnt](2, 0) = -(gx1 * (gx3 - fx3 - 1.0) + 2.0 * xi * fx3) * cof2;
1070  DN_De[pnt](3, 0) = 2.0 * xi * (gx3 + 4.0 * fx3);
1071  DN_De[pnt](4, 0) = -(gx2 * (gx3 - fx3 - 1.0) + 2.0 * xi * fx3) * cof2;
1072  }
1073  return DN_De;
1074  }
1075 
1076  static const IntegrationPointsContainerType AllIntegrationPoints()
1077  {
1078  IntegrationPointsContainerType integration_points = {{
1079  Quadrature<LineGaussLegendreIntegrationPoints1, 1, IntegrationPoint<3> >::GenerateIntegrationPoints(),
1080  Quadrature<LineGaussLegendreIntegrationPoints2, 1, IntegrationPoint<3> >::GenerateIntegrationPoints(),
1081  Quadrature<LineGaussLegendreIntegrationPoints3, 1, IntegrationPoint<3> >::GenerateIntegrationPoints(),
1082  Quadrature<LineGaussLegendreIntegrationPoints4, 1, IntegrationPoint<3> >::GenerateIntegrationPoints(),
1083  Quadrature<LineGaussLegendreIntegrationPoints5, 1, IntegrationPoint<3> >::GenerateIntegrationPoints()
1084  }
1085  };
1086  return integration_points;
1087  }
1088 
1089  static const ShapeFunctionsValuesContainerType AllShapeFunctionsValues()
1090  {
1091  ShapeFunctionsValuesContainerType shape_functions_values = {{
1092  Line2D5<TPointType>::CalculateShapeFunctionsIntegrationPointsValues(GeometryData::IntegrationMethod::GI_GAUSS_1),
1093  Line2D5<TPointType>::CalculateShapeFunctionsIntegrationPointsValues(GeometryData::IntegrationMethod::GI_GAUSS_2),
1094  Line2D5<TPointType>::CalculateShapeFunctionsIntegrationPointsValues(GeometryData::IntegrationMethod::GI_GAUSS_3),
1095  Line2D5<TPointType>::CalculateShapeFunctionsIntegrationPointsValues(GeometryData::IntegrationMethod::GI_GAUSS_4),
1096  Line2D5<TPointType>::CalculateShapeFunctionsIntegrationPointsValues(GeometryData::IntegrationMethod::GI_GAUSS_5)
1097  }
1098  };
1099  return shape_functions_values;
1100  }
1101 
1102  static const ShapeFunctionsLocalGradientsContainerType AllShapeFunctionsLocalGradients()
1103  {
1104  ShapeFunctionsLocalGradientsContainerType shape_functions_local_gradients = {{
1105  Line2D5<TPointType>::CalculateShapeFunctionsIntegrationPointsLocalGradients(GeometryData::IntegrationMethod::GI_GAUSS_1),
1106  Line2D5<TPointType>::CalculateShapeFunctionsIntegrationPointsLocalGradients(GeometryData::IntegrationMethod::GI_GAUSS_2),
1107  Line2D5<TPointType>::CalculateShapeFunctionsIntegrationPointsLocalGradients(GeometryData::IntegrationMethod::GI_GAUSS_3),
1108  Line2D5<TPointType>::CalculateShapeFunctionsIntegrationPointsLocalGradients(GeometryData::IntegrationMethod::GI_GAUSS_4),
1109  Line2D5<TPointType>::CalculateShapeFunctionsIntegrationPointsLocalGradients(GeometryData::IntegrationMethod::GI_GAUSS_5)
1110  }
1111  };
1112  return shape_functions_local_gradients;
1113  }
1114 
1118 
1122 
1126 
1127  template<class TOtherPointType> friend class Line2D5;
1128 
1132 
1134 
1135  }; // Class Geometry
1136 
1138 
1141 
1145 
1147  template<class TPointType>
1148  inline std::istream& operator >> (std::istream& rIStream, Line2D5<TPointType>& rThis);
1149 
1151  template<class TPointType>
1152  inline std::ostream& operator << (std::ostream& rOStream, const Line2D5<TPointType>& rThis)
1153  {
1154  rThis.PrintInfo(rOStream);
1155  rOStream << std::endl;
1156  rThis.PrintData(rOStream);
1157  return rOStream;
1158  }
1159 
1161 
1162  template<class TPointType>
1163  const GeometryData Line2D5<TPointType>::msGeometryData(
1166  Line2D5<TPointType>::AllIntegrationPoints(),
1167  Line2D5<TPointType>::AllShapeFunctionsValues(),
1168  AllShapeFunctionsLocalGradients());
1169 
1170  template<class TPointType>
1171  const GeometryDimension Line2D5<TPointType>::msGeometryDimension(2, 1);
1172 
1173 } // namespace Kratos.
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
SizeType size() const
Definition: geometry.h:518
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
std::size_t SizeType
Definition: geometry.h:144
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
static GeometryData::IntegrationMethod GetIntegrationMethodForExactMassMatrixEvaluation(const Geometry< TPointType > &rGeometry)
This method returns the integration order for the exact mass matrix evaluation.
Definition: integration_utilities.h:42
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
An five node 2D line geometry with quartic shape functions.
Definition: line_2d_5.h:62
double DeterminantOfJacobian(IndexType IntegrationPointIndex, IntegrationMethod ThisMethod) const override
Determinant of jacobian in specific integration point of given integration method....
Definition: line_2d_5.h:645
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_5.h:312
BaseType::PointsArrayType PointsArrayType
Definition: line_2d_5.h:102
TPointType PointType
Definition: line_2d_5.h:85
Line2D5 & operator=(const Line2D5 &rOther)
Definition: line_2d_5.h:253
BaseType::ShapeFunctionsGradientsType ShapeFunctionsGradientsType
Definition: line_2d_5.h:143
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_5.h:391
virtual ShapeFunctionsGradientsType ShapeFunctionsLocalGradients(IntegrationMethod &ThisMethod)
Definition: line_2d_5.h:828
Line2D5(const PointType &Point01, const PointType &Point02, const PointType &Point03, const PointType &Point04, const PointType &Point05)
Definition: line_2d_5.h:158
BaseType::ShapeFunctionsLocalGradientsContainerType ShapeFunctionsLocalGradientsContainerType
Definition: line_2d_5.h:131
void ShapeFunctionsIntegrationPointsGradients(ShapeFunctionsGradientsType &rResult, Vector &rDeterminantsOfJacobian, IntegrationMethod ThisMethod) const override
Definition: line_2d_5.h:775
Matrix & ShapeFunctionsLocalGradients(Matrix &rResult, const CoordinatesArrayType &rPoint) const override
Definition: line_2d_5.h:868
Vector & DeterminantOfJacobian(Vector &rResult, IntegrationMethod ThisMethod) const override
Determinant of jacobians for given integration method.
Definition: line_2d_5.h:624
Geometry< TPointType > BaseType
Geometry as base class.
Definition: line_2d_5.h:69
double Length() const override
Definition: line_2d_5.h:338
BaseType::NormalType NormalType
Definition: line_2d_5.h:147
friend class Line2D5
Definition: line_2d_5.h:1127
KRATOS_CLASS_POINTER_DEFINITION(Line2D5)
Pointer definition of Line2D5.
JacobiansType & Jacobian(JacobiansType &rResult, IntegrationMethod ThisMethod) const override
Definition: line_2d_5.h:485
BaseType::IntegrationPointsContainerType IntegrationPointsContainerType
Definition: line_2d_5.h:121
Line2D5 & operator=(Line2D5< TOtherPointType > const &rOther)
Definition: line_2d_5.h:268
double DeterminantOfJacobian(const CoordinatesArrayType &rPoint) const override
Determinant of jacobian in given point. This method calculate determinant of jacobian matrix in given...
Definition: line_2d_5.h:660
Line2D5(Line2D5< TOtherPointType > const &rOther)
Definition: line_2d_5.h:223
Line2D5(Line2D5 const &rOther)
Definition: line_2d_5.h:209
double DomainSize() const override
Definition: line_2d_5.h:378
BaseType::JacobiansType JacobiansType
Definition: line_2d_5.h:137
Matrix & Jacobian(Matrix &rResult, const CoordinatesArrayType &rPoint) const override
Definition: line_2d_5.h:599
double ShapeFunctionValue(const IndexType ShapeFunctionIndex, const CoordinatesArrayType &rPoint) const override
This method gives value of given shape function evaluated in given point.
Definition: line_2d_5.h:727
Line2D5(const IndexType GeometryId, const PointsArrayType &rThisPoints)
Constructor with Geometry Id.
Definition: line_2d_5.h:187
BaseType::ShapeFunctionsValuesContainerType ShapeFunctionsValuesContainerType
Definition: line_2d_5.h:126
virtual ShapeFunctionsGradientsType ShapeFunctionsLocalGradients()
Definition: line_2d_5.h:845
BaseType::IndexType IndexType
Definition: line_2d_5.h:91
void PrintData(std::ostream &rOStream) const override
Definition: line_2d_5.h:812
Matrix & PointsLocalCoordinates(Matrix &rResult) const override
Definition: line_2d_5.h:897
GeometryData::KratosGeometryType GetGeometryType() const override
Definition: line_2d_5.h:236
BaseType::IntegrationPointsArrayType IntegrationPointsArrayType
Definition: line_2d_5.h:115
BaseType::Pointer Create(const IndexType NewGeometryId, const BaseType &rGeometry) const override
Creates a new geometry pointer.
Definition: line_2d_5.h:296
BaseType::GeometriesArrayType GeometriesArrayType
Definition: line_2d_5.h:81
void PrintInfo(std::ostream &rOStream) const override
Definition: line_2d_5.h:801
BaseType::CoordinatesArrayType CoordinatesArrayType
Definition: line_2d_5.h:152
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_5.h:695
CoordinatesArrayType & PointLocalCoordinates(CoordinatesArrayType &rResult, const CoordinatesArrayType &rPoint) const override
Returns the local coordinates of a given arbitrary point.
Definition: line_2d_5.h:407
GeometryData::IntegrationMethod IntegrationMethod
Definition: line_2d_5.h:76
BaseType::SizeType SizeType
Definition: line_2d_5.h:97
JacobiansType & Jacobian(JacobiansType &rResult, IntegrationMethod ThisMethod, Matrix &rDeltaPosition) const override
Definition: line_2d_5.h:526
SizeType EdgesNumber() const override
Definition: line_2d_5.h:670
BaseType::IntegrationPointType IntegrationPointType
Definition: line_2d_5.h:108
BaseType::Pointer Create(const IndexType NewGeometryId, PointsArrayType const &rThisPoints) const override
Creates a new geometry pointer.
Definition: line_2d_5.h:284
double Area() const override
Definition: line_2d_5.h:363
std::string Info() const override
Definition: line_2d_5.h:791
void ShapeFunctionsIntegrationPointsGradients(ShapeFunctionsGradientsType &rResult, IntegrationMethod ThisMethod) const override
Definition: line_2d_5.h:769
Line2D5(const PointsArrayType &rThisPoints)
Definition: line_2d_5.h:180
~Line2D5() override
Destructor. Do nothing!!!
Definition: line_2d_5.h:229
virtual Matrix & ShapeFunctionsGradients(Matrix &rResult, const CoordinatesArrayType &rPoint)
Definition: line_2d_5.h:919
Line2D5(const std::string &rGeometryName, const PointsArrayType &rThisPoints)
Constructor with Geometry Name.
Definition: line_2d_5.h:195
GeometryData::KratosGeometryFamily GetGeometryFamily() const override
Definition: line_2d_5.h:231
Matrix & Jacobian(Matrix &rResult, IndexType IntegrationPointIndex, IntegrationMethod ThisMethod) const override
Definition: line_2d_5.h:569
SizeType FacesNumber() const override
Definition: line_2d_5.h:678
Line2D5(typename PointType::Pointer pPoint01, typename PointType::Pointer pPoint02, typename PointType::Pointer pPoint03, typename PointType::Pointer pPoint04, typename PointType::Pointer pPoint05)
Definition: line_2d_5.h:169
This class defines the node.
Definition: node.h:65
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 resize(size_type array_size, bool preserve=true)
Definition: array_1d.h:242
BOOST_UBLAS_INLINE size_type size() const
Definition: array_1d.h:370
#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_IF(label, conditional)
Definition: logger.h:266
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
KratosZeroVector< double > ZeroVector
Definition: amatrix_interface.h:561
const GeometryData Line2D5< TPointType >::msGeometryData & msGeometryDimension(), Line2D5< 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
AMatrix::MatrixProductExpression< TExpression1Type, TExpression2Type > prod(AMatrix::MatrixExpression< TExpression1Type, TCategory1 > const &First, AMatrix::MatrixExpression< TExpression2Type, TCategory2 > const &Second)
Definition: amatrix_interface.h:568
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
AMatrix::MatrixRow< const TExpressionType > row(AMatrix::MatrixExpression< TExpressionType, TCategory > const &TheExpression, std::size_t RowIndex)
Definition: amatrix_interface.h:649
AMatrix::TransposeMatrix< const T > trans(const T &TheMatrix)
Definition: amatrix_interface.h:486
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
res
Definition: generate_convection_diffusion_explicit_element.py:211
DN
Definition: generate_convection_diffusion_explicit_element.py:98
def load(f)
Definition: ode_solve.py:307
int k
Definition: quadrature.py:595
float temp
Definition: rotating_cone.py:85
J
Definition: sensitivityMatrix.py:58
integer i
Definition: TensorModule.f:17