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: KratosSolidMechanicsApplication $
3 // Last modified by: $Author: LMonforte $
4 // Date: $Date: July 2015 $
5 // Revision: $Revision: 0.1 $
6 //
7 //
8 
9 #if !defined(KRATOS_STRESS_INVARIANTS_UTILITIES)
10 #define KRATOS_STRESS_INVARIANTS_UTILITIES
11 #define PI 3.1415926535898
12 
13 /*#ifdef FIND_MAX
14 #undef FIND_MAX
15 #endif
16 
17 #define FIND_MAX(a, b) ((a)>(b)?(a):(b))
18 */
19 
20 
21 // System includes
22 #include <cmath>
23 #include <set>
24 
25 
26 // External includes
27 #include "boost/smart_ptr.hpp"
28 //#include "utilities/timer.h"
29 
30 // Project includes
31 #include "includes/define.h"
32 #include "includes/variables.h"
33 //#include "includes/model_part.h"
34 //#include "utilities/openmp_utils.h"
35 #include "utilities/math_utils.h"
36 //#include "solid_mechanics_application_variables.h"
37 
38 namespace Kratos
39 {
40 
41 
42  class KRATOS_API(PFEM_SOLID_MECHANICS_APPLICATION) StressInvariantsUtilities
43  {
44 
45  public:
46 
47  typedef Matrix MatrixType;
48 
49  typedef Vector VectorType;
50 
51  typedef unsigned int IndexType;
52 
53  typedef unsigned int SizeType;
54 
55 
56  static inline void CalculateStressInvariants( const Vector& rStress, double& I1, double& J2)
57  {
58 
59  I1 = 0;
60  for (unsigned int i = 0; i < 3; ++i)
61  I1 += rStress(i);
62  I1 /= 3.0;
63 
64  J2 = 0;
65  for (unsigned int i = 0; i < 3; i++)
66  J2 += pow( rStress(i) - I1, 2.0);
67 
68  for (unsigned int i = 3; i < 6; i++)
69  J2 += 2.0*pow( rStress(i), 2.0);
70 
71  J2 = pow( J2 /2.0, 1.0/2.0);
72 
73  }
74 
75  static inline void CalculateStressInvariants( const Vector& rStress, double& I1, double& J2, double& Lode)
76  {
77  CalculateStressInvariants( rStress, I1, J2);
78  Matrix StressTensor = MathUtils<double>::StressVectorToTensor( rStress);
79 
80  for (unsigned int i = 0; i < 3; ++i)
81  StressTensor(i,i) -= I1;
82 
83  Lode = MathUtils<double>::Det(StressTensor);
84  Lode = 3.0 * sqrt(3.0) / 2.0 * Lode / pow( J2, 3.0);
85 
86  double epsi = 1.0e-9;
87  if ( fabs( Lode ) > 1.0-epsi) {
88  Lode = -30.0*PI / 180.0 * Lode / fabs(Lode);
89  }
90  else if ( J2 < 10.0*epsi) {
91  Lode = 30.0*PI / 180.0;
92  }
93  else {
94  Lode = std::asin( -Lode) / 3.0;
95  }
96 
97  //std::cout << " THISLODE " << Lode << " Stress;atrox " << StressTensor << " Stress " << rStress <<
98  }
99 
100  static inline void CalculateDerivativeVectors( const Vector rStress, Vector& C1, Vector& C2)
101  {
102 
103  C1 = ZeroVector(6);
104  for (unsigned int i = 0; i < 3; i++)
105  C1(i) = 1.0/3.0;
106 
107  double I1, J2;
108  CalculateStressInvariants( rStress, I1, J2);
109 
110  C2 = ZeroVector(6);
111 
112  for (unsigned int i = 0; i < 3; i++)
113  C2(i) = rStress(i) - I1;
114 
115  for (unsigned int i = 3; i < 6; i++)
116  C2(i) = 2.0*rStress(i);
117 
118  if ( J2 > 1E-5) {
119  C2 /= 2.0 * J2;
120  }
121  else {
122  C2 = ZeroVector(6);
123  }
124 
125 
126 
127 
128  }
129 
130  static inline void CalculateDerivativeVectors( const Vector rStress, Vector& C1, Vector& C2, Vector& C3)
131  {
132  // COPY
133  C1 = ZeroVector(6);
134  for (unsigned int i = 0; i < 3; i++)
135  C1(i) = 1.0/3.0;
136 
137  double I1, J2;
138  CalculateStressInvariants( rStress, I1, J2);
139 
140  C2 = ZeroVector(6);
141 
142  for (unsigned int i = 0; i < 3; i++)
143  C2(i) = rStress(i) - I1;
144 
145  for (unsigned int i = 3; i < 6; i++)
146  C2(i) = 2.0*rStress(i);
147 
148  if ( J2 > 1E-5) {
149  C2 /= 2.0 * J2;
150  }
151  else {
152  C2 = ZeroVector(6);
153  C3 = ZeroVector(6);
154  return;
155  }
156 
157  C3 = ZeroVector(6);
158 
159  Vector ShearStress = rStress;
160  for (int i = 0; i < 3; i++)
161  ShearStress(i) -= I1;
162 
163  C3(0) = ShearStress(1)*ShearStress(2) - pow( ShearStress(4), 2.0);
164  C3(1) = ShearStress(2)*ShearStress(0) - pow( ShearStress(5), 2.0);
165  C3(2) = ShearStress(0)*ShearStress(1) - pow( ShearStress(3), 2.0);
166 
167  C3(3) = 2.0 * ( ShearStress(4)*ShearStress(5) - ShearStress(2)*ShearStress(3));
168  C3(4) = 2.0 * ( ShearStress(5)*ShearStress(3) - ShearStress(0)*ShearStress(4));
169  C3(5) = 2.0 * ( ShearStress(3)*ShearStress(4) - ShearStress(1)*ShearStress(5));
170 
171  for (unsigned int i = 0; i < 3; ++i)
172  C3(i) += pow(J2, 2.0) / 3.0;
173 
174  Matrix Aux, ShearStressM;
175  ShearStressM = MathUtils<double>::StressVectorToTensor( ShearStress);
176  Aux = prod( ShearStressM, ShearStressM);
177 
178  for (unsigned int i = 0; i < 3; i++)
179  Aux(i,i) -= 1.0/3.0 * 2.0*pow( J2 , 2.0);
180 
182 
183 
184  }
185 
186  }; // end Class StressInvariantsUtilities
187 
188 } // end namespace Kratos
189 
190 #endif // KRATOS_STRESS_INVARIANTS_UTILITIES
#define PI
Definition: stress_invariants_utilities.hpp:11
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
unsigned int IndexType
Definition: stress_invariants_utilities.hpp:51
unsigned int SizeType
Definition: stress_invariants_utilities.hpp:53
static void CalculateStressInvariants(const Vector &rStress, double &I1, double &J2)
Definition: stress_invariants_utilities.hpp:56
static void CalculateStressInvariants(const Vector &rStress, double &I1, double &J2, double &Lode)
Definition: stress_invariants_utilities.hpp:75
Vector VectorType
Definition: stress_invariants_utilities.hpp:49
static void CalculateDerivativeVectors(const Vector rStress, Vector &C1, Vector &C2)
Definition: stress_invariants_utilities.hpp:100
static void CalculateDerivativeVectors(const Vector rStress, Vector &C1, Vector &C2, Vector &C3)
Definition: stress_invariants_utilities.hpp:130
Matrix MatrixType
Definition: stress_invariants_utilities.hpp:47
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