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.
quadrilateral_3d_8.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 //
16 
17 #pragma once
18 
19 // System includes
20 
21 // External includes
22 
23 // Project includes
24 #include "geometries/line_3d_3.h"
27 
28 namespace Kratos
29 {
47 template<class TPointType> class Quadrilateral3D8
48  : public Geometry<TPointType>
49 {
50 public:
58 
63 
68 
73 
79 
83  typedef TPointType PointType;
84 
89 
90 
97  typedef typename BaseType::IndexType IndexType;
98 
104  typedef typename BaseType::SizeType SizeType;
105 
111 
118 
126 
133 
140 
147 
154 
161 
169 
170 
178 
183 
187 // Quadrilateral3D8( const PointType& Point1, const PointType& Point2,
188 // const PointType& Point3, const PointType& Point4,
189 // const PointType& Point5, const PointType& Point6,
190 // const PointType& Point7, const PointType& Point8
191 // )
192 // : BaseType( PointsArrayType(), &msGeometryData )
193 // {
194 // this->Points().push_back( typename PointType::Pointer( new PointType( Point1 ) ) );
195 // this->Points().push_back( typename PointType::Pointer( new PointType( Point2 ) ) );
196 // this->Points().push_back( typename PointType::Pointer( new PointType( Point3 ) ) );
197 // this->Points().push_back( typename PointType::Pointer( new PointType( Point4 ) ) );
198 // this->Points().push_back( typename PointType::Pointer( new PointType( Point5 ) ) );
199 // this->Points().push_back( typename PointType::Pointer( new PointType( Point6 ) ) );
200 // this->Points().push_back( typename PointType::Pointer( new PointType( Point7 ) ) );
201 // this->Points().push_back( typename PointType::Pointer( new PointType( Point8 ) ) );
202 // }
203 
204  Quadrilateral3D8( typename PointType::Pointer pPoint1, typename PointType::Pointer pPoint2,
205  typename PointType::Pointer pPoint3, typename PointType::Pointer pPoint4,
206  typename PointType::Pointer pPoint5, typename PointType::Pointer pPoint6,
207  typename PointType::Pointer pPoint7, typename PointType::Pointer pPoint8 )
208  : BaseType( PointsArrayType(), &msGeometryData )
209  {
210  this->Points().push_back( pPoint1 );
211  this->Points().push_back( pPoint2 );
212  this->Points().push_back( pPoint3 );
213  this->Points().push_back( pPoint4 );
214  this->Points().push_back( pPoint5 );
215  this->Points().push_back( pPoint6 );
216  this->Points().push_back( pPoint7 );
217  this->Points().push_back( pPoint8 );
218  }
219 
220  Quadrilateral3D8( const PointsArrayType& ThisPoints )
221  : BaseType( ThisPoints, &msGeometryData )
222  {
223  KRATOS_ERROR_IF( this->PointsNumber() != 8 ) << "Invalid points number. Expected 8, given " << this->PointsNumber() << std::endl;
224  }
225 
228  const IndexType GeometryId,
229  const PointsArrayType& rThisPoints
230  ) : BaseType(GeometryId, rThisPoints, &msGeometryData)
231  {
232  KRATOS_ERROR_IF( this->PointsNumber() != 8 ) << "Invalid points number. Expected 8, given " << this->PointsNumber() << std::endl;
233  }
234 
237  const std::string& rGeometryName,
238  const PointsArrayType& rThisPoints
239  ) : BaseType(rGeometryName, rThisPoints, &msGeometryData)
240  {
241  KRATOS_ERROR_IF(this->PointsNumber() != 8) << "Invalid points number. Expected 8, given " << this->PointsNumber() << std::endl;
242  }
243 
254  : BaseType( rOther )
255  {
256  }
257 
270  template<class TOtherPointType> Quadrilateral3D8( Quadrilateral3D8<TOtherPointType> const& rOther )
271  : BaseType( rOther )
272  {
273  }
274 
278  ~Quadrilateral3D8() override {}
279 
281  {
283  }
284 
286  {
288  }
289 
306  {
307  BaseType::operator=( rOther );
308 
309  return *this;
310  }
311 
323  template<class TOtherPointType>
325  {
326  BaseType::operator=( rOther );
327 
328  return *this;
329  }
330 
334 
341  typename BaseType::Pointer Create(
342  const IndexType NewGeometryId,
343  PointsArrayType const& rThisPoints
344  ) const override
345  {
346  return typename BaseType::Pointer( new Quadrilateral3D8( NewGeometryId, rThisPoints ) );
347  }
348 
355  typename BaseType::Pointer Create(
356  const IndexType NewGeometryId,
357  const BaseType& rGeometry
358  ) const override
359  {
360  auto p_geometry = typename BaseType::Pointer( new Quadrilateral3D8( NewGeometryId, rGeometry.Points() ) );
361  p_geometry->SetData(rGeometry.GetData());
362  return p_geometry;
363  }
364 
370  SizeType PointsNumberInDirection(IndexType LocalDirectionIndex) const override
371  {
372  if ((LocalDirectionIndex == 0) || (LocalDirectionIndex == 1)) {
373  return 3;
374  }
375  KRATOS_ERROR << "Possible direction index reaches from 0-1. Given direction index: "
376  << LocalDirectionIndex << std::endl;
377  }
378 
396  double Length() const override
397  {
398  return std::sqrt( std::abs( this->DeterminantOfJacobian( PointType() ) ) );
399  }
400 
413  double Area() const override
414  {
415  const IntegrationMethod integration_method = msGeometryData.DefaultIntegrationMethod();
416  return IntegrationUtilities::ComputeDomainSize(*this, integration_method);
417  }
418 
426  double Volume() const override
427  {
428  KRATOS_WARNING("Quadrilateral3D8") << "Method not well defined. Replace with DomainSize() instead. This method preserves current behaviour but will be changed in June 2023 (returning error instead)" << std::endl;
429  return Area();
430  // TODO: Replace in June 2023
431  // KRATOS_ERROR << "Quadrilateral3D8:: Method not well defined. Replace with DomainSize() instead." << std::endl;
432  // return 0.0;
433  }
434 
446  double DomainSize() const override
447  {
448  return Area();
449  }
450 
459  bool IsInside(
460  const CoordinatesArrayType& rPoint,
461  CoordinatesArrayType& rResult,
462  const double Tolerance = std::numeric_limits<double>::epsilon()
463  ) const override
464  {
465  PointLocalCoordinates( rResult, rPoint );
466 
467  if ( (rResult[0] >= (-1.0-Tolerance)) && (rResult[0] <= (1.0+Tolerance)) )
468  {
469  if ( (rResult[1] >= (-1.0-Tolerance)) && (rResult[1] <= (1.0+Tolerance)) )
470  {
471  return true;
472  }
473  }
474 
475  return false;
476  }
477 
485  CoordinatesArrayType& rResult,
486  const CoordinatesArrayType& rPoint
487  ) const override
488  {
489  const double tol = 1.0e-8;
490  const int maxiter = 1000;
491 
492  //check orientation of surface
493  std::vector< unsigned int> orientation( 3 );
494 
495  double dummy = this->GetPoint( 0 ).X();
496 
497  if ( std::abs( this->GetPoint( 1 ).X() - dummy ) <= tol && std::abs( this->GetPoint( 2 ).X() - dummy ) <= tol && std::abs( this->GetPoint( 3 ).X() - dummy ) <= tol )
498  orientation[0] = 0;
499 
500  dummy = this->GetPoint( 0 ).Y();
501 
502  if ( std::abs( this->GetPoint( 1 ).Y() - dummy ) <= tol && std::abs( this->GetPoint( 2 ).Y() - dummy ) <= tol && std::abs( this->GetPoint( 3 ).Y() - dummy ) <= tol )
503  orientation[0] = 1;
504 
505  dummy = this->GetPoint( 0 ).Z();
506 
507  if ( std::abs( this->GetPoint( 1 ).Z() - dummy ) <= tol && std::abs( this->GetPoint( 2 ).Z() - dummy ) <= tol && std::abs( this->GetPoint( 3 ).Z() - dummy ) <= tol )
508  orientation[0] = 2;
509 
510  switch ( orientation[0] )
511  {
512  case 0:
513  orientation[0] = 1;
514  orientation[1] = 2;
515  orientation[2] = 0;
516  break;
517  case 1:
518  orientation[0] = 0;
519  orientation[1] = 2;
520  orientation[2] = 1;
521  break;
522  case 2:
523  orientation[0] = 0;
524  orientation[1] = 1;
525  orientation[2] = 2;
526  break;
527  default:
528  orientation[0] = 0;
529  orientation[1] = 1;
530  orientation[2] = 2;
531  }
532 
533  Matrix J = ZeroMatrix( 2, 2 );
534 
535  Matrix invJ = ZeroMatrix( 2, 2 );
536 
537  if ( rResult.size() != 2 )
538  rResult.resize( 2, false );
539 
540  //starting with xi = 0
541  rResult = ZeroVector( 2 );
542 
543  Vector DeltaXi = ZeroVector( 2 );
544 
545  CoordinatesArrayType CurrentGlobalCoords( ZeroVector( 3 ) );
546 
547  //Newton iteration:
548  for ( int k = 0; k < maxiter; k++ )
549  {
550  CurrentGlobalCoords = ZeroVector( 3 );
551  this->GlobalCoordinates( CurrentGlobalCoords, rResult );
552  noalias( CurrentGlobalCoords ) = rPoint - CurrentGlobalCoords;
553 
554  //Caluclate Inverse of Jacobian
555  noalias(J) = ZeroMatrix(2, 2);
556 
557  //derivatives of shape functions
558  Matrix shape_functions_gradients;
559  shape_functions_gradients = ShapeFunctionsLocalGradients(
560  shape_functions_gradients, rResult );
561 
562  //Elements of jacobian matrix (e.g. J(1,1) = dX1/dXi1)
563  //loop over all nodes
564  for ( unsigned int i = 0; i < this->PointsNumber(); i++ )
565  {
566  Point dummyPoint = this->GetPoint( i );
567  J( 0, 0 ) += ( dummyPoint[orientation[0]] ) * ( shape_functions_gradients( i, 0 ) );
568  J( 0, 1 ) += ( dummyPoint[orientation[0]] ) * ( shape_functions_gradients( i, 1 ) );
569  J( 1, 0 ) += ( dummyPoint[orientation[1]] ) * ( shape_functions_gradients( i, 0 ) );
570  J( 1, 1 ) += ( dummyPoint[orientation[1]] ) * ( shape_functions_gradients( i, 1 ) );
571  }
572 
573  //deteminant of Jacobian
574  double det_j = J( 0, 0 ) * J( 1, 1 ) - J( 0, 1 ) * J( 1, 0 );
575 
576  //filling matrix
577  invJ( 0, 0 ) = ( J( 1, 1 ) ) / ( det_j );
578 
579  invJ( 1, 0 ) = -( J( 1, 0 ) ) / ( det_j );
580 
581  invJ( 0, 1 ) = -( J( 0, 1 ) ) / ( det_j );
582 
583  invJ( 1, 1 ) = ( J( 0, 0 ) ) / ( det_j );
584 
585 
586  DeltaXi( 0 ) = invJ( 0, 0 ) * CurrentGlobalCoords( orientation[0] ) + invJ( 0, 1 ) * CurrentGlobalCoords( orientation[1] );
587 
588  DeltaXi( 1 ) = invJ( 1, 0 ) * CurrentGlobalCoords( orientation[0] ) + invJ( 1, 1 ) * CurrentGlobalCoords( orientation[1] );
589 
590  noalias( rResult ) += DeltaXi;
591 
592  if ( MathUtils<double>::Norm3( DeltaXi ) > 30 )
593  {
594  break;
595  }
596 
597  if ( MathUtils<double>::Norm3( DeltaXi ) < tol )
598  {
599  if ( !( std::abs( CurrentGlobalCoords( orientation[2] ) ) <= tol ) )
600  rResult( 0 ) = 2.0;
601 
602  break;
603  }
604  }
605 
606  return( rResult );
607  }
608 
631  IntegrationMethod ThisMethod ) const override
632  {
633  //getting derivatives of shape functions
634  ShapeFunctionsGradientsType shape_functions_gradients =
635  CalculateShapeFunctionsIntegrationPointsLocalGradients( ThisMethod );
636  //getting values of shape functions
637  Matrix shape_functions_values =
638  CalculateShapeFunctionsIntegrationPointsValues( ThisMethod );
639  //workaround by riccardo...
640 
641  if ( rResult.size() != this->IntegrationPointsNumber( ThisMethod ) )
642  {
643  // KLUDGE: While there is a bug in ublas
644  // vector resize, I have to put this beside resizing!!
645  JacobiansType temp( this->IntegrationPointsNumber( ThisMethod ) );
646  rResult.swap( temp );
647  }
648 
649  //loop over all integration points
650  for ( unsigned int pnt = 0; pnt < this->IntegrationPointsNumber( ThisMethod ); pnt++ )
651  {
652  //defining single jacobian matrix
653  Matrix jacobian = ZeroMatrix( 3, 2 );
654  //loop over all nodes
655 
656  for ( unsigned int i = 0; i < this->PointsNumber(); i++ )
657  {
658  jacobian( 0, 0 ) += ( this->GetPoint( i ).X() ) * ( shape_functions_gradients[pnt]( i, 0 ) );
659  jacobian( 0, 1 ) += ( this->GetPoint( i ).X() ) * ( shape_functions_gradients[pnt]( i, 1 ) );
660  jacobian( 1, 0 ) += ( this->GetPoint( i ).Y() ) * ( shape_functions_gradients[pnt]( i, 0 ) );
661  jacobian( 1, 1 ) += ( this->GetPoint( i ).Y() ) * ( shape_functions_gradients[pnt]( i, 1 ) );
662  jacobian( 2, 0 ) += ( this->GetPoint( i ).Z() ) * ( shape_functions_gradients[pnt]( i, 0 ) );
663  jacobian( 2, 1 ) += ( this->GetPoint( i ).Z() ) * ( shape_functions_gradients[pnt]( i, 1 ) );
664  }
665 
666  rResult[pnt] = jacobian;
667  }//end of loop over all integration points
668 
669  return rResult;
670  }
671 
672 
692  IntegrationMethod ThisMethod,
693  Matrix & DeltaPosition ) const override
694  {
695  //getting derivatives of shape functions
696  ShapeFunctionsGradientsType shape_functions_gradients =
697  CalculateShapeFunctionsIntegrationPointsLocalGradients( ThisMethod );
698  //getting values of shape functions
699  Matrix shape_functions_values =
700  CalculateShapeFunctionsIntegrationPointsValues( ThisMethod );
701  //workaround by riccardo...
702 
703  if ( rResult.size() != this->IntegrationPointsNumber( ThisMethod ) )
704  {
705  // KLUDGE: While there is a bug in ublas
706  // vector resize, I have to put this beside resizing!!
707  JacobiansType temp( this->IntegrationPointsNumber( ThisMethod ) );
708  rResult.swap( temp );
709  }
710 
711  //loop over all integration points
712  for ( unsigned int pnt = 0; pnt < this->IntegrationPointsNumber( ThisMethod ); pnt++ )
713  {
714  //defining single jacobian matrix
715  Matrix jacobian = ZeroMatrix( 3, 2 );
716  //loop over all nodes
717 
718  for ( unsigned int i = 0; i < this->PointsNumber(); i++ )
719  {
720  jacobian( 0, 0 ) += ( this->GetPoint( i ).X() - DeltaPosition(i,0) ) * ( shape_functions_gradients[pnt]( i, 0 ) );
721  jacobian( 0, 1 ) += ( this->GetPoint( i ).X() - DeltaPosition(i,0) ) * ( shape_functions_gradients[pnt]( i, 1 ) );
722  jacobian( 1, 0 ) += ( this->GetPoint( i ).Y() - DeltaPosition(i,1) ) * ( shape_functions_gradients[pnt]( i, 0 ) );
723  jacobian( 1, 1 ) += ( this->GetPoint( i ).Y() - DeltaPosition(i,1) ) * ( shape_functions_gradients[pnt]( i, 1 ) );
724  jacobian( 2, 0 ) += ( this->GetPoint( i ).Z() - DeltaPosition(i,2) ) * ( shape_functions_gradients[pnt]( i, 0 ) );
725  jacobian( 2, 1 ) += ( this->GetPoint( i ).Z() - DeltaPosition(i,2) ) * ( shape_functions_gradients[pnt]( i, 1 ) );
726  }
727 
728  rResult[pnt] = jacobian;
729  }//end of loop over all integration points
730 
731  return rResult;
732  }
733 
754  Matrix& Jacobian( Matrix& rResult, IndexType IntegrationPointIndex, IntegrationMethod ThisMethod ) const override
755  {
756  // Setting up size of jacobian matrix
757  if (rResult.size1() != 3 || rResult.size2() != 2)
758  rResult.resize( 3, 2 , false);
759  rResult.clear();
760  //derivatives of shape functions
761  ShapeFunctionsGradientsType shape_functions_gradients =
762  CalculateShapeFunctionsIntegrationPointsLocalGradients( ThisMethod );
763  Matrix ShapeFunctionsGradientInIntegrationPoint =
764  shape_functions_gradients( IntegrationPointIndex );
765  //values of shape functions in integration points
766  DenseVector<double> ShapeFunctionsValuesInIntegrationPoint = ZeroVector( 8 );
767  /*vector<double>*/
768  ShapeFunctionsValuesInIntegrationPoint = row(
769  CalculateShapeFunctionsIntegrationPointsValues( ThisMethod ),
770  IntegrationPointIndex );
771 
772  //Elements of jacobian matrix (e.g. J(1,1) = dX1/dXi1)
773  //loop over all nodes
774 
775  for ( unsigned int i = 0; i < this->PointsNumber(); i++ )
776  {
777  rResult( 0, 0 ) +=
778  ( this->GetPoint( i ).X() ) * ( ShapeFunctionsGradientInIntegrationPoint( i, 0 ) );
779  rResult( 0, 1 ) +=
780  ( this->GetPoint( i ).X() ) * ( ShapeFunctionsGradientInIntegrationPoint( i, 1 ) );
781  rResult( 1, 0 ) +=
782  ( this->GetPoint( i ).Y() ) * ( ShapeFunctionsGradientInIntegrationPoint( i, 0 ) );
783  rResult( 1, 1 ) +=
784  ( this->GetPoint( i ).Y() ) * ( ShapeFunctionsGradientInIntegrationPoint( i, 1 ) );
785  rResult( 2, 0 ) +=
786  ( this->GetPoint( i ).Z() ) * ( ShapeFunctionsGradientInIntegrationPoint( i, 0 ) );
787  rResult( 2, 1 ) +=
788  ( this->GetPoint( i ).Z() ) * ( ShapeFunctionsGradientInIntegrationPoint( i, 1 ) );
789  }
790 
791  return rResult;
792  }
793 
810  Matrix& Jacobian( Matrix& rResult, const CoordinatesArrayType& rPoint ) const override
811  {
812  // Setting up size of jacobian matrix
813  if (rResult.size1() != 3 || rResult.size2() != 2)
814  rResult.resize( 3, 2 , false);
815  rResult.clear();
816  //derivatives of shape functions
817  Matrix shape_functions_gradients;
818  shape_functions_gradients = ShapeFunctionsLocalGradients(
819  shape_functions_gradients, rPoint );
820  //Elements of jacobian matrix (e.g. J(1,1) = dX1/dXi1)
821  //loop over all nodes
822 
823  for ( unsigned int i = 0; i < this->PointsNumber(); i++ )
824  {
825  rResult( 0, 0 ) += ( this->GetPoint( i ).X() ) * ( shape_functions_gradients( i, 0 ) );
826  rResult( 0, 1 ) += ( this->GetPoint( i ).X() ) * ( shape_functions_gradients( i, 1 ) );
827  rResult( 1, 0 ) += ( this->GetPoint( i ).Y() ) * ( shape_functions_gradients( i, 0 ) );
828  rResult( 1, 1 ) += ( this->GetPoint( i ).Y() ) * ( shape_functions_gradients( i, 1 ) );
829  rResult( 2, 0 ) += ( this->GetPoint( i ).Z() ) * ( shape_functions_gradients( i, 0 ) );
830  rResult( 2, 1 ) += ( this->GetPoint( i ).Z() ) * ( shape_functions_gradients( i, 1 ) );
831  }
832 
833  return rResult;
834  }
835 
847  SizeType EdgesNumber() const override
848  {
849  return 4;
850  }
851 
861  {
863  edges.push_back( Kratos::make_shared<EdgeType>( this->pGetPoint( 0 ), this->pGetPoint( 1 ), this->pGetPoint( 4 ) ) );
864  edges.push_back( Kratos::make_shared<EdgeType>( this->pGetPoint( 1 ), this->pGetPoint( 2 ), this->pGetPoint( 5 ) ) );
865  edges.push_back( Kratos::make_shared<EdgeType>( this->pGetPoint( 2 ), this->pGetPoint( 3 ), this->pGetPoint( 6 ) ) );
866  edges.push_back( Kratos::make_shared<EdgeType>( this->pGetPoint( 3 ), this->pGetPoint( 0 ), this->pGetPoint( 7 ) ) );
867  return edges;
868  }
869 
886  double ShapeFunctionValue( IndexType ShapeFunctionIndex,
887  const CoordinatesArrayType& rPoint ) const override
888  {
889  switch ( ShapeFunctionIndex )
890  {
891  case 0:
892  return -(( 1.0 - rPoint[0] )*( 1.0 - rPoint[1] )
893  *( 1.0 + rPoint[0]
894  + rPoint[1] ) ) / 4.0;
895  case 1:
896  return -(( 1.0 + rPoint[0] )
897  *( 1.0 - rPoint[1] )*( 1.0
898  - rPoint[0] + rPoint[1] ) ) / 4.0;
899  case 2 :
900  return -(( 1.0 + rPoint[0] )
901  *( 1.0 + rPoint[1] )*( 1.0
902  - rPoint[0] - rPoint[1] ) ) / 4.0;
903  case 3 :
904  return -(( 1.0 - rPoint[0] )*( 1.0
905  + rPoint[1] )*( 1.0 )*( 1.0
906  + rPoint[0] - rPoint[1] ) ) / 4.0;
907  case 4 :
908  return (( 1.0 -rPoint[0]*rPoint[0] )
909  *( 1.0 - rPoint[1] ) ) / 2.0;
910  case 5 :
911  return (( 1.0 + rPoint[0] )
912  *( 1.0 - rPoint[1]*rPoint[1] ) ) / 2.0 ;
913  case 6 :
914  return (( 1.0 -rPoint[0]
915  *rPoint[0] )*( 1.0 + rPoint[1] ) ) / 2.0 ;
916  case 7 :
917  return (( 1.0 -rPoint[0] )
918  *( 1.0 - rPoint[1]*rPoint[1] ) ) / 2.0 ;
919  default:
920  KRATOS_ERROR << "Wrong index of shape function!" << *this << std::endl;
921  }
922 
923  return 0;
924  }
925 
937  Vector& ShapeFunctionsValues (Vector &rResult, const CoordinatesArrayType& rCoordinates) const override
938  {
939  if(rResult.size() != 8) rResult.resize(8,false);
940 
941  rResult[0] = -(( 1.0 - rCoordinates[0] )*( 1.0 - rCoordinates[1] )
942  *( 1.0 + rCoordinates[0]
943  + rCoordinates[1] ) ) / 4.0;
944  rResult[1] = -(( 1.0 + rCoordinates[0] )
945  *( 1.0 - rCoordinates[1] )*( 1.0
946  - rCoordinates[0] + rCoordinates[1] ) ) / 4.0;
947  rResult[2] = -(( 1.0 + rCoordinates[0] )
948  *( 1.0 + rCoordinates[1] )*( 1.0
949  - rCoordinates[0] - rCoordinates[1] ) ) / 4.0;
950  rResult[3] = -(( 1.0 - rCoordinates[0] )*( 1.0
951  + rCoordinates[1] )*( 1.0 )*( 1.0
952  + rCoordinates[0] - rCoordinates[1] ) ) / 4.0;
953  rResult[4] = (( 1.0 -rCoordinates[0]*rCoordinates[0] )
954  *( 1.0 - rCoordinates[1] ) ) / 2.0;
955  rResult[5] = (( 1.0 + rCoordinates[0] )
956  *( 1.0 - rCoordinates[1]*rCoordinates[1] ) ) / 2.0 ;
957  rResult[6] = (( 1.0 -rCoordinates[0]
958  *rCoordinates[0] )*( 1.0 + rCoordinates[1] ) ) / 2.0 ;
959  rResult[7] = (( 1.0 -rCoordinates[0] )
960  *( 1.0 - rCoordinates[1]*rCoordinates[1] ) ) / 2.0 ;
961 
962  return rResult;
963  }
964 
966 
977  std::string Info() const override
978  {
979  return "2 dimensional quadrilateral with eight nodes in 2D space";
980  }
981 
988  void PrintInfo( std::ostream& rOStream ) const override
989  {
990  rOStream << "2 dimensional quadrilateral with eight nodes in 2D space";
991  }
992 
1002  void PrintData( std::ostream& rOStream ) const override
1003  {
1004  // Base Geometry class PrintData call
1005  BaseType::PrintData( rOStream );
1006  std::cout << std::endl;
1007 
1008  // If the geometry has valid points, calculate and output its data
1009  if (this->AllPointsAreValid()) {
1010  Matrix jacobian;
1011  this->Jacobian( jacobian, PointType() );
1012  rOStream << " Jacobian\t : " << jacobian;
1013  }
1014  }
1015 
1021  IntegrationMethod ThisMethod )
1022  {
1023  ShapeFunctionsGradientsType localGradients
1024  = CalculateShapeFunctionsIntegrationPointsLocalGradients( ThisMethod );
1025  const int integration_points_number
1026  = msGeometryData.IntegrationPointsNumber( ThisMethod );
1027  ShapeFunctionsGradientsType Result( integration_points_number );
1028 
1029  for ( int pnt = 0; pnt < integration_points_number; pnt++ )
1030  {
1031  Result[pnt] = localGradients[pnt];
1032  }
1033 
1034  return Result;
1035  }
1036 
1042  {
1043  IntegrationMethod ThisMethod = msGeometryData.DefaultIntegrationMethod();
1044  ShapeFunctionsGradientsType localGradients
1045  = CalculateShapeFunctionsIntegrationPointsLocalGradients( ThisMethod );
1046  const int integration_points_number
1047  = msGeometryData.IntegrationPointsNumber( ThisMethod );
1048  ShapeFunctionsGradientsType Result( integration_points_number );
1049 
1050  for ( int pnt = 0; pnt < integration_points_number; pnt++ )
1051  {
1052  Result[pnt] = localGradients[pnt];
1053  }
1054 
1055  return Result;
1056  }
1057 
1067  const CoordinatesArrayType& rPoint ) const override
1068  {
1069  //setting up result matrix
1070  rResult.resize( 8, 2, false );
1071  noalias( rResult ) = ZeroMatrix( 8, 2 );
1072 
1073  rResult( 0, 0 ) = (( -1.0 + rPoint[1] ) * ( -2.0 ) * ( 1.0 + 2.0
1074  * rPoint[0] + rPoint[1] - 1.0 ) ) / 8.0;
1075  rResult( 0, 1 ) = (( -1.0 + rPoint[0] ) * ( -2.0 ) * ( 1.0 + rPoint[0] + 2.0
1076  * rPoint[1] - 1.0 ) ) / 8.0;
1077 
1078  rResult( 1, 0 ) = -(( -1.0 + rPoint[1] ) * ( -2.0 ) * ( 1.0 - 2.0
1079  * rPoint[0] + rPoint[1] - 1.0 ) ) / 8.0;
1080  rResult( 1, 1 ) = (( 1.0 + rPoint[0] ) * ( -1.0 + rPoint[0] - 2.0
1081  * rPoint[1] + 1.0 ) * ( -2.0 ) ) / 8.0;
1082 
1083  rResult( 2, 0 ) = -(( 1.0 + rPoint[1] ) * ( -1.0 + 2.0
1084  * rPoint[0] + rPoint[1] + 1.0 ) * ( -2.0 ) ) / 8.0;
1085  rResult( 2, 1 ) = -(( 1.0 + rPoint[0] ) * ( -1.0 + rPoint[0] + 2.0
1086  * rPoint[1] + 1.0 ) * ( -2.0 ) ) / 8.0;
1087 
1088  rResult( 3, 0 ) = (( 1.0 + rPoint[1] ) * ( -1.0 - 2.0
1089  * rPoint[0] + rPoint[1] + 1.0 ) * ( -2.0 ) ) / 8.0;
1090  rResult( 3, 1 ) = -(( -1.0 + rPoint[0] ) * ( -2.0 ) * ( 1.0 + rPoint[0] - 2.0
1091  * rPoint[1] - 1.0 ) ) / 8.0;
1092 
1093  rResult( 4, 0 ) = -( rPoint[0] * ( -1.0 + rPoint[1] ) * ( -2.0 ) ) / 2.0;
1094  rResult( 4, 1 ) = -(( -1.0 + rPoint[0] * rPoint[0] ) * ( -2.0 ) ) / 4.0;
1095 
1096  rResult( 5, 0 ) = (( -1.0 + rPoint[1] * rPoint[1] ) * ( -2.0 ) ) / 4.0;
1097  rResult( 5, 1 ) = (( 1.0 + rPoint[0] ) * rPoint[1] * ( -2.0 ) ) / 2.0;
1098 
1099  rResult( 6, 0 ) = ( rPoint[0] * ( 1.0 + rPoint[1] ) * ( -2.0 ) ) / 2.0;
1100  rResult( 6, 1 ) = (( -1.0 + rPoint[0] * rPoint[0] ) * ( -2.0 ) ) / 4.0;
1101 
1102  rResult( 7, 0 ) = -(( -1.0 + rPoint[1] * rPoint[1] ) * ( -2.0 ) ) / 4.0;
1103  rResult( 7, 1 ) = -(( -1.0 + rPoint[0] ) * rPoint[1] * ( -2.0 ) ) / 2.0;
1104 
1105  return( rResult );
1106  }
1107 
1113  Matrix& PointsLocalCoordinates( Matrix& rResult ) const override
1114  {
1115  rResult.resize( 8, 2, false );
1116  noalias( rResult ) = ZeroMatrix( 8, 2 );
1117  rResult( 0, 0 ) = -1.0;
1118  rResult( 0, 1 ) = -1.0;
1119  rResult( 1, 0 ) = 1.0;
1120  rResult( 1, 1 ) = -1.0;
1121  rResult( 2, 0 ) = 1.0;
1122  rResult( 2, 1 ) = 1.0;
1123  rResult( 3, 0 ) = -1.0;
1124  rResult( 3, 1 ) = 1.0;
1125  rResult( 4, 0 ) = 0.0;
1126  rResult( 4, 1 ) = -1.0;
1127  rResult( 5, 0 ) = 1.0;
1128  rResult( 5, 1 ) = 0.0;
1129  rResult( 6, 0 ) = 0.0;
1130  rResult( 6, 1 ) = 1.0;
1131  rResult( 7, 0 ) = -1.0;
1132  rResult( 7, 1 ) = 0.0;
1133  return rResult;
1134  }
1135 
1144  virtual Matrix& ShapeFunctionsGradients( Matrix& rResult, PointType& rPoint )
1145  {
1146  rResult.resize( 8, 2, false );
1147  noalias( rResult ) = ZeroMatrix( 8, 2 );
1148 
1149  rResult( 0, 0 ) = (( -1.0 + rPoint.Y() ) * ( -2.0 ) * ( 1.0 + 2.0
1150  * rPoint.X() + rPoint.Y() - 1.0 ) ) / 8.0;
1151  rResult( 0, 1 ) = (( -1.0 + rPoint.X() ) * ( -2.0 ) * ( 1.0 + rPoint.X() + 2.0
1152  * rPoint.Y() - 1.0 ) ) / 8.0;
1153 
1154  rResult( 1, 0 ) = -(( -1.0 + rPoint.Y() ) * ( -2.0 ) * ( 1.0 - 2.0
1155  * rPoint.X() + rPoint.Y() - 1.0 ) ) / 8.0;
1156  rResult( 1, 1 ) = (( 1.0 + rPoint.X() ) * ( -1.0 + rPoint.X() - 2.0
1157  * rPoint.Y() + 1.0 ) * ( -2.0 ) ) / 8.0;
1158 
1159  rResult( 2, 0 ) = -(( 1.0 + rPoint.Y() ) * ( -1.0 + 2.0
1160  * rPoint.X() + rPoint.Y() + 1.0 ) * ( -2.0 ) ) / 8.0;
1161  rResult( 2, 1 ) = -(( 1.0 + rPoint.X() ) * ( -1.0 + rPoint.X() + 2.0
1162  * rPoint.Y() + 1.0 ) * ( -2.0 ) ) / 8.0;
1163 
1164  rResult( 3, 0 ) = (( 1.0 + rPoint.Y() ) * ( -1.0 - 2.0
1165  * rPoint.X() + rPoint.Y() + 1.0 ) * ( -2.0 ) ) / 8.0;
1166  rResult( 3, 1 ) = -(( -1.0 + rPoint.X() ) * ( -2.0 ) * ( 1.0 + rPoint.X() - 2.0
1167  * rPoint.Y() - 1.0 ) ) / 8.0;
1168 
1169  rResult( 4, 0 ) = -( rPoint.X() * ( -1.0 + rPoint.Y() ) * ( -2.0 ) ) / 2.0;
1170  rResult( 4, 1 ) = -(( -1.0 + rPoint.X() * rPoint.X() ) * ( -2.0 ) ) / 4.0;
1171 
1172  rResult( 5, 0 ) = (( -1.0 + rPoint.Y() * rPoint.Y() ) * ( -2.0 ) ) / 4.0;
1173  rResult( 5, 1 ) = (( 1.0 + rPoint.X() ) * rPoint.Y() * ( -2.0 ) ) / 2.0;
1174 
1175  rResult( 6, 0 ) = ( rPoint.X() * ( 1.0 + rPoint.Y() ) * ( -2.0 ) ) / 2.0;
1176  rResult( 6, 1 ) = (( -1.0 + rPoint.X() * rPoint.X() ) * ( -2.0 ) ) / 4.0;
1177 
1178  rResult( 7, 0 ) = -(( -1.0 + rPoint.Y() * rPoint.Y() ) * ( -2.0 ) ) / 4.0;
1179  rResult( 7, 1 ) = -(( -1.0 + rPoint.X() ) * rPoint.Y() * ( -2.0 ) ) / 2.0;
1180 
1181  return rResult;
1182  }
1183 
1192  {
1193  if ( rResult.size() != this->PointsNumber() )
1194  {
1195  // KLUDGE: While there is a bug in ublas
1196  // vector resize, I have to put this beside resizing!!
1198  rResult.swap( temp );
1199  }
1200 
1201  for ( unsigned int i = 0; i < this->PointsNumber(); i++ )
1202  {
1203  rResult[i].resize( 2, 2, false );
1204  noalias( rResult[i] ) = ZeroMatrix( 2, 2 );
1205  }
1206 
1207  rResult[0]( 0, 0 ) = ( 4.0 - 4 * rPoint[1] ) / 8.0;
1208 
1209  rResult[0]( 0, 1 ) = ( -2.0 ) * ( 1.0 + 2.0 * rPoint[0] + rPoint[1] - 1.0 ) / 8.0
1210  + (( -1.0 + rPoint[1] ) * ( -2.0 ) ) / 8.0;
1211  rResult[0]( 1, 0 ) = ( -2.0 ) * ( 1.0 + rPoint[0] + 2.0 * rPoint[1] - 1.0 ) / 8.0
1212  + (( -1.0 + rPoint[0] ) * ( -2.0 ) ) / 8.0;
1213  rResult[0]( 1, 1 ) = (( -1.0 + rPoint[0] ) * ( -2.0 ) * ( 2.0 ) ) / 8.0;
1214 
1215  rResult[1]( 0, 0 ) = -(( -1.0 + rPoint[1] ) * ( -2.0 ) * ( -2.0 ) ) / 8.0;
1216  rResult[1]( 0, 1 ) = ( 2.0 ) * ( 1.0 - 2.0 * rPoint[0] + rPoint[1] - 1.0 ) / 8.0
1217  - (( -1.0 + rPoint[1] ) * ( -2.0 ) ) / 8.0;
1218  rResult[1]( 1, 0 ) = ( -1.0 + rPoint[0] - 2.0 * rPoint[1] + 1.0 ) * ( -2.0 ) / 8.0
1219  + (( 1.0 + rPoint[0] ) * ( -2.0 ) ) / 8.0;
1220  rResult[1]( 1, 1 ) = (( 1.0 + rPoint[0] ) * ( -2.0 ) * ( -2.0 ) ) / 8.0;
1221 
1222  rResult[2]( 0, 0 ) = -(( 1.0 + rPoint[1] ) * ( 2.0 ) * ( -2.0 ) ) / 8.0;
1223  rResult[2]( 0, 1 ) = -(( 1.0 ) * ( -1.0 + 2.0 * rPoint[0] + rPoint[1] + 1.0 ) * ( -2.0 ) ) / 8.0
1224  - (( 1.0 + rPoint[1] ) * ( -2.0 ) ) / 8.0;
1225  rResult[2]( 1, 0 ) = -(( 1.0 ) * ( -1.0 + rPoint[0] + 2.0 * rPoint[1] + 1.0 ) * ( -2.0 ) ) / 8.0
1226  - (( 1.0 + rPoint[0] ) * ( -2.0 ) ) / 8.0;
1227  rResult[2]( 1, 1 ) = -(( 1.0 + rPoint[0] ) * ( 2.0 ) * ( -2.0 ) ) / 8.0;
1228 
1229  rResult[3]( 0, 0 ) = (( 1.0 + rPoint[1] ) * ( -2.0 ) * ( -2.0 ) ) / 8.0;
1230  rResult[3]( 0, 1 ) = (( 1.0 ) * ( -1.0 - 2.0 * rPoint[0] + rPoint[1] + 1.0 ) * ( -2.0 ) ) / 8.0
1231  + (( 1.0 + rPoint[1] ) * ( -2.0 ) ) / 8.0;
1232  rResult[3]( 1, 0 ) = -(( -2.0 ) * ( 1.0 + rPoint[0] - 2.0 * rPoint[1] - 1.0 ) ) / 8.0
1233  - (( -1.0 + rPoint[0] ) * ( -2.0 ) ) / 8.0;
1234  rResult[3]( 1, 1 ) = -(( -1.0 + rPoint[0] ) * ( -2.0 ) * ( -2.0 ) ) / 8.0;
1235 
1236  rResult[4]( 0, 0 ) = -(( -1.0 + rPoint[1] ) * ( -2.0 ) ) / 2.0;
1237  rResult[4]( 0, 1 ) = -( rPoint[0] * ( -2.0 ) ) / 2.0;
1238  rResult[4]( 1, 0 ) = -(( 2.0 * rPoint[0] ) * ( -2.0 ) ) / 4.0;
1239  rResult[4]( 1, 1 ) = 0.0;
1240 
1241  rResult[5]( 0, 0 ) = 0.0;
1242  rResult[5]( 0, 1 ) = (( 2.0 * rPoint[1] ) * ( -2.0 ) ) / 4.0;
1243  rResult[5]( 1, 0 ) = ( rPoint[1] * ( -2.0 ) ) / 2.0;
1244  rResult[5]( 1, 1 ) = (( 1.0 + rPoint[0] ) * ( -2.0 ) ) / 2.0;
1245 
1246  rResult[6]( 0, 0 ) = (( 1.0 + rPoint[1] ) * ( -2.0 ) ) / 2.0;
1247  rResult[6]( 0, 1 ) = ( rPoint[0] * ( -2.0 ) ) / 2.0;
1248  rResult[6]( 1, 0 ) = (( 2.0 * rPoint[0] ) * ( -2.0 ) ) / 4.0;
1249  rResult[6]( 1, 1 ) = 0.0;
1250 
1251  rResult[7]( 0, 0 ) = 0.0;
1252  rResult[7]( 0, 1 ) = -(( 2.0 * rPoint[1] ) * ( -2.0 ) ) / 4.0;
1253  rResult[7]( 1, 0 ) = -( rPoint[1] * ( -2.0 ) ) / 2.0;
1254  rResult[7]( 1, 1 ) = -(( -1.0 + rPoint[0] ) * ( -2.0 ) ) / 2.0;
1255 
1256  return rResult;
1257  }
1258 
1267  {
1268 
1269  if ( rResult.size() != this->PointsNumber() )
1270  {
1271  // KLUDGE: While there is a bug in
1272  // ublas vector resize, I have to put this beside resizing!!
1273 // ShapeFunctionsGradientsType
1275  rResult.swap( temp );
1276  }
1277 
1278  for ( IndexType i = 0; i < rResult.size(); i++ )
1279  {
1281  rResult[i].swap( temp );
1282  }
1283 
1284  for ( unsigned int i = 0; i < this->PointsNumber(); i++ )
1285  {
1286  for ( int j = 0; j < 2; j++ )
1287  {
1288  rResult[i][j].resize( 2, 2, false );
1289  noalias( rResult[i][j] ) = ZeroMatrix( 2, 2 );
1290  }
1291  }
1292 
1293  rResult[0][0]( 0, 0 ) = 0.0;
1294  rResult[0][0]( 0, 1 ) = -0.5;
1295  rResult[0][0]( 1, 0 ) = -0.5;
1296  rResult[0][0]( 1, 1 ) = -0.5;
1297  rResult[0][1]( 0, 0 ) = -0.5;
1298  rResult[0][1]( 0, 1 ) = -0.5;
1299  rResult[0][1]( 1, 0 ) = -0.5;
1300  rResult[0][1]( 1, 1 ) = 0.0;
1301  rResult[1][0]( 0, 0 ) = 0.0;
1302  rResult[1][0]( 0, 1 ) = -0.5;
1303  rResult[1][0]( 1, 0 ) = -0.5;
1304  rResult[1][0]( 1, 1 ) = 0.5;
1305  rResult[1][1]( 0, 0 ) = -0.5;
1306  rResult[1][1]( 0, 1 ) = 0.5;
1307  rResult[1][1]( 1, 0 ) = 0.5;
1308  rResult[1][1]( 1, 1 ) = 0.0;
1309  rResult[2][0]( 0, 0 ) = 0.0;
1310  rResult[2][0]( 0, 1 ) = 0.5;
1311  rResult[2][0]( 1, 0 ) = 0.5;
1312  rResult[2][0]( 1, 1 ) = 0.5;
1313  rResult[2][1]( 0, 0 ) = 0.5;
1314  rResult[2][1]( 0, 1 ) = 0.5;
1315  rResult[2][1]( 1, 0 ) = 0.5;
1316  rResult[2][1]( 1, 1 ) = 0.0;
1317  rResult[3][0]( 0, 0 ) = 0.0;
1318  rResult[3][0]( 0, 1 ) = 0.5;
1319  rResult[3][0]( 1, 0 ) = 0.5;
1320  rResult[3][0]( 1, 1 ) = -0.5;
1321  rResult[3][1]( 0, 0 ) = 0.5;
1322  rResult[3][1]( 0, 1 ) = -0.5;
1323  rResult[3][1]( 1, 0 ) = -0.5;
1324  rResult[3][1]( 1, 1 ) = 0.0;
1325  rResult[4][0]( 0, 0 ) = 0.0;
1326  rResult[4][0]( 0, 1 ) = 1.0;
1327  rResult[4][0]( 1, 0 ) = 1.0;
1328  rResult[4][0]( 1, 1 ) = 0.0;
1329  rResult[4][1]( 0, 0 ) = 1.0;
1330  rResult[4][1]( 0, 1 ) = 0.0;
1331  rResult[4][1]( 1, 0 ) = 0.0;
1332  rResult[4][1]( 1, 1 ) = 0.0;
1333  rResult[5][0]( 0, 0 ) = 0.0;
1334  rResult[5][0]( 0, 1 ) = 0.0;
1335  rResult[5][0]( 1, 0 ) = 0.0;
1336  rResult[5][0]( 1, 1 ) = -1.0;
1337  rResult[5][1]( 0, 0 ) = 0.0;
1338  rResult[5][1]( 0, 1 ) = -1.0;
1339  rResult[5][1]( 1, 0 ) = 1.0;
1340  rResult[5][1]( 1, 1 ) = 0.0;
1341  rResult[6][0]( 0, 0 ) = 0.0;
1342  rResult[6][0]( 0, 1 ) = -1.0;
1343  rResult[6][0]( 1, 0 ) = -1.0;
1344  rResult[6][0]( 1, 1 ) = 0.0;
1345  rResult[6][1]( 0, 0 ) = -1.0;
1346  rResult[6][1]( 0, 1 ) = 0.0;
1347  rResult[6][1]( 1, 0 ) = 0.0;
1348  rResult[6][1]( 1, 1 ) = 0.0;
1349  rResult[7][0]( 0, 0 ) = 0.0;
1350  rResult[7][0]( 0, 1 ) = 0.0;
1351  rResult[7][0]( 1, 0 ) = 0.0;
1352  rResult[7][0]( 1, 1 ) = 1.0;
1353  rResult[7][1]( 0, 0 ) = 0.0;
1354  rResult[7][1]( 0, 1 ) = 1.0;
1355  rResult[7][1]( 1, 0 ) = -1.0;
1356  rResult[7][1]( 1, 1 ) = 0.0;
1357 
1358  return rResult;
1359  }
1360 
1361 
1362 
1363 
1364 
1365 protected:
1366 
1371 private:
1372 
1377  static const GeometryData msGeometryData;
1378 
1379  static const GeometryDimension msGeometryDimension;
1380 
1384 
1385  friend class Serializer;
1386 
1387  void save( Serializer& rSerializer ) const override
1388  {
1390  }
1391 
1392  void load( Serializer& rSerializer ) override
1393  {
1395  }
1396 
1397  Quadrilateral3D8(): BaseType( PointsArrayType(), &msGeometryData ) {}
1398 
1416  static Matrix CalculateShapeFunctionsIntegrationPointsValues( typename BaseType::IntegrationMethod ThisMethod )
1417  {
1418  IntegrationPointsContainerType all_integration_points = AllIntegrationPoints();
1419  IntegrationPointsArrayType integration_points = all_integration_points[static_cast<int>(ThisMethod)];
1420  //number of integration points
1421  const int integration_points_number = integration_points.size();
1422  //number of nodes in current geometry
1423  const int points_number = 8;
1424  //setting up return matrix
1425  Matrix shape_function_values( integration_points_number, points_number );
1426  //loop over all integration points
1427 
1428  for ( int pnt = 0; pnt < integration_points_number; pnt++ )
1429  {
1430  row( shape_function_values, pnt )[0] =
1431  -(( 1.0 - integration_points[pnt].X() )
1432  * ( 1.0 - integration_points[pnt].Y() )
1433  * ( 1.0 + integration_points[pnt].X()
1434  + integration_points[pnt].Y() ) ) / 4.0;
1435  row( shape_function_values, pnt )[1] =
1436  -(( 1.0 + integration_points[pnt].X() )
1437  * ( 1.0 - integration_points[pnt].Y() ) * ( 1.0
1438  - integration_points[pnt].X()
1439  + integration_points[pnt].Y() ) ) / 4.0;
1440  row( shape_function_values, pnt )[2] =
1441  -(( 1.0 + integration_points[pnt].X() )
1442  * ( 1.0 + integration_points[pnt].Y() ) * ( 1.0
1443  - integration_points[pnt].X()
1444  - integration_points[pnt].Y() ) ) / 4.0;
1445  row( shape_function_values, pnt )[3] =
1446  -(( 1.0 - integration_points[pnt].X() ) * ( 1.0
1447  + integration_points[pnt].Y() ) * ( 1.0 ) * ( 1.0
1448  + integration_points[pnt].X()
1449  - integration_points[pnt].Y() ) ) / 4.0;
1450  row( shape_function_values, pnt )[4] =
1451  (( 1.0 - integration_points[pnt].X()
1452  * integration_points[pnt].X() )
1453  * ( 1.0 - integration_points[pnt].Y() ) ) / 2.0;
1454  row( shape_function_values, pnt )[5] =
1455  (( 1.0 + integration_points[pnt].X() )
1456  * ( 1.0 - integration_points[pnt].Y()
1457  * integration_points[pnt].Y() ) ) / 2.0 ;
1458  row( shape_function_values, pnt )[6] =
1459  (( 1.0 - integration_points[pnt].X()
1460  * integration_points[pnt].X() )
1461  * ( 1.0 + integration_points[pnt].Y() ) ) / 2.0 ;
1462  row( shape_function_values, pnt )[7] =
1463  (( 1.0 - integration_points[pnt].X() )
1464  * ( 1.0 - integration_points[pnt].Y()
1465  * integration_points[pnt].Y() ) ) / 2.0 ;
1466  }
1467 
1468  return shape_function_values;
1469  }
1470 
1483  CalculateShapeFunctionsIntegrationPointsLocalGradients(
1484  typename BaseType::IntegrationMethod ThisMethod )
1485  {
1486  IntegrationPointsContainerType all_integration_points = AllIntegrationPoints();
1487  IntegrationPointsArrayType integration_points = all_integration_points[static_cast<int>(ThisMethod)];
1488  //number of integration points
1489  const int integration_points_number = integration_points.size();
1490  ShapeFunctionsGradientsType d_shape_f_values( integration_points_number );
1491  //initialising container
1492  //std::fill(d_shape_f_values.begin(), d_shape_f_values.end(), Matrix(4,2));
1493  //loop over all integration points
1494 
1495  for ( int pnt = 0; pnt < integration_points_number; pnt++ )
1496  {
1497  Matrix result = ZeroMatrix( 8, 2 );
1498 
1499  result( 0, 0 ) = (( -1.0 + integration_points[pnt].Y() )
1500  * ( -2.0 ) * ( 1.0 + 2.0
1501  * integration_points[pnt].X()
1502  + integration_points[pnt].Y() - 1.0 ) ) / 8.0;
1503  result( 0, 1 ) = (( -1.0 + integration_points[pnt].X() ) * ( -2.0 ) * ( 1.0
1504  + integration_points[pnt].X() + 2.0
1505  * integration_points[pnt].Y() - 1.0 ) ) / 8.0;
1506 
1507  result( 1, 0 ) = -(( -1.0 + integration_points[pnt].Y() )
1508  * ( -2.0 ) * ( 1.0 - 2.0 * integration_points[pnt].X()
1509  + integration_points[pnt].Y() - 1.0 ) ) / 8.0;
1510  result( 1, 1 ) = (( 1.0 + integration_points[pnt].X() ) * ( -1.0
1511  + integration_points[pnt].X() - 2.0
1512  * integration_points[pnt].Y() + 1.0 ) * ( -2.0 ) ) / 8.0;
1513 
1514  result( 2, 0 ) = -(( 1.0 + integration_points[pnt].Y() )
1515  * ( -1.0 + 2.0 * integration_points[pnt].X()
1516  + integration_points[pnt].Y() + 1.0 ) * ( -2.0 ) ) / 8.0;
1517  result( 2, 1 ) = -(( 1.0 + integration_points[pnt].X() ) * ( -1.0
1518  + integration_points[pnt].X() + 2.0
1519  * integration_points[pnt].Y() + 1.0 ) * ( -2.0 ) ) / 8.0;
1520 
1521  result( 3, 0 ) = (( 1.0 + integration_points[pnt].Y() ) * ( -1.0 - 2.0
1522  * integration_points[pnt].X()
1523  + integration_points[pnt].Y() + 1.0 ) * ( -2.0 ) ) / 8.0;
1524  result( 3, 1 ) = -(( -1.0 + integration_points[pnt].X() ) * ( -2.0 ) * ( 1.0
1525  + integration_points[pnt].X() - 2.0
1526  * integration_points[pnt].Y() - 1.0 ) ) / 8.0;
1527 
1528  result( 4, 0 ) = -( integration_points[pnt].X() * ( -1.0
1529  + integration_points[pnt].Y() ) * ( -2.0 ) ) / 2.0;
1530 
1531  result( 4, 1 ) = -(( -1.0
1532  + integration_points[pnt].X()
1533  * integration_points[pnt].X() ) * ( -2.0 ) ) / 4.0;
1534 
1535  result( 5, 0 ) = (( -1.0
1536  + integration_points[pnt].Y()
1537  * integration_points[pnt].Y() ) * ( -2.0 ) ) / 4.0;
1538 
1539  result( 5, 1 ) = (( 1.0
1540  + integration_points[pnt].X() )
1541  * integration_points[pnt].Y() * ( -2.0 ) ) / 2.0;
1542 
1543  result( 6, 0 ) = ( integration_points[pnt].X() * ( 1.0
1544  + integration_points[pnt].Y() ) * ( -2.0 ) ) / 2.0;
1545  result( 6, 1 ) = (( -1.0
1546  + integration_points[pnt].X()
1547  * integration_points[pnt].X() ) * ( -2.0 ) ) / 4.0;
1548 
1549  result( 7, 0 ) = -(( -1.0
1550  + integration_points[pnt].Y()
1551  * integration_points[pnt].Y() ) * ( -2.0 ) ) / 4.0;
1552 
1553  result( 7, 1 ) = -(( -1.0
1554  + integration_points[pnt].X() )
1555  * integration_points[pnt].Y() * ( -2.0 ) ) / 2.0;
1556 
1557  d_shape_f_values[pnt] = result;
1558  }
1559 
1560  return d_shape_f_values;
1561  }
1562 
1566  static const IntegrationPointsContainerType AllIntegrationPoints()
1567  {
1568  IntegrationPointsContainerType integration_points =
1569  {
1570  {
1571  Quadrature < QuadrilateralGaussLegendreIntegrationPoints1,
1572  2, IntegrationPoint<3> >::GenerateIntegrationPoints(),
1573  Quadrature < QuadrilateralGaussLegendreIntegrationPoints2,
1574  2, IntegrationPoint<3> >::GenerateIntegrationPoints(),
1575  Quadrature < QuadrilateralGaussLegendreIntegrationPoints3,
1576  2, IntegrationPoint<3> >::GenerateIntegrationPoints(),
1577  Quadrature < QuadrilateralGaussLegendreIntegrationPoints4,
1578  2, IntegrationPoint<3> >::GenerateIntegrationPoints(),
1579  Quadrature < QuadrilateralGaussLegendreIntegrationPoints5,
1580  2, IntegrationPoint<3> >::GenerateIntegrationPoints()
1581  }
1582  };
1583  return integration_points;
1584  }
1585 
1589  static const ShapeFunctionsValuesContainerType AllShapeFunctionsValues()
1590  {
1591  ShapeFunctionsValuesContainerType shape_functions_values =
1592  {
1593  {
1594  Quadrilateral3D8<TPointType>::CalculateShapeFunctionsIntegrationPointsValues(
1596  Quadrilateral3D8<TPointType>::CalculateShapeFunctionsIntegrationPointsValues(
1598  Quadrilateral3D8<TPointType>::CalculateShapeFunctionsIntegrationPointsValues(
1600  Quadrilateral3D8<TPointType>::CalculateShapeFunctionsIntegrationPointsValues(
1602  Quadrilateral3D8<TPointType>::CalculateShapeFunctionsIntegrationPointsValues(
1604  }
1605  };
1606  return shape_functions_values;
1607  }
1608 
1613  AllShapeFunctionsLocalGradients()
1614  {
1615  ShapeFunctionsLocalGradientsContainerType shape_functions_local_gradients =
1616  {
1617  {
1618  Quadrilateral3D8<TPointType>::CalculateShapeFunctionsIntegrationPointsLocalGradients(
1620  Quadrilateral3D8<TPointType>::CalculateShapeFunctionsIntegrationPointsLocalGradients(
1622  Quadrilateral3D8<TPointType>::CalculateShapeFunctionsIntegrationPointsLocalGradients(
1624  Quadrilateral3D8<TPointType>::CalculateShapeFunctionsIntegrationPointsLocalGradients(
1626  Quadrilateral3D8<TPointType>::CalculateShapeFunctionsIntegrationPointsLocalGradients(
1628  }
1629  };
1630  return shape_functions_local_gradients;
1631  }
1632 
1637  template<class TOtherPointType> friend class Quadrilateral3D8;
1638 
1643 }; // Class Geometry
1644 
1651 template< class TPointType > inline std::istream& operator >> (
1652  std::istream& rIStream,
1654 
1658 template<class TPointType> inline std::ostream& operator << (
1659  std::ostream& rOStream,
1660  const Quadrilateral3D8<TPointType>& rThis )
1661 {
1662  rThis.PrintInfo( rOStream );
1663  rOStream << std::endl;
1664  rThis.PrintData( rOStream );
1665  return rOStream;
1666 }
1667 
1668 template<class TPointType>
1669 const GeometryData Quadrilateral3D8<TPointType>::msGeometryData(
1672  Quadrilateral3D8<TPointType>::AllIntegrationPoints(),
1673  Quadrilateral3D8<TPointType>::AllShapeFunctionsValues(),
1674  AllShapeFunctionsLocalGradients()
1675 );
1676 
1677 template<class TPointType>
1678 const GeometryDimension Quadrilateral3D8<TPointType>::msGeometryDimension(3, 2);
1679 
1680 } // 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
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
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
Vector & DeterminantOfJacobian(Vector &rResult) const
Definition: geometry.h:3154
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
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 double ComputeDomainSize(const TGeometryType &rGeometry)
This method calculates and returns the domain size of the geometry from any geometry in a generic man...
Definition: integration_utilities.h:63
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
void clear()
Definition: amatrix_interface.h:284
An three node 3D line geometry with quadratic shape functions.
Definition: line_3d_3.h:66
Various mathematical utilitiy functions.
Definition: math_utils.h:62
This class defines the node.
Definition: node.h:65
Point class.
Definition: point.h:59
double Y() const
Definition: point.h:187
double X() const
Definition: point.h:181
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
A eight node 3D quadrilateral geometry with quadratic shape functions.
Definition: quadrilateral_3d_8.h:49
BaseType::NormalType NormalType
Definition: quadrilateral_3d_8.h:182
Quadrilateral3D8(Quadrilateral3D8 const &rOther)
Definition: quadrilateral_3d_8.h:253
Quadrilateral3D8(const IndexType GeometryId, const PointsArrayType &rThisPoints)
Constructor with Geometry Id.
Definition: quadrilateral_3d_8.h:227
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: quadrilateral_3d_8.h:459
JacobiansType & Jacobian(JacobiansType &rResult, IntegrationMethod ThisMethod, Matrix &DeltaPosition) const override
Definition: quadrilateral_3d_8.h:691
void PrintData(std::ostream &rOStream) const override
Definition: quadrilateral_3d_8.h:1002
ShapeFunctionsThirdDerivativesType & ShapeFunctionsThirdDerivatives(ShapeFunctionsThirdDerivativesType &rResult, const CoordinatesArrayType &rPoint) const override
Definition: quadrilateral_3d_8.h:1266
GeometryData::IntegrationMethod IntegrationMethod
Definition: quadrilateral_3d_8.h:72
CoordinatesArrayType & PointLocalCoordinates(CoordinatesArrayType &rResult, const CoordinatesArrayType &rPoint) const override
Returns the local coordinates of a given arbitrary point.
Definition: quadrilateral_3d_8.h:484
BaseType::ShapeFunctionsGradientsType ShapeFunctionsGradientsType
Definition: quadrilateral_3d_8.h:160
virtual ShapeFunctionsGradientsType ShapeFunctionsLocalGradients()
Definition: quadrilateral_3d_8.h:1041
BaseType::IntegrationPointsArrayType IntegrationPointsArrayType
Definition: quadrilateral_3d_8.h:125
double DomainSize() const override
Definition: quadrilateral_3d_8.h:446
BaseType::IndexType IndexType
Definition: quadrilateral_3d_8.h:97
double Volume() const override
This method calculates and returns the volume of this geometry.
Definition: quadrilateral_3d_8.h:426
Matrix & Jacobian(Matrix &rResult, const CoordinatesArrayType &rPoint) const override
Definition: quadrilateral_3d_8.h:810
Line3D3< TPointType > EdgeType
Definition: quadrilateral_3d_8.h:62
Vector & ShapeFunctionsValues(Vector &rResult, const CoordinatesArrayType &rCoordinates) const override
Definition: quadrilateral_3d_8.h:937
GeometriesArrayType GenerateEdges() const override
This method gives you all edges of this geometry.
Definition: quadrilateral_3d_8.h:860
BaseType::ShapeFunctionsValuesContainerType ShapeFunctionsValuesContainerType
Definition: quadrilateral_3d_8.h:139
GeometryData::KratosGeometryFamily GetGeometryFamily() const override
Definition: quadrilateral_3d_8.h:280
BaseType::ShapeFunctionsSecondDerivativesType ShapeFunctionsSecondDerivativesType
Definition: quadrilateral_3d_8.h:168
SizeType EdgesNumber() const override
This method gives you number of all edges of this geometry.
Definition: quadrilateral_3d_8.h:847
virtual Matrix & ShapeFunctionsGradients(Matrix &rResult, PointType &rPoint)
Definition: quadrilateral_3d_8.h:1144
friend class Quadrilateral3D8
Definition: quadrilateral_3d_8.h:1637
BaseType::JacobiansType JacobiansType
Definition: quadrilateral_3d_8.h:153
BaseType::ShapeFunctionsLocalGradientsContainerType ShapeFunctionsLocalGradientsContainerType
Definition: quadrilateral_3d_8.h:146
~Quadrilateral3D8() override
Definition: quadrilateral_3d_8.h:278
BaseType::PointsArrayType PointsArrayType
Definition: quadrilateral_3d_8.h:110
Geometry< TPointType > BaseType
Definition: quadrilateral_3d_8.h:57
Quadrilateral3D8(typename PointType::Pointer pPoint1, typename PointType::Pointer pPoint2, typename PointType::Pointer pPoint3, typename PointType::Pointer pPoint4, typename PointType::Pointer pPoint5, typename PointType::Pointer pPoint6, typename PointType::Pointer pPoint7, typename PointType::Pointer pPoint8)
Definition: quadrilateral_3d_8.h:204
Quadrilateral3D8(const PointsArrayType &ThisPoints)
Definition: quadrilateral_3d_8.h:220
BaseType::Pointer Create(const IndexType NewGeometryId, PointsArrayType const &rThisPoints) const override
Creates a new geometry pointer.
Definition: quadrilateral_3d_8.h:341
Quadrilateral3D8 & operator=(const Quadrilateral3D8 &rOther)
Definition: quadrilateral_3d_8.h:305
Quadrilateral3D8(const std::string &rGeometryName, const PointsArrayType &rThisPoints)
Constructor with Geometry Name.
Definition: quadrilateral_3d_8.h:236
BaseType::GeometriesArrayType GeometriesArrayType
Definition: quadrilateral_3d_8.h:78
BaseType::Pointer Create(const IndexType NewGeometryId, const BaseType &rGeometry) const override
Creates a new geometry pointer.
Definition: quadrilateral_3d_8.h:355
BaseType::ShapeFunctionsThirdDerivativesType ShapeFunctionsThirdDerivativesType
Definition: quadrilateral_3d_8.h:177
double Area() const override
Definition: quadrilateral_3d_8.h:413
BaseType::CoordinatesArrayType CoordinatesArrayType
Definition: quadrilateral_3d_8.h:88
Matrix & ShapeFunctionsLocalGradients(Matrix &rResult, const CoordinatesArrayType &rPoint) const override
Definition: quadrilateral_3d_8.h:1066
KRATOS_CLASS_POINTER_DEFINITION(Quadrilateral3D8)
JacobiansType & Jacobian(JacobiansType &rResult, IntegrationMethod ThisMethod) const override
Definition: quadrilateral_3d_8.h:630
double ShapeFunctionValue(IndexType ShapeFunctionIndex, const CoordinatesArrayType &rPoint) const override
Definition: quadrilateral_3d_8.h:886
std::string Info() const override
Definition: quadrilateral_3d_8.h:977
GeometryData::KratosGeometryType GetGeometryType() const override
Definition: quadrilateral_3d_8.h:285
BaseType::IntegrationPointType IntegrationPointType
Definition: quadrilateral_3d_8.h:117
SizeType PointsNumberInDirection(IndexType LocalDirectionIndex) const override
Returns number of points per direction.
Definition: quadrilateral_3d_8.h:370
virtual ShapeFunctionsGradientsType ShapeFunctionsLocalGradients(IntegrationMethod ThisMethod)
Definition: quadrilateral_3d_8.h:1020
BaseType::IntegrationPointsContainerType IntegrationPointsContainerType
Definition: quadrilateral_3d_8.h:132
Quadrilateral3D8 & operator=(Quadrilateral3D8< TOtherPointType > const &rOther)
Definition: quadrilateral_3d_8.h:324
BaseType::SizeType SizeType
Definition: quadrilateral_3d_8.h:104
TPointType PointType
Definition: quadrilateral_3d_8.h:83
double Length() const override
Definition: quadrilateral_3d_8.h:396
void PrintInfo(std::ostream &rOStream) const override
Definition: quadrilateral_3d_8.h:988
ShapeFunctionsSecondDerivativesType & ShapeFunctionsSecondDerivatives(ShapeFunctionsSecondDerivativesType &rResult, const CoordinatesArrayType &rPoint) const override
Definition: quadrilateral_3d_8.h:1191
Quadrilateral3D8(Quadrilateral3D8< TOtherPointType > const &rOther)
Definition: quadrilateral_3d_8.h:270
Matrix & Jacobian(Matrix &rResult, IndexType IntegrationPointIndex, IntegrationMethod ThisMethod) const override
Definition: quadrilateral_3d_8.h:754
Matrix & PointsLocalCoordinates(Matrix &rResult) const override
Definition: quadrilateral_3d_8.h:1113
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(label)
Definition: logger.h:265
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
KratosZeroVector< double > ZeroVector
Definition: amatrix_interface.h:561
const GeometryData Quadrilateral3D8< TPointType >::msGeometryData & msGeometryDimension(), Quadrilateral3D8< 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
AMatrix::MatrixRow< const TExpressionType > row(AMatrix::MatrixExpression< TExpressionType, TCategory > const &TheExpression, std::size_t RowIndex)
Definition: amatrix_interface.h:649
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
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
dummy
Definition: script.py:194
J
Definition: sensitivityMatrix.py:58
integer i
Definition: TensorModule.f:17