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_invariants_utilities.hpp
Go to the documentation of this file.
1 //
2 // Project Name: KratosConstitutiveModelsApplication $
3 // Created by: $Author: LlMonforte $
4 // Last modified by: $Co-Author: $
5 // Date: $Date: April 2017 $
6 // Revision: $Revision: 0.0 $
7 //
8 //
9 
10 #if !defined(KRATOS_STRESS_INVARIANTS_UTILITIES)
11 #define KRATOS_STRESS_INVARIANTS_UTILITIES
12 
13 
14 // System includes
15 #include <cmath>
16 #include <set>
17 
18 
19 // External includes
20 #include "boost/smart_ptr.hpp"
21 
22 // Project includes
23 #include "includes/define.h"
24 #include "includes/variables.h"
25 
27 
28 namespace Kratos
29 {
30 
31 
33  {
34 
35  public:
36 
38 
40 
41  typedef unsigned int IndexType;
42 
43  typedef unsigned int SizeType;
44 
45  static inline void CalculateStressInvariants( const MatrixType& rStressMatrix, double & rI1, double & rJ2)
46  {
47  Vector StressVector = ZeroVector(6);
48  ConstitutiveModelUtilities::StressTensorToVector( rStressMatrix, StressVector);
49  CalculateStressInvariants( StressVector, rI1, rJ2);
50  }
51 
52  static inline void CalculateStressInvariants( const Vector& rStress, double& I1, double& J2)
53  {
54 
55  I1 = 0;
56  for (unsigned int i = 0; i < 3; ++i)
57  I1 += rStress(i);
58  I1 /= 3.0;
59 
60  J2 = 0;
61  for (unsigned int i = 0; i < 3; i++)
62  J2 += pow( rStress(i) - I1, 2);
63 
64  for (unsigned int i = 3; i < 6; i++)
65  J2 += 2.0*pow( rStress(i), 2);
66 
67  J2 = sqrt( 0.5 * J2 );
68 
69  }
70 
71  static inline void CalculateStressInvariants( const MatrixType& rStressMatrix, double & rI1, double & rJ2, double & rLode)
72  {
73  Vector StressVector = ZeroVector(6);
74  ConstitutiveModelUtilities::StressTensorToVector( rStressMatrix, StressVector);
75  CalculateStressInvariants( StressVector, rI1, rJ2, rLode);
76  }
77  static inline void CalculateStressInvariants( const Vector& rStress, double& I1, double& J2, double& Lode)
78  {
79  CalculateStressInvariants( rStress, I1, J2);
80  Matrix StressTensor = MathUtils<double>::StressVectorToTensor( rStress);
81 
82  for (unsigned int i = 0; i < 3; ++i)
83  StressTensor(i,i) -= I1;
84 
85  Lode = MathUtils<double>::Det(StressTensor);
86  Lode = 3.0 * sqrt(3.0) / 2.0 * Lode / pow( J2, 3);
87 
88  double epsi = 1.0e-9;
89  if ( fabs( Lode ) > 1.0-epsi) {
90  Lode = -30.0*Globals::Pi / 180.0 * Lode / fabs(Lode);
91  }
92  else if ( J2 < 10.0*epsi) {
93  Lode = 30.0*Globals::Pi / 180.0;
94  }
95  else {
96  Lode = std::asin( -Lode) / 3.0;
97  }
98 
99  }
100 
101  static inline void CalculateDerivativeVectors( const MatrixType& rStressMatrix, VectorType& C1, VectorType & C2)
102  {
103  Vector StressVector = ZeroVector(6);
104  ConstitutiveModelUtilities::StressTensorToVector( rStressMatrix, StressVector);
105  CalculateDerivativeVectors( StressVector, C1, C2);
106  }
107 
108  static inline void CalculateDerivativeVectors( const Vector & rStress, VectorType& C1, VectorType& C2)
109  {
110 
111  C1.clear();
112  for (unsigned int i = 0; i < 3; i++)
113  C1(i) = 1.0/3.0;
114 
115  double I1, J2;
116  CalculateStressInvariants( rStress, I1, J2);
117 
118  C2.clear();
119 
120  for (unsigned int i = 0; i < 3; i++)
121  C2(i) = rStress(i) - I1;
122 
123  for (unsigned int i = 3; i < 6; i++)
124  C2(i) = 2.0*rStress(i);
125 
126  if ( J2 > 1E-5) {
127  C2 /= 2.0 * J2;
128  }
129  else {
130  C2 = ZeroVector(6);
131  }
132 
133  }
134 
135  static inline void CalculateDerivativeVectors( const Vector rStress, Vector& C1, Vector& C2, Vector& C3)
136  {
137  // COPY
138  C1 = ZeroVector(6);
139  for (unsigned int i = 0; i < 3; i++)
140  C1(i) = 1.0/3.0;
141 
142  double I1, J2;
143  CalculateStressInvariants( rStress, I1, J2);
144 
145  C2 = ZeroVector(6);
146 
147  for (unsigned int i = 0; i < 3; i++)
148  C2(i) = rStress(i) - I1;
149 
150  for (unsigned int i = 3; i < 6; i++)
151  C2(i) = 2.0*rStress(i);
152 
153  if ( J2 > 1E-5) {
154  C2 /= (2.0 * J2);
155  }
156  else {
157  C2 = ZeroVector(6);
158  C3 = ZeroVector(6);
159  return;
160  }
161 
162  C3 = ZeroVector(6);
163 
164  Vector ShearStress = rStress;
165  for (int i = 0; i < 3; i++)
166  ShearStress(i) -= I1;
167 
168  C3(0) = ShearStress(1)*ShearStress(2) - pow( ShearStress(4), 2);
169  C3(1) = ShearStress(2)*ShearStress(0) - pow( ShearStress(5), 2);
170  C3(2) = ShearStress(0)*ShearStress(1) - pow( ShearStress(3), 2);
171 
172  C3(3) = 2.0 * ( ShearStress(4)*ShearStress(5) - ShearStress(2)*ShearStress(3));
173  C3(4) = 2.0 * ( ShearStress(5)*ShearStress(3) - ShearStress(0)*ShearStress(4));
174  C3(5) = 2.0 * ( ShearStress(3)*ShearStress(4) - ShearStress(1)*ShearStress(5));
175 
176  for (unsigned int i = 0; i < 3; ++i)
177  C3(i) += pow(J2, 2) / 3.0;
178 
179  Matrix Aux, ShearStressM;
180  ShearStressM = MathUtils<double>::StressVectorToTensor( ShearStress);
181  Aux = prod( ShearStressM, ShearStressM);
182 
183  for (unsigned int i = 0; i < 3; i++)
184  Aux(i,i) -= 1.0/3.0 * 2.0 * pow( J2 , 2);
185 
187 
188 
189  }
190 
191  }; // end Class StressInvariantsUtilities
192 
193 } // end namespace Kratos
194 
195 #endif // KRATOS_STRESS_INVARIANTS_UTILITIES
static Vector & StressTensorToVector(const MatrixType &rStressTensor, Vector &rStressVector)
Definition: constitutive_model_utilities.hpp:843
Definition: amatrix_interface.h:41
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 double Det(const TMatrixType &rA)
Calculates the determinant of a matrix of a square matrix of any size (no check performed on release ...
Definition: math_utils.h:597
Definition: stress_invariants_utilities.hpp:33
static void CalculateStressInvariants(const MatrixType &rStressMatrix, double &rI1, double &rJ2, double &rLode)
Definition: stress_invariants_utilities.hpp:71
unsigned int IndexType
Definition: stress_invariants_utilities.hpp:41
static void CalculateDerivativeVectors(const Vector &rStress, VectorType &C1, VectorType &C2)
Definition: stress_invariants_utilities.hpp:108
unsigned int SizeType
Definition: stress_invariants_utilities.hpp:43
static void CalculateStressInvariants(const MatrixType &rStressMatrix, double &rI1, double &rJ2)
Definition: stress_invariants_utilities.hpp:45
static void CalculateStressInvariants(const Vector &rStress, double &I1, double &J2)
Definition: stress_invariants_utilities.hpp:52
static void CalculateStressInvariants(const Vector &rStress, double &I1, double &J2, double &Lode)
Definition: stress_invariants_utilities.hpp:77
static void CalculateDerivativeVectors(const MatrixType &rStressMatrix, VectorType &C1, VectorType &C2)
Definition: stress_invariants_utilities.hpp:101
BoundedMatrix< double, 3, 3 > MatrixType
Definition: stress_invariants_utilities.hpp:37
array_1d< double, 6 > VectorType
Definition: stress_invariants_utilities.hpp:39
static void CalculateDerivativeVectors(const Vector rStress, Vector &C1, Vector &C2, Vector &C3)
Definition: stress_invariants_utilities.hpp:135
BOOST_UBLAS_INLINE void clear()
Definition: array_1d.h:325
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::MatrixProductExpression< TExpression1Type, TExpression2Type > prod(AMatrix::MatrixExpression< TExpression1Type, TCategory1 > const &First, AMatrix::MatrixExpression< TExpression2Type, TCategory2 > const &Second)
Definition: amatrix_interface.h:568
E
Definition: generate_hyper_elastic_simo_taylor_neo_hookean.py:26
float J2
Definition: isotropic_damage_automatic_differentiation.py:133
I1
Definition: isotropic_damage_automatic_differentiation.py:230
integer i
Definition: TensorModule.f:17