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_law_utilities.h
Go to the documentation of this file.
1 // KRATOS ___| | | |
2 // \___ \ __| __| | | __| __| | | __| _` | |
3 // | | | | | ( | | | | ( | |
4 // _____/ \__|_| \__,_|\___|\__|\__,_|_| \__,_|_| MECHANICS
5 //
6 // License: BSD License
7 // license: StructuralMechanicsApplication/license.txt
8 //
9 // Main authors: Vicente Mataix Ferrandiz
10 // Alejandro Cornejo
11 //
12 
13 #pragma once
14 
15 // System includes
16 
17 // External includes
18 
19 // Project includes
20 
22 #include "includes/node.h"
23 #include "geometries/geometry.h"
25 
26 namespace Kratos
27 {
30 
34 
36  typedef std::size_t SizeType;
37 
41 
45 
49 
58 template <SizeType TVoigtSize = 6>
59 class KRATOS_API(STRUCTURAL_MECHANICS_APPLICATION) ConstitutiveLawUtilities
60 {
61  public:
64 
66  typedef std::size_t IndexType;
67 
69  static constexpr SizeType Dimension = TVoigtSize == 6 ? 3 : 2;
70 
72  static constexpr SizeType VoigtSize = TVoigtSize;
73 
75  typedef Matrix MatrixType;
76 
78  typedef Vector VectorType;
79 
82 
85 
88 
90  typedef Node NodeType;
91 
94 
96  static constexpr double tolerance = std::numeric_limits<double>::epsilon();
97 
101 
105 
109 
117  const MatrixType& rCauchyTensor,
118  VectorType& rStrainVector
119  );
120 
121 
129  static void PolarDecomposition(
130  const MatrixType& rFDeformationGradient,
131  MatrixType& rRMatrix,
132  MatrixType& rUMatrix
133  );
134 
145  const Vector& rStrainVector,
146  MatrixType& rProjectionOperator
147  );
148 
155  template<class TVector>
156  static void CalculateI1Invariant(
157  const TVector& rStressVector,
158  double& rI1
159  )
160  {
161  rI1 = rStressVector[0];
162  for (IndexType i = 1; i < Dimension; ++i)
163  rI1 += rStressVector[i];
164  }
165 
174  template<class TVector>
175  static void CalculateJ2Invariant(
176  const TVector& rStressVector,
177  const double I1,
178  BoundedVectorType& rDeviator,
179  double& rJ2
180  )
181  {
182  if constexpr (Dimension == 3) {
183  rDeviator = rStressVector;
184  const double p_mean = I1 / 3.0;
185  for (IndexType i = 0; i < Dimension; ++i)
186  rDeviator[i] -= p_mean;
187  rJ2 = 0.0;
188  for (IndexType i = 0; i < Dimension; ++i)
189  rJ2 += 0.5 * std::pow(rDeviator[i], 2);
190  for (IndexType i = Dimension; i < 6; ++i)
191  rJ2 += std::pow(rDeviator[i], 2);
192  } else {
193  rDeviator = rStressVector;
194  const double p_mean = I1 / 3.0;
195  for (IndexType i = 0; i < Dimension; ++i)
196  rDeviator[i] -= p_mean;
197  rJ2 = 0.5 * (std::pow(rDeviator[0], 2.0) + std::pow(rDeviator[1], 2.0) + std::pow(p_mean, 2.0)) + std::pow(rDeviator[2], 2.0);
198  }
199  }
200 
207  template<class TVector>
208  static double CalculateVonMisesEquivalentStress(const TVector& rStressVector)
209  {
210  double I1, J2;
211  array_1d<double, VoigtSize> deviator = ZeroVector(VoigtSize);
212 
215 
216  return std::sqrt(3.0 * J2);
217  }
218 
225  static void CalculateRotationOperatorVoigt(
226  const BoundedMatrixType &rOldOperator,
227  BoundedMatrixVoigtType &rNewOperator
228  );
229 
233  template <class TVector>
235  TVector& rVector
236  )
237  {
238  const double norm = MathUtils<double>::Norm3(rVector);
239  if (norm > std::numeric_limits<double>::epsilon()) {
240  rVector /= norm;
241  } else {
242  KRATOS_ERROR << "The norm of one LOCAL_AXIS is null" << std::endl;
243  }
244  }
245 
252  static void CalculateElasticMatrixPlaneStress(
253  MatrixType& rC,
254  const double E,
255  const double NU);
256 
263  static void CalculateElasticMatrixPlaneStrain(
264  MatrixType& rC,
265  const double E,
266  const double N);
267 
275  MatrixType& rC,
276  const double E,
277  const double N);
278 
284  static void CalculateCauchyGreenStrain(
286  ConstitutiveLaw::StrainVectorType &rStrainVector);
287 
295  static void CalculatePK2StressFromStrain(
296  ConstitutiveLaw::StressVectorType& rStressVector,
297  const ConstitutiveLaw::StrainVectorType& rStrainVector,
298  const double YoungModulus,
299  const double PoissonRatio);
300 
308  static void CalculatePK2StressFromStrainPlaneStress(
309  ConstitutiveLaw::StressVectorType& rStressVector,
310  const ConstitutiveLaw::StrainVectorType& rStrainVector,
311  const double YoungModulus,
312  const double PoissonRatio);
313 
321  static void CalculatePK2StressFromStrainPlaneStrain(
322  ConstitutiveLaw::StressVectorType& rStressVector,
323  const ConstitutiveLaw::StrainVectorType& rStrainVector,
324  const double YoungModulus,
325  const double PoissonRatio);
326 
327 }; // class ConstitutiveLawUtilities
328 } // namespace Kratos
static void CalculateI1Invariant(const TVector &rStressVector, double &rI1)
This method computes the first invariant from a given stress vector.
Definition: constitutive_law_utilities.h:156
Geometry< NodeType > GeometryType
Geometry definitions.
Definition: constitutive_law_utilities.h:93
BoundedMatrix< double, VoigtSize, VoigtSize > BoundedMatrixVoigtType
The definition of the bounded matrix type.
Definition: constitutive_law_utilities.h:87
Vector VectorType
the vector type definition
Definition: constitutive_law_utilities.h:78
static void CalculateGreenLagrangianStrain(const MatrixType &rCauchyTensor, VectorType &rStrainVector)
Calculation of the Green-Lagrange strain vector.
Matrix MatrixType
The matrix type definition.
Definition: constitutive_law_utilities.h:75
static void CalculateJ2Invariant(const BoundedVectorType &rStressVector, const double I1, BoundedVectorType &rDeviator, double &rJ2)
This method computes the second invariant of J.
std::size_t IndexType
The index type definition.
Definition: constitutive_law_utilities.h:66
static void CalculateProjectionOperator(const Vector &rStrainVector, MatrixType &rProjectionOperator)
This method calculates the projection operator and calculates the Projection Operator.
array_1d< double, VoigtSize > BoundedVectorType
The definition of the bounded vector type.
Definition: constitutive_law_utilities.h:81
Node NodeType
Node type definition.
Definition: constitutive_law_utilities.h:90
static void CheckAndNormalizeVector(TVector &rVector)
This checks if a vector has null norm.
Definition: constitutive_law_utilities.h:234
static void CalculateI1Invariant(const BoundedVectorType &rStressVector, double &rI1)
This method computes the first invariant from a given stress vector.
Definition: constitutive_law_utilities.cpp:148
BoundedMatrix< double, Dimension, Dimension > BoundedMatrixType
The definition of the bounded matrix type.
Definition: constitutive_law_utilities.h:84
static void CalculateJ2Invariant(const TVector &rStressVector, const double I1, BoundedVectorType &rDeviator, double &rJ2)
This method computes the second invariant of J.
Definition: constitutive_law_utilities.h:175
static double CalculateVonMisesEquivalentStress(const TVector &rStressVector)
This method the uniaxial equivalent stress for Von Mises.
Definition: constitutive_law_utilities.h:208
static void CalculateElasticMatrix(MatrixType &rC, const double E, const double N)
Geometry base class.
Definition: geometry.h:71
static double Norm3(const TVectorType &a)
Calculates the norm of vector "a" which is assumed to be of size 3.
Definition: math_utils.h:691
This class defines the node.
Definition: node.h:65
#define KRATOS_ERROR
Definition: exception.h:161
Matrix MatrixType
Definition: geometrical_transformation_utilities.h:55
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
KratosZeroVector< double > ZeroVector
Definition: amatrix_interface.h:561
std::size_t SizeType
The definition of the size type.
Definition: mortar_classes.h:43
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
N
Definition: sensitivityMatrix.py:29
integer i
Definition: TensorModule.f:17
Definition: constitutive_law.h:189