14 #ifndef KRATOS_MPM_STRESS_PRINCIPAL_INVARIANTS_UTILITY
15 #define KRATOS_MPM_STRESS_PRINCIPAL_INVARIANTS_UTILITY
61 for(
unsigned int i=0;
i<3;
i++)
63 principal_direction_1[
i] = rMainDirections(0,
i);
64 principal_direction_2[
i] = rMainDirections(1,
i);
65 principal_direction_3[
i] = rMainDirections(2,
i);
69 if(rPrincipalStress[0]<rPrincipalStress[1])
71 std::swap(rPrincipalStress[0],rPrincipalStress[1]);
72 std::swap(rMainStrain[0],rMainStrain[1]);
73 Vector temp_vector = principal_direction_1;
74 principal_direction_1 = principal_direction_2;
75 principal_direction_2 = temp_vector;
78 if(rPrincipalStress[1]<rPrincipalStress[2])
80 std::swap(rPrincipalStress[1],rPrincipalStress[2]);
81 std::swap(rMainStrain[1],rMainStrain[2]);
82 Vector temp_vector = principal_direction_2;
83 principal_direction_2 = principal_direction_3;
84 principal_direction_3 = temp_vector;
87 if(rPrincipalStress[0]<rPrincipalStress[1])
89 std::swap(rPrincipalStress[0],rPrincipalStress[1]);
90 std::swap(rMainStrain[0],rMainStrain[1]);
91 Vector temp_vector = principal_direction_1;
92 principal_direction_1 = principal_direction_2;
93 principal_direction_2 = temp_vector;
97 for(
unsigned int i=0;
i<3;
i++)
99 rMainDirections(
i,0) = principal_direction_1[
i];
100 rMainDirections(
i,1) = principal_direction_2[
i];
101 rMainDirections(
i,2) = principal_direction_3[
i];
116 for (
unsigned int i = 0;
i < 3; ++
i)
121 for (
unsigned int i = 0;
i < 3;
i++)
122 rJ2 += std::pow( rVector[
i] - rI1/3.0, 2);
124 if ( rVector.size() == 6 )
126 for (
unsigned int i = 3;
i < 6;
i++)
127 rJ2 += 2.0 * std::pow( rVector[
i], 2);
147 Vector s_vector = rVector;
148 for (
unsigned int i = 0;
i < 3; ++
i)
149 s_vector[
i] -= rI1/3.0;
164 double i_1, j_2, j_3;
169 for (
unsigned int i = 0;
i < 3; ++
i)
175 for (
unsigned int i = 0;
i < 3; ++
i)
182 for (
unsigned int i = 0;
i < 3; ++
i)
183 t_tensor(
i,
i) -= 2.0/3.0 * j_2;
199 if (rVector.size() == 3)
209 for (
unsigned int i = 0;
i < 3; ++
i)
210 for (
unsigned int j = 0;
j < 3; ++
j)
212 if (
i ==
j) rD2J2(
i,
j) = 2.0/3.0;
213 else rD2J2(
i,
j) = -1.0/3.0;
218 Vector s_vector = rVector;
219 for (
unsigned int i = 0;
i < 3; ++
i)
220 s_vector[
i] -= i_1/3.0;
222 for (
unsigned int i = 0;
i < 3; ++
i)
223 for (
unsigned int j = 0;
j < 3; ++
j)
225 if (
i ==
j) rD2J3(
i,
j) = 2.0/3.0 * s_vector[
i];
226 else rD2J3(
i,
j) = - 2.0/3.0* (s_vector[
i] + s_vector[
j]);
231 KRATOS_ERROR <<
"The given vector dimension is wrong! Given: " << rVector.size() <<
"; Expected: 3" << std::endl;
248 rMeanStressP = rMeanStressP / 3.0;
251 rDeviatoricQ = std::sqrt(3 * rDeviatoricQ);
262 double i_1, j_2, j_3;
269 rLodeAngle = -j_3 / 2.0 * std::pow(3.0/j_2, 1.5);
270 if ( std::abs( rLodeAngle ) > 1.0 )
271 rLodeAngle = (
Globals::Pi / 6.0 ) * rLodeAngle / std::abs(rLodeAngle);
273 rLodeAngle = std::asin( rLodeAngle ) / 3.0;
309 for (
unsigned int i = 0;
i < 3;
i++)
316 for (
unsigned int i = 0;
i < 3;
i++)
319 rC2 *= 3.0 / (2.0 *
q);
334 double i_1, j_2, j_3;
351 rC3 = dj_3 - (3.0/2.0 * j_3/j_2) * dj_2;
352 rC3 *= - std::sqrt(3.0) / (2.0 * std::cos(3*lode_angle) * std::pow(j_2, 1.5));
366 if (rStress.size() == 3)
379 Vector s_vector = rStress;
380 for (
unsigned int i = 0;
i < 3; ++
i)
383 for (
unsigned int i = 0;
i < 3; ++
i)
384 for (
unsigned int j = 0;
j < 3; ++
j)
386 if (
i ==
j) r2C2(
i,
j) = 1.0 /
q;
387 else r2C2(
i,
j) = - 1.0/2.0/
q;
389 r2C2(
i,
j) -= (9.0/4.0/std::pow(
q, 3) * s_vector[
i] * s_vector[
j]);
396 KRATOS_ERROR <<
"The given vector dimension is wrong! Given: " << rStress.size() <<
"; Expected: 3" << std::endl;
412 if (rStress.size() == 3)
418 double i_1, j_2, j_3;
424 Matrix d2i_1, d2j_2, d2j_3;
427 Vector dp, dq, dlode_angle;
439 const double AT = - std::sqrt(3) / (2.0 * j_2 * std::sqrt(j_2) * std::cos(3 * lode_angle));
440 const double AS = AT * (- 1.50 * j_3 / j_2);
446 aux_dAT = AT * (-3.0/2.0/j_2 * dj_2 + 3.0 * std::tan(3*lode_angle) * dlode_angle);
448 first_component += AT * d2j_3;
453 aux_dAS = AS * (-5.0/2.0/j_2 * dj_2 + 3.0 * std::tan(3*lode_angle) * dlode_angle + 1.0/j_3 * dj_3);
455 second_component += AS * d2j_2;
458 r2C3 = first_component + second_component;
463 KRATOS_ERROR <<
"The given vector dimension is wrong! Given: " << rStress.size() <<
"; Expected: 3" << std::endl;
479 for(
unsigned int i=0;
i<3; ++
i)
480 matrix(
i,
i) = rVector[
i];
501 for(
unsigned int i=0;
i<3; ++
i)
502 vector[
i] = rMatrix(
i,
i);
516 <<
"CalculateMatrixDoubleContraction only takes square matrices\n";
517 for (
size_t i = 0;
i < rInput.size1(); ++
i)
519 for (
size_t j = 0;
j < rInput.size2(); ++
j)
521 result += rInput(
i,
j) * rInput(
i,
j);
530 KRATOS_ERROR_IF(rInput.size1() != rInput.size2()) <<
"Can only calculate trace of square matrices";
532 for (
size_t i = 0;
i < rInput.size1(); ++
i) trace += rInput(
i,
i);
Definition: mpm_stress_principal_invariants_utility.h:32
static void CalculateTensorInvariants(const Vector &rVector, double &rI1, double &rJ2)
Calculate invariants I1 and J2 of a tensor.
Definition: mpm_stress_principal_invariants_utility.h:112
unsigned int SizeType
Definition: mpm_stress_principal_invariants_utility.h:42
static void CalculateTensorInvariants(const Vector &rVector, double &rI1, double &rJ2, double &rJ3)
Calculate invariants I1, J2, and J3 of a tensor.
Definition: mpm_stress_principal_invariants_utility.h:141
static Matrix PrincipalVectorToMatrix(const Vector &rVector, const unsigned int &rSize)
Transform Stress or Principal stress tensor to Matrix form (fully assuming 3D space).
Definition: mpm_stress_principal_invariants_utility.h:474
static double CalculateMatrixDoubleContraction(const Matrix &rInput)
Definition: mpm_stress_principal_invariants_utility.h:512
static Vector PrincipalMatrixtoVector(const Matrix &rMatrix, const unsigned int &rSize)
Transform Stress or Principal stress tensor to Vector form (fully assuming 3D space).
Definition: mpm_stress_principal_invariants_utility.h:496
static double CalculateMatrixTrace(const Matrix &rInput)
Definition: mpm_stress_principal_invariants_utility.h:528
unsigned int IndexType
Definition: mpm_stress_principal_invariants_utility.h:40
static void CalculateSecondDerivativeMatrices(const Vector rStress, Matrix &r2C1, Matrix &r2C2)
Calculate second stress invariant derivatives d2p/d2sigma (volumetric) and d2q/d2sigma (deviatoric).
Definition: mpm_stress_principal_invariants_utility.h:363
Matrix MatrixType
Definition: mpm_stress_principal_invariants_utility.h:36
static void CalculateSecondDerivativeMatrices(const Vector rStress, Matrix &r2C1, Matrix &r2C2, Matrix &r2C3)
Calculate second stress invariant derivatives d2p/d2sigma (volumetric), d2q/d2sigma (deviatoric),...
Definition: mpm_stress_principal_invariants_utility.h:409
static void SortPrincipalStress(Vector &rPrincipalStress, Vector &rMainStrain, Matrix &rMainDirections)
Sort Principal Stresses, Strains, and Directions to magnitude order.
Definition: mpm_stress_principal_invariants_utility.h:54
static void CalculateDerivativeVectors(const Vector rStress, Vector &rC1, Vector &rC2)
Calculate stress invariant derivatives dp/dsigma (volumetric) and dq/dsigma (deviatoric).
Definition: mpm_stress_principal_invariants_utility.h:301
static void CalculateTensorInvariantsDerivatives(const Vector &rVector, Vector &rDI1, Vector &rDJ2, Vector &rDJ3)
Calculate derivatives of invariants dI1/dtensor, dJ2/dtensor, and dJ3/dtensor.
Definition: mpm_stress_principal_invariants_utility.h:162
Vector VectorType
Definition: mpm_stress_principal_invariants_utility.h:38
static void CalculateStressInvariants(const Vector &rStress, double &rMeanStressP, double &rDeviatoricQ, double &rLodeAngle)
Calculate stress invariants p, q, and lode angle.
Definition: mpm_stress_principal_invariants_utility.h:285
static void CalculateTensorInvariantsSecondDerivatives(const Vector &rVector, Matrix &rD2I1, Matrix &rD2J2, Matrix &rD2J3)
Calculate second derivatives of invariants d2I1/d2tensor, d2J2/d2tensor, and d2J3/d2tensor.
Definition: mpm_stress_principal_invariants_utility.h:196
static constexpr double tolerance
Definition: mpm_stress_principal_invariants_utility.h:45
static void CalculateDerivativeVectors(const Vector rStress, Vector &rC1, Vector &rC2, Vector &rC3)
Calculate stress invariant derivatives dp/dsigma (volumetric), dq/dsigma (deviatoric),...
Definition: mpm_stress_principal_invariants_utility.h:332
static void CalculateThirdStressInvariant(const Vector &rStress, double &rLodeAngle)
Calculate the third stress invariants lode angle (we are using positive sine definition).
Definition: mpm_stress_principal_invariants_utility.h:260
static void CalculateStressInvariants(const Vector &rStress, double &rMeanStressP, double &rDeviatoricQ)
Calculate stress invariants p (volumetric equivalent) and q (deviatoric equivalent).
Definition: mpm_stress_principal_invariants_utility.h:243
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 TVector StressTensorToVector(const TMatrixType &rStressTensor, SizeType rSize=0)
Transforms a given symmetric Stress Tensor to Voigt Notation:
Definition: math_utils.h:1399
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
static MatrixType TensorProduct3(const Vector &a, const Vector &b)
Returns a matrix : A = a.tensorproduct.b.
Definition: math_utils.h:959
#define KRATOS_ERROR
Definition: exception.h:161
#define KRATOS_ERROR_IF(conditional)
Definition: exception.h:162
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
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
q
Definition: generate_convection_diffusion_explicit_element.py:109
int j
Definition: quadrature.py:648
p
Definition: sensitivityMatrix.py:52
integer i
Definition: TensorModule.f:17