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.
constitutive_model_utilities.hpp
Go to the documentation of this file.
1 //
2 // Project Name: KratosConstitutiveModelsApplication $
3 // Created by: $Author: JMCarbonell $
4 // Last modified by: $Co-Author: $
5 // Date: $Date: April 2017 $
6 // Revision: $Revision: 0.0 $
7 //
8 //
9 
10 #if !defined(KRATOS_CONSTITUTIVE_MODEL_UTILITIES )
11 #define KRATOS_CONSTITUTIVE_MODEL_UTILITIES
12 
13 // System includes
14 #include <cmath>
15 #include <limits>
16 #include <algorithm>
17 
18 // External includes
19 
20 // Project includes
21 #include "utilities/math_utils.h"
22 #include "geometries/geometry.h"
23 #include "includes/node.h"
24 
25 namespace Kratos
26 {
29 
32 
36 
40 
44 
48 
50 
53  class KRATOS_API(CONSTITUTIVE_MODELS_APPLICATION) ConstitutiveModelUtilities
54  {
55  public:
56 
64 
67 
70 
74 
75 
83  static inline MatrixType& DeformationGradientTo3D(const MatrixType& rF, MatrixType& rF3D)
84  {
86 
87  for(unsigned int i=0; i<rF.size1(); i++)
88  for(unsigned int j=0; j<rF.size2(); j++)
89  rF3D(i,j) = rF(i,j);
90 
91  if (rF.size1() == 2 && rF.size2() == 2)
92  {
93  rF3D( 0 , 2 ) = 0.0;
94  rF3D( 1 , 2 ) = 0.0;
95 
96  rF3D( 2 , 0 ) = 0.0;
97  rF3D( 2 , 1 ) = 0.0;
98 
99  rF3D( 2 , 2 ) = 1.0;
100  }
101  else if(rF.size1() != 3 && rF.size2() != 3)
102  {
103  KRATOS_ERROR << "Matrix Dimensions are not correct" << std::endl;
104  }
105 
106  return rF3D;
107 
108  KRATOS_CATCH(" ")
109  }
110 
118  static inline MatrixType& VelocityGradientTo3D(const MatrixType& rL, MatrixType& rL3D)
119  {
120  KRATOS_TRY
121 
122  for(unsigned int i=0; i<rL.size1(); i++)
123  for(unsigned int j=0; j<rL.size2(); j++)
124  rL3D(i,j) = rL(i,j);
125 
126  if (rL.size1() == 2 && rL.size2() == 2)
127  {
128  rL3D( 0 , 2 ) = 0.0;
129  rL3D( 1 , 2 ) = 0.0;
130 
131  rL3D( 2 , 0 ) = 0.0;
132  rL3D( 2 , 1 ) = 0.0;
133 
134  rL3D( 2 , 2 ) = 0.0;
135  }
136  else if(rL.size1() != 3 && rL.size2() != 3)
137  {
138  KRATOS_ERROR << "Matrix Dimensions are not correct" << std::endl;
139  }
140 
141  return rL3D;
142 
143  KRATOS_CATCH(" ")
144  }
145 
146 
153  static inline void CalculateRightCauchyGreen( const MatrixType& rDeformationGradientF,
154  MatrixType& rRightCauchyGreen )
155  {
156  noalias( rRightCauchyGreen ) = prod( trans(rDeformationGradientF), rDeformationGradientF );
157  }
158 
159 
166  static inline void CalculateLeftCauchyGreen( const Matrix & rDeformationGradientF,
167  Matrix& rLeftCauchyGreen )
168  {
169  noalias( rLeftCauchyGreen ) = prod( rDeformationGradientF, trans(rDeformationGradientF) );
170  }
171 
172 
179  static inline void CalculateInverseLeftCauchyGreen( const Matrix & rDeformationGradientF,
180  Matrix& rInverseLeftCauchyGreen )
181  {
182  Matrix LeftCauchyGreen;
183  CalculateLeftCauchyGreen( rDeformationGradientF, LeftCauchyGreen );
184 
185  //calculating the inverse
186  double det_b=0;
187  MathUtils<double>::InvertMatrix( LeftCauchyGreen, rInverseLeftCauchyGreen, det_b);
188  }
189 
196  static inline void RightCauchyToGreenLagrangeStrain( const MatrixType& rRightCauchyGreen,
197  MatrixType& rStrainMatrix )
198  {
199  rStrainMatrix = rRightCauchyGreen;
200 
201  rStrainMatrix(0,0) -= 1.0;
202  rStrainMatrix(1,1) -= 1.0;
203  rStrainMatrix(2,2) -= 1.0;
204 
205  rStrainMatrix *= 0.5;
206  }
207 
214  static inline void LeftCauchyToAlmansiStrain( const MatrixType& rLeftCauchyGreen,
215  MatrixType& rStrainMatrix )
216  {
217  double I3 = 0;
218 
219  InvertMatrix3( rLeftCauchyGreen, rStrainMatrix, I3 );
220 
221  rStrainMatrix *= (-0.5);
222 
223  rStrainMatrix(0,0) += 0.5;
224  rStrainMatrix(1,1) += 0.5;
225  rStrainMatrix(2,2) += 0.5;
226  }
227 
234  static inline void RightCauchyToGreenLagrangeStrain( const Matrix& rRightCauchyGreen,
235  Vector& rStrainVector )
236  {
237 
238  if( rStrainVector.size() == 6 ){
239 
240  rStrainVector[0] = 0.5 * ( rRightCauchyGreen( 0, 0 ) - 1.00 );
241  rStrainVector[1] = 0.5 * ( rRightCauchyGreen( 1, 1 ) - 1.00 );
242  rStrainVector[2] = 0.5 * ( rRightCauchyGreen( 2, 2 ) - 1.00 );
243  rStrainVector[3] = rRightCauchyGreen( 0, 1 ); // xy
244  rStrainVector[4] = rRightCauchyGreen( 1, 2 ); // yz
245  rStrainVector[5] = rRightCauchyGreen( 0, 2 ); // xz
246 
247  }
248  else if( rStrainVector.size() == 4 ){
249 
250  rStrainVector[0] = 0.5 * ( rRightCauchyGreen( 0, 0 ) - 1.00 );
251  rStrainVector[1] = 0.5 * ( rRightCauchyGreen( 1, 1 ) - 1.00 );
252  rStrainVector[2] = 0.5 * ( rRightCauchyGreen( 2, 2 ) - 1.00 );
253  rStrainVector[3] = rRightCauchyGreen( 0, 1 ); // xy
254  }
255  else if( rStrainVector.size() == 3){
256 
257  rStrainVector[0] = 0.5 * ( rRightCauchyGreen( 0, 0 ) - 1.00 );
258  rStrainVector[1] = 0.5 * ( rRightCauchyGreen( 1, 1 ) - 1.00 );
259  rStrainVector[2] = rRightCauchyGreen( 0, 1 ); // xy
260 
261  }
262  else{
263  KRATOS_ERROR << "Strain Vector dimensions are not correct" << std::endl;
264  }
265 
266  }
267 
274  static inline void CalculateGreenLagrangeStrain( const Matrix& rDeformationGradientF,
275  Vector& rStrainVector )
276  {
277 
278  //E= 0.5*(FT*F-1) or E = 0.5*(C-1)
279  MatrixType RightCauchyGreen;
280  CalculateRightCauchyGreen( rDeformationGradientF, RightCauchyGreen );
281 
282 
283  RightCauchyToGreenLagrangeStrain(RightCauchyGreen,rStrainVector);
284 
285  // Matrix StrainMatrix(3,3);
286  // CalculateGreenLagrangeStrain(rDeformationGradientF, StrainMatrix);
287  // noalias(rStrainVector) = MathUtils<double>::StrainTensorToVector( StrainMatrix, rStrainVector.size() );
288 
289  }
290 
291 
292 
298  static inline void CalculateGreenLagrangeStrain( const MatrixType & rDeformationGradientF,
299  MatrixType& rStrainMatrix )
300  {
301 
302  CalculateRightCauchyGreen( rDeformationGradientF, rStrainMatrix );
303 
304  rStrainMatrix(0,0) -= 1;
305  rStrainMatrix(1,1) -= 1;
306  rStrainMatrix(2,2) -= 1;
307 
308  rStrainMatrix *= 0.5;
309 
310  }
311 
318  static inline void LeftCauchyToAlmansiStrain( const Matrix& rLeftCauchyGreen,
319  Vector& rStrainVector )
320  {
321  double I3 = 0;
322  Matrix InverseLeftCauchyGreen;
323  MathUtils<double>::InvertMatrix( rLeftCauchyGreen, InverseLeftCauchyGreen, I3 );
324  InverseLeftCauchyToAlmansiStrain( InverseLeftCauchyGreen, rStrainVector );
325  }
326 
333  static inline void InverseLeftCauchyToAlmansiStrain( const Matrix & rInverseLeftCauchyGreen,
334  Vector& rStrainVector )
335  {
336 
337  if( rStrainVector.size() == 6 ){
338 
339  rStrainVector[0] = 0.5 * ( 1.00 - rInverseLeftCauchyGreen( 0, 0 ) );
340  rStrainVector[1] = 0.5 * ( 1.00 - rInverseLeftCauchyGreen( 1, 1 ) );
341  rStrainVector[2] = 0.5 * ( 1.00 - rInverseLeftCauchyGreen( 2, 2 ) );
342  rStrainVector[3] = - rInverseLeftCauchyGreen( 0, 1 ); // xy
343  rStrainVector[4] = - rInverseLeftCauchyGreen( 1, 2 ); // yz
344  rStrainVector[5] = - rInverseLeftCauchyGreen( 0, 2 ); // xz
345 
346  }
347  else if( rStrainVector.size() == 4 ){
348 
349  rStrainVector[0] = 0.5 * ( 1.00 - rInverseLeftCauchyGreen( 0, 0 ) );
350  rStrainVector[1] = 0.5 * ( 1.00 - rInverseLeftCauchyGreen( 1, 1 ) );
351  rStrainVector[2] = 0.5 * ( 1.00 - rInverseLeftCauchyGreen( 2, 2 ) );
352  rStrainVector[3] = - rInverseLeftCauchyGreen( 0, 1 ); // xy
353 
354  }
355  else if( rStrainVector.size() == 3){
356 
357  rStrainVector[0] = 0.5 * ( 1.00 - rInverseLeftCauchyGreen( 0, 0 ) );
358  rStrainVector[1] = 0.5 * ( 1.00 - rInverseLeftCauchyGreen( 1, 1 ) );
359  rStrainVector[2] = - rInverseLeftCauchyGreen( 0, 1 ); // xy
360 
361  }
362  else{
363  KRATOS_ERROR << "Strain Vector dimensions are not correct" << std::endl;
364  }
365 
366  // Matrix StrainMatrix(3,3);
367  // CalculateAlmansiStrain(rDeformationGradientF, StrainMatrix);
368  // noalias(rStrainVector) = MathUtils<double>::StrainTensorToVector( StrainMatrix, rStrainVector.size() );
369 
370  }
371 
372 
379  static inline void CalculateAlmansiStrain( const Matrix & rDeformationGradientF,
380  Vector& rStrainVector )
381  {
382 
383  // e = 0.5*(1-invFT*invF) or e = 0.5*(1-inv(b))
384  Matrix InverseLeftCauchyGreen(3,3);
385  CalculateInverseLeftCauchyGreen( rDeformationGradientF, InverseLeftCauchyGreen );
386 
387  InverseLeftCauchyToAlmansiStrain( InverseLeftCauchyGreen, rStrainVector );
388 
389  // Matrix StrainMatrix(3,3);
390  // CalculateAlmansiStrain(rDeformationGradientF, StrainMatrix);
391  // noalias(rStrainVector) = MathUtils<double>::StrainTensorToVector( StrainMatrix, rStrainVector.size() );
392 
393  }
394 
395 
401  static inline void CalculateAlmansiStrain( const Matrix & rDeformationGradientF,
402  Matrix& rStrainMatrix )
403  {
404 
405  CalculateInverseLeftCauchyGreen( rDeformationGradientF, rStrainMatrix );
406 
407  rStrainMatrix(0,0) -= 1;
408  rStrainMatrix(1,1) -= 1;
409  rStrainMatrix(2,2) -= 1;
410 
411  rStrainMatrix *= -0.5;
412 
413  }
414 
415 
423  static inline Matrix& ConstitutiveTensorToMatrix(const BoundedMatrix<double,6,6>& rTensor, Matrix& rMatrix)
424  {
425  KRATOS_TRY;
426 
427  if( rMatrix.size1() == 6 ){
428 
429  rMatrix = rTensor;
430 
431  }
432  else if( rMatrix.size1() == 4 ){
433 
434  for(unsigned int i=0; i<3; i++)
435  {
436  for(unsigned int j=0; j<3; j++)
437  {
438  rMatrix(i,j) = rTensor(i,j);
439  }
440  }
441 
442  rMatrix(3,3) = rTensor(3,3);
443 
444  }
445  else if( rMatrix.size1() == 3){
446 
447  for(unsigned int i=0; i<2; i++)
448  {
449  for(unsigned int j=0; j<2; j++)
450  {
451  rMatrix(i,j) = rTensor(i,j);
452  }
453  }
454 
455  rMatrix(2,2) = rTensor(3,3);
456 
457  }
458  else{
459  KRATOS_ERROR << "Constitutive Matrix dimensions are not correct" << std::endl;
460  }
461 
462  return rMatrix;
463 
464  KRATOS_CATCH("");
465  }
466 
467 
475  static inline MatrixType& VectorToTensor(const Vector& rVector, MatrixType& rTensor)
476  {
477  KRATOS_TRY;
478 
479  // vector2D = [ a00, a11, a01, a10, a21, a02 ]
480  // vector3D = [ a00, a11, a22, a01, a12, a20, a10, a21, a02 ]
481 
482  if (rVector.size() == 4)
483  {
484  rTensor(0,0) = rVector[0];
485  rTensor(0,1) = rVector[2];
486  rTensor(0,2) = 0.0;
487 
488  rTensor(1,0) = rVector[3];
489  rTensor(1,1) = rVector[1];
490  rTensor(1,2) = 0.0;
491 
492  rTensor(2,0) = 0.0;
493  rTensor(2,1) = 0.0;
494  rTensor(2,2) = 0.0;
495  }
496  else if (rVector.size() == 9)
497  {
498  rTensor(0,0) = rVector[0];
499  rTensor(0,1) = rVector[3];
500  rTensor(0,2) = rVector[8];
501 
502  rTensor(1,0) = rVector[6];
503  rTensor(1,1) = rVector[1];
504  rTensor(1,2) = rVector[4];
505 
506  rTensor(2,0) = rVector[5];
507  rTensor(2,1) = rVector[7];
508  rTensor(2,2) = rVector[2];
509  }
510  else{
511  KRATOS_ERROR << " VectorToTensor transform Vector Size not correct : " << rVector.size() <<std::endl;
512  }
513 
514  return rTensor;
515 
516  KRATOS_CATCH("");
517  }
518 
527  static inline Vector& TensorToVector(const MatrixType& rTensor, Vector& rVector)
528  {
529  KRATOS_TRY;
530 
531  // vector2D = [ a00, a11, a01, a10, a21, a02 ]
532  // vector3D = [ a00, a11, a22, a01, a12, a20, a10, a21, a02 ]
533 
534  if (rVector.size() == 4)
535  {
536  rVector[0] = rTensor(0,0);
537  rVector[1] = rTensor(1,1);
538  rVector[2] = rTensor(0,1);
539  rVector[3] = rTensor(1,0);
540  }
541  else if (rVector.size() == 9)
542  {
543  rVector[0] = rTensor(0,0);
544  rVector[1] = rTensor(1,1);
545  rVector[2] = rTensor(2,2);
546  rVector[3] = rTensor(0,1);
547  rVector[4] = rTensor(1,2);
548  rVector[5] = rTensor(2,0);
549  rVector[6] = rTensor(1,0);
550  rVector[7] = rTensor(2,1);
551  rVector[8] = rTensor(0,2);
552  }
553  else{
554  KRATOS_ERROR << " TensorToVector transform Vector Size not correct : " << rVector.size() <<std::endl;
555  }
556 
557  return rVector;
558 
559  KRATOS_CATCH("");
560  }
561 
568  static inline MatrixType& VectorToSymmetricTensor(const array_1d<double,6>& rVector, MatrixType& rMatrix)
569  {
570  KRATOS_TRY;
571 
572  rMatrix(0,0) = rVector[0];
573  rMatrix(0,1) = rVector[3];
574  rMatrix(0,2) = rVector[5];
575 
576  rMatrix(1,0) = rVector[3];
577  rMatrix(1,1) = rVector[1];
578  rMatrix(1,2) = rVector[4];
579 
580  rMatrix(2,0) = rVector[5];
581  rMatrix(2,1) = rVector[4];
582  rMatrix(2,2) = rVector[2];
583 
584  return rMatrix;
585 
586  KRATOS_CATCH("");
587  }
588 
589 
597  static inline void SymmetricTensorToVector(const MatrixType& rMatrix, array_1d<double,6>& rVector)
598  {
599  KRATOS_TRY;
600 
601  rVector[0]= rMatrix(0,0);
602  rVector[1]= rMatrix(1,1);
603  rVector[2]= rMatrix(2,2);
604 
605  rVector[3]= rMatrix(0,1);
606  rVector[4]= rMatrix(1,2);
607  rVector[5]= rMatrix(2,0);
608 
609  KRATOS_CATCH("");
610  }
611 
612 
619  static inline MatrixType& StrainVectorToTensor(const array_1d<double,6>& rVector, MatrixType& rMatrix)
620  {
621  KRATOS_TRY;
622 
623  rMatrix(0,0) = rVector[0];
624  rMatrix(0,1) = 0.5*rVector[3];
625  rMatrix(0,2) = 0.5*rVector[5];
626  rMatrix(1,0) = 0.5*rVector[3];
627  rMatrix(1,1) = rVector[1];
628  rMatrix(1,2) = 0.5*rVector[4];
629  rMatrix(2,0) = 0.5*rVector[5];
630  rMatrix(2,1) = 0.5*rVector[4];
631  rMatrix(2,2) = rVector[2];
632 
633  return rMatrix;
634 
635  KRATOS_CATCH("");
636  }
637 
638 
646  static inline void StrainTensorToVector(const MatrixType& rMatrix, array_1d<double,6>& rVector)
647  {
648  KRATOS_TRY;
649 
650  rVector[0]= rMatrix(0,0);
651  rVector[1]= rMatrix(1,1);
652  rVector[2]= rMatrix(2,2);
653  rVector[3]= 2.0*rMatrix(0,1);
654  rVector[4]= 2.0*rMatrix(1,2);
655  rVector[5]= 2.0*rMatrix(0,2);
656 
657  KRATOS_CATCH("");
658  }
659 
669  static inline MatrixType& StrainVectorToTensor(const Vector& rStrainVector, MatrixType& rStrainTensor)
670  {
671  KRATOS_TRY;
672 
673  if (rStrainVector.size() == 3)
674  {
675  rStrainTensor(0,0) = rStrainVector[0];
676  rStrainTensor(0,1) = 0.5*rStrainVector[2];
677  rStrainTensor(0,2) = 0.0;
678 
679  rStrainTensor(1,0) = 0.5*rStrainVector[2];
680  rStrainTensor(1,1) = rStrainVector[1];
681  rStrainTensor(1,2) = 0.0;
682 
683  rStrainTensor(2,0) = 0.0;
684  rStrainTensor(2,1) = 0.0;
685  rStrainTensor(2,2) = 0.0;
686  }
687  else if (rStrainVector.size() == 4)
688  {
689  rStrainTensor(0,0) = rStrainVector[0];
690  rStrainTensor(0,1) = 0.5*rStrainVector[3];
691  rStrainTensor(0,2) = 0.0;
692 
693  rStrainTensor(1,0) = 0.5*rStrainVector[3];
694  rStrainTensor(1,1) = rStrainVector[1];
695  rStrainTensor(1,2) = 0.0;
696 
697  rStrainTensor(2,0) = 0.0;
698  rStrainTensor(2,1) = 0.0;
699  rStrainTensor(2,2) = rStrainVector[2];
700  }
701  else if (rStrainVector.size() == 6)
702  {
703  rStrainTensor(0,0) = rStrainVector[0];
704  rStrainTensor(0,1) = 0.5*rStrainVector[3];
705  rStrainTensor(0,2) = 0.5*rStrainVector[5];
706 
707  rStrainTensor(1,0) = 0.5*rStrainVector[3];
708  rStrainTensor(1,1) = rStrainVector[1];
709  rStrainTensor(1,2) = 0.5*rStrainVector[4];
710 
711  rStrainTensor(2,0) = 0.5*rStrainVector[5];
712  rStrainTensor(2,1) = 0.5*rStrainVector[4];
713  rStrainTensor(2,2) = rStrainVector[2];
714  }
715  else{
716  KRATOS_ERROR << "Unexpected voigt size: " << rStrainVector.size() << std::endl;
717  }
718 
719  return rStrainTensor;
720 
721  KRATOS_CATCH("");
722  }
723 
733  static inline Vector& StrainTensorToVector(const MatrixType& rStrainTensor, Vector& rStrainVector)
734  {
735  KRATOS_TRY;
736 
737  if (rStrainVector.size() == 3)
738  {
739  rStrainVector[0] = rStrainTensor(0,0);
740  rStrainVector[1] = rStrainTensor(1,1);
741  rStrainVector[2] = 2.0*rStrainTensor(0,1);
742  }
743  else if (rStrainVector.size() == 4)
744  {
745  rStrainVector[0] = rStrainTensor(0,0);
746  rStrainVector[1] = rStrainTensor(1,1);
747  rStrainVector[2] = rStrainTensor(2,2);
748  rStrainVector[3] = 2.0*rStrainTensor(0,1);
749  }
750  else if (rStrainVector.size() == 6)
751  {
752  rStrainVector[0] = rStrainTensor(0,0);
753  rStrainVector[1] = rStrainTensor(1,1);
754  rStrainVector[2] = rStrainTensor(2,2);
755  rStrainVector[3] = 2.0*rStrainTensor(0,1);
756  rStrainVector[4] = 2.0*rStrainTensor(1,2);
757  rStrainVector[5] = 2.0*rStrainTensor(0,2);
758  }
759  else{
760  KRATOS_ERROR << "Unexpected voigt size: " << rStrainVector.size() << std::endl;
761  }
762 
763 
764  return rStrainVector;
765 
766 
767  KRATOS_CATCH("");
768  }
769 
779  static inline MatrixType& StressVectorToTensor(const Vector& rStressVector, MatrixType& rStressTensor)
780  {
781  KRATOS_TRY;
782 
783  if (rStressVector.size() == 3)
784  {
785  rStressTensor(0,0) = rStressVector[0];
786  rStressTensor(0,1) = rStressVector[2];
787  rStressTensor(0,2) = 0.0;
788 
789  rStressTensor(1,0) = rStressVector[2];
790  rStressTensor(1,1) = rStressVector[1];
791  rStressTensor(1,2) = 0.0;
792 
793  rStressTensor(2,0) = 0.0;
794  rStressTensor(2,1) = 0.0;
795  rStressTensor(2,2) = 0.0;
796  }
797  else if (rStressVector.size() == 4)
798  {
799  rStressTensor(0,0) = rStressVector[0];
800  rStressTensor(0,1) = rStressVector[3];
801  rStressTensor(0,2) = 0.0;
802 
803  rStressTensor(1,0) = rStressVector[3];
804  rStressTensor(1,1) = rStressVector[1];
805  rStressTensor(1,2) = 0.0;
806 
807  rStressTensor(2,0) = 0.0;
808  rStressTensor(2,1) = 0.0;
809  rStressTensor(2,2) = rStressVector[2];
810  }
811  else if (rStressVector.size() == 6)
812  {
813  rStressTensor(0,0) = rStressVector[0];
814  rStressTensor(0,1) = rStressVector[3];
815  rStressTensor(0,2) = rStressVector[5];
816 
817  rStressTensor(1,0) = rStressVector[3];
818  rStressTensor(1,1) = rStressVector[1];
819  rStressTensor(1,2) = rStressVector[4];
820 
821  rStressTensor(2,0) = rStressVector[5];
822  rStressTensor(2,1) = rStressVector[4];
823  rStressTensor(2,2) = rStressVector[2];
824  }
825  else{
826  KRATOS_ERROR << "Unexpected voigt size: " << rStressVector.size() << std::endl;
827  }
828 
829  return rStressTensor;
830 
831  KRATOS_CATCH("");
832  }
833 
843  static inline Vector& StressTensorToVector(const MatrixType& rStressTensor, Vector& rStressVector)
844  {
845  KRATOS_TRY;
846 
847  if (rStressVector.size() == 3)
848  {
849  rStressVector[0] = rStressTensor(0,0);
850  rStressVector[1] = rStressTensor(1,1);
851  rStressVector[2] = rStressTensor(0,1);
852  }
853  else if (rStressVector.size() == 4)
854  {
855  rStressVector[0] = rStressTensor(0,0);
856  rStressVector[1] = rStressTensor(1,1);
857  rStressVector[2] = rStressTensor(2,2);
858  rStressVector[3] = rStressTensor(0,1);
859  }
860  else if (rStressVector.size() == 6)
861  {
862  rStressVector[0] = rStressTensor(0,0);
863  rStressVector[1] = rStressTensor(1,1);
864  rStressVector[2] = rStressTensor(2,2);
865  rStressVector[3] = rStressTensor(0,1);
866  rStressVector[4] = rStressTensor(1,2);
867  rStressVector[5] = rStressTensor(0,2);
868  }
869 
870  return rStressVector;
871 
872  KRATOS_CATCH("");
873  }
874 
875 
881  static inline double& CalculateStressNorm( const MatrixType& rStressMatrix,
882  double& rStressNorm )
883  {
884 
885  rStressNorm = sqrt((rStressMatrix(0,0)*rStressMatrix(0,0))+(rStressMatrix(1,1)*rStressMatrix(1,1))+(rStressMatrix(2,2)*rStressMatrix(2,2))+
886  (rStressMatrix(0,1)*rStressMatrix(0,1))+(rStressMatrix(0,2)*rStressMatrix(0,2))+(rStressMatrix(1,2)*rStressMatrix(1,2))+
887  (rStressMatrix(1,0)*rStressMatrix(1,0))+(rStressMatrix(2,0)*rStressMatrix(2,0))+(rStressMatrix(2,1)*rStressMatrix(2,1)));
888 
889 
890  return rStressNorm;
891 
892  }
893 
894 
900  static inline double& CalculateCharacteristicSize( const Geometry<Node >& rDomainGeometry,
901  double& rCharacteristicSize )
902  {
903 
904  if( rDomainGeometry.WorkingSpaceDimension() == 2)
905  //rCharacteristicSize is the diameter of a circle with the same area as the element
906  rCharacteristicSize = sqrt(4.0*rDomainGeometry.Area()/Globals::Pi);
907 
908  if( rDomainGeometry.WorkingSpaceDimension() == 3)
909  //rCharacteristicSize is the diameter of a sphere with the same volume as the element
910  rCharacteristicSize = pow((6.0*rDomainGeometry.Volume()/Globals::Pi),0.33333333333333);
911 
912  return rCharacteristicSize;
913 
914  }
915 
916 
920 
926  static inline void ComputePerturbationVector( Vector& rPerturbationVector, const Vector& InputVector )
927  {
928  const unsigned int VSize = InputVector.size();
929  if(rPerturbationVector.size() != VSize)
930  rPerturbationVector.resize(VSize,false);
931 
932  const double MinTol = 1.0e-10;
933  const double MaxTol = 1.0e-5;
934 
935  //Maximum and minimum vector components
936  double max_component = fabs(InputVector[0]) , min_component = fabs(InputVector[0]);
937 
938  for( unsigned int i=1; i<VSize; i++ )
939  {
940  if( fabs(InputVector[i]) < min_component )
941  {
942  min_component = fabs(InputVector[i]);
943  }
944  else if( fabs(InputVector[i]) > max_component )
945  {
946  max_component = fabs(InputVector[i]);
947  }
948  }
949 
950  double aux = min_component*MaxTol;
951 
952  if( aux < (max_component*MinTol) )
953  {
954  aux = max_component*MinTol;
955  }
956 
957  //PerturbationVector
958  for( unsigned int i=0; i<VSize; i++ )
959  {
960  if( fabs(InputVector[i]) > 1.0e-20 ) // different from zero
961  {
962  rPerturbationVector[i] = InputVector[i]*MaxTol;
963  }
964  else if( InputVector[i] >= 0.0 )
965  {
966  rPerturbationVector[i] = aux;
967  }
968  else
969  {
970  rPerturbationVector[i] = -aux;
971  }
972  }
973  }
974 
975 
983  static inline Vector EigenValuesDirectMethod(const Matrix& A)
984  {
985  // Given a real symmetric 3x3 matrix A, compute the eigenvalues
986  int dim= A.size1();
987  Vector Result(dim);
988  noalias(Result) = ZeroVector(dim);
989 
990  const double p1 = A(0,1)*A(0,1) + A(0,2)*A(0,2) + A(1,2)*A(1,2);
991  if (p1 == 0)
992  {//A is diagonal.
993  Result[0] = A(0,0);
994  Result[1] = A(1,1);
995  Result[2] = A(2,2);
996  return Result;
997  }
998 
999  const double q = (A(0,0) + A(1,1) + A(2,2)) / 3.0;
1000  const double p2 = (A(0,0) - q) * (A(0,0) - q) + (A(1,1) - q) * (A(1,1) - q) + (A(2,2) - q) * (A(2,2) - q) + 2.0 * p1;
1001  const double p = sqrt(p2 / 6.0);
1002 
1003  Matrix B(3,3);
1004  const double inv_p = 1.0/p;
1005 
1006  // B = (1 / p) * (A - q * I) where I is the identity matrix
1007  B(0,0) = inv_p * (A(0,0) - q);
1008  B(1,1) = inv_p * (A(1,1) - q);
1009  B(2,2) = inv_p * (A(2,2) - q);
1010  B(0,1) = inv_p * A(0,1);
1011  B(1,0) = inv_p * A(1,0);
1012  B(0,2) = inv_p * A(0,2);
1013  B(2,0) = inv_p * A(2,0);
1014  B(1,2) = inv_p * A(1,2);
1015  B(2,1) = inv_p * A(2,1);
1016 
1017  //r = det(B) / 2
1018  double r = 0.5 * ( B(0,0)*B(1,1)*B(2,2) + B(0,1)*B(1,2)*B(2,0) + B(1,0)*B(2,1)*B(0,2) - B(2,0)*B(1,1)*B(0,2) - B(1,0)*B(0,1)*B(2,2) - B(0,0)*B(2,1)*B(1,2) );
1019 
1020  // In exact arithmetic for a symmetric matrix -1 <= r <= 1
1021  // but computation error can leave it slightly outside this range.
1022  double phi = 0.0;
1023  if (r <= -1) { phi = Globals::Pi / 3.0; }
1024  else if (r >= 1) { phi = 0.0; }
1025  else { phi = acos(r) / 3.0;}
1026 
1027  // the eigenvalues satisfy eig3 <= eig2 <= eig1
1028  Result[0] = q + 2.0 * p * cos(phi);
1029  Result[2] = q + 2.0 * p * cos(phi + (2.0*Globals::Pi/3.0));
1030  Result[1] = 3.0 * q - Result[0] - Result[2]; //% since trace(A) = eig1 + eig2 + eig3
1031 
1032  return Result;
1033  }
1034 
1035 
1043  static void InvertMatrix3(const MatrixType& InputMatrix,
1044  MatrixType& InvertedMatrix,
1045  double& InputMatrixDet
1046  )
1047  {
1048  KRATOS_TRY;
1049 
1050 
1051  // Filling the inverted matrix with the algebraic complements
1052  // First column
1053  InvertedMatrix(0,0) = InputMatrix(1,1)*InputMatrix(2,2) - InputMatrix(1,2)*InputMatrix(2,1);
1054  InvertedMatrix(1,0) = -InputMatrix(1,0)*InputMatrix(2,2) + InputMatrix(1,2)*InputMatrix(2,0);
1055  InvertedMatrix(2,0) = InputMatrix(1,0)*InputMatrix(2,1) - InputMatrix(1,1)*InputMatrix(2,0);
1056 
1057  // Second column
1058  InvertedMatrix(0,1) = -InputMatrix(0,1)*InputMatrix(2,2) + InputMatrix(0,2)*InputMatrix(2,1);
1059  InvertedMatrix(1,1) = InputMatrix(0,0)*InputMatrix(2,2) - InputMatrix(0,2)*InputMatrix(2,0);
1060  InvertedMatrix(2,1) = -InputMatrix(0,0)*InputMatrix(2,1) + InputMatrix(0,1)*InputMatrix(2,0);
1061 
1062  // Third column
1063  InvertedMatrix(0,2) = InputMatrix(0,1)*InputMatrix(1,2) - InputMatrix(0,2)*InputMatrix(1,1);
1064  InvertedMatrix(1,2) = -InputMatrix(0,0)*InputMatrix(1,2) + InputMatrix(0,2)*InputMatrix(1,0);
1065  InvertedMatrix(2,2) = InputMatrix(0,0)*InputMatrix(1,1) - InputMatrix(0,1)*InputMatrix(1,0);
1066 
1067  // Calculation of determinant (of the input matrix)
1068  InputMatrixDet = InputMatrix(0,0)*InvertedMatrix(0,0) + InputMatrix(0,1)*InvertedMatrix(1,0) + InputMatrix(0,2)*InvertedMatrix(2,0);
1069 
1070  // Finalizing the calculation of the inverted matrix
1071  InvertedMatrix *= ( 1.0 / InputMatrixDet );
1072 
1073  KRATOS_CATCH("")
1074  }
1075 
1076 
1082  static inline void ComputePerturbationVector( VectorType& rPerturbationVector, const VectorType& InputVector )
1083  {
1084  const unsigned int VSize = InputVector.size();
1085  if(rPerturbationVector.size() != VSize)
1086  rPerturbationVector.resize(VSize,false);
1087 
1088  const double MinTol = 1.0e-10;
1089  const double MaxTol = 1.0e-5;
1090 
1091  //Maximum and minimum vector components
1092  double max_component = fabs(InputVector[0]) , min_component = fabs(InputVector[0]);
1093 
1094  for( unsigned int i=1; i<VSize; i++ )
1095  {
1096  if( fabs(InputVector[i]) < min_component )
1097  {
1098  min_component = fabs(InputVector[i]);
1099  }
1100  else if( fabs(InputVector[i]) > max_component )
1101  {
1102  max_component = fabs(InputVector[i]);
1103  }
1104  }
1105 
1106  double aux = min_component*MaxTol;
1107 
1108  if( aux < (max_component*MinTol) )
1109  {
1110  aux = max_component*MinTol;
1111  }
1112 
1113  //PerturbationVector
1114  for( unsigned int i=0; i<VSize; i++ )
1115  {
1116  if( fabs(InputVector[i]) > 1.0e-20 ) // different from zero
1117  {
1118  rPerturbationVector[i] = InputVector[i]*MaxTol;
1119  }
1120  else if( InputVector[i] >= 0.0 )
1121  {
1122  rPerturbationVector[i] = aux;
1123  }
1124  else
1125  {
1126  rPerturbationVector[i] = -aux;
1127  }
1128  }
1129  }
1130 
1131 
1140  static inline double& CalculateFourthOrderUnitTensor( double& rValue,
1141  const unsigned int& a, const unsigned int& b,
1142  const unsigned int& c, const unsigned int& d )
1143  {
1144  MatrixType Identity;
1145  noalias(Identity) = IdentityMatrix(3);
1146 
1147  rValue = CalculateFourthOrderUnitTensor(Identity,rValue,a,b,c,d);
1148 
1149  return rValue;
1150  }
1151 
1161  static inline double& CalculateFourthOrderUnitTensor( const MatrixType& rIdentityMatrix, double& rValue,
1162  const unsigned int& a, const unsigned int& b,
1163  const unsigned int& c, const unsigned int& d )
1164  {
1165  //rValue = 0.5*(rIdentityMatrix(a,c)*rIdentityMatrix(b,d)+rIdentityMatrix(a,d)*rIdentityMatrix(b,c));
1166 
1167  if((a==c && b==d) && (a==d && b==c))
1168  rValue = 1.0;
1169  else if((a==c && b==d) || (a==d && b==c))
1170  rValue = 0.5;
1171  else
1172  rValue = 0.0;
1173 
1174  return rValue;
1175  }
1176 
1177 
1187  static inline double& CalculateFourthOrderTensor(const MatrixType& rMatrix,
1188  double& rValue,
1189  const double& a,
1190  const double& b,
1191  const double& c,
1192  const double& d)
1193  {
1194  rValue = 0.5*(rMatrix(a,c)*rMatrix(b,d)+rMatrix(a,d)*rMatrix(b,c));
1195 
1196  return rValue;
1197  }
1198 
1208  static inline double& CalculateSquareTensorDerivative( const MatrixType& rMatrix, double& rValue,
1209  const unsigned int& a, const unsigned int& b,
1210  const unsigned int& c, const unsigned int& d )
1211  {
1212  MatrixType Identity;
1213  noalias(Identity) = IdentityMatrix(3);
1214 
1215  rValue = CalculateSquareTensorDerivative(rMatrix,Identity,rValue,a,b,c,d);
1216 
1217  return rValue;
1218  }
1219 
1230  static inline double& CalculateSquareTensorDerivative( const MatrixType& rMatrix, const MatrixType& rIdentityMatrix, double& rValue,
1231  const unsigned int& a, const unsigned int& b,
1232  const unsigned int& c, const unsigned int& d )
1233  {
1234  rValue = 0.5*(rIdentityMatrix(a,c)*rMatrix(d,b)+rIdentityMatrix(a,d)*rMatrix(c,b)+rIdentityMatrix(b,d)*rMatrix(a,c)+rIdentityMatrix(c,b)*rMatrix(a,d));
1235 
1236  return rValue;
1237  }
1238 
1239 
1250  static inline double& CalculateFourthOrderTensorProduct( const MatrixType& rMatrixA, const MatrixType& rMatrixB, double& rValue,
1251  const unsigned int& a, const unsigned int& b,
1252  const unsigned int& c, const unsigned int& d )
1253  {
1254  rValue = rMatrixA(a,b)*rMatrixB(c,d);
1255 
1256  return rValue;
1257  }
1258 
1269  static inline double& CalculateFourthOrderTensorProduct( const array_1d<double,3>& rVectorA, const array_1d<double,3>& rVectorB, double& rValue,
1270  const unsigned int& a, const unsigned int& b,
1271  const unsigned int& c, const unsigned int& d )
1272  {
1273  rValue = (rVectorA[a]*rVectorA[b])*(rVectorB[c]*rVectorB[d]);
1274 
1275  return rValue;
1276  }
1277 
1278 
1289  static inline double& CalculateFourthOrderTensorProduct( const MatrixType& rMatrixA, const array_1d<double,3>& rVectorB, double& rValue,
1290  const unsigned int& a, const unsigned int& b,
1291  const unsigned int& c, const unsigned int& d )
1292  {
1293  rValue = rMatrixA(a,b)*(rVectorB[c]*rVectorB[d]);
1294 
1295  return rValue;
1296  }
1297 
1308  static inline double& CalculateFourthOrderTensorProduct( const array_1d<double,3>& rVectorA, const MatrixType& rMatrixB, double& rValue,
1309  const unsigned int& a, const unsigned int& b,
1310  const unsigned int& c, const unsigned int& d )
1311  {
1312  rValue = (rVectorA[a]*rVectorA[b])*rMatrixB(c,d);
1313 
1314  return rValue;
1315  }
1316 
1317 
1323  static inline bool AreEqual( const double& rA, const double& rB )
1324  {
1325  //different sign
1326  if( rA*rB < 0 )
1327  return false;
1328 
1329  //different order of magnitude
1330  double absDiff = std::fabs(rA - rB);
1331  if(absDiff <= std::numeric_limits<double>::epsilon())
1332  {
1333  return true;
1334  }
1335 
1336  //similar order of magnitude
1337  double maxAbs = std::max(std::fabs(rA), std::fabs(rB));
1338  return (absDiff/maxAbs) < 1E-8;
1339 
1340  }
1341 
1342 
1343 
1353  static inline void PullBackConstitutiveMatrix( Matrix& rConstitutiveMatrix,
1354  const Matrix & rF )
1355  {
1356  Matrix OriginalConstitutiveMatrix = rConstitutiveMatrix;
1357 
1358  rConstitutiveMatrix.clear();
1359 
1360  Matrix InverseF ( 3, 3 );
1361  double detF = 0;
1362  MathUtils<double>::InvertMatrix( rF, InverseF, detF);
1363 
1364  ConstitutiveMatrixTransformation( rConstitutiveMatrix, OriginalConstitutiveMatrix, InverseF );
1365  }
1366 
1367 
1371  static inline void PushForwardConstitutiveMatrix( Matrix& rConstitutiveMatrix,
1372  const Matrix & rF )
1373  {
1374  Matrix OriginalConstitutiveMatrix = rConstitutiveMatrix;
1375 
1376  rConstitutiveMatrix.clear();
1377 
1378  ConstitutiveMatrixTransformation( rConstitutiveMatrix, OriginalConstitutiveMatrix, rF );
1379  }
1380 
1381 
1385  static inline void ConstitutiveMatrixTransformation ( Matrix& rConstitutiveMatrix,
1386  const Matrix& rOriginalConstitutiveMatrix,
1387  const Matrix & rF )
1388  {
1389  unsigned int size = rOriginalConstitutiveMatrix.size1();
1390  if( size == 6 )
1391  {
1392  const unsigned int IndexVoigt3D6C [6][2] = { {0, 0}, {1, 1}, {2, 2}, {0, 1}, {1, 2}, {0, 2} };
1393 
1394  for(unsigned int i=0; i<6; i++)
1395  {
1396  for(unsigned int j=0; j<6; j++)
1397  {
1398  rConstitutiveMatrix( i, j ) = TransformConstitutiveComponent(rConstitutiveMatrix( i, j ), rOriginalConstitutiveMatrix, rF,
1399  IndexVoigt3D6C[i][0], IndexVoigt3D6C[i][1], IndexVoigt3D6C[j][0], IndexVoigt3D6C[j][1]);
1400  }
1401 
1402  }
1403  }
1404  else if( size == 4 )
1405  {
1406 
1407  const unsigned int IndexVoigt2D4C [4][2] = { {0, 0}, {1, 1}, {2, 2}, {0, 1} };
1408 
1409  for(unsigned int i=0; i<4; i++)
1410  {
1411  for(unsigned int j=0; j<4; j++)
1412  {
1413  rConstitutiveMatrix( i, j ) = TransformConstitutiveComponent(rConstitutiveMatrix( i, j ), rOriginalConstitutiveMatrix, rF,
1414  IndexVoigt2D4C[i][0], IndexVoigt2D4C[i][1], IndexVoigt2D4C[j][0], IndexVoigt2D4C[j][1]);
1415  }
1416 
1417  }
1418  }
1419  else if( size == 3 )
1420  {
1421 
1422  const unsigned int IndexVoigt2D3C [3][2] = { {0, 0}, {1, 1}, {0, 1} };
1423 
1424  for(unsigned int i=0; i<3; i++)
1425  {
1426  for(unsigned int j=0; j<3; j++)
1427  {
1428  rConstitutiveMatrix( i, j ) = TransformConstitutiveComponent(rConstitutiveMatrix( i, j ), rOriginalConstitutiveMatrix, rF,
1429  IndexVoigt2D3C[i][0], IndexVoigt2D3C[i][1], IndexVoigt2D3C[j][0], IndexVoigt2D3C[j][1]);
1430  }
1431 
1432  }
1433  }
1434 
1435 
1436  }
1437 
1438 
1442  static inline double& TransformConstitutiveComponent(double & rCabcd,
1443  const Matrix & rConstitutiveMatrix,
1444  const Matrix & rF,
1445  const unsigned int& a, const unsigned int& b,
1446  const unsigned int& c, const unsigned int& d)
1447 
1448  {
1449 
1450  rCabcd = 0;
1451  double Cijkl=0;
1452 
1453  unsigned int dimension = rF.size1();
1454 
1455  //Cabcd
1456  for(unsigned int j=0; j<dimension; j++)
1457  {
1458  for(unsigned int l=0; l<dimension; l++)
1459  {
1460  for(unsigned int k=0; k<dimension; k++)
1461  {
1462  for(unsigned int i=0; i<dimension; i++)
1463  {
1464  //Cijkl
1465  rCabcd +=rF(a,i)*rF(b,j)*rF(c,k)*rF(d,l)*GetConstitutiveComponent(Cijkl,rConstitutiveMatrix,i,j,k,l);
1466  }
1467  }
1468  }
1469  }
1470 
1471  return rCabcd;
1472 
1473  }
1474 
1479  static inline double& GetConstitutiveComponent(double & rCabcd,
1480  const Matrix& rConstitutiveMatrix,
1481  const unsigned int& a, const unsigned int& b,
1482  const unsigned int& c, const unsigned int& d)
1483  {
1484  // matrix indices
1485  unsigned int k=0, l= 0;
1486 
1487  unsigned int size = rConstitutiveMatrix.size1();
1488 
1489  if( size == 3 )
1490  {
1491 
1492  const unsigned int IndexVoigt2D3C [3][2] = { {0, 0}, {1, 1}, {0, 1} };
1493 
1494  //index k
1495  for(unsigned int i=0; i<3; i++)
1496  {
1497  if( a == b )
1498  {
1499  if( IndexVoigt2D3C[i][0] == a && IndexVoigt2D3C[i][1] == b )
1500  {
1501  k = i;
1502  break;
1503  }
1504  }
1505  else
1506  {
1507  if( (IndexVoigt2D3C[i][0] == a && IndexVoigt2D3C[i][1] == b) ||
1508  (IndexVoigt2D3C[i][1] == a && IndexVoigt2D3C[i][0] == b) )
1509  {
1510  k = i;
1511  break;
1512  }
1513  }
1514  }
1515 
1516  //index l
1517  for(unsigned int i=0; i<3; i++)
1518  {
1519  if( c == d )
1520  {
1521  if( IndexVoigt2D3C[i][0] == c && IndexVoigt2D3C[i][1] == d )
1522  {
1523  l = i;
1524  break;
1525  }
1526  }
1527  else
1528  {
1529  if( (IndexVoigt2D3C[i][0] == c && IndexVoigt2D3C[i][1] == d) ||
1530  (IndexVoigt2D3C[i][1] == c && IndexVoigt2D3C[i][0] == d) )
1531  {
1532  l = i;
1533  break;
1534  }
1535  }
1536  }
1537 
1538 
1539  }
1540  else if( size == 4 )
1541  {
1542 
1543  const unsigned int IndexVoigt2D4C [4][2] = { {0, 0}, {1, 1}, {2, 2}, {0, 1} };
1544  //index k
1545  for(unsigned int i=0; i<4; i++)
1546  {
1547  if( a == b )
1548  {
1549  if( IndexVoigt2D4C[i][0] == a && IndexVoigt2D4C[i][1] == b )
1550  {
1551  k = i;
1552  break;
1553  }
1554  }
1555  else
1556  {
1557  if( (IndexVoigt2D4C[i][0] == a && IndexVoigt2D4C[i][1] == b) ||
1558  (IndexVoigt2D4C[i][1] == a && IndexVoigt2D4C[i][0] == b) )
1559  {
1560  k = i;
1561  break;
1562  }
1563  }
1564  }
1565 
1566  //index l
1567  for(unsigned int i=0; i<4; i++)
1568  {
1569  if( c == d )
1570  {
1571  if( IndexVoigt2D4C[i][0] == c && IndexVoigt2D4C[i][1] == d )
1572  {
1573  l = i;
1574  break;
1575  }
1576  }
1577  else
1578  {
1579  if( (IndexVoigt2D4C[i][0] == c && IndexVoigt2D4C[i][1] == d) ||
1580  (IndexVoigt2D4C[i][1] == c && IndexVoigt2D4C[i][0] == d) )
1581  {
1582  l = i;
1583  break;
1584  }
1585  }
1586  }
1587 
1588  }
1589  else if( size == 6 )
1590  {
1591 
1592  const unsigned int IndexVoigt3D6C [6][2] = { {0, 0}, {1, 1}, {2, 2}, {0, 1}, {1, 2}, {0, 2} };
1593 
1594  //index k
1595  for(unsigned int i=0; i<6; i++)
1596  {
1597  if( a == b )
1598  {
1599  if( IndexVoigt3D6C[i][0] == a && IndexVoigt3D6C[i][1] == b )
1600  {
1601  k = i;
1602  break;
1603  }
1604  }
1605  else
1606  {
1607  if( (IndexVoigt3D6C[i][0] == a && IndexVoigt3D6C[i][1] == b) ||
1608  (IndexVoigt3D6C[i][1] == a && IndexVoigt3D6C[i][0] == b) )
1609  {
1610  k = i;
1611  break;
1612  }
1613  }
1614  }
1615 
1616  //index l
1617  for(unsigned int i=0; i<6; i++)
1618  {
1619  if( c == d )
1620  {
1621  if( IndexVoigt3D6C[i][0] == c && IndexVoigt3D6C[i][1] == d )
1622  {
1623  l = i;
1624  break;
1625  }
1626  }
1627  else
1628  {
1629  if( (IndexVoigt3D6C[i][0] == c && IndexVoigt3D6C[i][1] == d) ||
1630  (IndexVoigt3D6C[i][1] == c && IndexVoigt3D6C[i][0] == d) )
1631  {
1632  l = i;
1633  break;
1634  }
1635  }
1636  }
1637  }
1638 
1639  rCabcd = rConstitutiveMatrix(k,l);
1640 
1641  return rCabcd;
1642  }
1643 
1644 
1645 
1649 
1650 
1654 
1655 
1659 
1663 
1664 
1666 
1667 
1668  protected:
1669 
1672 
1676 
1680 
1684 
1688 
1692 
1696 
1697 
1699 
1700  private:
1701 
1704 
1708 
1712 
1716 
1720 
1724 
1728 
1732 
1734 
1735 
1736  }; // Class ConstitutiveModelUtilities
1737 
1739 
1742 
1743 
1748 
1750 
1751 
1752 } // namespace Kratos.
1753 
1754 #endif // KRATOS_CONSTITUTIVE_MODEL_UTILITIES defined
Short class definition.
Definition: constitutive_model_utilities.hpp:54
static void ComputePerturbationVector(VectorType &rPerturbationVector, const VectorType &InputVector)
Definition: constitutive_model_utilities.hpp:1082
~ConstitutiveModelUtilities()
Destructor.
Definition: constitutive_model_utilities.hpp:69
static MatrixType & StrainVectorToTensor(const Vector &rStrainVector, MatrixType &rStrainTensor)
Definition: constitutive_model_utilities.hpp:669
static Vector EigenValuesDirectMethod(const Matrix &A)
Definition: constitutive_model_utilities.hpp:983
static MatrixType & VectorToTensor(const Vector &rVector, MatrixType &rTensor)
Definition: constitutive_model_utilities.hpp:475
static double & CalculateSquareTensorDerivative(const MatrixType &rMatrix, double &rValue, const unsigned int &a, const unsigned int &b, const unsigned int &c, const unsigned int &d)
Definition: constitutive_model_utilities.hpp:1208
static double & CalculateStressNorm(const MatrixType &rStressMatrix, double &rStressNorm)
Definition: constitutive_model_utilities.hpp:881
static void RightCauchyToGreenLagrangeStrain(const MatrixType &rRightCauchyGreen, MatrixType &rStrainMatrix)
Definition: constitutive_model_utilities.hpp:196
static MatrixType & DeformationGradientTo3D(const MatrixType &rF, MatrixType &rF3D)
Definition: constitutive_model_utilities.hpp:83
static void CalculateAlmansiStrain(const Matrix &rDeformationGradientF, Matrix &rStrainMatrix)
Definition: constitutive_model_utilities.hpp:401
static void CalculateAlmansiStrain(const Matrix &rDeformationGradientF, Vector &rStrainVector)
Definition: constitutive_model_utilities.hpp:379
static void CalculateRightCauchyGreen(const MatrixType &rDeformationGradientF, MatrixType &rRightCauchyGreen)
Definition: constitutive_model_utilities.hpp:153
static void ConstitutiveMatrixTransformation(Matrix &rConstitutiveMatrix, const Matrix &rOriginalConstitutiveMatrix, const Matrix &rF)
Definition: constitutive_model_utilities.hpp:1385
static void CalculateGreenLagrangeStrain(const MatrixType &rDeformationGradientF, MatrixType &rStrainMatrix)
Definition: constitutive_model_utilities.hpp:298
static double & CalculateFourthOrderTensorProduct(const MatrixType &rMatrixA, const array_1d< double, 3 > &rVectorB, double &rValue, const unsigned int &a, const unsigned int &b, const unsigned int &c, const unsigned int &d)
Definition: constitutive_model_utilities.hpp:1289
static double & GetConstitutiveComponent(double &rCabcd, const Matrix &rConstitutiveMatrix, const unsigned int &a, const unsigned int &b, const unsigned int &c, const unsigned int &d)
Definition: constitutive_model_utilities.hpp:1479
static MatrixType & VectorToSymmetricTensor(const array_1d< double, 6 > &rVector, MatrixType &rMatrix)
Definition: constitutive_model_utilities.hpp:568
static double & CalculateFourthOrderUnitTensor(const MatrixType &rIdentityMatrix, double &rValue, const unsigned int &a, const unsigned int &b, const unsigned int &c, const unsigned int &d)
Definition: constitutive_model_utilities.hpp:1161
static double & TransformConstitutiveComponent(double &rCabcd, const Matrix &rConstitutiveMatrix, const Matrix &rF, const unsigned int &a, const unsigned int &b, const unsigned int &c, const unsigned int &d)
Definition: constitutive_model_utilities.hpp:1442
static double & CalculateFourthOrderUnitTensor(double &rValue, const unsigned int &a, const unsigned int &b, const unsigned int &c, const unsigned int &d)
Definition: constitutive_model_utilities.hpp:1140
static void ComputePerturbationVector(Vector &rPerturbationVector, const Vector &InputVector)
Definition: constitutive_model_utilities.hpp:926
ConstitutiveModelUtilities()
Default constructor.
Definition: constitutive_model_utilities.hpp:66
static void StrainTensorToVector(const MatrixType &rMatrix, array_1d< double, 6 > &rVector)
Definition: constitutive_model_utilities.hpp:646
static void CalculateLeftCauchyGreen(const Matrix &rDeformationGradientF, Matrix &rLeftCauchyGreen)
Definition: constitutive_model_utilities.hpp:166
static void LeftCauchyToAlmansiStrain(const MatrixType &rLeftCauchyGreen, MatrixType &rStrainMatrix)
Definition: constitutive_model_utilities.hpp:214
static void InvertMatrix3(const MatrixType &InputMatrix, MatrixType &InvertedMatrix, double &InputMatrixDet)
Definition: constitutive_model_utilities.hpp:1043
static Matrix & ConstitutiveTensorToMatrix(const BoundedMatrix< double, 6, 6 > &rTensor, Matrix &rMatrix)
Definition: constitutive_model_utilities.hpp:423
static void CalculateGreenLagrangeStrain(const Matrix &rDeformationGradientF, Vector &rStrainVector)
Definition: constitutive_model_utilities.hpp:274
static double & CalculateFourthOrderTensorProduct(const MatrixType &rMatrixA, const MatrixType &rMatrixB, double &rValue, const unsigned int &a, const unsigned int &b, const unsigned int &c, const unsigned int &d)
Definition: constitutive_model_utilities.hpp:1250
BoundedMatrix< double, 3, 3 > MatrixType
Definition: constitutive_model_utilities.hpp:59
static Vector & StressTensorToVector(const MatrixType &rStressTensor, Vector &rStressVector)
Definition: constitutive_model_utilities.hpp:843
static MatrixType & VelocityGradientTo3D(const MatrixType &rL, MatrixType &rL3D)
Definition: constitutive_model_utilities.hpp:118
static Vector & StrainTensorToVector(const MatrixType &rStrainTensor, Vector &rStrainVector)
Definition: constitutive_model_utilities.hpp:733
static double & CalculateFourthOrderTensorProduct(const array_1d< double, 3 > &rVectorA, const array_1d< double, 3 > &rVectorB, double &rValue, const unsigned int &a, const unsigned int &b, const unsigned int &c, const unsigned int &d)
Definition: constitutive_model_utilities.hpp:1269
static double & CalculateFourthOrderTensorProduct(const array_1d< double, 3 > &rVectorA, const MatrixType &rMatrixB, double &rValue, const unsigned int &a, const unsigned int &b, const unsigned int &c, const unsigned int &d)
Definition: constitutive_model_utilities.hpp:1308
static void PullBackConstitutiveMatrix(Matrix &rConstitutiveMatrix, const Matrix &rF)
Definition: constitutive_model_utilities.hpp:1353
static bool AreEqual(const double &rA, const double &rB)
Definition: constitutive_model_utilities.hpp:1323
static double & CalculateSquareTensorDerivative(const MatrixType &rMatrix, const MatrixType &rIdentityMatrix, double &rValue, const unsigned int &a, const unsigned int &b, const unsigned int &c, const unsigned int &d)
Definition: constitutive_model_utilities.hpp:1230
static MatrixType & StressVectorToTensor(const Vector &rStressVector, MatrixType &rStressTensor)
Definition: constitutive_model_utilities.hpp:779
static MatrixType & StrainVectorToTensor(const array_1d< double, 6 > &rVector, MatrixType &rMatrix)
Definition: constitutive_model_utilities.hpp:619
array_1d< double, 6 > VectorType
Definition: constitutive_model_utilities.hpp:60
static void CalculateInverseLeftCauchyGreen(const Matrix &rDeformationGradientF, Matrix &rInverseLeftCauchyGreen)
Definition: constitutive_model_utilities.hpp:179
static Vector & TensorToVector(const MatrixType &rTensor, Vector &rVector)
Definition: constitutive_model_utilities.hpp:527
static void RightCauchyToGreenLagrangeStrain(const Matrix &rRightCauchyGreen, Vector &rStrainVector)
Definition: constitutive_model_utilities.hpp:234
static void LeftCauchyToAlmansiStrain(const Matrix &rLeftCauchyGreen, Vector &rStrainVector)
Definition: constitutive_model_utilities.hpp:318
static double & CalculateFourthOrderTensor(const MatrixType &rMatrix, double &rValue, const double &a, const double &b, const double &c, const double &d)
Definition: constitutive_model_utilities.hpp:1187
static void SymmetricTensorToVector(const MatrixType &rMatrix, array_1d< double, 6 > &rVector)
Definition: constitutive_model_utilities.hpp:597
static void InverseLeftCauchyToAlmansiStrain(const Matrix &rInverseLeftCauchyGreen, Vector &rStrainVector)
Definition: constitutive_model_utilities.hpp:333
static void PushForwardConstitutiveMatrix(Matrix &rConstitutiveMatrix, const Matrix &rF)
Definition: constitutive_model_utilities.hpp:1371
static double & CalculateCharacteristicSize(const Geometry< Node > &rDomainGeometry, double &rCharacteristicSize)
Definition: constitutive_model_utilities.hpp:900
Geometry base class.
Definition: geometry.h:71
virtual double Volume() const
This method calculate and return volume of this geometry.
Definition: geometry.h:1358
SizeType WorkingSpaceDimension() const
Definition: geometry.h:1287
virtual double Area() const
This method calculate and return area or surface area of this geometry depending to it's dimension.
Definition: geometry.h:1345
Definition: amatrix_interface.h:41
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
static BoundedMatrix< double, TDim, TDim > InvertMatrix(const BoundedMatrix< double, TDim, TDim > &rInputMatrix, double &rInputMatrixDet, const double Tolerance=ZeroTolerance)
Calculates the inverse of a 2x2, 3x3 and 4x4 matrices (using bounded matrix for performance)
Definition: math_utils.h:197
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_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
#define KRATOS_ERROR
Definition: exception.h:161
static double max(double a, double b)
Definition: GeometryFunctions.h:79
constexpr double Pi
Definition: global_variables.h:25
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
KratosZeroVector< double > ZeroVector
Definition: amatrix_interface.h:561
AMatrix::IdentityMatrix< double > IdentityMatrix
Definition: amatrix_interface.h:564
AMatrix::MatrixProductExpression< TExpression1Type, TExpression2Type > prod(AMatrix::MatrixExpression< TExpression1Type, TCategory1 > const &First, AMatrix::MatrixExpression< TExpression2Type, TCategory2 > const &Second)
Definition: amatrix_interface.h:568
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
AMatrix::TransposeMatrix< const T > trans(const T &TheMatrix)
Definition: amatrix_interface.h:486
q
Definition: generate_convection_diffusion_explicit_element.py:109
E
Definition: generate_hyper_elastic_simo_taylor_neo_hookean.py:26
a
Definition: generate_stokes_twofluid_element.py:77
b
Definition: generate_total_lagrangian_mixed_volumetric_strain_element.py:31
c
Definition: generate_weakly_compressible_navier_stokes_element.py:108
int dimension
Definition: isotropic_damage_automatic_differentiation.py:123
phi
Definition: isotropic_damage_automatic_differentiation.py:168
tuple I3
Definition: isotropic_damage_automatic_differentiation.py:232
int d
Definition: ode_solve.py:397
int k
Definition: quadrature.py:595
int j
Definition: quadrature.py:648
A
Definition: sensitivityMatrix.py:70
p
Definition: sensitivityMatrix.py:52
int dim
Definition: sensitivityMatrix.py:25
B
Definition: sensitivityMatrix.py:76
integer i
Definition: TensorModule.f:17
integer l
Definition: TensorModule.f:17