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.
stress_strain_utilities.hpp
Go to the documentation of this file.
1 // KRATOS___
2 // // ) )
3 // // ___ ___
4 // // ____ //___) ) // ) )
5 // // / / // // / /
6 // ((____/ / ((____ ((___/ / MECHANICS
7 //
8 // License: geo_mechanics_application/license.txt
9 //
10 // Main authors: JMCarbonell,
11 // Vahid Galavi
12 //
13 
14 #pragma once
15 
16 /* Project includes */
19 
20 namespace Kratos
21 {
22 
23 class KRATOS_API(GEO_MECHANICS_APPLICATION) StressStrainUtilities
24 {
25 public:
26  static double CalculateStressNorm(const Vector& StressVector)
27  {
29 
30  Matrix LocalStressTensor = MathUtils<>::StressVectorToTensor(StressVector); //reduced dimension stress tensor
31 
32  double StressNorm = 0.;
33  for(unsigned int i = 0; i < LocalStressTensor.size1(); ++i) {
34  for(unsigned int j = 0; j < LocalStressTensor.size2(); ++j) {
35  StressNorm += LocalStressTensor(i,j)*LocalStressTensor(i,j);
36  }
37  }
38  return std::sqrt(StressNorm);
39 
40  KRATOS_CATCH("")
41  }
42 
43  static double CalculateVonMisesStress(const Vector& StressVector)
44  {
46 
47  Matrix LocalStressTensor = MathUtils<double>::StressVectorToTensor(StressVector); //reduced dimension stress tensor
48 
49  Matrix StressTensor(3,3); //3D stress tensor
50  noalias(StressTensor) = ZeroMatrix(3,3);
51  for (std::size_t i=0; i < LocalStressTensor.size1(); ++i) {
52  for (std::size_t j=0; j < LocalStressTensor.size2(); ++j) {
53  StressTensor(i,j) = LocalStressTensor(i,j);
54  }
55  }
56 
57  double SigmaEquivalent = 0.5*((StressTensor(0,0)-StressTensor(1,1))*(StressTensor(0,0)-StressTensor(1,1))+
58  (StressTensor(1,1)-StressTensor(2,2))*(StressTensor(1,1)-StressTensor(2,2))+
59  (StressTensor(2,2)-StressTensor(0,0))*(StressTensor(2,2)-StressTensor(0,0))+
60  6.0*(StressTensor(0,1)*StressTensor(1,0)+
61  StressTensor(1,2)*StressTensor(2,1)+
62  StressTensor(2,0)*StressTensor(0,2) ));
63 
64  return std::sqrt(std::max(SigmaEquivalent, 0.));
65 
66  KRATOS_CATCH("")
67  }
68 
69  static double CalculateTrace(const Vector& StressVector)
70  {
72 
73  Matrix StressTensor = MathUtils<double>::StressVectorToTensor(StressVector); //reduced dimension stress tensor
74 
75  double trace = 0.0;
76  for (std::size_t i = 0; i < StressTensor.size1(); ++i) {
77  trace += StressTensor(i,i);
78  }
79 
80  return trace;
81 
82  KRATOS_CATCH("")
83  }
84 
85  static double CalculateMeanStress(const Vector& StressVector)
86  {
88  return CalculateTrace(StressVector) / (StressVector.size() == 3 ? 2.0 : 3.0);
89  KRATOS_CATCH("")
90  }
91 
92  static double CalculateVonMisesStrain(const Vector& StrainVector)
93  {
95  return (2.0/3.0) * CalculateVonMisesStress(StrainVector);
96  KRATOS_CATCH("")
97  }
98 
99  static Vector CalculateHenckyStrain(const Matrix& DeformationGradient, size_t VoigtSize)
100  {
101  KRATOS_TRY
102 
103  // right Cauchy Green deformation tensor C
104  Matrix C = prod(trans(DeformationGradient), DeformationGradient);
105  // Eigenvalues of C matrix, so principal right Cauchy Green deformation tensor C
106  Matrix EigenValuesMatrix, EigenVectorsMatrix;
107  MathUtils<double>::GaussSeidelEigenSystem(C, EigenVectorsMatrix, EigenValuesMatrix, 1.0e-16, 20);
108  // Compute natural strain == Logarithmic strain == Hencky strain from principal strains
109  for (std::size_t i = 0; i < DeformationGradient.size1(); ++i){
110  EigenValuesMatrix(i,i) = 0.5 * std::log(EigenValuesMatrix(i,i));
111  }
112 
113  // Rotate from principal strains back to the used coordinate system
114  Matrix ETensor;
115  MathUtils<double>::BDBtProductOperation(ETensor, EigenValuesMatrix, EigenVectorsMatrix);
116 
117  // From tensor to vector
118  if (DeformationGradient.size1()==2 && VoigtSize == 4) {
119  // Plane strain
120  Vector StrainVector2D;
121  StrainVector2D = MathUtils<double>::StrainTensorToVector(ETensor, 3);
122  Vector StrainVector(4);
123  StrainVector[INDEX_2D_PLANE_STRAIN_XX] = StrainVector2D[0];
124  StrainVector[INDEX_2D_PLANE_STRAIN_YY] = StrainVector2D[1];
125  StrainVector[INDEX_2D_PLANE_STRAIN_ZZ] = 0.0;
126  StrainVector[INDEX_2D_PLANE_STRAIN_XY] = StrainVector2D[2];
127  return StrainVector;
128  } else {
129  return MathUtils<double>::StrainTensorToVector(ETensor, VoigtSize);
130  }
131 
132  KRATOS_CATCH("")
133  }
134 
135 };
136 
137 }
static TMatrixType StressVectorToTensor(const TVector &rStressVector)
Transforms a stess vector into a matrix. Stresses are assumed to be stored in the following way: for...
Definition: math_utils.h:1174
static Vector StrainTensorToVector(const TMatrixType &rStrainTensor, SizeType rSize=0)
Transforms a given symmetric Strain Tensor to Voigt Notation:
Definition: math_utils.h:1344
static void BDBtProductOperation(TMatrixType1 &rA, const TMatrixType2 &rD, const TMatrixType3 &rB)
Calculates the product operation BDB'.
Definition: math_utils.h:1543
static bool GaussSeidelEigenSystem(const TMatrixType1 &rA, TMatrixType2 &rEigenVectorsMatrix, TMatrixType2 &rEigenValuesMatrix, const double Tolerance=1.0e-18, const SizeType MaxIterations=20)
Calculates the eigenvectors and eigenvalues of given symmetric matrix.
Definition: math_utils.h:1587
Definition: stress_strain_utilities.hpp:24
static double CalculateTrace(const Vector &StressVector)
Definition: stress_strain_utilities.hpp:69
static Vector CalculateHenckyStrain(const Matrix &DeformationGradient, size_t VoigtSize)
Definition: stress_strain_utilities.hpp:99
static double CalculateVonMisesStrain(const Vector &StrainVector)
Definition: stress_strain_utilities.hpp:92
static double CalculateMeanStress(const Vector &StressVector)
Definition: stress_strain_utilities.hpp:85
static double CalculateVonMisesStress(const Vector &StressVector)
Definition: stress_strain_utilities.hpp:43
static double CalculateStressNorm(const Vector &StressVector)
Definition: stress_strain_utilities.hpp:26
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
static double max(double a, double b)
Definition: GeometryFunctions.h:79
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
KratosZeroMatrix< double > ZeroMatrix
Definition: amatrix_interface.h:559
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
@ INDEX_2D_PLANE_STRAIN_XX
Definition: geo_mechanics_application_constants.h:62
@ INDEX_2D_PLANE_STRAIN_ZZ
Definition: geo_mechanics_application_constants.h:64
@ INDEX_2D_PLANE_STRAIN_YY
Definition: geo_mechanics_application_constants.h:63
@ INDEX_2D_PLANE_STRAIN_XY
Definition: geo_mechanics_application_constants.h:65
int C
Definition: generate_hyper_elastic_simo_taylor_neo_hookean.py:27
int j
Definition: quadrature.py:648
integer i
Definition: TensorModule.f:17