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.
hexahedra_interface_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: Ignasi de Pouplana
11 //
12 
13 #if !defined(KRATOS_HEXAHEDRA_INTERFACE_3D_8_H_INCLUDED )
14 #define KRATOS_HEXAHEDRA_INTERFACE_3D_8_H_INCLUDED
15 
16 
17 // System includes
18 
19 // External includes
20 
21 // Project includes
24 
25 
26 
27 namespace Kratos
28 {
35 template<class TPointType> class HexahedraInterface3D8 : public Geometry<TPointType>
36 {
37 public:
46 
52 
57 
62 
68 
72  typedef TPointType PointType;
73 
79  typedef typename BaseType::IndexType IndexType;
80 
81 
87  typedef typename BaseType::SizeType SizeType;
88 
94 
101 
109 
116 
123 
130 
137 
144 
149 
154 
159 
160 
164 /* HexahedraInterface3D8( const PointType& Point1, const PointType& Point2,
165  const PointType& Point3, const PointType& Point4,
166  const PointType& Point5, const PointType& Point6,
167  const PointType& Point7, const PointType& Point8 )
168  : BaseType( PointsArrayType(), &msGeometryData )
169  {
170  array_1d< double , 3 > vx;
171  vx.clear();
172  noalias(vx) += - Point1 - Point5;
173  noalias(vx) += - Point4 - Point8;
174  noalias(vx) += Point2 + Point6;
175  noalias(vx) += Point3 + Point7;
176 
177  vx *= 0.25;
178 
179  array_1d< double , 3 > vy;
180  vy.clear();
181  noalias(vy) += Point4 + Point3;
182  noalias(vy) += Point7 + Point8;
183  noalias(vy) += - Point1 - Point2;
184  noalias(vy) += - Point6 - Point5;
185 
186  vy *= 0.25;
187 
188  array_1d< double , 3 > vz;
189  vz.clear();
190  noalias(vz) += Point5 + Point6;
191  noalias(vz) += Point7 + Point8;
192  noalias(vz) += - Point1 - Point2;
193  noalias(vz) += - Point3 - Point4;
194 
195  vz *= 0.25;
196 
197  double lx = MathUtils<double>::Norm3(vx);
198  double ly = MathUtils<double>::Norm3(vy);
199  double lz = MathUtils<double>::Norm3(vz);
200  if(lz < lx)
201  {
202  if(lz < ly)
203  {
204  // LZ
205  this->Points().push_back( typename PointType::Pointer( new PointType( Point1 ) ) );
206  this->Points().push_back( typename PointType::Pointer( new PointType( Point2 ) ) );
207  this->Points().push_back( typename PointType::Pointer( new PointType( Point3 ) ) );
208  this->Points().push_back( typename PointType::Pointer( new PointType( Point4 ) ) );
209  this->Points().push_back( typename PointType::Pointer( new PointType( Point5 ) ) );
210  this->Points().push_back( typename PointType::Pointer( new PointType( Point6 ) ) );
211  this->Points().push_back( typename PointType::Pointer( new PointType( Point7 ) ) );
212  this->Points().push_back( typename PointType::Pointer( new PointType( Point8 ) ) );
213  }
214  else
215  {
216  if(ly < lx)
217  {
218  // LY
219  this->Points().push_back( typename PointType::Pointer( new PointType( Point2 ) ) );
220  this->Points().push_back( typename PointType::Pointer( new PointType( Point1 ) ) );
221  this->Points().push_back( typename PointType::Pointer( new PointType( Point5 ) ) );
222  this->Points().push_back( typename PointType::Pointer( new PointType( Point6 ) ) );
223  this->Points().push_back( typename PointType::Pointer( new PointType( Point3 ) ) );
224  this->Points().push_back( typename PointType::Pointer( new PointType( Point4 ) ) );
225  this->Points().push_back( typename PointType::Pointer( new PointType( Point8 ) ) );
226  this->Points().push_back( typename PointType::Pointer( new PointType( Point7 ) ) );
227  }
228  else
229  {
230  // LX
231  this->Points().push_back( typename PointType::Pointer( new PointType( Point1 ) ) );
232  this->Points().push_back( typename PointType::Pointer( new PointType( Point4 ) ) );
233  this->Points().push_back( typename PointType::Pointer( new PointType( Point8 ) ) );
234  this->Points().push_back( typename PointType::Pointer( new PointType( Point5 ) ) );
235  this->Points().push_back( typename PointType::Pointer( new PointType( Point2 ) ) );
236  this->Points().push_back( typename PointType::Pointer( new PointType( Point3 ) ) );
237  this->Points().push_back( typename PointType::Pointer( new PointType( Point7 ) ) );
238  this->Points().push_back( typename PointType::Pointer( new PointType( Point6 ) ) );
239  }
240  }
241  }
242  else
243  {
244  if(lx < ly)
245  {
246  // LX
247  this->Points().push_back( typename PointType::Pointer( new PointType( Point1 ) ) );
248  this->Points().push_back( typename PointType::Pointer( new PointType( Point4 ) ) );
249  this->Points().push_back( typename PointType::Pointer( new PointType( Point8 ) ) );
250  this->Points().push_back( typename PointType::Pointer( new PointType( Point5 ) ) );
251  this->Points().push_back( typename PointType::Pointer( new PointType( Point2 ) ) );
252  this->Points().push_back( typename PointType::Pointer( new PointType( Point3 ) ) );
253  this->Points().push_back( typename PointType::Pointer( new PointType( Point7 ) ) );
254  this->Points().push_back( typename PointType::Pointer( new PointType( Point6 ) ) );
255  }
256  else
257  {
258  if(lz < ly)
259  {
260  // LZ
261  this->Points().push_back( typename PointType::Pointer( new PointType( Point1 ) ) );
262  this->Points().push_back( typename PointType::Pointer( new PointType( Point2 ) ) );
263  this->Points().push_back( typename PointType::Pointer( new PointType( Point3 ) ) );
264  this->Points().push_back( typename PointType::Pointer( new PointType( Point4 ) ) );
265  this->Points().push_back( typename PointType::Pointer( new PointType( Point5 ) ) );
266  this->Points().push_back( typename PointType::Pointer( new PointType( Point6 ) ) );
267  this->Points().push_back( typename PointType::Pointer( new PointType( Point7 ) ) );
268  this->Points().push_back( typename PointType::Pointer( new PointType( Point8 ) ) );
269  }
270  else
271  {
272  // LY
273  this->Points().push_back( typename PointType::Pointer( new PointType( Point2 ) ) );
274  this->Points().push_back( typename PointType::Pointer( new PointType( Point1 ) ) );
275  this->Points().push_back( typename PointType::Pointer( new PointType( Point5 ) ) );
276  this->Points().push_back( typename PointType::Pointer( new PointType( Point6 ) ) );
277  this->Points().push_back( typename PointType::Pointer( new PointType( Point3 ) ) );
278  this->Points().push_back( typename PointType::Pointer( new PointType( Point4 ) ) );
279  this->Points().push_back( typename PointType::Pointer( new PointType( Point8 ) ) );
280  this->Points().push_back( typename PointType::Pointer( new PointType( Point7 ) ) );
281  }
282  }
283  }
284  }
285 */
286  HexahedraInterface3D8( typename PointType::Pointer pPoint1,
287  typename PointType::Pointer pPoint2,
288  typename PointType::Pointer pPoint3,
289  typename PointType::Pointer pPoint4,
290  typename PointType::Pointer pPoint5,
291  typename PointType::Pointer pPoint6,
292  typename PointType::Pointer pPoint7,
293  typename PointType::Pointer pPoint8 )
294  : BaseType( PointsArrayType(), &msGeometryData )
295  {
297  vx.clear();
298  noalias(vx) += - *pPoint1 - *pPoint5;
299  noalias(vx) += - *pPoint4 - *pPoint8;
300  noalias(vx) += *pPoint2 + *pPoint6;
301  noalias(vx) += *pPoint3 + *pPoint7;
302  vx *= 0.25;
303 
305  vy.clear();
306  noalias(vy) += *pPoint4 + *pPoint3;
307  noalias(vy) += *pPoint7 + *pPoint8;
308  noalias(vy) += - *pPoint1 - *pPoint2;
309  noalias(vy) += - *pPoint6 - *pPoint5;
310  vy *= 0.25;
311 
313  vz.clear();
314  noalias(vz) += *pPoint5 + *pPoint6;
315  noalias(vz) += *pPoint7 + *pPoint8;
316  noalias(vz) += - *pPoint1 - *pPoint2;
317  noalias(vz) += - *pPoint3 - *pPoint4;
318  vz *= 0.25;
319 
320  double lx = MathUtils<double>::Norm3(vx);
321  double ly = MathUtils<double>::Norm3(vy);
322  double lz = MathUtils<double>::Norm3(vz);
323 
324  if(lz < lx)
325  {
326  if(lz < ly)
327  {
328  // lz < lx && lz < ly
329 
330  this->Points().push_back( pPoint1 );
331  this->Points().push_back( pPoint2 );
332  this->Points().push_back( pPoint3 );
333  this->Points().push_back( pPoint4 );
334  this->Points().push_back( pPoint5 );
335  this->Points().push_back( pPoint6 );
336  this->Points().push_back( pPoint7 );
337  this->Points().push_back( pPoint8 );
338  }
339  else
340  {
341  // ly < lz < lx
342 
343  this->Points().push_back( pPoint1 );
344  this->Points().push_back( pPoint4 );
345  this->Points().push_back( pPoint8 );
346  this->Points().push_back( pPoint5 );
347  this->Points().push_back( pPoint2 );
348  this->Points().push_back( pPoint3 );
349  this->Points().push_back( pPoint7 );
350  this->Points().push_back( pPoint6 );
351  }
352  }
353  else if( ly < lx )
354  {
355  // ly < lx < lz
356 
357  this->Points().push_back( pPoint1 );
358  this->Points().push_back( pPoint4 );
359  this->Points().push_back( pPoint8 );
360  this->Points().push_back( pPoint5 );
361  this->Points().push_back( pPoint2 );
362  this->Points().push_back( pPoint3 );
363  this->Points().push_back( pPoint7 );
364  this->Points().push_back( pPoint6 );
365  }
366  else
367  {
368  // lx < lz && lx < ly
369 
370  this->Points().push_back( pPoint1 );
371  this->Points().push_back( pPoint5 );
372  this->Points().push_back( pPoint6 );
373  this->Points().push_back( pPoint2 );
374  this->Points().push_back( pPoint4 );
375  this->Points().push_back( pPoint8 );
376  this->Points().push_back( pPoint7 );
377  this->Points().push_back( pPoint3 );
378  }
379  }
380 
382  : BaseType( ThisPoints, &msGeometryData )
383  {
384  if ( this->PointsNumber() != 8 )
385  KRATOS_ERROR << "Invalid points number. Expected 8, given " << this->PointsNumber() << std::endl;
386  }
387 
398  : BaseType( rOther )
399  {
400  }
401 
414  template<class TOtherPointType> HexahedraInterface3D8( HexahedraInterface3D8<TOtherPointType> const& rOther )
415  : BaseType( rOther )
416  {
417  }
418 
421 
423  {
425  }
426 
428  {
430  }
431 
448  {
449  BaseType::operator=( rOther );
450  return *this;
451  }
452 
464  template<class TOtherPointType>
466  {
467  BaseType::operator=( rOther );
468 
469  return *this;
470  }
471 
472 
477  typename BaseType::Pointer Create( PointsArrayType const& ThisPoints ) const override
478  {
479  return typename BaseType::Pointer( new HexahedraInterface3D8( ThisPoints ) );
480  }
481 
501  double Length() const override
502  {
503  return std::sqrt(Area());
504  }
505 
520  double Area() const override
521  {
522  //return fabs( DeterminantOfJacobian( PointType() ) ) * 0.5;
523 
528 
529  //const TPointType& p1 = this->Points()[0];
530  //const TPointType& p2 = this->Points()[1];
531  //const TPointType& p3 = this->Points()[2];
532  //const TPointType& p4 = this->Points()[3];
533 
534  double p1x = p1[0];
535  double p1y = p1[1];
536  double p1z = p1[2];
537 
538  double p2x = p2[0];
539  double p2y = p2[1];
540  double p2z = p2[2];
541 
542  double p3x = p3[0];
543  double p3y = p3[1];
544  double p3z = p3[2];
545 
546  double p4x = p4[0];
547  double p4y = p4[1];
548  double p4z = p4[2];
549 
550  double pos = 0.5 + 0.5 / std::sqrt(3.0);
551  double w = 0.25;
552 
553  double C1 = pos*(p1z - p2z + p3z - p4z);
554  double C2 = pos*(p1y - p2y + p3y - p4y);
555  double C3 = pos*(p1x - p2x + p3x - p4x);
556  double C4 = C1 - p1z + p2z;
557  double C5 = C1 + p1z - p2z;
558  double C6 = C2 + p1y - p2y;
559  double C7 = C2 - p1y + p2y;
560  double C8 = C3 - p1x + p2x;
561  double C9 = C3 + p1x - p2x;
562  double C10 = C1 - p1z + p4z;
563  double C11 = C2 - p1y + p4y;
564  double C12 = C3 - p1x + p4x;
565  double C13 = C1 + p1z - p4z;
566  double C14 = C2 + p1y - p4y;
567  double C15 = C3 + p1x - p4x;
568 
569  return w * (
570  std::sqrt( std::pow(C4*C11 - C7*C10, 2) + std::pow(C4*C12 - C8*C10, 2) + std::pow(C7*C12 - C8*C11, 2)) +
571  std::sqrt( std::pow(C5*C11 - C6*C10, 2) + std::pow(C5*C12 - C9*C10, 2) + std::pow(C6*C12 - C9*C11, 2)) +
572  std::sqrt( std::pow(C4*C14 - C7*C13, 2) + std::pow(C4*C15 - C8*C13, 2) + std::pow(C7*C15 - C8*C14, 2)) +
573  std::sqrt( std::pow(C5*C14 - C6*C13, 2) + std::pow(C5*C15 - C9*C13, 2) + std::pow(C6*C15 - C9*C14, 2))
574  );
575  }
576 
577  double Volume() const override
578  {
579  return Area();
580  }
581 
582 
596  double DomainSize() const override
597  {
598  return Area();
599  }
600 
606  Matrix& PointsLocalCoordinates( Matrix& rResult ) const override
607  {
608  if ( rResult.size1() != 8 || rResult.size2() != 3 )
609  rResult.resize( 8, 3 ,false);
610 
611  rResult( 0, 0 ) = -1.0;
612  rResult( 0, 1 ) = -1.0;
613  rResult( 0, 2 ) = -1.0;
614 
615  rResult( 1, 0 ) = 1.0;
616  rResult( 1, 1 ) = -1.0;
617  rResult( 1, 2 ) = -1.0;
618 
619  rResult( 2, 0 ) = 1.0;
620  rResult( 2, 1 ) = 1.0;
621  rResult( 2, 2 ) = -1.0;
622 
623  rResult( 3, 0 ) = -1.0;
624  rResult( 3, 1 ) = 1.0;
625  rResult( 3, 2 ) = -1.0;
626 
627  rResult( 4, 0 ) = -1.0;
628  rResult( 4, 1 ) = -1.0;
629  rResult( 4, 2 ) = 1.0;
630 
631  rResult( 5, 0 ) = 1.0;
632  rResult( 5, 1 ) = -1.0;
633  rResult( 5, 2 ) = 1.0;
634 
635  rResult( 6, 0 ) = 1.0;
636  rResult( 6, 1 ) = 1.0;
637  rResult( 6, 2 ) = 1.0;
638 
639  rResult( 7, 0 ) = -1.0;
640  rResult( 7, 1 ) = 1.0;
641  rResult( 7, 2 ) = 1.0;
642 
643  return rResult;
644  }
645 
654  bool IsInside(
655  const CoordinatesArrayType& rPoint,
656  CoordinatesArrayType& rResult,
657  const double Tolerance = std::numeric_limits<double>::epsilon()
658  ) const override
659  {
660  this->PointLocalCoordinates( rResult, rPoint );
661 
662  if ( std::abs( rResult[0] ) <= (1.0 + Tolerance) )
663  {
664  if ( std::abs( rResult[1] ) <= (1.0 + Tolerance) )
665  {
666  if ( std::abs( rResult[2] ) <= (1.0 + Tolerance) )
667  {
668  return true;
669  }
670  }
671  }
672 
673  return false;
674  }
675 
683  CoordinatesArrayType& rResult,
684  const CoordinatesArrayType& rPoint
685  ) const override
686  {
689  for(unsigned int i=0; i<4;i++)
690  {
691  X(0,i ) = 0.5*(this->GetPoint( i ).X() + this->GetPoint( i+4 ).X());
692  X(1,i ) = 0.5*(this->GetPoint( i ).Y() + this->GetPoint( i+4 ).Y());
693  X(2,i ) = 0.5*(this->GetPoint( i ).Z() + this->GetPoint( i+4 ).Z());
694  }
695 
696  double tol = 1.0e-8;
697  int maxiter = 1000;
698 
699  Matrix J = ZeroMatrix( 2, 2 );
700  Matrix invJ = ZeroMatrix( 2, 2 );
701 
702  //starting with xi = 0
703  rResult = ZeroVector( 3 );
704  Vector DeltaXi = ZeroVector( 2 );
705  array_1d<double,3> CurrentGlobalCoords;
706 
707 
708  //Newton iteration:
709  for ( int k = 0; k < maxiter; k++ )
710  {
711  noalias(CurrentGlobalCoords) = ZeroVector( 3 );
712  this->GlobalCoordinates( CurrentGlobalCoords, rResult );
713 
714  noalias( CurrentGlobalCoords ) = rPoint - CurrentGlobalCoords;
715 
716 
717  //derivatives of shape functions
718  Matrix shape_functions_gradients;
719  shape_functions_gradients = ShapeFunctionsLocalGradients(shape_functions_gradients, rResult );
720  noalias(DN) = prod(X,shape_functions_gradients);
721 
722  noalias(J) = prod(trans(DN),DN);
723  Vector res = prod(trans(DN),CurrentGlobalCoords);
724 
725  //deteminant of Jacobian
726  double det_j = J( 0, 0 ) * J( 1, 1 ) - J( 0, 1 ) * J( 1, 0 );
727 
728  //filling matrix
729  invJ( 0, 0 ) = ( J( 1, 1 ) ) / ( det_j );
730  invJ( 1, 0 ) = -( J( 1, 0 ) ) / ( det_j );
731  invJ( 0, 1 ) = -( J( 0, 1 ) ) / ( det_j );
732  invJ( 1, 1 ) = ( J( 0, 0 ) ) / ( det_j );
733 
734 
735  DeltaXi( 0 ) = invJ( 0, 0 ) * res[0] + invJ( 0, 1 ) * res[1];
736  DeltaXi( 1 ) = invJ( 1, 0 ) * res[0] + invJ( 1, 1 ) * res[1];
737 
738  rResult[0] += DeltaXi[0];
739  rResult[1] += DeltaXi[1];
740  rResult[2] = 0.0;
741 
742  if ( norm_2( DeltaXi ) > 300 )
743  {
744  res[0] = 0.0;
745  res[1] = 0.0;
746  std::cout << "detJ =" << det_j << "DeltaX = " << DeltaXi << " stopping calculation and assigning the baricenter" << std::endl;
747  break;
748  //KRATOS_ERROR << "Computation of local coordinates failed at iteration" << k << std::endl;
749  }
750 
751  if ( norm_2( DeltaXi ) < tol )
752  {
753  break;
754  }
755  }
756 
757  return( rResult );
758  }
759 
784  Matrix& Jacobian( Matrix& rResult,
785  IndexType IntegrationPointIndex,
786  IntegrationMethod ThisMethod ) const override
787  {
788  //setting up size of jacobian matrix
789  rResult.resize( 3, 2, false );
790  noalias(rResult) = ZeroMatrix(3,2);
791  //derivatives of shape functions
792  ShapeFunctionsGradientsType shape_functions_gradients =
793  CalculateShapeFunctionsIntegrationPointsLocalGradients( ThisMethod );
794  Matrix& ShapeFunctionsGradientInIntegrationPoint = shape_functions_gradients( IntegrationPointIndex );
795 
796  //Elements of jacobian matrix (e.g. J(1,1) = dX1/dXi1)
797  //loop over all nodes
798 
799  for ( unsigned int i = 0; i < this->PointsNumber(); i++ )
800  {
801  rResult( 0, 0 ) +=
802  ( this->GetPoint( i ).X() ) * ( ShapeFunctionsGradientInIntegrationPoint( i, 0 ) );
803  rResult( 0, 1 ) +=
804  ( this->GetPoint( i ).X() ) * ( ShapeFunctionsGradientInIntegrationPoint( i, 1 ) );
805  rResult( 1, 0 ) +=
806  ( this->GetPoint( i ).Y() ) * ( ShapeFunctionsGradientInIntegrationPoint( i, 0 ) );
807  rResult( 1, 1 ) +=
808  ( this->GetPoint( i ).Y() ) * ( ShapeFunctionsGradientInIntegrationPoint( i, 1 ) );
809  rResult( 2, 0 ) +=
810  ( this->GetPoint( i ).Z() ) * ( ShapeFunctionsGradientInIntegrationPoint( i, 0 ) );
811  rResult( 2, 1 ) +=
812  ( this->GetPoint( i ).Z() ) * ( ShapeFunctionsGradientInIntegrationPoint( i, 1 ) );
813  }
814 
815  return rResult;
816  }
817 
838  Matrix& Jacobian( Matrix& rResult,
839  IndexType IntegrationPointIndex,
840  IntegrationMethod ThisMethod,
841  const Matrix& DeltaPosition ) const override
842  {
843  //setting up size of jacobian matrix
844  rResult.resize( 3, 2 ,false);
845  noalias(rResult) = ZeroMatrix(3,2);
846  //derivatives of shape functions
847  ShapeFunctionsGradientsType shape_functions_gradients =
848  CalculateShapeFunctionsIntegrationPointsLocalGradients( ThisMethod );
849  Matrix& ShapeFunctionsGradientInIntegrationPoint = shape_functions_gradients( IntegrationPointIndex );
850 
851  //Elements of jacobian matrix (e.g. J(1,1) = dX1/dXi1)
852  //loop over all nodes
853 
854  for ( unsigned int i = 0; i < this->PointsNumber(); i++ )
855  {
856  rResult( 0, 0 ) +=
857  ( this->GetPoint( i ).X() - DeltaPosition(i,0) ) * ( ShapeFunctionsGradientInIntegrationPoint( i, 0 ) );
858  rResult( 0, 1 ) +=
859  ( this->GetPoint( i ).X() - DeltaPosition(i,0) ) * ( ShapeFunctionsGradientInIntegrationPoint( i, 1 ) );
860  rResult( 1, 0 ) +=
861  ( this->GetPoint( i ).Y() - DeltaPosition(i,1) ) * ( ShapeFunctionsGradientInIntegrationPoint( i, 0 ) );
862  rResult( 1, 1 ) +=
863  ( this->GetPoint( i ).Y() - DeltaPosition(i,1) ) * ( ShapeFunctionsGradientInIntegrationPoint( i, 1 ) );
864  rResult( 2, 0 ) +=
865  ( this->GetPoint( i ).Z() - DeltaPosition(i,2) ) * ( ShapeFunctionsGradientInIntegrationPoint( i, 0 ) );
866  rResult( 2, 1 ) +=
867  ( this->GetPoint( i ).Z() - DeltaPosition(i,2) ) * ( ShapeFunctionsGradientInIntegrationPoint( i, 1 ) );
868  }
869 
870  return rResult;
871  }
872 
888  Matrix& Jacobian( Matrix& rResult, const CoordinatesArrayType& rPoint ) const override
889  {
890  //setting up size of jacobian matrix
891  rResult.resize( 3, 2 ,false );
892  noalias(rResult) = ZeroMatrix(3,2);
893  //derivatives of shape functions
894  Matrix shape_functions_gradients;
895  shape_functions_gradients = ShapeFunctionsLocalGradients(
896  shape_functions_gradients, rPoint );
897  //Elements of jacobian matrix (e.g. J(1,1) = dX1/dXi1)
898  //loop over all nodes
899 
900  for ( unsigned int i = 0; i < this->PointsNumber(); i++ )
901  {
902  rResult( 0, 0 ) += ( this->GetPoint( i ).X() ) * ( shape_functions_gradients( i, 0 ) );
903  rResult( 0, 1 ) += ( this->GetPoint( i ).X() ) * ( shape_functions_gradients( i, 1 ) );
904  rResult( 1, 0 ) += ( this->GetPoint( i ).Y() ) * ( shape_functions_gradients( i, 0 ) );
905  rResult( 1, 1 ) += ( this->GetPoint( i ).Y() ) * ( shape_functions_gradients( i, 1 ) );
906  rResult( 2, 0 ) += ( this->GetPoint( i ).Z() ) * ( shape_functions_gradients( i, 0 ) );
907  rResult( 2, 1 ) += ( this->GetPoint( i ).Z() ) * ( shape_functions_gradients( i, 1 ) );
908  }
909 
910  return rResult;
911  }
912 
929  IntegrationMethod ThisMethod ) const override
930  {
931  if( rResult.size() != this->IntegrationPointsNumber( ThisMethod ) )
932  rResult.resize( this->IntegrationPointsNumber( ThisMethod ), false );
933 
934  Matrix J;
935  array_1d<double,3> Tangent0;
936  array_1d<double,3> Tangent1;
938 
939  for ( unsigned int pnt = 0; pnt < this->IntegrationPointsNumber( ThisMethod ); pnt++ )
940  {
941  this->Jacobian( J, pnt, ThisMethod);
942 
943  Tangent0[0] = J(0,0);
944  Tangent0[1] = J(1,0);
945  Tangent0[2] = J(2,0);
946 
947  Tangent1[0] = J(0,1);
948  Tangent1[1] = J(1,1);
949  Tangent1[2] = J(2,1);
950 
951  MathUtils<double>::CrossProduct(Normal, Tangent0, Tangent1);
952 
953  rResult[pnt] = MathUtils<double>::Norm3(Normal);
954  }
955  return rResult;
956  }
957 
980  double DeterminantOfJacobian( IndexType IntegrationPointIndex,
981  IntegrationMethod ThisMethod ) const override
982  {
983  Matrix J;
984  this->Jacobian( J, IntegrationPointIndex, ThisMethod);
985 
986  array_1d<double,3> Tangent0;
987  array_1d<double,3> Tangent1;
989 
990  Tangent0[0] = J(0,0);
991  Tangent0[1] = J(1,0);
992  Tangent0[2] = J(2,0);
993 
994  Tangent1[0] = J(0,1);
995  Tangent1[1] = J(1,1);
996  Tangent1[2] = J(2,1);
997 
998  MathUtils<double>::CrossProduct(Normal, Tangent0, Tangent1);
999 
1001  }
1002 
1023  IntegrationMethod ThisMethod ) const override
1024  {
1025  KRATOS_ERROR << "Jacobian is not square" << std::endl;
1026  return rResult;
1027  }
1028 
1054  IndexType IntegrationPointIndex,
1055  IntegrationMethod ThisMethod ) const override
1056  {
1057  KRATOS_ERROR << "Jacobian is not square" << std::endl;
1058  return rResult;
1059  }
1060 
1077  Matrix& InverseOfJacobian( Matrix& rResult, const CoordinatesArrayType& rPoint ) const override
1078  {
1079  KRATOS_ERROR << "Jacobian is not square" << std::endl;
1080  return rResult;
1081  }
1082 
1086 
1098  SizeType EdgesNumber() const override
1099  {
1100  return 12;
1101  }
1102 
1112  {
1114  typedef typename Geometry<TPointType>::Pointer EdgePointerType;
1115  edges.push_back( EdgePointerType( new EdgeType(
1116  this->pGetPoint( 0 ),
1117  this->pGetPoint( 1 ) ) ) );
1118  edges.push_back( EdgePointerType( new EdgeType(
1119  this->pGetPoint( 1 ),
1120  this->pGetPoint( 2 ) ) ) );
1121  edges.push_back( EdgePointerType( new EdgeType(
1122  this->pGetPoint( 2 ),
1123  this->pGetPoint( 3 ) ) ) );
1124  edges.push_back( EdgePointerType( new EdgeType(
1125  this->pGetPoint( 3 ),
1126  this->pGetPoint( 0 ) ) ) );
1127  edges.push_back( EdgePointerType( new EdgeType(
1128  this->pGetPoint( 4 ),
1129  this->pGetPoint( 5 ) ) ) );
1130  edges.push_back( EdgePointerType( new EdgeType(
1131  this->pGetPoint( 5 ),
1132  this->pGetPoint( 6 ) ) ) );
1133  edges.push_back( EdgePointerType( new EdgeType(
1134  this->pGetPoint( 6 ),
1135  this->pGetPoint( 7 ) ) ) );
1136  edges.push_back( EdgePointerType( new EdgeType(
1137  this->pGetPoint( 7 ),
1138  this->pGetPoint( 4 ) ) ) );
1139  edges.push_back( EdgePointerType( new EdgeType(
1140  this->pGetPoint( 0 ),
1141  this->pGetPoint( 4 ) ) ) );
1142  edges.push_back( EdgePointerType( new EdgeType(
1143  this->pGetPoint( 1 ),
1144  this->pGetPoint( 5 ) ) ) );
1145  edges.push_back( EdgePointerType( new EdgeType(
1146  this->pGetPoint( 2 ),
1147  this->pGetPoint( 6 ) ) ) );
1148  edges.push_back( EdgePointerType( new EdgeType(
1149  this->pGetPoint( 3 ),
1150  this->pGetPoint( 7 ) ) ) );
1151  return edges;
1152  }
1153 
1157 
1165  SizeType FacesNumber() const override
1166  {
1167  return 6;
1168  }
1169 
1179  {
1181  typedef typename Geometry<TPointType>::Pointer FacePointerType;
1182  faces.push_back( FacePointerType( new FaceType(
1183  this->pGetPoint( 3 ),
1184  this->pGetPoint( 2 ),
1185  this->pGetPoint( 1 ),
1186  this->pGetPoint( 0 ) ) ) );
1187  faces.push_back( FacePointerType( new FaceType(
1188  this->pGetPoint( 0 ),
1189  this->pGetPoint( 1 ),
1190  this->pGetPoint( 5 ),
1191  this->pGetPoint( 4 ) ) ) );
1192  faces.push_back( FacePointerType( new FaceType(
1193  this->pGetPoint( 2 ),
1194  this->pGetPoint( 6 ),
1195  this->pGetPoint( 5 ),
1196  this->pGetPoint( 1 ) ) ) );
1197  faces.push_back( FacePointerType( new FaceType(
1198  this->pGetPoint( 7 ),
1199  this->pGetPoint( 6 ),
1200  this->pGetPoint( 2 ),
1201  this->pGetPoint( 3 ) ) ) );
1202  faces.push_back( FacePointerType( new FaceType(
1203  this->pGetPoint( 7 ),
1204  this->pGetPoint( 3 ),
1205  this->pGetPoint( 0 ),
1206  this->pGetPoint( 4 ) ) ) );
1207  faces.push_back( FacePointerType( new FaceType(
1208  this->pGetPoint( 4 ),
1209  this->pGetPoint( 5 ),
1210  this->pGetPoint( 6 ),
1211  this->pGetPoint( 7 ) ) ) );
1212  return faces;
1213  }
1214 
1229  double ShapeFunctionValue( IndexType ShapeFunctionIndex,
1230  const CoordinatesArrayType& rPoint ) const override
1231  {
1232  switch ( ShapeFunctionIndex )
1233  {
1234  case 0:
1235  return( 0.125*( 1.0 - rPoint[0] )*( 1.0 - rPoint[1] )*( 1.0 - rPoint[2] ) );
1236  case 1:
1237  return( 0.125*( 1.0 + rPoint[0] )*( 1.0 - rPoint[1] )*( 1.0 - rPoint[2] ) );
1238  case 2:
1239  return( 0.125*( 1.0 + rPoint[0] )*( 1.0 + rPoint[1] )*( 1.0 - rPoint[2] ) );
1240  case 3:
1241  return( 0.125*( 1.0 - rPoint[0] )*( 1.0 + rPoint[1] )*( 1.0 - rPoint[2] ) );
1242  case 4:
1243  return( 0.125*( 1.0 - rPoint[0] )*( 1.0 - rPoint[1] )*( 1.0 + rPoint[2] ) );
1244  case 5:
1245  return( 0.125*( 1.0 + rPoint[0] )*( 1.0 - rPoint[1] )*( 1.0 + rPoint[2] ) );
1246  case 6:
1247  return( 0.125*( 1.0 + rPoint[0] )*( 1.0 + rPoint[1] )*( 1.0 + rPoint[2] ) );
1248  case 7:
1249  return( 0.125*( 1.0 - rPoint[0] )*( 1.0 + rPoint[1] )*( 1.0 + rPoint[2] ) );
1250  default:
1251  KRATOS_ERROR << "Wrong index of shape function!" << *this << std::endl;
1252  }
1253 
1254  return 0;
1255  }
1256 
1268  Vector& ShapeFunctionsValues (Vector &rResult, const CoordinatesArrayType& rCoordinates) const override
1269  {
1270  if(rResult.size() != 8) rResult.resize(8,false);
1271  rResult[0] = 0.125*( 1.0 - rCoordinates[0] )*( 1.0 - rCoordinates[1] )*( 1.0 - rCoordinates[2] ) ;
1272  rResult[1] = 0.125*( 1.0 + rCoordinates[0] )*( 1.0 - rCoordinates[1] )*( 1.0 - rCoordinates[2] ) ;
1273  rResult[2] = 0.125*( 1.0 + rCoordinates[0] )*( 1.0 + rCoordinates[1] )*( 1.0 - rCoordinates[2] ) ;
1274  rResult[3] = 0.125*( 1.0 - rCoordinates[0] )*( 1.0 + rCoordinates[1] )*( 1.0 - rCoordinates[2] ) ;
1275  rResult[4] = 0.125*( 1.0 - rCoordinates[0] )*( 1.0 - rCoordinates[1] )*( 1.0 + rCoordinates[2] ) ;
1276  rResult[5] = 0.125*( 1.0 + rCoordinates[0] )*( 1.0 - rCoordinates[1] )*( 1.0 + rCoordinates[2] ) ;
1277  rResult[6] = 0.125*( 1.0 + rCoordinates[0] )*( 1.0 + rCoordinates[1] )*( 1.0 + rCoordinates[2] ) ;
1278  rResult[7] = 0.125*( 1.0 - rCoordinates[0] )*( 1.0 + rCoordinates[1] )*( 1.0 + rCoordinates[2] ) ;
1279  return rResult;
1280  }
1281 
1290  Matrix& ShapeFunctionsLocalGradients( Matrix& rResult, const CoordinatesArrayType& rPoint ) const override
1291  {
1292  if ( rResult.size1() != 8 || rResult.size2() != 3 )
1293  rResult.resize( 8, 3 ,false);
1294 
1295  rResult = ZeroMatrix( 8, 3 );
1296 
1297  rResult( 0, 0 ) = -0.125 * ( 1.0 - rPoint[1] ) * ( 1.0 - rPoint[2] );
1298  rResult( 0, 1 ) = -0.125 * ( 1.0 - rPoint[0] ) * ( 1.0 - rPoint[2] );
1299  rResult( 0, 2 ) = -0.125 * ( 1.0 - rPoint[0] ) * ( 1.0 - rPoint[1] );
1300  rResult( 1, 0 ) = 0.125 * ( 1.0 - rPoint[1] ) * ( 1.0 - rPoint[2] );
1301  rResult( 1, 1 ) = -0.125 * ( 1.0 + rPoint[0] ) * ( 1.0 - rPoint[2] );
1302  rResult( 1, 2 ) = -0.125 * ( 1.0 + rPoint[0] ) * ( 1.0 - rPoint[1] );
1303  rResult( 2, 0 ) = 0.125 * ( 1.0 + rPoint[1] ) * ( 1.0 - rPoint[2] );
1304  rResult( 2, 1 ) = 0.125 * ( 1.0 + rPoint[0] ) * ( 1.0 - rPoint[2] );
1305  rResult( 2, 2 ) = -0.125 * ( 1.0 + rPoint[0] ) * ( 1.0 + rPoint[1] );
1306  rResult( 3, 0 ) = -0.125 * ( 1.0 + rPoint[1] ) * ( 1.0 - rPoint[2] );
1307  rResult( 3, 1 ) = 0.125 * ( 1.0 - rPoint[0] ) * ( 1.0 - rPoint[2] );
1308  rResult( 3, 2 ) = -0.125 * ( 1.0 - rPoint[0] ) * ( 1.0 + rPoint[1] );
1309  rResult( 4, 0 ) = -0.125 * ( 1.0 - rPoint[1] ) * ( 1.0 + rPoint[2] );
1310  rResult( 4, 1 ) = -0.125 * ( 1.0 - rPoint[0] ) * ( 1.0 + rPoint[2] );
1311  rResult( 4, 2 ) = 0.125 * ( 1.0 - rPoint[0] ) * ( 1.0 - rPoint[1] );
1312  rResult( 5, 0 ) = 0.125 * ( 1.0 - rPoint[1] ) * ( 1.0 + rPoint[2] );
1313  rResult( 5, 1 ) = -0.125 * ( 1.0 + rPoint[0] ) * ( 1.0 + rPoint[2] );
1314  rResult( 5, 2 ) = 0.125 * ( 1.0 + rPoint[0] ) * ( 1.0 - rPoint[1] );
1315  rResult( 6, 0 ) = 0.125 * ( 1.0 + rPoint[1] ) * ( 1.0 + rPoint[2] );
1316  rResult( 6, 1 ) = 0.125 * ( 1.0 + rPoint[0] ) * ( 1.0 + rPoint[2] );
1317  rResult( 6, 2 ) = 0.125 * ( 1.0 + rPoint[0] ) * ( 1.0 + rPoint[1] );
1318  rResult( 7, 0 ) = -0.125 * ( 1.0 + rPoint[1] ) * ( 1.0 + rPoint[2] );
1319  rResult( 7, 1 ) = 0.125 * ( 1.0 - rPoint[0] ) * ( 1.0 + rPoint[2] );
1320  rResult( 7, 2 ) = 0.125 * ( 1.0 - rPoint[0] ) * ( 1.0 + rPoint[1] );
1321 
1322  return rResult;
1323  }
1324 
1341  ShapeFunctionsGradientsType& rResult,
1342  IntegrationMethod ThisMethod ) const override
1343  {
1344  const unsigned int integration_points_number =
1345  msGeometryData.IntegrationPointsNumber( ThisMethod );
1346 
1347  if ( integration_points_number == 0 )
1348  KRATOS_ERROR << "This integration method is not supported" << *this << std::endl;
1349 
1350  //workaround by riccardo
1351  if ( rResult.size() != integration_points_number )
1352  {
1353  // KLUDGE: While there is a bug in ublas
1354  // vector resize, I have to put this beside resizing!!
1355  ShapeFunctionsGradientsType temp( integration_points_number );
1356  rResult.swap( temp );
1357  }
1358 
1359  //calculating the local gradients
1361  CalculateShapeFunctionsIntegrationPointsLocalGradients( ThisMethod );
1362 
1363  //getting the inverse jacobian matrices
1364  JacobiansType temp( integration_points_number );
1365 
1366  JacobiansType invJ = InverseOfJacobian( temp, ThisMethod );
1367 
1368  //loop over all integration points
1369  for ( unsigned int pnt = 0; pnt < integration_points_number; pnt++ )
1370  {
1371  rResult[pnt].resize( 8, 3,false );
1372 
1373  for ( int i = 0; i < 8; i++ )
1374  {
1375  for ( int j = 0; j < 3; j++ )
1376  {
1377  rResult[pnt]( i, j ) =
1378  ( locG[pnt]( i, 0 ) * invJ[pnt]( j, 0 ) )
1379  + ( locG[pnt]( i, 1 ) * invJ[pnt]( j, 1 ) )
1380  + ( locG[pnt]( i, 2 ) * invJ[pnt]( j, 2 ) );
1381  }
1382  }
1383  }//end of loop over integration points
1384  }
1385 
1386 
1388  ShapeFunctionsGradientsType& rResult,
1389  Vector& determinants_of_jacobian,
1390  IntegrationMethod ThisMethod) const override
1391  {
1392  //TODO: this is not correct
1393  const unsigned int integration_points_number = msGeometryData.IntegrationPointsNumber(ThisMethod);
1394 
1395  if ( integration_points_number == 0 )
1396  KRATOS_ERROR << "This integration method is not supported" << *this << std::endl;
1397 
1398  //workaround by riccardo
1399  if ( rResult.size() != integration_points_number )
1400  {
1401  // KLUDGE: While there is a bug in ublas
1402  // vector resize, I have to put this beside resizing!!
1403  ShapeFunctionsGradientsType temp( integration_points_number );
1404  rResult.swap( temp );
1405  }
1406 
1407  if ( determinants_of_jacobian.size() != integration_points_number)
1408  determinants_of_jacobian.resize(integration_points_number,false);
1409 
1410  //calculating the local gradients
1412  CalculateShapeFunctionsIntegrationPointsLocalGradients( ThisMethod );
1413 
1414  JacobiansType J( integration_points_number );
1415  BaseType::Jacobian(J,ThisMethod);
1416 // JacobiansType invJ = InverseOfJacobian( temp, ThisMethod );
1417 
1418  //loop over all integration points
1419  for ( unsigned int pnt = 0; pnt < integration_points_number; pnt++ )
1420  {
1421  //current jacobian
1422 // Matrix J = ZeroMatrix( 3, 3 );
1423 // this->Jacobian( J, pnt, ThisMethod );
1424 // double DetJ = DeterminantOfJacobian(pnt,ThisMethod);
1425 
1426  Matrix invJ = ZeroMatrix( 3, 3 );
1427  double DetJ;
1428 
1429  MathUtils<double>::InvertMatrix3( J[pnt], invJ, DetJ );
1430 
1431  determinants_of_jacobian[pnt] = DetJ;
1432 
1433  rResult[pnt].resize( 4, 3 ,false);
1434 
1435  for ( int i = 0; i < 4; i++ )
1436  {
1437  for ( int j = 0; j < 3; j++ )
1438  {
1439  rResult[pnt]( i, j ) =
1440 // ( locG[pnt]( i, 0 ) * invJ[pnt]( j, 0 ) )
1441 // + ( locG[pnt]( i, 1 ) * invJ[pnt]( j, 1 ) )
1442 // + ( locG[pnt]( i, 2 ) * invJ[pnt]( j, 2 ) );
1443  ( locG[pnt]( i, 0 ) * invJ( 0, j ) )
1444  + ( locG[pnt]( i, 1 ) * invJ( 1, j ) )
1445  + ( locG[pnt]( i, 2 ) * invJ( 2, j ) );
1446  }
1447  }
1448  }
1449  }
1450 
1451 
1463  std::string Info() const override
1464  {
1465  return "3 dimensional hexahedra with eight nodes in 3D space";
1466  }
1467 
1475  void PrintInfo( std::ostream& rOStream ) const override
1476  {
1477  rOStream << "3 dimensional hexahedra with eight nodes in 3D space";
1478  }
1479 
1489  void PrintData( std::ostream& rOStream ) const override
1490  {
1491  // Base Geometry class PrintData call
1492  BaseType::PrintData( rOStream );
1493  std::cout << std::endl;
1494 
1495  // If the geometry has valid points, calculate and output its data
1496  if (this->AllPointsAreValid()) {
1497  Matrix jacobian;
1498  this->Jacobian( jacobian, PointType() );
1499  rOStream << " Jacobian\t : " << jacobian;
1500  }
1501  }
1502 
1503 private:
1506 
1507  static const GeometryData msGeometryData;
1508 
1509  static const GeometryDimension msGeometryDimension;
1510 
1514 
1515  friend class Serializer;
1516 
1517  void save( Serializer& rSerializer ) const override
1518  {
1520  }
1521 
1522  void load( Serializer& rSerializer ) override
1523  {
1525  }
1526 
1527  HexahedraInterface3D8(): BaseType( PointsArrayType(), &msGeometryData ) {}
1528 
1545  {
1546  Matrix result = ZeroMatrix( 8, 3 );
1547  result( 0, 0 ) = -0.125 * ( 1.0 - rPoint[1] ) * ( 1.0 - rPoint[2] );
1548  result( 0, 1 ) = -0.125 * ( 1.0 - rPoint[0] ) * ( 1.0 - rPoint[2] );
1549  result( 0, 2 ) = -0.125 * ( 1.0 - rPoint[0] ) * ( 1.0 - rPoint[1] );
1550  result( 1, 0 ) = 0.125 * ( 1.0 - rPoint[1] ) * ( 1.0 - rPoint[2] );
1551  result( 1, 1 ) = -0.125 * ( 1.0 + rPoint[0] ) * ( 1.0 - rPoint[2] );
1552  result( 1, 2 ) = -0.125 * ( 1.0 + rPoint[0] ) * ( 1.0 - rPoint[1] );
1553  result( 2, 0 ) = 0.125 * ( 1.0 + rPoint[1] ) * ( 1.0 - rPoint[2] );
1554  result( 2, 1 ) = 0.125 * ( 1.0 + rPoint[0] ) * ( 1.0 - rPoint[2] );
1555  result( 2, 2 ) = -0.125 * ( 1.0 + rPoint[0] ) * ( 1.0 + rPoint[1] );
1556  result( 3, 0 ) = -0.125 * ( 1.0 + rPoint[1] ) * ( 1.0 - rPoint[2] );
1557  result( 3, 1 ) = 0.125 * ( 1.0 - rPoint[0] ) * ( 1.0 - rPoint[2] );
1558  result( 3, 2 ) = -0.125 * ( 1.0 - rPoint[0] ) * ( 1.0 + rPoint[1] );
1559  result( 4, 0 ) = -0.125 * ( 1.0 - rPoint[1] ) * ( 1.0 + rPoint[2] );
1560  result( 4, 1 ) = -0.125 * ( 1.0 - rPoint[0] ) * ( 1.0 + rPoint[2] );
1561  result( 4, 2 ) = 0.125 * ( 1.0 - rPoint[0] ) * ( 1.0 - rPoint[1] );
1562  result( 5, 0 ) = 0.125 * ( 1.0 - rPoint[1] ) * ( 1.0 + rPoint[2] );
1563  result( 5, 1 ) = -0.125 * ( 1.0 + rPoint[0] ) * ( 1.0 + rPoint[2] );
1564  result( 5, 2 ) = 0.125 * ( 1.0 + rPoint[0] ) * ( 1.0 - rPoint[1] );
1565  result( 6, 0 ) = 0.125 * ( 1.0 + rPoint[1] ) * ( 1.0 + rPoint[2] );
1566  result( 6, 1 ) = 0.125 * ( 1.0 + rPoint[0] ) * ( 1.0 + rPoint[2] );
1567  result( 6, 2 ) = 0.125 * ( 1.0 + rPoint[0] ) * ( 1.0 + rPoint[1] );
1568  result( 7, 0 ) = -0.125 * ( 1.0 + rPoint[1] ) * ( 1.0 + rPoint[2] );
1569  result( 7, 1 ) = 0.125 * ( 1.0 - rPoint[0] ) * ( 1.0 + rPoint[2] );
1570  result( 7, 2 ) = 0.125 * ( 1.0 - rPoint[0] ) * ( 1.0 + rPoint[1] );
1571  return result;
1572  }
1573 
1574 
1586  static Matrix CalculateShapeFunctionsIntegrationPointsValues(
1587  typename BaseType::IntegrationMethod ThisMethod )
1588  {
1589  IntegrationPointsContainerType all_integration_points = AllIntegrationPoints();
1590  IntegrationPointsArrayType& integration_points = all_integration_points[static_cast<int>(ThisMethod)];
1591 
1592  //number of integration points
1593  const int integration_points_number = integration_points.size();
1594  //number of nodes in current geometry
1595  const int points_number = 8;
1596  //setting up return matrix
1597  Matrix shape_function_values( integration_points_number, points_number );
1598  //loop over all integration points
1599 
1600  for ( int pnt = 0; pnt < integration_points_number; pnt++ )
1601  {
1602  shape_function_values( pnt, 0 ) =
1603  0.125 * ( 1.0 - integration_points[pnt].X() )
1604  * ( 1.0 - integration_points[pnt].Y() )
1605  * ( 1.0 - integration_points[pnt].Z() );
1606  shape_function_values( pnt, 1 ) =
1607  0.125 * ( 1.0 + integration_points[pnt].X() )
1608  * ( 1.0 - integration_points[pnt].Y() )
1609  * ( 1.0 - integration_points[pnt].Z() );
1610  shape_function_values( pnt, 2 ) =
1611  0.125 * ( 1.0 + integration_points[pnt].X() )
1612  * ( 1.0 + integration_points[pnt].Y() )
1613  * ( 1.0 - integration_points[pnt].Z() );
1614  shape_function_values( pnt, 3 ) =
1615  0.125 * ( 1.0 - integration_points[pnt].X() )
1616  * ( 1.0 + integration_points[pnt].Y() )
1617  * ( 1.0 - integration_points[pnt].Z() );
1618  shape_function_values( pnt, 4 ) =
1619  0.125 * ( 1.0 - integration_points[pnt].X() )
1620  * ( 1.0 - integration_points[pnt].Y() )
1621  * ( 1.0 + integration_points[pnt].Z() );
1622  shape_function_values( pnt, 5 ) =
1623  0.125 * ( 1.0 + integration_points[pnt].X() )
1624  * ( 1.0 - integration_points[pnt].Y() )
1625  * ( 1.0 + integration_points[pnt].Z() );
1626  shape_function_values( pnt, 6 ) =
1627  0.125 * ( 1.0 + integration_points[pnt].X() )
1628  * ( 1.0 + integration_points[pnt].Y() )
1629  * ( 1.0 + integration_points[pnt].Z() );
1630  shape_function_values( pnt, 7 ) =
1631  0.125 * ( 1.0 - integration_points[pnt].X() )
1632  * ( 1.0 + integration_points[pnt].Y() )
1633  * ( 1.0 + integration_points[pnt].Z() );
1634  }
1635 
1636  return shape_function_values;
1637  }
1638 
1651  static ShapeFunctionsGradientsType CalculateShapeFunctionsIntegrationPointsLocalGradients(
1652  typename BaseType::IntegrationMethod ThisMethod )
1653  {
1654  IntegrationPointsContainerType all_integration_points =
1655  AllIntegrationPoints();
1656  IntegrationPointsArrayType integration_points = all_integration_points[static_cast<int>(ThisMethod)];
1657  //number of integration points
1658  const int integration_points_number = integration_points.size();
1659  ShapeFunctionsGradientsType d_shape_f_values( integration_points_number );
1660  //initialising container
1661  //loop over all integration points
1662 
1663  for ( int pnt = 0; pnt < integration_points_number; pnt++ )
1664  {
1665  Matrix& result = d_shape_f_values[pnt];
1666  result = ZeroMatrix( 8, 3 );
1667  result( 0, 0 ) =
1668  -0.125 * ( 1.0 - integration_points[pnt].Y() )
1669  * ( 1.0 - integration_points[pnt].Z() );
1670  result( 0, 1 ) =
1671  -0.125 * ( 1.0 - integration_points[pnt].X() )
1672  * ( 1.0 - integration_points[pnt].Z() );
1673  result( 0, 2 ) =
1674  -0.125 * ( 1.0 - integration_points[pnt].X() )
1675  * ( 1.0 - integration_points[pnt].Y() );
1676  result( 1, 0 ) =
1677  0.125 * ( 1.0 - integration_points[pnt].Y() )
1678  * ( 1.0 - integration_points[pnt].Z() );
1679  result( 1, 1 ) =
1680  -0.125 * ( 1.0 + integration_points[pnt].X() )
1681  * ( 1.0 - integration_points[pnt].Z() );
1682  result( 1, 2 ) =
1683  -0.125 * ( 1.0 + integration_points[pnt].X() )
1684  * ( 1.0 - integration_points[pnt].Y() );
1685  result( 2, 0 ) =
1686  0.125 * ( 1.0 + integration_points[pnt].Y() )
1687  * ( 1.0 - integration_points[pnt].Z() );
1688  result( 2, 1 ) =
1689  0.125 * ( 1.0 + integration_points[pnt].X() )
1690  * ( 1.0 - integration_points[pnt].Z() );
1691  result( 2, 2 ) =
1692  -0.125 * ( 1.0 + integration_points[pnt].X() )
1693  * ( 1.0 + integration_points[pnt].Y() );
1694  result( 3, 0 ) =
1695  -0.125 * ( 1.0 + integration_points[pnt].Y() )
1696  * ( 1.0 - integration_points[pnt].Z() );
1697  result( 3, 1 ) =
1698  0.125 * ( 1.0 - integration_points[pnt].X() )
1699  * ( 1.0 - integration_points[pnt].Z() );
1700  result( 3, 2 ) =
1701  -0.125 * ( 1.0 - integration_points[pnt].X() )
1702  * ( 1.0 + integration_points[pnt].Y() );
1703  result( 4, 0 ) =
1704  -0.125 * ( 1.0 - integration_points[pnt].Y() )
1705  * ( 1.0 + integration_points[pnt].Z() );
1706  result( 4, 1 ) =
1707  -0.125 * ( 1.0 - integration_points[pnt].X() )
1708  * ( 1.0 + integration_points[pnt].Z() );
1709  result( 4, 2 ) =
1710  0.125 * ( 1.0 - integration_points[pnt].X() )
1711  * ( 1.0 - integration_points[pnt].Y() );
1712  result( 5, 0 ) =
1713  0.125 * ( 1.0 - integration_points[pnt].Y() )
1714  * ( 1.0 + integration_points[pnt].Z() );
1715  result( 5, 1 ) =
1716  -0.125 * ( 1.0 + integration_points[pnt].X() )
1717  * ( 1.0 + integration_points[pnt].Z() );
1718  result( 5, 2 ) =
1719  0.125 * ( 1.0 + integration_points[pnt].X() )
1720  * ( 1.0 - integration_points[pnt].Y() );
1721  result( 6, 0 ) =
1722  0.125 * ( 1.0 + integration_points[pnt].Y() )
1723  * ( 1.0 + integration_points[pnt].Z() );
1724  result( 6, 1 ) =
1725  0.125 * ( 1.0 + integration_points[pnt].X() )
1726  * ( 1.0 + integration_points[pnt].Z() );
1727  result( 6, 2 ) =
1728  0.125 * ( 1.0 + integration_points[pnt].X() )
1729  * ( 1.0 + integration_points[pnt].Y() );
1730  result( 7, 0 ) =
1731  -0.125 * ( 1.0 + integration_points[pnt].Y() )
1732  * ( 1.0 + integration_points[pnt].Z() );
1733  result( 7, 1 ) =
1734  0.125 * ( 1.0 - integration_points[pnt].X() )
1735  * ( 1.0 + integration_points[pnt].Z() );
1736  result( 7, 2 ) =
1737  0.125 * ( 1.0 - integration_points[pnt].X() )
1738  * ( 1.0 + integration_points[pnt].Y() );
1739  }
1740 
1741  return d_shape_f_values;
1742  }
1743 
1744  static const IntegrationPointsContainerType AllIntegrationPoints()
1745  {
1746  IntegrationPointsContainerType integration_points =
1747  {
1748  {
1749  Quadrature < HexahedronGaussLobattoIntegrationPoints1,
1750  3, IntegrationPoint<3> >::GenerateIntegrationPoints(),
1751  Quadrature < HexahedronGaussLobattoIntegrationPoints2,
1752  3, IntegrationPoint<3> >::GenerateIntegrationPoints(),
1755  }
1756  };
1757  return integration_points;
1758  }
1759 
1760  static const ShapeFunctionsValuesContainerType AllShapeFunctionsValues()
1761  {
1762  ShapeFunctionsValuesContainerType shape_functions_values =
1763  {
1764  {
1765  HexahedraInterface3D8<TPointType>::CalculateShapeFunctionsIntegrationPointsValues(
1767  HexahedraInterface3D8<TPointType>::CalculateShapeFunctionsIntegrationPointsValues(
1769  Matrix(),
1770  Matrix()
1771  }
1772  };
1773  return shape_functions_values;
1774  }
1775 
1780  AllShapeFunctionsLocalGradients()
1781  {
1782  ShapeFunctionsLocalGradientsContainerType shape_functions_local_gradients =
1783  {
1784  {
1785  HexahedraInterface3D8<TPointType>::CalculateShapeFunctionsIntegrationPointsLocalGradients(
1787  HexahedraInterface3D8<TPointType>::CalculateShapeFunctionsIntegrationPointsLocalGradients(
1791  }
1792  };
1793  return shape_functions_local_gradients;
1794  }
1795 
1796 
1801  template<class TOtherPointType> friend class HexahedraInterface3D8;
1802 
1803 
1808 };// Class HexahedraInterface3D8
1809 
1810 
1818 template<class TPointType> inline std::istream& operator >> (
1819  std::istream& rIStream, HexahedraInterface3D8<TPointType>& rThis );
1820 
1824 template<class TPointType> inline std::ostream& operator << (
1825  std::ostream& rOStream, const HexahedraInterface3D8<TPointType>& rThis )
1826 {
1827  rThis.PrintInfo( rOStream );
1828  rOStream << std::endl;
1829  rThis.PrintData( rOStream );
1830 
1831  return rOStream;
1832 }
1833 
1834 
1835 template<class TPointType> const
1836 GeometryData HexahedraInterface3D8<TPointType>::msGeometryData(
1839  HexahedraInterface3D8<TPointType>::AllIntegrationPoints(),
1840  HexahedraInterface3D8<TPointType>::AllShapeFunctionsValues(),
1841  AllShapeFunctionsLocalGradients()
1842 );
1843 
1844 template<class TPointType>
1845 const GeometryDimension HexahedraInterface3D8<TPointType>::msGeometryDimension(3, 3);
1846 
1847 }// namespace Kratos.
1848 
1849 #endif // KRATOS_HEXAHEDRA_INTERFACE_3D_8_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
JacobiansType & Jacobian(JacobiansType &rResult) const
Definition: geometry.h:2901
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
Definition: hexahedra_interface_3d_8.h:36
BaseType::IndexType IndexType
Definition: hexahedra_interface_3d_8.h:79
Matrix & PointsLocalCoordinates(Matrix &rResult) const override
Definition: hexahedra_interface_3d_8.h:606
HexahedraInterface3D8(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: hexahedra_interface_3d_8.h:286
double Volume() const override
This method calculate and return volume of this geometry.
Definition: hexahedra_interface_3d_8.h:577
SizeType EdgesNumber() const override
This method gives you number of all edges of this geometry.
Definition: hexahedra_interface_3d_8.h:1098
double ShapeFunctionValue(IndexType ShapeFunctionIndex, const CoordinatesArrayType &rPoint) const override
Definition: hexahedra_interface_3d_8.h:1229
double DeterminantOfJacobian(IndexType IntegrationPointIndex, IntegrationMethod ThisMethod) const override
Definition: hexahedra_interface_3d_8.h:980
BaseType::CoordinatesArrayType CoordinatesArrayType
Definition: hexahedra_interface_3d_8.h:153
BaseType::ShapeFunctionsLocalGradientsContainerType ShapeFunctionsLocalGradientsContainerType
Definition: hexahedra_interface_3d_8.h:129
double DomainSize() const override
Definition: hexahedra_interface_3d_8.h:596
BaseType::IntegrationPointsContainerType IntegrationPointsContainerType
Definition: hexahedra_interface_3d_8.h:115
BaseType::Pointer Create(PointsArrayType const &ThisPoints) const override
Definition: hexahedra_interface_3d_8.h:477
BaseType::SizeType SizeType
Definition: hexahedra_interface_3d_8.h:87
GeometryData::KratosGeometryFamily GetGeometryFamily() const override
Definition: hexahedra_interface_3d_8.h:422
BaseType::GeometriesArrayType GeometriesArrayType
Definition: hexahedra_interface_3d_8.h:67
void PrintInfo(std::ostream &rOStream) const override
Definition: hexahedra_interface_3d_8.h:1475
double Area() const override
Definition: hexahedra_interface_3d_8.h:520
SizeType FacesNumber() const override
Returns the number of faces of the current geometry.
Definition: hexahedra_interface_3d_8.h:1165
Matrix & InverseOfJacobian(Matrix &rResult, const CoordinatesArrayType &rPoint) const override
Definition: hexahedra_interface_3d_8.h:1077
BaseType::IntegrationPointsArrayType IntegrationPointsArrayType
Definition: hexahedra_interface_3d_8.h:108
HexahedraInterface3D8 & operator=(HexahedraInterface3D8< TOtherPointType > const &rOther)
Definition: hexahedra_interface_3d_8.h:465
Matrix & ShapeFunctionsLocalGradients(Matrix &rResult, const CoordinatesArrayType &rPoint) const override
Definition: hexahedra_interface_3d_8.h:1290
HexahedraInterface3D8(const PointsArrayType &ThisPoints)
Definition: hexahedra_interface_3d_8.h:381
HexahedraInterface3D8(HexahedraInterface3D8 const &rOther)
Definition: hexahedra_interface_3d_8.h:397
BaseType::PointsArrayType PointsArrayType
Definition: hexahedra_interface_3d_8.h:93
virtual ~HexahedraInterface3D8()
Destructor. Does nothing!!!
Definition: hexahedra_interface_3d_8.h:420
CoordinatesArrayType & PointLocalCoordinates(CoordinatesArrayType &rResult, const CoordinatesArrayType &rPoint) const override
Returns the local coordinates of a given arbitrary point.
Definition: hexahedra_interface_3d_8.h:682
GeometriesArrayType GenerateFaces() const override
Returns all faces of the current geometry.
Definition: hexahedra_interface_3d_8.h:1178
Vector & DeterminantOfJacobian(Vector &rResult, IntegrationMethod ThisMethod) const override
Definition: hexahedra_interface_3d_8.h:928
TPointType PointType
Definition: hexahedra_interface_3d_8.h:72
void ShapeFunctionsIntegrationPointsGradients(ShapeFunctionsGradientsType &rResult, IntegrationMethod ThisMethod) const override
Definition: hexahedra_interface_3d_8.h:1340
Geometry< TPointType > BaseType
Definition: hexahedra_interface_3d_8.h:45
Matrix & Jacobian(Matrix &rResult, const CoordinatesArrayType &rPoint) const override
Definition: hexahedra_interface_3d_8.h:888
BaseType::IntegrationPointType IntegrationPointType
Definition: hexahedra_interface_3d_8.h:100
GeometriesArrayType GenerateEdges() const override
This method gives you all edges of this geometry.
Definition: hexahedra_interface_3d_8.h:1111
GeometryData::IntegrationMethod IntegrationMethod
Definition: hexahedra_interface_3d_8.h:61
HexahedraInterface3D8 & operator=(const HexahedraInterface3D8 &rOther)
Definition: hexahedra_interface_3d_8.h:447
Line3D2< TPointType > EdgeType
Definition: hexahedra_interface_3d_8.h:50
Vector & ShapeFunctionsValues(Vector &rResult, const CoordinatesArrayType &rCoordinates) const override
Definition: hexahedra_interface_3d_8.h:1268
std::string Info() const override
Definition: hexahedra_interface_3d_8.h:1463
BaseType::ShapeFunctionsValuesContainerType ShapeFunctionsValuesContainerType
Definition: hexahedra_interface_3d_8.h:122
BaseType::JacobiansType JacobiansType
Definition: hexahedra_interface_3d_8.h:136
bool IsInside(const CoordinatesArrayType &rPoint, CoordinatesArrayType &rResult, const double Tolerance=std::numeric_limits< double >::epsilon()) const override
Definition: hexahedra_interface_3d_8.h:654
KRATOS_CLASS_POINTER_DEFINITION(HexahedraInterface3D8)
double Length() const override
Definition: hexahedra_interface_3d_8.h:501
Matrix & Jacobian(Matrix &rResult, IndexType IntegrationPointIndex, IntegrationMethod ThisMethod, const Matrix &DeltaPosition) const override
Definition: hexahedra_interface_3d_8.h:838
Matrix MatrixType
Definition: hexahedra_interface_3d_8.h:158
JacobiansType & InverseOfJacobian(JacobiansType &rResult, IntegrationMethod ThisMethod) const override
Definition: hexahedra_interface_3d_8.h:1022
Matrix & InverseOfJacobian(Matrix &rResult, IndexType IntegrationPointIndex, IntegrationMethod ThisMethod) const override
Definition: hexahedra_interface_3d_8.h:1053
Quadrilateral3D4< TPointType > FaceType
Definition: hexahedra_interface_3d_8.h:51
BaseType::NormalType NormalType
Definition: hexahedra_interface_3d_8.h:148
BaseType::ShapeFunctionsGradientsType ShapeFunctionsGradientsType
Definition: hexahedra_interface_3d_8.h:143
void ShapeFunctionsIntegrationPointsGradients(ShapeFunctionsGradientsType &rResult, Vector &determinants_of_jacobian, IntegrationMethod ThisMethod) const override
Definition: hexahedra_interface_3d_8.h:1387
GeometryData::KratosGeometryType GetGeometryType() const override
Definition: hexahedra_interface_3d_8.h:427
friend class HexahedraInterface3D8
Definition: hexahedra_interface_3d_8.h:1801
void PrintData(std::ostream &rOStream) const override
Definition: hexahedra_interface_3d_8.h:1489
HexahedraInterface3D8(HexahedraInterface3D8< TOtherPointType > const &rOther)
Definition: hexahedra_interface_3d_8.h:414
Matrix & Jacobian(Matrix &rResult, IndexType IntegrationPointIndex, IntegrationMethod ThisMethod) const override
Definition: hexahedra_interface_3d_8.h:784
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 void InvertMatrix3(const TMatrix1 &rInputMatrix, TMatrix2 &rInvertedMatrix, double &rInputMatrixDet)
It inverts matrices of order 3.
Definition: math_utils.h:449
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 push_back(const TPointerType &x)
Definition: pointer_vector.h:270
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
Short class definition.
Definition: array_1d.h:61
BOOST_UBLAS_INLINE void clear()
Definition: array_1d.h:325
#define KRATOS_SERIALIZE_SAVE_BASE_CLASS(Serializer, BaseType)
Definition: define.h:812
#define KRATOS_SERIALIZE_LOAD_BASE_CLASS(Serializer, BaseType)
Definition: define.h:815
#define KRATOS_ERROR
Definition: exception.h:161
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
const GeometryData HexahedraInterface3D8< TPointType >::msGeometryData & msGeometryDimension(), HexahedraInterface3D8< TPointType >::AllShapeFunctionsValues(), AllShapeFunctionsLocalGradients()
Definition: brep_curve.h:483
Internals::Matrix< double, AMatrix::dynamic, AMatrix::dynamic > Matrix
Definition: amatrix_interface.h:470
AMatrix::MatrixProductExpression< TExpression1Type, TExpression2Type > prod(AMatrix::MatrixExpression< TExpression1Type, TCategory1 > const &First, AMatrix::MatrixExpression< TExpression2Type, TCategory2 > const &Second)
Definition: amatrix_interface.h:568
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
const GeometryData BrepCurve< TContainerPointType, TContainerPointEmbeddedType >::msGeometryData & msGeometryDimension
Definition: brep_curve.h:483
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
AMatrix::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
w
Definition: generate_convection_diffusion_explicit_element.py:108
DN
Definition: generate_convection_diffusion_explicit_element.py:98
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