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.
prism_interface_3d_6.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: Ignasi de Pouplana
11 //
12 
13 #if !defined(KRATOS_PRISM_INTERFACE_3D_6_H_INCLUDED )
14 #define KRATOS_PRISM_INTERFACE_3D_6_H_INCLUDED
15 
16 // System includes
17 
18 // External includes
19 
20 // Project includes
24 
25 namespace Kratos
26 {
29 
33 
37 
41 
45 
52 template<class TPointType> class PrismInterface3D6
53  : public Geometry<TPointType>
54 {
55 public:
59 
64 
71 
76 
81 
87 
91  typedef TPointType PointType;
92 
99  typedef typename BaseType::IndexType IndexType;
100 
106  typedef typename BaseType::SizeType SizeType;
107 
113 
118 
124 
133 
140 
146 
152 
159 
166 
174 
182 
187 
191 
192 // PrismInterface3D6( const PointType& Point1, const PointType& Point2,
193 // const PointType& Point3, const PointType& Point4,
194 // const PointType& Point5, const PointType& Point6 )
195 // : BaseType( PointsArrayType(), &msGeometryData )
196 // {
197 // this->Points().reserve( 6 );
198 // this->Points().push_back( typename PointType::Pointer( new PointType( Point1 ) ) );
199 // this->Points().push_back( typename PointType::Pointer( new PointType( Point2 ) ) );
200 // this->Points().push_back( typename PointType::Pointer( new PointType( Point3 ) ) );
201 // this->Points().push_back( typename PointType::Pointer( new PointType( Point4 ) ) );
202 // this->Points().push_back( typename PointType::Pointer( new PointType( Point5 ) ) );
203 // this->Points().push_back( typename PointType::Pointer( new PointType( Point6 ) ) );
204 // }
205 
206  PrismInterface3D6( typename PointType::Pointer pPoint1,
207  typename PointType::Pointer pPoint2,
208  typename PointType::Pointer pPoint3,
209  typename PointType::Pointer pPoint4,
210  typename PointType::Pointer pPoint5,
211  typename PointType::Pointer pPoint6 )
212  : BaseType( PointsArrayType(), &msGeometryData )
213  {
214  this->Points().reserve( 6 );
215  this->Points().push_back( pPoint1 );
216  this->Points().push_back( pPoint2 );
217  this->Points().push_back( pPoint3 );
218  this->Points().push_back( pPoint4 );
219  this->Points().push_back( pPoint5 );
220  this->Points().push_back( pPoint6 );
221  }
222 
223  PrismInterface3D6( const PointsArrayType& ThisPoints )
224  : BaseType( ThisPoints, &msGeometryData )
225  {
226  if ( this->PointsNumber() != 6 )
227  KRATOS_ERROR << "Invalid points number. Expected 6, given " << this->PointsNumber() << std::endl;
228  }
229 
240  : BaseType( rOther )
241  {
242  }
243 
256  template<class TOtherPointType> PrismInterface3D6( PrismInterface3D6<TOtherPointType> const& rOther )
257  : BaseType( rOther )
258  {
259  }
260 
264  virtual ~PrismInterface3D6() {}
265 
267  {
269  }
270 
272  {
274  }
275 
279 
292  {
293  BaseType::operator=( rOther );
294  return *this;
295  }
296 
308  template<class TOtherPointType>
310  {
311  BaseType::operator=( rOther );
312  return *this;
313  }
314 
318 
319  typename BaseType::Pointer Create( PointsArrayType const& ThisPoints ) const override
320  {
321  return typename BaseType::Pointer( new PrismInterface3D6( ThisPoints ) );
322  }
323 
329  Matrix& PointsLocalCoordinates( Matrix& rResult ) const override
330  {
331  if ( rResult.size1() != 6 || rResult.size2() != 3 )
332  rResult.resize( 6, 3, false );
333 
334  rResult( 0, 0 ) = 0.0;
335  rResult( 0, 1 ) = 0.0;
336  rResult( 0, 2 ) = 0.0;
337 
338  rResult( 1, 0 ) = 1.0;
339  rResult( 1, 1 ) = 0.0;
340  rResult( 1, 2 ) = 0.0;
341 
342  rResult( 2, 0 ) = 0.0;
343  rResult( 2, 1 ) = 1.0;
344  rResult( 2, 2 ) = 0.0;
345 
346  rResult( 3, 0 ) = 0.0;
347  rResult( 3, 1 ) = 0.0;
348  rResult( 3, 2 ) = 1.0;
349 
350  rResult( 4, 0 ) = 1.0;
351  rResult( 4, 1 ) = 0.0;
352  rResult( 4, 2 ) = 1.0;
353 
354  rResult( 5, 0 ) = 0.0;
355  rResult( 5, 1 ) = 1.0;
356  rResult( 5, 2 ) = 1.0;
357 
358  return rResult;
359  }
360 
364 
384  double Length() const override
385  {
386  return std::sqrt(2.0*Area());
387  }
388 
404  double Area() const override
405  {
409 
410  //heron formula
411  Vector side_a = ( p0 - p1 );
412  double a = MathUtils<double>::Norm3( side_a );
413  Vector side_b = ( p1 - p2 );
414  double b = MathUtils<double>::Norm3( side_b );
415  Vector side_c = ( p2 - p0 );
416  double c = MathUtils<double>::Norm3( side_c );
417  double s = ( a + b + c ) / 2;
418  return( sqrt( s*( s - a )*( s - b )*( s - c ) ) );
419  }
420 
421  double Volume() const override
422  {
423  return Area();
424  }
425 
440  double DomainSize() const override
441  {
442  return Area();
443  }
444 
453  bool IsInside(
454  const CoordinatesArrayType& rPoint,
455  CoordinatesArrayType& rResult,
456  const double Tolerance = std::numeric_limits<double>::epsilon()
457  ) const override
458  {
459  this->PointLocalCoordinates( rResult, rPoint );
460 
461  if ( rResult[0] >= (0.0 - Tolerance) )
462  if ( rResult[1] >= (0.0 - Tolerance) )
463  if ( rResult[2] >= (0.0 - Tolerance) )
464  if( rResult[2] <= (1.0 + Tolerance) )
465  if ( (rResult[0] + rResult[1]) <= (1.0 + Tolerance) )
466  return true;
467 
468  return false;
469  }
470 
478  CoordinatesArrayType& rResult,
479  const CoordinatesArrayType& rPoint
480  ) const override
481  {
484  for(unsigned int i=0; i<3;i++) {
485  X(0,i ) = 0.5*(this->GetPoint( i ).X() + this->GetPoint( i+3 ).X());
486  X(1,i ) = 0.5*(this->GetPoint( i ).Y() + this->GetPoint( i+3 ).Y());
487  X(2,i ) = 0.5*(this->GetPoint( i ).Z() + this->GetPoint( i+3 ).Z());
488  }
489 
490  double tol = 1.0e-8;
491  int maxiter = 1000;
492 
493  Matrix J = ZeroMatrix( 2, 2 );
494  Matrix invJ = ZeroMatrix( 2, 2 );
495 
496  //starting with xi = 0
497  rResult = ZeroVector( 3 );
498  Vector DeltaXi = ZeroVector( 2 );
499  array_1d<double,3> CurrentGlobalCoords;
500 
501 
502  //Newton iteration:
503  for ( int k = 0; k < maxiter; k++ )
504  {
505  noalias(CurrentGlobalCoords) = ZeroVector( 3 );
506  this->GlobalCoordinates( CurrentGlobalCoords, rResult );
507 
508  noalias( CurrentGlobalCoords ) = rPoint - CurrentGlobalCoords;
509 
510 
511  //derivatives of shape functions
512  Matrix shape_functions_gradients;
513  shape_functions_gradients = ShapeFunctionsLocalGradients(shape_functions_gradients, rResult );
514  noalias(DN) = prod(X,shape_functions_gradients);
515 
516  noalias(J) = prod(trans(DN),DN);
517  Vector res = prod(trans(DN),CurrentGlobalCoords);
518 
519  //deteminant of Jacobian
520  const double det_j = J( 0, 0 ) * J( 1, 1 ) - J( 0, 1 ) * J( 1, 0 );
521 
522  //filling matrix
523  invJ( 0, 0 ) = ( J( 1, 1 ) ) / ( det_j );
524  invJ( 1, 0 ) = -( J( 1, 0 ) ) / ( det_j );
525  invJ( 0, 1 ) = -( J( 0, 1 ) ) / ( det_j );
526  invJ( 1, 1 ) = ( J( 0, 0 ) ) / ( det_j );
527 
528 
529  DeltaXi( 0 ) = invJ( 0, 0 ) * res[0] + invJ( 0, 1 ) * res[1];
530  DeltaXi( 1 ) = invJ( 1, 0 ) * res[0] + invJ( 1, 1 ) * res[1];
531 
532  rResult[0] += DeltaXi[0];
533  rResult[1] += DeltaXi[1];
534  rResult[2] = 0.0;
535 
536  if ( k>0 && norm_2( DeltaXi ) > 30 )
537  {
538  KRATOS_ERROR << "Computation of local coordinates failed at iteration " << k<< std::endl;
539  }
540 
541  if ( norm_2( DeltaXi ) < tol )
542  {
543  break;
544  }
545  }
546 
547  return( rResult );
548  }
549 
571  Matrix& Jacobian( Matrix& rResult,
572  IndexType IntegrationPointIndex,
573  IntegrationMethod ThisMethod ) const override
574  {
578 
579  rResult.resize( 3, 2, false );
580  rResult( 0, 0 ) = -( p0[0] ) + ( p1[0] ); //on the Gauss points (J is constant at each element)
581  rResult( 1, 0 ) = -( p0[1] ) + ( p1[1] );
582  rResult( 2, 0 ) = -( p0[2] ) + ( p1[2] );
583  rResult( 0, 1 ) = -( p0[0] ) + ( p2[0] );
584  rResult( 1, 1 ) = -( p0[1] ) + ( p2[1] );
585  rResult( 2, 1 ) = -( p0[2] ) + ( p2[2] );
586  return rResult;
587  }
588 
609  Matrix& Jacobian( Matrix& rResult,
610  IndexType IntegrationPointIndex,
611  IntegrationMethod ThisMethod,
612  const Matrix& DeltaPosition ) const override
613  {
617 
618  Matrix deltaPosMid(3, 3);
619  for(unsigned int i = 0; i < 3; i++)
620  for(unsigned int j = 0; j < 3; j++)
621  deltaPosMid(i, j) = 0.5*( DeltaPosition(i, j) + DeltaPosition(i+3, j) );
622 
623  if(rResult.size1() != 3 || rResult.size2() != 2)
624  rResult.resize(3, 2, false);
625 
626  rResult( 0, 0 ) = -( p0[0] - deltaPosMid(0,0) ) + ( p1[0] - deltaPosMid(1,0) ); //on the Gauss points (J is constant at each element)
627  rResult( 1, 0 ) = -( p0[1] - deltaPosMid(0,1) ) + ( p1[1] - deltaPosMid(1,1) );
628  rResult( 2, 0 ) = -( p0[2] - deltaPosMid(0,2) ) + ( p1[2] - deltaPosMid(1,2) );
629  rResult( 0, 1 ) = -( p0[0] - deltaPosMid(0,0) ) + ( p2[0] - deltaPosMid(2,0) );
630  rResult( 1, 1 ) = -( p0[1] - deltaPosMid(0,1) ) + ( p2[1] - deltaPosMid(2,1) );
631  rResult( 2, 1 ) = -( p0[2] - deltaPosMid(0,2) ) + ( p2[2] - deltaPosMid(2,2) );
632 
633  return rResult;
634  }
635 
651  Matrix& Jacobian( Matrix& rResult, const CoordinatesArrayType& rPoint ) const override
652  {
656 
657  rResult.resize( 3, 2 , false);
658  rResult( 0, 0 ) = -( p0[0] ) + ( p1[0] ); //on the Gauss points (J is constant at each element)
659  rResult( 1, 0 ) = -( p0[1] ) + ( p1[1] );
660  rResult( 2, 0 ) = -( p0[2] ) + ( p1[2] );
661  rResult( 0, 1 ) = -( p0[0] ) + ( p2[0] );
662  rResult( 1, 1 ) = -( p0[1] ) + ( p2[1] );
663  rResult( 2, 1 ) = -( p0[2] ) + ( p2[2] );
664  return rResult;
665  }
666 
683  IntegrationMethod ThisMethod ) const override
684  {
688 
689  array_1d<double, 3> Tangent1( p1 - p0 );
690  array_1d<double, 3> Tangent2( p2 - p0 );
691 
693  MathUtils<double>::CrossProduct( Normal, Tangent1, Tangent2);
694 
695  double detJ = norm_2(Normal);
696 
697  //for all integration points
698  if ( rResult.size() != this->IntegrationPointsNumber( ThisMethod ) )
699  rResult.resize( this->IntegrationPointsNumber( ThisMethod ), false );
700 
701  for ( unsigned int pnt = 0; pnt < this->IntegrationPointsNumber( ThisMethod ); pnt++ )
702  rResult[pnt] = detJ;
703 
704  return rResult;
705  }
706 
729  double DeterminantOfJacobian( IndexType IntegrationPointIndex,
730  IntegrationMethod ThisMethod ) const override
731  {
735 
736  array_1d<double, 3> Tangent1( p1 - p0 );
737  array_1d<double, 3> Tangent2( p2 - p0 );
738 
740  MathUtils<double>::CrossProduct( Normal, Tangent1, Tangent2);
741 
742  return norm_2(Normal);
743  }
744 
770  double DeterminantOfJacobian( const CoordinatesArrayType& rPoint ) const override
771  {
775 
776  array_1d<double, 3> Tangent1( p1 - p0 );
777  array_1d<double, 3> Tangent2( p2 - p0 );
778 
780  MathUtils<double>::CrossProduct( Normal, Tangent1, Tangent2);
781 
782  return norm_2(Normal);
783  }
784 
807  IntegrationMethod ThisMethod ) const override
808  {
809  KRATOS_ERROR << "Jacobian is not square" << std::endl;;
810  return rResult;
811  }
812 
837  IndexType IntegrationPointIndex,
838  IntegrationMethod ThisMethod ) const override
839  {
840  KRATOS_ERROR << "Jacobian is not square" << std::endl;
841  return rResult;
842  }
843 
861  const CoordinatesArrayType& rPoint ) const override
862  {
863  KRATOS_ERROR << "Jacobian is not square" << std::endl;
864  return rResult;
865  }
866 
870 
882  SizeType EdgesNumber() const override
883  {
884  return 9;
885  }
886 
896  {
898  typedef typename Geometry<TPointType>::Pointer EdgePointerType;
899  edges.push_back( EdgePointerType( new EdgeType(
900  this->pGetPoint( 0 ),
901  this->pGetPoint( 1 ) ) ) );
902  edges.push_back( EdgePointerType( new EdgeType(
903  this->pGetPoint( 1 ),
904  this->pGetPoint( 2 ) ) ) );
905  edges.push_back( EdgePointerType( new EdgeType(
906  this->pGetPoint( 2 ),
907  this->pGetPoint( 0 ) ) ) );
908  edges.push_back( EdgePointerType( new EdgeType(
909  this->pGetPoint( 3 ),
910  this->pGetPoint( 4 ) ) ) );
911  edges.push_back( EdgePointerType( new EdgeType(
912  this->pGetPoint( 4 ),
913  this->pGetPoint( 5 ) ) ) );
914  edges.push_back( EdgePointerType( new EdgeType(
915  this->pGetPoint( 5 ),
916  this->pGetPoint( 3 ) ) ) );
917  edges.push_back( EdgePointerType( new EdgeType(
918  this->pGetPoint( 0 ),
919  this->pGetPoint( 3 ) ) ) );
920  edges.push_back( EdgePointerType( new EdgeType(
921  this->pGetPoint( 1 ),
922  this->pGetPoint( 4 ) ) ) );
923  edges.push_back( EdgePointerType( new EdgeType(
924  this->pGetPoint( 2 ),
925  this->pGetPoint( 5 ) ) ) );
926  return edges;
927  }
928 
932 
940  SizeType FacesNumber() const override
941  {
942  return 5;
943  }
944 
954  {
956  typedef typename Geometry<TPointType>::Pointer FacePointerType;
957  faces.push_back( FacePointerType( new FaceType1(
958  this->pGetPoint( 0 ),
959  this->pGetPoint( 2 ),
960  this->pGetPoint( 1 ) ) ) );
961  faces.push_back( FacePointerType( new FaceType1(
962  this->pGetPoint( 3 ),
963  this->pGetPoint( 4 ),
964  this->pGetPoint( 5 ) ) ) );
965  faces.push_back( FacePointerType( new FaceType2(
966  this->pGetPoint( 1 ),
967  this->pGetPoint( 2 ),
968  this->pGetPoint( 5 ),
969  this->pGetPoint( 4 ) ) ) );
970  faces.push_back( FacePointerType( new FaceType2(
971  this->pGetPoint( 0 ),
972  this->pGetPoint( 3 ),
973  this->pGetPoint( 5 ),
974  this->pGetPoint( 2 ) ) ) );
975  faces.push_back( FacePointerType( new FaceType2(
976  this->pGetPoint( 0 ),
977  this->pGetPoint( 1 ),
978  this->pGetPoint( 4 ),
979  this->pGetPoint( 3 ) ) ) );
980  return faces;
981  }
982 
986 
999  double ShapeFunctionValue( IndexType ShapeFunctionIndex,
1000  const CoordinatesArrayType& rPoint ) const override
1001  {
1002  switch ( ShapeFunctionIndex )
1003  {
1004  case 0:
1005  return( 1.0 -( rPoint[0] + rPoint[1] + rPoint[2] - ( rPoint[0]*rPoint[2] ) - ( rPoint[1]*rPoint[2] ) ) );
1006  case 1:
1007  return( rPoint[0] - ( rPoint[0]*rPoint[2] ) );
1008  case 2:
1009  return( rPoint[1] - ( rPoint[1]*rPoint[2] ) );
1010  case 3:
1011  return( rPoint[2] - ( rPoint[0]*rPoint[2] ) - ( rPoint[1]*rPoint[2] ) );
1012  case 4:
1013  return( rPoint[0]*rPoint[2] );
1014  case 5:
1015  return( rPoint[1]*rPoint[2] );
1016  default:
1017  KRATOS_ERROR << "Wrong index of shape function!" << *this << std::endl;
1018  }
1019 
1020  return 0;
1021  }
1022 
1034  Vector& ShapeFunctionsValues (Vector &rResult, const CoordinatesArrayType& rCoordinates) const override
1035  {
1036  if(rResult.size() != 6) rResult.resize(6,false);
1037  rResult[0] = 1.0 -( rCoordinates[0] + rCoordinates[1] + rCoordinates[2] - ( rCoordinates[0]*rCoordinates[2] ) - ( rCoordinates[1]*rCoordinates[2] ) );
1038  rResult[1] = rCoordinates[0] - ( rCoordinates[0]*rCoordinates[2] );
1039  rResult[2] = rCoordinates[1] - ( rCoordinates[1]*rCoordinates[2] );
1040  rResult[3] = rCoordinates[2] - ( rCoordinates[0]*rCoordinates[2] ) - ( rCoordinates[1]*rCoordinates[2] );
1041  rResult[4] = rCoordinates[0]*rCoordinates[2];
1042  rResult[5] = rCoordinates[1]*rCoordinates[2];
1043 
1044  return rResult;
1045  }
1046 
1064  ShapeFunctionsGradientsType& rResult,
1065  IntegrationMethod ThisMethod ) const override
1066  {
1067  const unsigned int integration_points_number =
1068  msGeometryData.IntegrationPointsNumber( ThisMethod );
1069 
1070  if ( integration_points_number == 0 )
1071  KRATOS_ERROR << "This integration method is not supported" << *this << std::endl;
1072 
1073  //workaround by riccardo
1074  if ( rResult.size() != integration_points_number )
1075  {
1076  // KLUDGE: While there is a bug in ublas
1077  // vector resize, I have to put this beside resizing!!
1078  ShapeFunctionsGradientsType temp( integration_points_number );
1079  rResult.swap( temp );
1080  }
1081 
1082  //calculating the local gradients
1084  CalculateShapeFunctionsIntegrationPointsLocalGradients( ThisMethod );
1085 
1086  //getting the inverse jacobian matrices
1087  JacobiansType temp( integration_points_number );
1088 
1089  JacobiansType invJ = InverseOfJacobian( temp, ThisMethod );
1090 
1091  //loop over all integration points
1092  for ( unsigned int pnt = 0; pnt < integration_points_number; pnt++ )
1093  {
1094  rResult[pnt].resize( 6, 3, false );
1095 
1096  for ( int i = 0; i < 6; i++ )
1097  {
1098  for ( int j = 0; j < 3; j++ )
1099  {
1100  rResult[pnt]( i, j ) =
1101  ( locG[pnt]( i, 0 ) * invJ[pnt]( j, 0 ) )
1102  + ( locG[pnt]( i, 1 ) * invJ[pnt]( j, 1 ) )
1103  + ( locG[pnt]( i, 2 ) * invJ[pnt]( j, 2 ) );
1104  }
1105  }
1106  }//end of loop over integration points
1107  }
1108 
1112 
1120  std::string Info() const override
1121  {
1122  return "3 dimensional interface Prism with six nodes in 3D space";
1123  }
1124 
1131  void PrintInfo( std::ostream& rOStream ) const override
1132  {
1133  rOStream << "3 dimensional interface Prism with six nodes in 3D space";
1134  }
1135 
1150  void PrintData( std::ostream& rOStream ) const override
1151  {
1152  // Base Geometry class PrintData call
1153  BaseType::PrintData( rOStream );
1154  std::cout << std::endl;
1155 
1156  // If the geometry has valid points, calculate and output its data
1157  if (this->AllPointsAreValid()) {
1158  Matrix jacobian;
1159  this->Jacobian( jacobian, PointType() );
1160  rOStream << " Jacobian in the origin\t : " << jacobian;
1161  }
1162  }
1163 
1174  const CoordinatesArrayType& rPoint ) const override
1175  {
1176  rResult.resize( 6, 3, false );
1177  noalias( rResult ) = ZeroMatrix( 6, 3 );
1178 
1179  rResult( 0, 0 ) = -1.0 + rPoint[2];
1180  rResult( 0, 1 ) = -1.0 + rPoint[2];
1181  rResult( 0, 2 ) = -1.0 + rPoint[0] + rPoint[1];
1182 
1183  rResult( 1, 0 ) = 1.0 - rPoint[2];
1184  rResult( 1, 1 ) = 0.0;
1185  rResult( 1, 2 ) = -rPoint[0];
1186 
1187  rResult( 2, 0 ) = 0.0;
1188  rResult( 2, 1 ) = 1.0 - rPoint[2];
1189  rResult( 2, 2 ) = -rPoint[1];
1190 
1191  rResult( 3, 0 ) = -rPoint[2];
1192  rResult( 3, 1 ) = -rPoint[2];
1193  rResult( 3, 2 ) = 1.0 - rPoint[0] - rPoint[1];
1194 
1195  rResult( 4, 0 ) = rPoint[2];
1196  rResult( 4, 1 ) = 0.0;
1197  rResult( 4, 2 ) = rPoint[0];
1198 
1199  rResult( 5, 0 ) = 0.0;
1200  rResult( 5, 1 ) = rPoint[2];
1201  rResult( 5, 2 ) = rPoint[1];
1202 
1203  return rResult;
1204  }
1205 
1206 
1214  const CoordinatesArrayType& rPoint ) const override
1215  {
1216  if ( rResult.size() != this->PointsNumber() )
1217  {
1218  // KLUDGE: While there is a bug in
1219  // ublas vector resize, I have to put this beside resizing!!
1221  rResult.swap( temp );
1222  }
1223 
1224  //TODO: this is not correct for a prism
1225 
1226  rResult[0].resize( 2, 2 , false);
1227  rResult[1].resize( 2, 2 , false);
1228  rResult[2].resize( 2, 2 , false);
1229 
1230  rResult[0]( 0, 0 ) = 0.0;
1231  rResult[0]( 0, 1 ) = 0.0;
1232  rResult[0]( 1, 0 ) = 0.0;
1233  rResult[0]( 1, 1 ) = 0.0;
1234  rResult[1]( 0, 0 ) = 0.0;
1235  rResult[1]( 0, 1 ) = 0.0;
1236  rResult[1]( 1, 0 ) = 0.0;
1237  rResult[1]( 1, 1 ) = 0.0;
1238  rResult[2]( 0, 0 ) = 0.0;
1239  rResult[2]( 0, 1 ) = 0.0;
1240  rResult[2]( 1, 0 ) = 0.0;
1241  rResult[2]( 1, 1 ) = 0.0;
1242  return rResult;
1243  }
1244 
1252  const CoordinatesArrayType& rPoint ) const override
1253  {
1254  if ( rResult.size() != this->PointsNumber() )
1255  {
1256  // KLUDGE: While there is a bug in
1257  // ublas vector resize, I have to put this beside resizing!!
1258 // ShapeFunctionsGradientsType
1260  rResult.swap( temp );
1261  }
1262 
1263  for ( IndexType i = 0; i < rResult.size(); i++ )
1264  {
1266  rResult[i].swap( temp );
1267  }
1268 
1269  //TODO: this is not correct for a prism
1270 
1271  rResult[0][0].resize( 2, 2 , false);
1272  rResult[0][1].resize( 2, 2 , false);
1273  rResult[1][0].resize( 2, 2 , false);
1274  rResult[1][1].resize( 2, 2 , false);
1275  rResult[2][0].resize( 2, 2 , false);
1276  rResult[2][1].resize( 2, 2 , false);
1277 
1278  for ( int i = 0; i < 3; i++ )
1279  {
1280  rResult[i][0]( 0, 0 ) = 0.0;
1281  rResult[i][0]( 0, 1 ) = 0.0;
1282  rResult[i][0]( 1, 0 ) = 0.0;
1283  rResult[i][0]( 1, 1 ) = 0.0;
1284  rResult[i][1]( 0, 0 ) = 0.0;
1285  rResult[i][1]( 0, 1 ) = 0.0;
1286  rResult[i][1]( 1, 0 ) = 0.0;
1287  rResult[i][1]( 1, 1 ) = 0.0;
1288  }
1289 
1290  return rResult;
1291  }
1292 
1296 
1298 
1299 protected:
1304 private:
1307 
1308  static const GeometryData msGeometryData;
1309 
1310  static const GeometryDimension msGeometryDimension;
1311 
1315 
1316  friend class Serializer;
1317 
1318  void save( Serializer& rSerializer ) const override
1319  {
1321  }
1322 
1323  void load( Serializer& rSerializer ) override
1324  {
1326  }
1327 
1328  PrismInterface3D6(): BaseType( PointsArrayType(), &msGeometryData ) {}
1329 
1333 
1334 
1338 
1339 
1343 
1354  static Matrix CalculateShapeFunctionsIntegrationPointsValues(
1355  typename BaseType::IntegrationMethod ThisMethod )
1356  {
1357  IntegrationPointsContainerType all_integration_points =
1358  AllIntegrationPoints();
1359  IntegrationPointsArrayType integration_points = all_integration_points[static_cast<int>(ThisMethod)];
1360  //number of integration points
1361  const int integration_points_number = integration_points.size();
1362  //number of nodes in current geometry
1363  const int points_number = 6;
1364  //setting up return matrix
1365  Matrix shape_function_values( integration_points_number, points_number );
1366  //loop over all integration points
1367 
1368  for ( int pnt = 0; pnt < integration_points_number; pnt++ )
1369  {
1370  shape_function_values ( pnt, 0 ) = ( 1.0
1371  - integration_points[pnt].X()
1372  - integration_points[pnt].Y()
1373  - integration_points[pnt].Z()
1374  + ( integration_points[pnt].X() * integration_points[pnt].Z() )
1375  + ( integration_points[pnt].Y() * integration_points[pnt].Z() ) );
1376  shape_function_values( pnt, 1 ) = integration_points[pnt].X()
1377  - ( integration_points[pnt].X() * integration_points[pnt].Z() );
1378  shape_function_values( pnt, 2 ) = integration_points[pnt].Y()
1379  - ( integration_points[pnt].Y() * integration_points[pnt].Z() );
1380  shape_function_values( pnt, 3 ) = integration_points[pnt].Z()
1381  - ( integration_points[pnt].X() * integration_points[pnt].Z() )
1382  - ( integration_points[pnt].Y() * integration_points[pnt].Z() );
1383  shape_function_values( pnt, 4 ) = ( integration_points[pnt].X() * integration_points[pnt].Z() );
1384  shape_function_values( pnt, 5 ) = ( integration_points[pnt].Y() * integration_points[pnt].Z() );
1385  }
1386 
1387  return shape_function_values;
1388  }
1389 
1402  static ShapeFunctionsGradientsType CalculateShapeFunctionsIntegrationPointsLocalGradients(
1403  typename BaseType::IntegrationMethod ThisMethod )
1404  {
1405  IntegrationPointsContainerType all_integration_points =
1406  AllIntegrationPoints();
1407  IntegrationPointsArrayType integration_points = all_integration_points[static_cast<int>(ThisMethod)];
1408  //number of integration points
1409  const int integration_points_number = integration_points.size();
1410  ShapeFunctionsGradientsType d_shape_f_values( integration_points_number );
1411  //initialising container
1412  //std::fill(d_shape_f_values.begin(), d_shape_f_values.end(), Matrix(4,2));
1413  //loop over all integration points
1414 
1415  for ( int pnt = 0; pnt < integration_points_number; pnt++ )
1416  {
1417  Matrix result = ZeroMatrix( 6, 3 );
1418  result( 0, 0 ) = -1.0 + integration_points[pnt].Z();
1419  result( 0, 1 ) = -1.0 + integration_points[pnt].Z();
1420  result( 0, 2 ) = -1.0 + integration_points[pnt].X() + integration_points[pnt].Y();
1421  result( 1, 0 ) = 1.0 - integration_points[pnt].Z();
1422  result( 1, 1 ) = 0.0;
1423  result( 1, 2 ) = -integration_points[pnt].X();
1424  result( 2, 0 ) = 0.0;
1425  result( 2, 1 ) = 1.0 - integration_points[pnt].Z();
1426  result( 2, 2 ) = -integration_points[pnt].Y();
1427  result( 3, 0 ) = -integration_points[pnt].Z();
1428  result( 3, 1 ) = -integration_points[pnt].Z();
1429  result( 3, 2 ) = 1.0 - integration_points[pnt].X() - integration_points[pnt].Y();
1430  result( 4, 0 ) = integration_points[pnt].Z();
1431  result( 4, 1 ) = 0.0;
1432  result( 4, 2 ) = integration_points[pnt].X();
1433  result( 5, 0 ) = 0.0;
1434  result( 5, 1 ) = integration_points[pnt].Z();
1435  result( 5, 2 ) = integration_points[pnt].Y();
1436  d_shape_f_values[pnt] = result;
1437  }
1438 
1439  return d_shape_f_values;
1440  }
1441 
1445  static const IntegrationPointsContainerType AllIntegrationPoints()
1446  {
1447  IntegrationPointsContainerType integration_points =
1448  {
1449  {
1450  Quadrature<PrismGaussLobattoIntegrationPoints1,
1451  3, IntegrationPoint<3> >::GenerateIntegrationPoints(),
1452  Quadrature<PrismGaussLobattoIntegrationPoints2,
1453  3, IntegrationPoint<3> >::GenerateIntegrationPoints(),
1456  }
1457  };
1458 
1459  return integration_points;
1460  }
1461 
1465  static const ShapeFunctionsValuesContainerType AllShapeFunctionsValues()
1466  {
1467  ShapeFunctionsValuesContainerType shape_functions_values =
1468  {
1469  {
1470  PrismInterface3D6<TPointType>::CalculateShapeFunctionsIntegrationPointsValues(
1472  PrismInterface3D6<TPointType>::CalculateShapeFunctionsIntegrationPointsValues(
1474  Matrix(),
1475  Matrix()
1476  }
1477  };
1478  return shape_functions_values;
1479  }
1480 
1485  AllShapeFunctionsLocalGradients()
1486  {
1487  ShapeFunctionsLocalGradientsContainerType shape_functions_local_gradients =
1488  {
1489  {
1490  PrismInterface3D6<TPointType>::CalculateShapeFunctionsIntegrationPointsLocalGradients( GeometryData::IntegrationMethod::GI_GAUSS_1 ),
1491  PrismInterface3D6<TPointType>::CalculateShapeFunctionsIntegrationPointsLocalGradients( GeometryData::IntegrationMethod::GI_GAUSS_2 ),
1494  }
1495  };
1496  return shape_functions_local_gradients;
1497  }
1498 
1502 
1503 
1507 
1508 
1512 
1513  template<class TOtherPointType> friend class PrismInterface3D6;
1514 
1518 
1519 
1520 
1522 }; // Class Geometry
1523 
1527 
1528 
1532 
1535 template<class TPointType> inline std::istream& operator >> (
1536  std::istream& rIStream,
1541 template<class TPointType> inline std::ostream& operator << (
1542  std::ostream& rOStream,
1543  const PrismInterface3D6<TPointType>& rThis )
1544 {
1545  rThis.PrintInfo( rOStream );
1546  rOStream << std::endl;
1547  rThis.PrintData( rOStream );
1548  return rOStream;
1549 }
1550 
1552 
1553 template<class TPointType> const
1554 GeometryData PrismInterface3D6<TPointType>::msGeometryData(
1557  PrismInterface3D6<TPointType>::AllIntegrationPoints(),
1558  PrismInterface3D6<TPointType>::AllShapeFunctionsValues(),
1559  AllShapeFunctionsLocalGradients()
1560 );
1561 
1562 template<class TPointType> const
1564 
1565 }// namespace Kratos.
1566 
1567 #endif // KRATOS_PRISM_INTERFACE_3D_6_H_INCLUDED defined
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
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
virtual array_1d< double, 3 > Normal(const CoordinatesArrayType &rPointLocalCoordinates) const
It returns a vector that is normal to its corresponding geometry in the given local point.
Definition: geometry.h:1543
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
const ShapeFunctionsGradientsType & ShapeFunctionsLocalGradients() const
Definition: geometry.h:3539
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
An two node 3D line geometry with linear shape functions.
Definition: line_3d_2.h:64
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
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
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
Definition: prism_interface_3d_6.h:54
BaseType::IndexType IndexType
Definition: prism_interface_3d_6.h:99
BaseType::Pointer Create(PointsArrayType const &ThisPoints) const override
Creates a new geometry pointer.
Definition: prism_interface_3d_6.h:319
Quadrilateral3D4< TPointType > FaceType2
Definition: prism_interface_3d_6.h:70
BaseType::PointsArrayType PointsArrayType
Definition: prism_interface_3d_6.h:112
double Volume() const override
This method calculate and return volume of this geometry.
Definition: prism_interface_3d_6.h:421
BaseType::ShapeFunctionsValuesContainerType ShapeFunctionsValuesContainerType
Definition: prism_interface_3d_6.h:145
JacobiansType & InverseOfJacobian(JacobiansType &rResult, IntegrationMethod ThisMethod) const override
Definition: prism_interface_3d_6.h:806
std::string Info() const override
Definition: prism_interface_3d_6.h:1120
friend class PrismInterface3D6
Definition: prism_interface_3d_6.h:1513
void PrintData(std::ostream &rOStream) const override
Definition: prism_interface_3d_6.h:1150
BaseType::NormalType NormalType
Definition: prism_interface_3d_6.h:186
PrismInterface3D6(PrismInterface3D6< TOtherPointType > const &rOther)
Definition: prism_interface_3d_6.h:256
Matrix & PointsLocalCoordinates(Matrix &rResult) const override
Definition: prism_interface_3d_6.h:329
PrismInterface3D6 & operator=(PrismInterface3D6< TOtherPointType > const &rOther)
Definition: prism_interface_3d_6.h:309
Geometry< TPointType > BaseType
Definition: prism_interface_3d_6.h:63
double Length() const override
Definition: prism_interface_3d_6.h:384
Matrix & Jacobian(Matrix &rResult, IndexType IntegrationPointIndex, IntegrationMethod ThisMethod, const Matrix &DeltaPosition) const override
Definition: prism_interface_3d_6.h:609
Line3D2< TPointType > EdgeType
Definition: prism_interface_3d_6.h:68
SizeType EdgesNumber() const override
This method gives you number of all edges of this geometry.
Definition: prism_interface_3d_6.h:882
void ShapeFunctionsIntegrationPointsGradients(ShapeFunctionsGradientsType &rResult, IntegrationMethod ThisMethod) const override
Definition: prism_interface_3d_6.h:1063
BaseType::ShapeFunctionsThirdDerivativesType ShapeFunctionsThirdDerivativesType
Definition: prism_interface_3d_6.h:181
Matrix & Jacobian(Matrix &rResult, IndexType IntegrationPointIndex, IntegrationMethod ThisMethod) const override
Definition: prism_interface_3d_6.h:571
virtual ~PrismInterface3D6()
Definition: prism_interface_3d_6.h:264
double Area() const override
Definition: prism_interface_3d_6.h:404
BaseType::JacobiansType JacobiansType
Definition: prism_interface_3d_6.h:158
GeometryData::IntegrationMethod IntegrationMethod
Definition: prism_interface_3d_6.h:80
BaseType::CoordinatesArrayType CoordinatesArrayType
Definition: prism_interface_3d_6.h:117
PrismInterface3D6(PrismInterface3D6 const &rOther)
Definition: prism_interface_3d_6.h:239
TPointType PointType
Definition: prism_interface_3d_6.h:91
BaseType::GeometriesArrayType GeometriesArrayType
Definition: prism_interface_3d_6.h:86
PrismInterface3D6(const PointsArrayType &ThisPoints)
Definition: prism_interface_3d_6.h:223
CoordinatesArrayType & PointLocalCoordinates(CoordinatesArrayType &rResult, const CoordinatesArrayType &rPoint) const override
Returns the local coordinates of a given arbitrary point.
Definition: prism_interface_3d_6.h:477
BaseType::ShapeFunctionsSecondDerivativesType ShapeFunctionsSecondDerivativesType
Definition: prism_interface_3d_6.h:173
double DeterminantOfJacobian(const CoordinatesArrayType &rPoint) const override
Definition: prism_interface_3d_6.h:770
Vector & DeterminantOfJacobian(Vector &rResult, IntegrationMethod ThisMethod) const override
Definition: prism_interface_3d_6.h:682
PrismInterface3D6(typename PointType::Pointer pPoint1, typename PointType::Pointer pPoint2, typename PointType::Pointer pPoint3, typename PointType::Pointer pPoint4, typename PointType::Pointer pPoint5, typename PointType::Pointer pPoint6)
Definition: prism_interface_3d_6.h:206
BaseType::IntegrationPointsArrayType IntegrationPointsArrayType
Definition: prism_interface_3d_6.h:132
ShapeFunctionsSecondDerivativesType & ShapeFunctionsSecondDerivatives(ShapeFunctionsSecondDerivativesType &rResult, const CoordinatesArrayType &rPoint) const override
Definition: prism_interface_3d_6.h:1213
Matrix & InverseOfJacobian(Matrix &rResult, IndexType IntegrationPointIndex, IntegrationMethod ThisMethod) const override
Definition: prism_interface_3d_6.h:836
PrismInterface3D6 & operator=(const PrismInterface3D6 &rOther)
Definition: prism_interface_3d_6.h:291
BaseType::ShapeFunctionsGradientsType ShapeFunctionsGradientsType
Definition: prism_interface_3d_6.h:165
double DeterminantOfJacobian(IndexType IntegrationPointIndex, IntegrationMethod ThisMethod) const override
Definition: prism_interface_3d_6.h:729
void PrintInfo(std::ostream &rOStream) const override
Definition: prism_interface_3d_6.h:1131
GeometryData::KratosGeometryFamily GetGeometryFamily() const override
Definition: prism_interface_3d_6.h:266
bool IsInside(const CoordinatesArrayType &rPoint, CoordinatesArrayType &rResult, const double Tolerance=std::numeric_limits< double >::epsilon()) const override
Definition: prism_interface_3d_6.h:453
ShapeFunctionsThirdDerivativesType & ShapeFunctionsThirdDerivatives(ShapeFunctionsThirdDerivativesType &rResult, const CoordinatesArrayType &rPoint) const override
Definition: prism_interface_3d_6.h:1251
Matrix & ShapeFunctionsLocalGradients(Matrix &rResult, const CoordinatesArrayType &rPoint) const override
Definition: prism_interface_3d_6.h:1173
Vector & ShapeFunctionsValues(Vector &rResult, const CoordinatesArrayType &rCoordinates) const override
Definition: prism_interface_3d_6.h:1034
double DomainSize() const override
Definition: prism_interface_3d_6.h:440
BaseType::ShapeFunctionsLocalGradientsContainerType ShapeFunctionsLocalGradientsContainerType
Definition: prism_interface_3d_6.h:151
BaseType::IntegrationPointType IntegrationPointType
Definition: prism_interface_3d_6.h:123
GeometryData::KratosGeometryType GetGeometryType() const override
Definition: prism_interface_3d_6.h:271
Matrix & InverseOfJacobian(Matrix &rResult, const CoordinatesArrayType &rPoint) const override
Definition: prism_interface_3d_6.h:860
double ShapeFunctionValue(IndexType ShapeFunctionIndex, const CoordinatesArrayType &rPoint) const override
Definition: prism_interface_3d_6.h:999
BaseType::IntegrationPointsContainerType IntegrationPointsContainerType
Definition: prism_interface_3d_6.h:139
GeometriesArrayType GenerateFaces() const override
Returns all faces of the current geometry.
Definition: prism_interface_3d_6.h:953
Triangle3D3< TPointType > FaceType1
Definition: prism_interface_3d_6.h:69
SizeType FacesNumber() const override
Returns the number of faces of the current geometry.
Definition: prism_interface_3d_6.h:940
KRATOS_CLASS_POINTER_DEFINITION(PrismInterface3D6)
GeometriesArrayType GenerateEdges() const override
This method gives you all edges of this geometry.
Definition: prism_interface_3d_6.h:895
Matrix & Jacobian(Matrix &rResult, const CoordinatesArrayType &rPoint) const override
Definition: prism_interface_3d_6.h:651
BaseType::SizeType SizeType
Definition: prism_interface_3d_6.h:106
A four node 3D quadrilateral geometry with bi-linear shape functions.
Definition: quadrilateral_3d_4.h:76
The serialization consists in storing the state of an object into a storage format like data file or ...
Definition: serializer.h:123
A three node 3D triangle geometry with linear shape functions.
Definition: triangle_3d_3.h:77
Short class definition.
Definition: array_1d.h:61
#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
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
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
const GeometryData PrismInterface3D6< TPointType >::msGeometryData & msGeometryDimension(), PrismInterface3D6< TPointType >::AllShapeFunctionsValues(), AllShapeFunctionsLocalGradients()
Definition: brep_curve.h:483
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
a
Definition: generate_stokes_twofluid_element.py:77
b
Definition: generate_total_lagrangian_mixed_volumetric_strain_element.py:31
c
Definition: generate_weakly_compressible_navier_stokes_element.py:108
int tol
Definition: hinsberg_optimization.py:138
def load(f)
Definition: ode_solve.py:307
int k
Definition: quadrature.py:595
int j
Definition: quadrature.py:648
float temp
Definition: rotating_cone.py:85
J
Definition: sensitivityMatrix.py:58
integer i
Definition: TensorModule.f:17