www.mooseframework.org
Public Types | Public Member Functions | Static Public Member Functions | Static Private Attributes | Friends | List of all members
RankTwoTensor Class Reference

RankTwoTensor is designed to handle the Stress or Strain Tensor for a fully anisotropic material. More...

#include <RankTwoTensor.h>

Inheritance diagram for RankTwoTensor:
[legend]

Public Types

enum  InitMethod { initNone, initIdentity }
 
enum  FillMethod {
  autodetect = 0, isotropic1 = 1, diagonal3 = 3, symmetric6 = 6,
  general = 9
}
 To fill up the 9 entries in the 2nd-order tensor, fillFromInputVector is called with one of the following fill_methods. More...
 

Public Member Functions

 RankTwoTensor ()
 Default constructor; fills to zero. More...
 
 RankTwoTensor (const InitMethod)
 Select specific initialization pattern. More...
 
 RankTwoTensor (const TypeVector< Real > &row1, const TypeVector< Real > &row2, const TypeVector< Real > &row3)
 Constructor that takes in 3 vectors and uses them to create rows _coords[0][i] = row1(i), _coords[1][i] = row2(i), _coords[2][i] = row3(i) More...
 
 RankTwoTensor (const std::vector< Real > &input)
 Constructor that proxies the fillFromInputVector method. More...
 
 RankTwoTensor (Real S11, Real S22, Real S33, Real S23, Real S13, Real S12)
 Initialization list replacement constructors, 6 arguments. More...
 
 RankTwoTensor (Real S11, Real S21, Real S31, Real S12, Real S22, Real S32, Real S13, Real S23, Real S33)
 Initialization list replacement constructors, 9 arguments. More...
 
 RankTwoTensor (const RealTensorValue &a)
 Copy constructor from RealTensorValue. More...
 
 RankTwoTensor (const TypeTensor< Real > &a)
 Copy constructor from TypeTensor<Real> More...
 
void fillFromInputVector (const std::vector< Real > &input, FillMethod fill_method=autodetect)
 fillFromInputVector takes 6 or 9 inputs to fill in the Rank-2 tensor. More...
 
void fillFromScalarVariable (const VariableValue &scalar_variable)
 fillFromScalarVariable takes FIRST/THIRD/SIXTH order scalar variable to fill in the Rank-2 tensor. More...
 
TypeVector< Real > column (const unsigned int c) const
 returns _coords[i][c], ie, column c, with c = 0, 1, 2 More...
 
RankTwoTensor rotated (const RankTwoTensor &R) const
 Returns a rotated version of the tensor data given a rank two tensor rotation tensor _coords[i][j] = R_ij * R_jl * _coords[k][l]. More...
 
void rotate (const RankTwoTensor &R)
 rotates the tensor data given a rank two tensor rotation tensor _coords[i][j] = R_ij * R_jl * _coords[k][l] More...
 
RankTwoTensor rotateXyPlane (Real a)
 rotates the tensor data anticlockwise around the z-axis More...
 
RankTwoTensor transpose () const
 Returns a matrix that is the transpose of the matrix this was called on. More...
 
RankTwoTensoroperator= (const RankTwoTensor &a)
 sets _coords to a, and returns _coords More...
 
RankTwoTensoroperator+= (const RankTwoTensor &a)
 adds a to _coords More...
 
RankTwoTensor operator+ (const RankTwoTensor &a) const
 returns _coords + a More...
 
RankTwoTensoroperator-= (const RankTwoTensor &a)
 sets _coords -= a and returns vals More...
 
RankTwoTensor operator- (const RankTwoTensor &a) const
 returns _coords - a More...
 
RankTwoTensor operator- () const
 returns -_coords More...
 
RankTwoTensoroperator*= (const Real a)
 performs _coords *= a More...
 
RankTwoTensor operator* (const Real a) const
 returns _coords*a More...
 
RankTwoTensoroperator/= (const Real a)
 performs _coords /= a More...
 
RankTwoTensor operator/ (const Real a) const
 returns _coords/a More...
 
TypeVector< Real > operator* (const TypeVector< Real > &a) const
 Defines multiplication with a vector to get a vector. More...
 
RankTwoTensor operator* (const TypeTensor< Real > &a) const
 Defines multiplication with a TypeTensor<Real> More...
 
RankTwoTensoroperator*= (const TypeTensor< Real > &a)
 Defines multiplication with a TypeTensor<Real> More...
 
bool operator== (const RankTwoTensor &a) const
 Defines logical equality with another RankTwoTensor. More...
 
RankTwoTensoroperator= (const ColumnMajorMatrix &a)
 Sets _coords to the values in a ColumnMajorMatrix (must be 3x3) More...
 
Real doubleContraction (const RankTwoTensor &a) const
 returns _coords_ij * a_ij (sum on i, j) More...
 
RankFourTensor outerProduct (const RankTwoTensor &a) const
 returns C_ijkl = a_ij * b_kl More...
 
RankFourTensor mixedProductIkJl (const RankTwoTensor &a) const
 returns C_ijkl = a_ik * b_jl More...
 
RankFourTensor mixedProductJkIl (const RankTwoTensor &a) const
 returns C_ijkl = a_jk * b_il More...
 
RankFourTensor mixedProductIlJk (const RankTwoTensor &a) const
 returns C_ijkl = a_il * b_jk More...
 
RankFourTensor positiveProjectionEigenDecomposition (std::vector< Real > &eigval, RankTwoTensor &eigvec) const
 return positive projection tensor of eigen-decomposition More...
 
RankTwoTensor deviatoric () const
 returns A_ij - de_ij*tr(A)/3, where A are the _coords More...
 
Real trace () const
 returns the trace of the tensor, ie _coords[i][i] (sum i = 0, 1, 2) More...
 
RankTwoTensor inverse () const
 retuns the inverse of the tensor More...
 
RankTwoTensor dtrace () const
 Denote the _coords[i][j] by A_ij, then this returns d(trace)/dA_ij. More...
 
Real generalSecondInvariant () const
 Denote the _coords[i][j] by A_ij, then S_ij = A_ij - de_ij*tr(A)/3 Then this returns (S_ij + S_ji)*(S_ij + S_ji)/8 Note the explicit symmeterisation. More...
 
Real secondInvariant () const
 Calculates the second invariant (I2) of a tensor. More...
 
RankTwoTensor dsecondInvariant () const
 Denote the _coords[i][j] by A_ij, then this returns d(secondInvariant)/dA_ij. More...
 
RankFourTensor d2secondInvariant () const
 Denote the _coords[i][j] by A_ij, then this returns d^2(secondInvariant)/dA_ij/dA_kl. More...
 
Real sin3Lode (const Real r0, const Real r0_value) const
 Sin(3*Lode_angle) If secondInvariant() <= r0 then return r0_value This is to gaurd against precision-loss errors. More...
 
RankTwoTensor dsin3Lode (const Real r0) const
 d(sin3Lode)/dA_ij If secondInvariant() <= r0 then return zero This is to gaurd against precision-loss errors. More...
 
RankFourTensor d2sin3Lode (const Real r0) const
 d^2(sin3Lode)/dA_ij/dA_kl If secondInvariant() <= r0 then return zero This is to gaurd against precision-loss errors. More...
 
Real thirdInvariant () const
 Denote the _coords[i][j] by A_ij, then S_ij = A_ij - de_ij*tr(A)/3 Then this returns det(S + S.transpose())/2 Note the explicit symmeterisation. More...
 
RankTwoTensor dthirdInvariant () const
 Denote the _coords[i][j] by A_ij, then this returns d(thirdInvariant()/dA_ij. More...
 
RankFourTensor d2thirdInvariant () const
 Denote the _coords[i][j] by A_ij, then this returns d^2(thirdInvariant)/dA_ij/dA_kl. More...
 
RankTwoTensor ddet () const
 Denote the _coords[i][j] by A_ij, then this returns d(det)/dA_ij. More...
 
void print (std::ostream &stm=Moose::out) const
 Print the rank two tensor. More...
 
void addIa (const Real a)
 Add identity times a to _coords. More...
 
Real L2norm () const
 Sqrt(_coords[i][j]*_coords[i][j]) More...
 
void surfaceFillFromInputVector (const std::vector< Real > &input)
 sets _coords[0][0], _coords[0][1], _coords[1][0], _coords[1][1] to input, and the remainder to zero More...
 
void symmetricEigenvalues (std::vector< Real > &eigvals) const
 computes eigenvalues, assuming tens is symmetric, and places them in ascending order in eigvals More...
 
void symmetricEigenvaluesEigenvectors (std::vector< Real > &eigvals, RankTwoTensor &eigvecs) const
 computes eigenvalues and eigenvectors, assuming tens is symmetric, and places them in ascending order in eigvals. More...
 
void dsymmetricEigenvalues (std::vector< Real > &eigvals, std::vector< RankTwoTensor > &deigvals) const
 computes eigenvalues, and their symmetric derivatives wrt vals, assuming tens is symmetric More...
 
void d2symmetricEigenvalues (std::vector< RankFourTensor > &deriv) const
 Computes second derivatives of Eigenvalues of a rank two tensor. More...
 
void syev (const char *calculation_type, std::vector< PetscScalar > &eigvals, std::vector< PetscScalar > &a) const
 Uses the petscblaslapack.h LAPACKsyev_ routine to find, for symmetric _coords: (1) the eigenvalues (if calculation_type == "N") (2) the eigenvalues and eigenvectors (if calculation_type == "V") More...
 
void getRUDecompositionRotation (RankTwoTensor &rot) const
 Uses the petscblaslapack.h LAPACKsyev_ routine to perform RU decomposition and obtain the rotation tensor. More...
 
void vectorOuterProduct (const TypeVector< Real > &, const TypeVector< Real > &)
 RankTwoTensor from outer product of vectors. More...
 
void fillRealTensor (RealTensorValue &)
 Return real tensor of a rank two tensor. More...
 
void fillRow (unsigned int, const TypeVector< Real > &)
 Assigns value to the columns of a specified row. More...
 
void fillColumn (unsigned int, const TypeVector< Real > &)
 Assigns value to the rows of a specified column. More...
 
RankTwoTensor initialContraction (const RankFourTensor &b) const
 returns this_ij * b_ijkl More...
 

Static Public Member Functions

static RankTwoTensor initializeFromRows (const TypeVector< Real > &row0, const TypeVector< Real > &row1, const TypeVector< Real > &row2)
 named constructor for initializing from row vectors More...
 
static RankTwoTensor initializeFromColumns (const TypeVector< Real > &col0, const TypeVector< Real > &col1, const TypeVector< Real > &col2)
 named constructor for initializing from column vectors More...
 
static RankTwoTensor Identity ()
 
static MooseEnum fillMethodEnum ()
 Static method for use in validParams for getting the "fill_method". More...
 
static void initRandom (unsigned int)
 This function initializes random seed based on a user-defined number. More...
 
static RankTwoTensor genRandomTensor (Real, Real)
 This function generates a random unsymmetric rank two tensor. More...
 
static RankTwoTensor genRandomSymmTensor (Real, Real)
 This function generates a random symmetric rank two tensor. More...
 

Static Private Attributes

static constexpr unsigned int N = LIBMESH_DIM
 
static constexpr unsigned int N2 = N * N
 

Friends

class RankFourTensor
 
class RankThreeTensor
 
template<class T >
void dataStore (std::ostream &, T &, void *)
 
template<class T >
void dataLoad (std::istream &, T &, void *)
 

Detailed Description

RankTwoTensor is designed to handle the Stress or Strain Tensor for a fully anisotropic material.

It is designed to allow for maximum clarity of the mathematics and ease of use. Original class authors: A. M. Jokisaari, O. Heinonen, M. R. Tonks

RankTwoTensor holds the 9 separate Sigma_ij or Epsilon_ij entries. The entries are accessed by index, with i, j equal to 1, 2, or 3, or internally i, j = 0, 1, 2.

Definition at line 51 of file RankTwoTensor.h.

Member Enumeration Documentation

◆ FillMethod

To fill up the 9 entries in the 2nd-order tensor, fillFromInputVector is called with one of the following fill_methods.

See the fill*FromInputVector functions for more details

Enumerator
autodetect 
isotropic1 
diagonal3 
symmetric6 
general 

Definition at line 72 of file RankTwoTensor.h.

◆ InitMethod

Enumerator
initNone 
initIdentity 

Definition at line 55 of file RankTwoTensor.h.

Constructor & Destructor Documentation

◆ RankTwoTensor() [1/8]

RankTwoTensor::RankTwoTensor ( )

Default constructor; fills to zero.

Definition at line 48 of file RankTwoTensor.C.

Referenced by dsin3Lode(), dtrace(), Identity(), initializeFromColumns(), and initializeFromRows().

49 {
50  mooseAssert(N == 3, "RankTwoTensor is currently only tested for 3 dimensions.");
51 
52  for (unsigned int i = 0; i < N2; i++)
53  _coords[i] = 0.0;
54 }
static constexpr unsigned int N
static constexpr unsigned int N2

◆ RankTwoTensor() [2/8]

RankTwoTensor::RankTwoTensor ( const InitMethod  init)

Select specific initialization pattern.

Definition at line 56 of file RankTwoTensor.C.

57 {
58  switch (init)
59  {
60  case initNone:
61  break;
62 
63  case initIdentity:
64  zero();
65  for (unsigned int i = 0; i < N; ++i)
66  (*this)(i, i) = 1.0;
67  break;
68 
69  default:
70  mooseError("Unknown RankTwoTensor initialization pattern.");
71  }
72 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
static constexpr unsigned int N

◆ RankTwoTensor() [3/8]

RankTwoTensor::RankTwoTensor ( const TypeVector< Real > &  row1,
const TypeVector< Real > &  row2,
const TypeVector< Real > &  row3 
)

Constructor that takes in 3 vectors and uses them to create rows _coords[0][i] = row1(i), _coords[1][i] = row2(i), _coords[2][i] = row3(i)

TODO: deprecate this method in favor of initializeFromRows.

Definition at line 75 of file RankTwoTensor.C.

78 {
79  // Initialize the Tensor matrix from the passed in vectors
80  for (unsigned int i = 0; i < N; i++)
81  _coords[i] = row1(i);
82 
83  for (unsigned int i = 0; i < N; i++)
84  _coords[N + i] = row2(i);
85 
86  const unsigned int two_n = N * 2;
87  for (unsigned int i = 0; i < N; i++)
88  _coords[two_n + i] = row3(i);
89 }
static constexpr unsigned int N

◆ RankTwoTensor() [4/8]

RankTwoTensor::RankTwoTensor ( const std::vector< Real > &  input)
inline

Constructor that proxies the fillFromInputVector method.

Definition at line 100 of file RankTwoTensor.h.

100 { this->fillFromInputVector(input); };
void fillFromInputVector(const std::vector< Real > &input, FillMethod fill_method=autodetect)
fillFromInputVector takes 6 or 9 inputs to fill in the Rank-2 tensor.

◆ RankTwoTensor() [5/8]

RankTwoTensor::RankTwoTensor ( Real  S11,
Real  S22,
Real  S33,
Real  S23,
Real  S13,
Real  S12 
)

Initialization list replacement constructors, 6 arguments.

Definition at line 109 of file RankTwoTensor.C.

110 {
111  (*this)(0, 0) = S11;
112  (*this)(1, 1) = S22;
113  (*this)(2, 2) = S33;
114  (*this)(1, 2) = (*this)(2, 1) = S23;
115  (*this)(0, 2) = (*this)(2, 0) = S13;
116  (*this)(0, 1) = (*this)(1, 0) = S12;
117 }

◆ RankTwoTensor() [6/8]

RankTwoTensor::RankTwoTensor ( Real  S11,
Real  S21,
Real  S31,
Real  S12,
Real  S22,
Real  S32,
Real  S13,
Real  S23,
Real  S33 
)

Initialization list replacement constructors, 9 arguments.

Definition at line 119 of file RankTwoTensor.C.

121 {
122  (*this)(0, 0) = S11;
123  (*this)(1, 0) = S21;
124  (*this)(2, 0) = S31;
125  (*this)(0, 1) = S12;
126  (*this)(1, 1) = S22;
127  (*this)(2, 1) = S32;
128  (*this)(0, 2) = S13;
129  (*this)(1, 2) = S23;
130  (*this)(2, 2) = S33;
131 }

◆ RankTwoTensor() [7/8]

RankTwoTensor::RankTwoTensor ( const RealTensorValue &  a)
inline

Copy constructor from RealTensorValue.

Definition at line 110 of file RankTwoTensor.h.

110 : RealTensorValue(a) {}

◆ RankTwoTensor() [8/8]

RankTwoTensor::RankTwoTensor ( const TypeTensor< Real > &  a)
inline

Copy constructor from TypeTensor<Real>

Definition at line 113 of file RankTwoTensor.h.

113 : RealTensorValue(a) {}

Member Function Documentation

◆ addIa()

void RankTwoTensor::addIa ( const Real  a)

Add identity times a to _coords.

Definition at line 804 of file RankTwoTensor.C.

Referenced by deviatoric().

805 {
806  for (unsigned int i = 0; i < N; ++i)
807  (*this)(i, i) += a;
808 }
static constexpr unsigned int N

◆ column()

TypeVector< Real > RankTwoTensor::column ( const unsigned int  c) const

returns _coords[i][c], ie, column c, with c = 0, 1, 2

Definition at line 215 of file RankTwoTensor.C.

Referenced by positiveProjectionEigenDecomposition().

216 {
217  RealVectorValue result;
218 
219  for (unsigned int i = 0; i < N; ++i)
220  result(i) = (*this)(i, c);
221 
222  return result;
223 }
static constexpr unsigned int N

◆ d2secondInvariant()

RankFourTensor RankTwoTensor::d2secondInvariant ( ) const

Denote the _coords[i][j] by A_ij, then this returns d^2(secondInvariant)/dA_ij/dA_kl.

Definition at line 561 of file RankTwoTensor.C.

Referenced by d2sin3Lode().

562 {
563  RankFourTensor result;
564 
565  unsigned int index = 0;
566  for (unsigned int i = 0; i < N; ++i)
567  for (unsigned int j = 0; j < N; ++j)
568  for (unsigned int k = 0; k < N; ++k)
569  for (unsigned int l = 0; l < N; ++l)
570  result._vals[index++] = 0.5 * (i == k) * (j == l) + 0.5 * (i == l) * (j == k) -
571  (1.0 / 3.0) * (i == j) * (k == l);
572 
573  return result;
574 }
Real _vals[N4]
The values of the rank-four tensor stored by index=(((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) * LIBME...
static constexpr unsigned int N
RankFourTensor is designed to handle any N-dimensional fourth order tensor, C.

◆ d2sin3Lode()

RankFourTensor RankTwoTensor::d2sin3Lode ( const Real  r0) const

d^2(sin3Lode)/dA_ij/dA_kl If secondInvariant() <= r0 then return zero This is to gaurd against precision-loss errors.

Note that sin(3*Lode_angle) is not defined for secondInvariant() = 0

Definition at line 749 of file RankTwoTensor.C.

750 {
751  Real bar = secondInvariant();
752  if (bar <= r0)
753  return RankFourTensor();
754 
755  Real J3 = thirdInvariant();
758  RankFourTensor deriv =
759  d2thirdInvariant() / std::pow(bar, 1.5) - 1.5 * d2secondInvariant() * J3 / std::pow(bar, 2.5);
760 
761  for (unsigned i = 0; i < N; ++i)
762  for (unsigned j = 0; j < N; ++j)
763  for (unsigned k = 0; k < N; ++k)
764  for (unsigned l = 0; l < N; ++l)
765  deriv(i, j, k, l) +=
766  (-1.5 * dII(i, j) * dIII(k, l) - 1.5 * dIII(i, j) * dII(k, l)) / std::pow(bar, 2.5) +
767  1.5 * 2.5 * dII(i, j) * dII(k, l) * J3 / std::pow(bar, 3.5);
768 
769  deriv *= -1.5 * std::sqrt(3.0);
770  return deriv;
771 }
RankTwoTensor dthirdInvariant() const
Denote the _coords[i][j] by A_ij, then this returns d(thirdInvariant()/dA_ij.
friend class RankFourTensor
Real thirdInvariant() const
Denote the _coords[i][j] by A_ij, then S_ij = A_ij - de_ij*tr(A)/3 Then this returns det(S + S...
RankFourTensor d2secondInvariant() const
Denote the _coords[i][j] by A_ij, then this returns d^2(secondInvariant)/dA_ij/dA_kl.
Real pow(Real x, int e)
Definition: MathUtils.C:211
RankTwoTensor is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: RankTwoTensor.h:51
RankTwoTensor dsecondInvariant() const
Denote the _coords[i][j] by A_ij, then this returns d(secondInvariant)/dA_ij.
static constexpr unsigned int N
Real secondInvariant() const
Calculates the second invariant (I2) of a tensor.
RankFourTensor d2thirdInvariant() const
Denote the _coords[i][j] by A_ij, then this returns d^2(thirdInvariant)/dA_ij/dA_kl.
RankFourTensor is designed to handle any N-dimensional fourth order tensor, C.

◆ d2symmetricEigenvalues()

void RankTwoTensor::d2symmetricEigenvalues ( std::vector< RankFourTensor > &  deriv) const

Computes second derivatives of Eigenvalues of a rank two tensor.

Parameters
derivstore second derivative of the current tensor in here

Definition at line 896 of file RankTwoTensor.C.

897 {
898  std::vector<PetscScalar> eigvec;
899  std::vector<PetscScalar> eigvals;
900  Real ev[N][N];
901 
902  // reset rank four tensor
903  deriv.assign(N, RankFourTensor());
904 
905  // get eigen values and eigen vectors
906  syev("V", eigvals, eigvec);
907 
908  for (unsigned int i = 0; i < N; ++i)
909  for (unsigned int j = 0; j < N; ++j)
910  ev[i][j] = eigvec[i * N + j];
911 
912  for (unsigned int alpha = 0; alpha < N; ++alpha)
913  for (unsigned int beta = 0; beta < N; ++beta)
914  {
915  if (eigvals[alpha] == eigvals[beta])
916  continue;
917 
918  for (unsigned int i = 0; i < N; ++i)
919  for (unsigned int j = 0; j < N; ++j)
920  for (unsigned int k = 0; k < N; ++k)
921  for (unsigned int l = 0; l < N; ++l)
922  {
923  deriv[alpha](i, j, k, l) +=
924  0.5 * (ev[beta][i] * ev[alpha][j] + ev[alpha][i] * ev[beta][j]) *
925  (ev[beta][k] * ev[alpha][l] + ev[beta][l] * ev[alpha][k]) /
926  (eigvals[alpha] - eigvals[beta]);
927  }
928  }
929 }
friend class RankFourTensor
void syev(const char *calculation_type, std::vector< PetscScalar > &eigvals, std::vector< PetscScalar > &a) const
Uses the petscblaslapack.h LAPACKsyev_ routine to find, for symmetric _coords: (1) the eigenvalues (i...
static constexpr unsigned int N

◆ d2thirdInvariant()

RankFourTensor RankTwoTensor::d2thirdInvariant ( ) const

Denote the _coords[i][j] by A_ij, then this returns d^2(thirdInvariant)/dA_ij/dA_kl.

Definition at line 633 of file RankTwoTensor.C.

Referenced by d2sin3Lode().

634 {
635  RankTwoTensor s = 0.5 * deviatoric();
636  s += s.transpose();
637 
638  RankFourTensor d2;
639  unsigned int index = 0;
640  for (unsigned int i = 0; i < N; ++i)
641  for (unsigned int j = 0; j < N; ++j)
642  for (unsigned int k = 0; k < N; ++k)
643  for (unsigned int l = 0; l < N; ++l)
644  {
645  d2._vals[index++] = (i == j) * s(k, l) / 3.0 + (k == l) * s(i, j) / 3.0;
646  // for (unsigned int a = 0; a < N; ++a)
647  // for (unsigned int b = 0; b < N; ++b)
648  // d2(i, j, k, l) += 0.5*(PermutationTensor::eps(i, k, a)*PermutationTensor::eps(j, l,
649  // b) + PermutationTensor::eps(i, l, a)*PermutationTensor::eps(j, k, b))*s(a, b);
650  }
651 
652  // I'm not sure which is more readable: the above
653  // PermutationTensor stuff, or the stuff below.
654  // Anyway, they yield the same result, and so i leave
655  // both of them here to enlighten you!
656 
657  d2(0, 0, 1, 1) += s(2, 2);
658  d2(0, 0, 1, 2) -= s(2, 1);
659  d2(0, 0, 2, 1) -= s(1, 2);
660  d2(0, 0, 2, 2) += s(1, 1);
661 
662  d2(0, 1, 0, 1) -= s(2, 2) / 2.0;
663  d2(0, 1, 1, 0) -= s(2, 2) / 2.0;
664  d2(0, 1, 0, 2) += s(1, 2) / 2.0;
665  d2(0, 1, 2, 0) += s(1, 2) / 2.0;
666  d2(0, 1, 1, 2) += s(2, 0) / 2.0;
667  d2(0, 1, 2, 1) += s(2, 0) / 2.0;
668  d2(0, 1, 2, 2) -= s(1, 0);
669 
670  d2(0, 2, 0, 1) += s(2, 1) / 2.0;
671  d2(0, 2, 1, 0) += s(2, 1) / 2.0;
672  d2(0, 2, 0, 2) -= s(1, 1) / 2.0;
673  d2(0, 2, 2, 0) -= s(1, 1) / 2.0;
674  d2(0, 2, 1, 1) -= s(2, 0);
675  d2(0, 2, 1, 2) += s(1, 0) / 2.0;
676  d2(0, 2, 2, 1) += s(1, 0) / 2.0;
677 
678  d2(1, 0, 0, 1) -= s(2, 2) / 2.0;
679  d2(1, 0, 1, 0) -= s(2, 2) / 2.0;
680  d2(1, 0, 0, 2) += s(1, 2) / 2.0;
681  d2(1, 0, 2, 0) += s(1, 2) / 2.0;
682  d2(1, 0, 1, 2) += s(2, 0) / 2.0;
683  d2(1, 0, 2, 1) += s(2, 0) / 2.0;
684  d2(1, 0, 2, 2) -= s(1, 0);
685 
686  d2(1, 1, 0, 0) += s(2, 2);
687  d2(1, 1, 0, 2) -= s(2, 0);
688  d2(1, 1, 2, 0) -= s(2, 0);
689  d2(1, 1, 2, 2) += s(0, 0);
690 
691  d2(1, 2, 0, 0) -= s(2, 1);
692  d2(1, 2, 0, 1) += s(2, 0) / 2.0;
693  d2(1, 2, 1, 0) += s(2, 0) / 2.0;
694  d2(1, 2, 0, 2) += s(0, 1) / 2.0;
695  d2(1, 2, 2, 0) += s(0, 1) / 2.0;
696  d2(1, 2, 1, 2) -= s(0, 0) / 2.0;
697  d2(1, 2, 2, 1) -= s(0, 0) / 2.0;
698 
699  d2(2, 0, 0, 1) += s(2, 1) / 2.0;
700  d2(2, 0, 1, 0) += s(2, 1) / 2.0;
701  d2(2, 0, 0, 2) -= s(1, 1) / 2.0;
702  d2(2, 0, 2, 0) -= s(1, 1) / 2.0;
703  d2(2, 0, 1, 1) -= s(2, 0);
704  d2(2, 0, 1, 2) += s(1, 0) / 2.0;
705  d2(2, 0, 2, 1) += s(1, 0) / 2.0;
706 
707  d2(2, 1, 0, 0) -= s(2, 1);
708  d2(2, 1, 0, 1) += s(2, 0) / 2.0;
709  d2(2, 1, 1, 0) += s(2, 0) / 2.0;
710  d2(2, 1, 0, 2) += s(0, 1) / 2.0;
711  d2(2, 1, 2, 0) += s(0, 1) / 2.0;
712  d2(2, 1, 1, 2) -= s(0, 0) / 2.0;
713  d2(2, 1, 2, 1) -= s(0, 0) / 2.0;
714 
715  d2(2, 2, 0, 0) += s(1, 1);
716  d2(2, 2, 0, 1) -= s(1, 0);
717  d2(2, 2, 1, 0) -= s(1, 0);
718  d2(2, 2, 1, 1) += s(0, 0);
719 
720  return d2;
721 }
RankTwoTensor transpose() const
Returns a matrix that is the transpose of the matrix this was called on.
RankTwoTensor is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: RankTwoTensor.h:51
Real _vals[N4]
The values of the rank-four tensor stored by index=(((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) * LIBME...
RankTwoTensor deviatoric() const
returns A_ij - de_ij*tr(A)/3, where A are the _coords
static constexpr unsigned int N
RankFourTensor is designed to handle any N-dimensional fourth order tensor, C.

◆ ddet()

RankTwoTensor RankTwoTensor::ddet ( ) const

Denote the _coords[i][j] by A_ij, then this returns d(det)/dA_ij.

Definition at line 774 of file RankTwoTensor.C.

775 {
776  RankTwoTensor d;
777 
778  d(0, 0) = (*this)(1, 1) * (*this)(2, 2) - (*this)(2, 1) * (*this)(1, 2);
779  d(0, 1) = (*this)(2, 0) * (*this)(1, 2) - (*this)(1, 0) * (*this)(2, 2);
780  d(0, 2) = (*this)(1, 0) * (*this)(2, 1) - (*this)(2, 0) * (*this)(1, 1);
781  d(1, 0) = (*this)(2, 1) * (*this)(0, 2) - (*this)(0, 1) * (*this)(2, 2);
782  d(1, 1) = (*this)(0, 0) * (*this)(2, 2) - (*this)(2, 0) * (*this)(0, 2);
783  d(1, 2) = (*this)(2, 0) * (*this)(0, 1) - (*this)(0, 0) * (*this)(2, 1);
784  d(2, 0) = (*this)(0, 1) * (*this)(1, 2) - (*this)(1, 1) * (*this)(0, 2);
785  d(2, 1) = (*this)(1, 0) * (*this)(0, 2) - (*this)(0, 0) * (*this)(1, 2);
786  d(2, 2) = (*this)(0, 0) * (*this)(1, 1) - (*this)(1, 0) * (*this)(0, 1);
787 
788  return d;
789 }
RankTwoTensor is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: RankTwoTensor.h:51

◆ deviatoric()

RankTwoTensor RankTwoTensor::deviatoric ( ) const

returns A_ij - de_ij*tr(A)/3, where A are the _coords

Definition at line 515 of file RankTwoTensor.C.

Referenced by d2thirdInvariant(), dsecondInvariant(), dthirdInvariant(), and thirdInvariant().

516 {
517  RankTwoTensor deviatoric(*this);
518  deviatoric.addIa(-1.0 / 3.0 * tr()); // actually construct deviatoric part
519  return deviatoric;
520 }
void addIa(const Real a)
Add identity times a to _coords.
RankTwoTensor is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: RankTwoTensor.h:51
RankTwoTensor deviatoric() const
returns A_ij - de_ij*tr(A)/3, where A are the _coords

◆ doubleContraction()

Real RankTwoTensor::doubleContraction ( const RankTwoTensor a) const

returns _coords_ij * a_ij (sum on i, j)

Definition at line 392 of file RankTwoTensor.C.

393 {
394  // deprecate this!
395  return RealTensorValue::contract(b);
396 }

◆ dsecondInvariant()

RankTwoTensor RankTwoTensor::dsecondInvariant ( ) const

Denote the _coords[i][j] by A_ij, then this returns d(secondInvariant)/dA_ij.

Definition at line 555 of file RankTwoTensor.C.

Referenced by d2sin3Lode(), and dsin3Lode().

556 {
557  return 0.5 * (deviatoric() + deviatoric().transpose());
558 }
RankTwoTensor transpose() const
Returns a matrix that is the transpose of the matrix this was called on.
RankTwoTensor deviatoric() const
returns A_ij - de_ij*tr(A)/3, where A are the _coords

◆ dsin3Lode()

RankTwoTensor RankTwoTensor::dsin3Lode ( const Real  r0) const

d(sin3Lode)/dA_ij If secondInvariant() <= r0 then return zero This is to gaurd against precision-loss errors.

Note that sin(3*Lode_angle) is not defined for secondInvariant() = 0

Definition at line 737 of file RankTwoTensor.C.

738 {
739  Real bar = secondInvariant();
740  if (bar <= r0)
741  return RankTwoTensor();
742  else
743  return -1.5 * std::sqrt(3.0) *
744  (dthirdInvariant() / std::pow(bar, 1.5) -
745  1.5 * dsecondInvariant() * thirdInvariant() / std::pow(bar, 2.5));
746 }
RankTwoTensor dthirdInvariant() const
Denote the _coords[i][j] by A_ij, then this returns d(thirdInvariant()/dA_ij.
Real thirdInvariant() const
Denote the _coords[i][j] by A_ij, then S_ij = A_ij - de_ij*tr(A)/3 Then this returns det(S + S...
RankTwoTensor()
Default constructor; fills to zero.
Definition: RankTwoTensor.C:48
Real pow(Real x, int e)
Definition: MathUtils.C:211
RankTwoTensor dsecondInvariant() const
Denote the _coords[i][j] by A_ij, then this returns d(secondInvariant)/dA_ij.
Real secondInvariant() const
Calculates the second invariant (I2) of a tensor.

◆ dsymmetricEigenvalues()

void RankTwoTensor::dsymmetricEigenvalues ( std::vector< Real > &  eigvals,
std::vector< RankTwoTensor > &  deigvals 
) const

computes eigenvalues, and their symmetric derivatives wrt vals, assuming tens is symmetric

Parameters
eigvalsare the eigenvalues of the matrix, in ascending order
deigvalsHere digvals[i](j,k) = (1/2)*(d(eigvals[i])/dA_jk + d(eigvals[i]/dA_kj)) Note the explicit symmeterisation here. For equal eigenvalues, these derivatives are not gauranteed to be the ones you expect, since the derivatives in this case are often defined by continuation from the un-equal case, and that is too sophisticated for this routine.

Definition at line 858 of file RankTwoTensor.C.

860 {
861  deigvals.resize(N);
862 
863  std::vector<PetscScalar> a;
864  syev("V", eigvals, a);
865 
866  // now a contains the eigenvetors
867  // extract these and place appropriately in deigvals
868  std::vector<Real> eig_vec;
869  eig_vec.resize(N);
870 
871  for (unsigned int i = 0; i < N; ++i)
872  {
873  for (unsigned int j = 0; j < N; ++j)
874  eig_vec[j] = a[i * N + j];
875  for (unsigned int j = 0; j < N; ++j)
876  for (unsigned int k = 0; k < N; ++k)
877  deigvals[i](j, k) = eig_vec[j] * eig_vec[k];
878  }
879 
880  // There are discontinuities in the derivative
881  // for equal eigenvalues. The following is
882  // an attempt to make a sensible choice for
883  // the derivative. This agrees with a central-difference
884  // approximation to the derivative.
885  if (eigvals[0] == eigvals[1] && eigvals[0] == eigvals[2])
886  deigvals[0] = deigvals[1] = deigvals[2] = (deigvals[0] + deigvals[1] + deigvals[2]) / 3.0;
887  else if (eigvals[0] == eigvals[1])
888  deigvals[0] = deigvals[1] = (deigvals[0] + deigvals[1]) / 2.0;
889  else if (eigvals[0] == eigvals[2])
890  deigvals[0] = deigvals[2] = (deigvals[0] + deigvals[2]) / 2.0;
891  else if (eigvals[1] == eigvals[2])
892  deigvals[1] = deigvals[2] = (deigvals[1] + deigvals[2]) / 2.0;
893 }
void syev(const char *calculation_type, std::vector< PetscScalar > &eigvals, std::vector< PetscScalar > &a) const
Uses the petscblaslapack.h LAPACKsyev_ routine to find, for symmetric _coords: (1) the eigenvalues (i...
static constexpr unsigned int N

◆ dthirdInvariant()

RankTwoTensor RankTwoTensor::dthirdInvariant ( ) const

Denote the _coords[i][j] by A_ij, then this returns d(thirdInvariant()/dA_ij.

Definition at line 611 of file RankTwoTensor.C.

Referenced by d2sin3Lode(), and dsin3Lode().

612 {
613  RankTwoTensor s = 0.5 * deviatoric();
614  s += s.transpose();
615 
616  RankTwoTensor d;
617  Real sec_over_three = secondInvariant() / 3.0;
618 
619  d(0, 0) = s(1, 1) * s(2, 2) - s(2, 1) * s(1, 2) + sec_over_three;
620  d(0, 1) = s(2, 0) * s(1, 2) - s(1, 0) * s(2, 2);
621  d(0, 2) = s(1, 0) * s(2, 1) - s(2, 0) * s(1, 1);
622  d(1, 0) = s(2, 1) * s(0, 2) - s(0, 1) * s(2, 2);
623  d(1, 1) = s(0, 0) * s(2, 2) - s(2, 0) * s(0, 2) + sec_over_three;
624  d(1, 2) = s(2, 0) * s(0, 1) - s(0, 0) * s(2, 1);
625  d(2, 0) = s(0, 1) * s(1, 2) - s(1, 1) * s(0, 2);
626  d(2, 1) = s(1, 0) * s(0, 2) - s(0, 0) * s(1, 2);
627  d(2, 2) = s(0, 0) * s(1, 1) - s(1, 0) * s(0, 1) + sec_over_three;
628 
629  return d;
630 }
RankTwoTensor transpose() const
Returns a matrix that is the transpose of the matrix this was called on.
RankTwoTensor is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: RankTwoTensor.h:51
RankTwoTensor deviatoric() const
returns A_ij - de_ij*tr(A)/3, where A are the _coords
Real secondInvariant() const
Calculates the second invariant (I2) of a tensor.

◆ dtrace()

RankTwoTensor RankTwoTensor::dtrace ( ) const

Denote the _coords[i][j] by A_ij, then this returns d(trace)/dA_ij.

Definition at line 590 of file RankTwoTensor.C.

591 {
592  return RankTwoTensor(1, 0, 0, 0, 1, 0, 0, 0, 1);
593 }
RankTwoTensor()
Default constructor; fills to zero.
Definition: RankTwoTensor.C:48

◆ fillColumn()

void RankTwoTensor::fillColumn ( unsigned int  c,
const TypeVector< Real > &  v 
)

Assigns value to the rows of a specified column.

Definition at line 1053 of file RankTwoTensor.C.

1054 {
1055  for (unsigned int i = 0; i < N; ++i)
1056  (*this)(i, c) = v(i);
1057 }
static constexpr unsigned int N

◆ fillFromInputVector()

void RankTwoTensor::fillFromInputVector ( const std::vector< Real > &  input,
FillMethod  fill_method = autodetect 
)

fillFromInputVector takes 6 or 9 inputs to fill in the Rank-2 tensor.

If 6 inputs, then symmetry is assumed S_ij = S_ji, and _coords[0][0] = input[0] _coords[1][1] = input[1] _coords[2][2] = input[2] _coords[1][2] = input[3] _coords[0][2] = input[4] _coords[0][1] = input[5] If 9 inputs then input order is [0][0], [1][0], [2][0], [0][1], [1][1], ..., [2][2]

Definition at line 134 of file RankTwoTensor.C.

Referenced by GenericConstantRankTwoTensor::GenericConstantRankTwoTensor(), and RankTwoTensor().

135 {
136  if (fill_method != autodetect && fill_method != input.size())
137  mooseError("Expected an input vector size of ", fill_method, " to fill the RankTwoTensor");
138 
139  switch (input.size())
140  {
141  case 1:
142  zero();
143  (*this)(0, 0) = input[0]; // S11
144  (*this)(1, 1) = input[0]; // S22
145  (*this)(2, 2) = input[0]; // S33
146  break;
147 
148  case 3:
149  zero();
150  (*this)(0, 0) = input[0]; // S11
151  (*this)(1, 1) = input[1]; // S22
152  (*this)(2, 2) = input[2]; // S33
153  break;
154 
155  case 6:
156  (*this)(0, 0) = input[0]; // S11
157  (*this)(1, 1) = input[1]; // S22
158  (*this)(2, 2) = input[2]; // S33
159  (*this)(1, 2) = (*this)(2, 1) = input[3]; // S23
160  (*this)(0, 2) = (*this)(2, 0) = input[4]; // S13
161  (*this)(0, 1) = (*this)(1, 0) = input[5]; // S12
162  break;
163 
164  case 9:
165  (*this)(0, 0) = input[0]; // S11
166  (*this)(1, 0) = input[1]; // S21
167  (*this)(2, 0) = input[2]; // S31
168  (*this)(0, 1) = input[3]; // S12
169  (*this)(1, 1) = input[4]; // S22
170  (*this)(2, 1) = input[5]; // S32
171  (*this)(0, 2) = input[6]; // S13
172  (*this)(1, 2) = input[7]; // S23
173  (*this)(2, 2) = input[8]; // S33
174  break;
175 
176  default:
177  mooseError("Please check the number of entries in the input vector for building "
178  "a RankTwoTensor. It must be 1, 3, 6, or 9");
179  }
180 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208

◆ fillFromScalarVariable()

void RankTwoTensor::fillFromScalarVariable ( const VariableValue scalar_variable)

fillFromScalarVariable takes FIRST/THIRD/SIXTH order scalar variable to fill in the Rank-2 tensor.

Definition at line 183 of file RankTwoTensor.C.

184 {
185  switch (scalar_variable.size())
186  {
187  case 1:
188  zero();
189  (*this)(0, 0) = scalar_variable[0]; // S11
190  break;
191 
192  case 3:
193  zero();
194  (*this)(0, 0) = scalar_variable[0]; // S11
195  (*this)(1, 1) = scalar_variable[1]; // S22
196  (*this)(0, 1) = (*this)(1, 0) = scalar_variable[2]; // S12
197  break;
198 
199  case 6:
200  (*this)(0, 0) = scalar_variable[0]; // S11
201  (*this)(1, 1) = scalar_variable[1]; // S22
202  (*this)(2, 2) = scalar_variable[2]; // S33
203  (*this)(1, 2) = (*this)(2, 1) = scalar_variable[3]; // S23
204  (*this)(0, 2) = (*this)(2, 0) = scalar_variable[4]; // S13
205  (*this)(0, 1) = (*this)(1, 0) = scalar_variable[5]; // S12
206  break;
207 
208  default:
209  mooseError("Only FIRST, THIRD, or SIXTH order scalar variable can be used to build "
210  "a RankTwoTensor.");
211  }
212 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
unsigned int size() const
The number of elements that can currently be stored in the array.
Definition: MooseArray.h:245

◆ fillMethodEnum()

MooseEnum RankTwoTensor::fillMethodEnum ( )
static

Static method for use in validParams for getting the "fill_method".

Definition at line 43 of file RankTwoTensor.C.

44 {
45  return MooseEnum("autodetect=0 isotropic1=1 diagonal3=3 symmetric6=6 general=9", "autodetect");
46 }
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:32

◆ fillRealTensor()

void RankTwoTensor::fillRealTensor ( RealTensorValue &  tensor)

Return real tensor of a rank two tensor.

Definition at line 1038 of file RankTwoTensor.C.

1039 {
1040  for (unsigned int i = 0; i < N; ++i)
1041  for (unsigned int j = 0; j < N; ++j)
1042  tensor(i, j) = (*this)(i, j);
1043 }
static constexpr unsigned int N

◆ fillRow()

void RankTwoTensor::fillRow ( unsigned int  r,
const TypeVector< Real > &  v 
)

Assigns value to the columns of a specified row.

Definition at line 1046 of file RankTwoTensor.C.

1047 {
1048  for (unsigned int i = 0; i < N; ++i)
1049  (*this)(r, i) = v(i);
1050 }
static constexpr unsigned int N

◆ generalSecondInvariant()

Real RankTwoTensor::generalSecondInvariant ( ) const

Denote the _coords[i][j] by A_ij, then S_ij = A_ij - de_ij*tr(A)/3 Then this returns (S_ij + S_ji)*(S_ij + S_ji)/8 Note the explicit symmeterisation.

Definition at line 523 of file RankTwoTensor.C.

524 {
525  // clang-format off
526  Real result = (*this)(0, 0) * (*this)(1, 1) +
527  (*this)(0, 0) * (*this)(2, 2) +
528  (*this)(1, 1) * (*this)(2, 2) -
529  (*this)(0, 1) * (*this)(1, 0) -
530  (*this)(0, 2) * (*this)(2, 0) -
531  (*this)(1, 2) * (*this)(2, 1);
532  // clang-format on
533  return result;
534 }

◆ genRandomSymmTensor()

RankTwoTensor RankTwoTensor::genRandomSymmTensor ( Real  scale,
Real  offset 
)
static

This function generates a random symmetric rank two tensor.

The first real scales the random number. The second real offsets the uniform random number

Definition at line 1018 of file RankTwoTensor.C.

1019 {
1020  RankTwoTensor tensor;
1021 
1022  for (unsigned int i = 0; i < N; i++)
1023  for (unsigned int j = i; j < N; j++)
1024  tensor(i, j) = tensor(j, i) = (MooseRandom::rand() + offset) * scale;
1025 
1026  return tensor;
1027 }
static double rand()
This method returns the next random number (double format) from the generator.
Definition: MooseRandom.h:50
RankTwoTensor is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: RankTwoTensor.h:51
static constexpr unsigned int N

◆ genRandomTensor()

RankTwoTensor RankTwoTensor::genRandomTensor ( Real  scale,
Real  offset 
)
static

This function generates a random unsymmetric rank two tensor.

The first real scales the random number. The second real offsets the uniform random number

Definition at line 1006 of file RankTwoTensor.C.

1007 {
1008  RankTwoTensor tensor;
1009 
1010  for (unsigned int i = 0; i < N; i++)
1011  for (unsigned int j = 0; j < N; j++)
1012  tensor(i, j) = (MooseRandom::rand() + offset) * scale;
1013 
1014  return tensor;
1015 }
static double rand()
This method returns the next random number (double format) from the generator.
Definition: MooseRandom.h:50
RankTwoTensor is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: RankTwoTensor.h:51
static constexpr unsigned int N

◆ getRUDecompositionRotation()

void RankTwoTensor::getRUDecompositionRotation ( RankTwoTensor rot) const

Uses the petscblaslapack.h LAPACKsyev_ routine to perform RU decomposition and obtain the rotation tensor.

Definition at line 964 of file RankTwoTensor.C.

965 {
966  const RankTwoTensor & a = *this;
967  RankTwoTensor c, diag, evec;
968  PetscScalar cmat[N][N], work[10];
969  PetscReal w[N];
970 
971  // prepare data for the LAPACKsyev_ routine (which comes from petscblaslapack.h)
972  PetscBLASInt nd = N, lwork = 10, info;
973 
974  c = a.transpose() * a;
975 
976  for (unsigned int i = 0; i < N; ++i)
977  for (unsigned int j = 0; j < N; ++j)
978  cmat[i][j] = c(i, j);
979 
980  LAPACKsyev_("V", "U", &nd, &cmat[0][0], &nd, w, work, &lwork, &info);
981 
982  if (info != 0)
983  mooseError("In computing the eigenvalues and eigenvectors of a symmetric rank-2 tensor, the "
984  "PETSC LAPACK syev routine returned error code ",
985  info);
986 
987  diag.zero();
988 
989  for (unsigned int i = 0; i < N; ++i)
990  diag(i, i) = std::sqrt(w[i]);
991 
992  for (unsigned int i = 0; i < N; ++i)
993  for (unsigned int j = 0; j < N; ++j)
994  evec(i, j) = cmat[i][j];
995 
996  rot = a * ((evec.transpose() * diag * evec).inverse());
997 }
RankTwoTensor transpose() const
Returns a matrix that is the transpose of the matrix this was called on.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
RankTwoTensor is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: RankTwoTensor.h:51
RankTwoTensor inverse() const
retuns the inverse of the tensor
static constexpr unsigned int N

◆ Identity()

static RankTwoTensor RankTwoTensor::Identity ( )
inlinestatic

Definition at line 116 of file RankTwoTensor.h.

116 { return RankTwoTensor(initIdentity); }
RankTwoTensor()
Default constructor; fills to zero.
Definition: RankTwoTensor.C:48

◆ initialContraction()

RankTwoTensor RankTwoTensor::initialContraction ( const RankFourTensor b) const

returns this_ij * b_ijkl

Definition at line 1060 of file RankTwoTensor.C.

1061 {
1062  RankTwoTensor result;
1063 
1064  unsigned int index = 0;
1065  for (unsigned int i = 0; i < N; ++i)
1066  for (unsigned int j = 0; j < N; ++j)
1067  {
1068  const Real a = (*this)(i, j);
1069  for (unsigned int k = 0; k < N; ++k)
1070  for (unsigned int l = 0; l < N; ++l)
1071  result(k, l) += a * b._vals[index++];
1072  }
1073 
1074  return result;
1075 }
RankTwoTensor is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: RankTwoTensor.h:51
Real _vals[N4]
The values of the rank-four tensor stored by index=(((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) * LIBME...
static constexpr unsigned int N

◆ initializeFromColumns()

RankTwoTensor RankTwoTensor::initializeFromColumns ( const TypeVector< Real > &  col0,
const TypeVector< Real > &  col1,
const TypeVector< Real > &  col2 
)
static

named constructor for initializing from column vectors

Definition at line 101 of file RankTwoTensor.C.

104 {
105  return RankTwoTensor(
106  col0(0), col0(1), col0(2), col1(0), col1(1), col1(2), col2(0), col2(1), col2(2));
107 }
RankTwoTensor()
Default constructor; fills to zero.
Definition: RankTwoTensor.C:48

◆ initializeFromRows()

RankTwoTensor RankTwoTensor::initializeFromRows ( const TypeVector< Real > &  row0,
const TypeVector< Real > &  row1,
const TypeVector< Real > &  row2 
)
static

named constructor for initializing from row vectors

Definition at line 92 of file RankTwoTensor.C.

95 {
96  return RankTwoTensor(
97  row0(0), row1(0), row2(0), row0(1), row1(1), row2(1), row0(2), row1(2), row2(2));
98 }
RankTwoTensor()
Default constructor; fills to zero.
Definition: RankTwoTensor.C:48

◆ initRandom()

void RankTwoTensor::initRandom ( unsigned int  rand_seed)
static

This function initializes random seed based on a user-defined number.

Definition at line 1000 of file RankTwoTensor.C.

1001 {
1002  MooseRandom::seed(rand_seed);
1003 }
static void seed(unsigned int seed)
The method seeds the random number generator.
Definition: MooseRandom.h:44

◆ inverse()

RankTwoTensor RankTwoTensor::inverse ( ) const

retuns the inverse of the tensor

Definition at line 584 of file RankTwoTensor.C.

Referenced by getRUDecompositionRotation().

585 {
586  return RealTensorValue::inverse();
587 }
void inverse(const std::vector< std::vector< Real >> &m, std::vector< std::vector< Real >> &m_inv)
Inverse the dense square matrix m using LAPACK routines.
Definition: MatrixTools.C:27

◆ L2norm()

Real RankTwoTensor::L2norm ( ) const

Sqrt(_coords[i][j]*_coords[i][j])

Definition at line 811 of file RankTwoTensor.C.

812 {
813  Real norm = 0.0;
814  for (unsigned int i = 0; i < N2; ++i)
815  {
816  Real v = _coords[i];
817  norm += v * v;
818  }
819  return std::sqrt(norm);
820 }
static constexpr unsigned int N2

◆ mixedProductIkJl()

RankFourTensor RankTwoTensor::mixedProductIkJl ( const RankTwoTensor a) const

returns C_ijkl = a_ik * b_jl

Definition at line 415 of file RankTwoTensor.C.

Referenced by positiveProjectionEigenDecomposition().

416 {
417  RankFourTensor result;
418 
419  unsigned int index = 0;
420  for (unsigned int i = 0; i < N; ++i)
421  for (unsigned int j = 0; j < N; ++j)
422  for (unsigned int k = 0; k < N; ++k)
423  {
424  const Real a = (*this)(i, k);
425  for (unsigned int l = 0; l < N; ++l)
426  result._vals[index++] = a * b(j, l);
427  }
428 
429  return result;
430 }
Real _vals[N4]
The values of the rank-four tensor stored by index=(((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) * LIBME...
static constexpr unsigned int N
RankFourTensor is designed to handle any N-dimensional fourth order tensor, C.

◆ mixedProductIlJk()

RankFourTensor RankTwoTensor::mixedProductIlJk ( const RankTwoTensor a) const

returns C_ijkl = a_il * b_jk

Definition at line 433 of file RankTwoTensor.C.

Referenced by positiveProjectionEigenDecomposition().

434 {
435  RankFourTensor result;
436 
437  for (unsigned int i = 0; i < N; ++i)
438  for (unsigned int j = 0; j < N; ++j)
439  for (unsigned int k = 0; k < N; ++k)
440  for (unsigned int l = 0; l < N; ++l)
441  result(i, j, k, l) = (*this)(i, l) * b(j, k);
442 
443  return result;
444 }
static constexpr unsigned int N
RankFourTensor is designed to handle any N-dimensional fourth order tensor, C.

◆ mixedProductJkIl()

RankFourTensor RankTwoTensor::mixedProductJkIl ( const RankTwoTensor a) const

returns C_ijkl = a_jk * b_il

Definition at line 447 of file RankTwoTensor.C.

448 {
449  RankFourTensor result;
450 
451  unsigned int index = 0;
452  for (unsigned int i = 0; i < N; ++i)
453  for (unsigned int j = 0; j < N; ++j)
454  for (unsigned int k = 0; k < N; ++k)
455  {
456  const Real a = (*this)(j, k);
457  for (unsigned int l = 0; l < N; ++l)
458  result._vals[index++] = a * b(i, l);
459  }
460 
461  return result;
462 }
Real _vals[N4]
The values of the rank-four tensor stored by index=(((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) * LIBME...
static constexpr unsigned int N
RankFourTensor is designed to handle any N-dimensional fourth order tensor, C.

◆ operator*() [1/3]

RankTwoTensor RankTwoTensor::operator* ( const Real  a) const

returns _coords*a

Definition at line 334 of file RankTwoTensor.C.

334 { return RealTensorValue::operator*(b); }
RankFourTensor operator*(Real a, const RankFourTensor &b)

◆ operator*() [2/3]

TypeVector< Real > RankTwoTensor::operator* ( const TypeVector< Real > &  a) const

Defines multiplication with a vector to get a vector.

Definition at line 349 of file RankTwoTensor.C.

350 {
351  return RealTensorValue::operator*(b);
352 }
RankFourTensor operator*(Real a, const RankFourTensor &b)

◆ operator*() [3/3]

RankTwoTensor RankTwoTensor::operator* ( const TypeTensor< Real > &  a) const

Defines multiplication with a TypeTensor<Real>

Definition at line 354 of file RankTwoTensor.C.

355 {
356  return RealTensorValue::operator*(b);
357 }
RankFourTensor operator*(Real a, const RankFourTensor &b)

◆ operator*=() [1/2]

RankTwoTensor & RankTwoTensor::operator*= ( const Real  a)

performs _coords *= a

Definition at line 328 of file RankTwoTensor.C.

329 {
330  RealTensorValue::operator*=(a);
331  return *this;
332 }

◆ operator*=() [2/2]

RankTwoTensor & RankTwoTensor::operator*= ( const TypeTensor< Real > &  a)

Defines multiplication with a TypeTensor<Real>

Definition at line 360 of file RankTwoTensor.C.

361 {
362  *this = *this * a;
363  return *this;
364 }

◆ operator+()

RankTwoTensor RankTwoTensor::operator+ ( const RankTwoTensor a) const

returns _coords + a

Definition at line 303 of file RankTwoTensor.C.

304 {
305  return RealTensorValue::operator+(b);
306 }

◆ operator+=()

RankTwoTensor & RankTwoTensor::operator+= ( const RankTwoTensor a)

adds a to _coords

Definition at line 296 of file RankTwoTensor.C.

297 {
298  RealTensorValue::operator+=(a);
299  return *this;
300 }

◆ operator-() [1/2]

RankTwoTensor RankTwoTensor::operator- ( const RankTwoTensor a) const

returns _coords - a

Definition at line 316 of file RankTwoTensor.C.

317 {
318  return RealTensorValue::operator-(b);
319 }

◆ operator-() [2/2]

RankTwoTensor RankTwoTensor::operator- ( ) const

returns -_coords

Definition at line 322 of file RankTwoTensor.C.

323 {
324  return RealTensorValue::operator-();
325 }

◆ operator-=()

RankTwoTensor & RankTwoTensor::operator-= ( const RankTwoTensor a)

sets _coords -= a and returns vals

Definition at line 309 of file RankTwoTensor.C.

310 {
311  RealTensorValue::operator-=(a);
312  return *this;
313 }

◆ operator/()

RankTwoTensor RankTwoTensor::operator/ ( const Real  a) const

returns _coords/a

Definition at line 344 of file RankTwoTensor.C.

345 {
346  return RealTensorValue::operator/(b);
347 }

◆ operator/=()

RankTwoTensor & RankTwoTensor::operator/= ( const Real  a)

performs _coords /= a

Definition at line 337 of file RankTwoTensor.C.

338 {
339  RealTensorValue::operator/=(a);
340  return *this;
341 }

◆ operator=() [1/2]

RankTwoTensor & RankTwoTensor::operator= ( const RankTwoTensor a)

sets _coords to a, and returns _coords

Definition at line 289 of file RankTwoTensor.C.

290 {
291  RealTensorValue::operator=(a);
292  return *this;
293 }

◆ operator=() [2/2]

RankTwoTensor & RankTwoTensor::operator= ( const ColumnMajorMatrix a)

Sets _coords to the values in a ColumnMajorMatrix (must be 3x3)

Definition at line 378 of file RankTwoTensor.C.

379 {
380  if (a.n() != N || a.m() != N)
381  mooseError("Dimensions of ColumnMajorMatrix are incompatible with RankTwoTensor");
382 
383  const Real * cmm_rawdata = a.rawData();
384  for (unsigned int i = 0; i < N; ++i)
385  for (unsigned int j = 0; j < N; ++j)
386  _coords[i * N + j] = cmm_rawdata[i + j * N];
387 
388  return *this;
389 }
Real * rawData()
Returns a reference to the raw data pointer.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
unsigned int m() const
Returns the number of columns.
unsigned int n() const
Returns the number of rows.
static constexpr unsigned int N

◆ operator==()

bool RankTwoTensor::operator== ( const RankTwoTensor a) const

Defines logical equality with another RankTwoTensor.

Definition at line 367 of file RankTwoTensor.C.

368 {
369  for (unsigned int i = 0; i < N; ++i)
370  for (unsigned int j = 0; j < N; ++j)
371  if (!MooseUtils::absoluteFuzzyEqual((*this)(i, j), a(i, j)))
372  return false;
373 
374  return true;
375 }
static constexpr unsigned int N
bool absoluteFuzzyEqual(const libMesh::Real &var1, const libMesh::Real &var2, const libMesh::Real &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
Function to check whether two variables are equal within an absolute tolerance.

◆ outerProduct()

RankFourTensor RankTwoTensor::outerProduct ( const RankTwoTensor a) const

returns C_ijkl = a_ij * b_kl

Definition at line 399 of file RankTwoTensor.C.

Referenced by positiveProjectionEigenDecomposition().

400 {
401  RankFourTensor result;
402 
403  unsigned int index = 0;
404  for (unsigned int ij = 0; ij < N2; ++ij)
405  {
406  const Real a = _coords[ij];
407  for (unsigned int kl = 0; kl < N2; ++kl)
408  result._vals[index++] = a * b._coords[kl];
409  }
410 
411  return result;
412 }
Real _vals[N4]
The values of the rank-four tensor stored by index=(((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) * LIBME...
static constexpr unsigned int N2
RankFourTensor is designed to handle any N-dimensional fourth order tensor, C.

◆ positiveProjectionEigenDecomposition()

RankFourTensor RankTwoTensor::positiveProjectionEigenDecomposition ( std::vector< Real > &  eigval,
RankTwoTensor eigvec 
) const

return positive projection tensor of eigen-decomposition

Definition at line 465 of file RankTwoTensor.C.

467 {
468  // The calculate of projection tensor follows
469  // C. Miehe and M. Lambrecht, Commun. Numer. Meth. Engng 2001; 17:337~353
470 
471  // Compute eigenvectors and eigenvalues of this tensor
472  this->symmetricEigenvaluesEigenvectors(eigval, eigvec);
473 
474  // Separate out positive and negative eigen values
475  std::array<Real, N> epos;
476  std::array<Real, N> d;
477  for (unsigned int i = 0; i < N; ++i)
478  {
479  epos[i] = (std::abs(eigval[i]) + eigval[i]) / 2.0;
480  d[i] = eigval[i] > 0 ? 1.0 : 0.0;
481  }
482 
483  // projection tensor
484  RankFourTensor proj_pos;
485  RankFourTensor Gab, Gba;
486  RankTwoTensor Ma, Mb;
487 
488  for (unsigned int a = 0; a < N; ++a)
489  {
490  Ma.vectorOuterProduct(eigvec.column(a), eigvec.column(a));
491  proj_pos += d[a] * Ma.outerProduct(Ma);
492  }
493 
494  for (unsigned int a = 0; a < N; ++a)
495  for (unsigned int b = 0; b < a; ++b)
496  {
497  Ma.vectorOuterProduct(eigvec.column(a), eigvec.column(a));
498  Mb.vectorOuterProduct(eigvec.column(b), eigvec.column(b));
499 
500  Gab = Ma.mixedProductIkJl(Mb) + Ma.mixedProductIlJk(Mb);
501  Gba = Mb.mixedProductIkJl(Ma) + Mb.mixedProductIlJk(Ma);
502 
503  Real theta_ab;
504  if (!MooseUtils::absoluteFuzzyEqual(eigval[a], eigval[b]))
505  theta_ab = 0.5 * (epos[a] - epos[b]) / (eigval[a] - eigval[b]);
506  else
507  theta_ab = 0.25 * (d[a] + d[b]);
508 
509  proj_pos += theta_ab * (Gab + Gba);
510  }
511  return proj_pos;
512 }
RankFourTensor outerProduct(const RankTwoTensor &a) const
returns C_ijkl = a_ij * b_kl
void vectorOuterProduct(const TypeVector< Real > &, const TypeVector< Real > &)
RankTwoTensor from outer product of vectors.
void symmetricEigenvaluesEigenvectors(std::vector< Real > &eigvals, RankTwoTensor &eigvecs) const
computes eigenvalues and eigenvectors, assuming tens is symmetric, and places them in ascending order...
RankFourTensor mixedProductIkJl(const RankTwoTensor &a) const
returns C_ijkl = a_ik * b_jl
RankTwoTensor is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: RankTwoTensor.h:51
TypeVector< Real > column(const unsigned int c) const
returns _coords[i][c], ie, column c, with c = 0, 1, 2
RankFourTensor mixedProductIlJk(const RankTwoTensor &a) const
returns C_ijkl = a_il * b_jk
static constexpr unsigned int N
bool absoluteFuzzyEqual(const libMesh::Real &var1, const libMesh::Real &var2, const libMesh::Real &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
Function to check whether two variables are equal within an absolute tolerance.
RankFourTensor is designed to handle any N-dimensional fourth order tensor, C.

◆ print()

void RankTwoTensor::print ( std::ostream &  stm = Moose::out) const

Print the rank two tensor.

Definition at line 792 of file RankTwoTensor.C.

793 {
794  const RankTwoTensor & a = *this;
795  for (unsigned int i = 0; i < N; ++i)
796  {
797  for (unsigned int j = 0; j < N; ++j)
798  stm << std::setw(15) << a(i, j) << ' ';
799  stm << std::endl;
800  }
801 }
RankTwoTensor is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: RankTwoTensor.h:51
static constexpr unsigned int N

◆ rotate()

void RankTwoTensor::rotate ( const RankTwoTensor R)

rotates the tensor data given a rank two tensor rotation tensor _coords[i][j] = R_ij * R_jl * _coords[k][l]

Parameters
Rrotation matrix as a RankTwoTensor

Definition at line 234 of file RankTwoTensor.C.

Referenced by rotated().

235 {
236  RankTwoTensor temp;
237  unsigned int i1 = 0;
238  for (unsigned int i = 0; i < N; i++)
239  {
240  unsigned int j1 = 0;
241  for (unsigned int j = 0; j < N; j++)
242  {
243  // tmp += R(i,k)*R(j,l)*(*this)(k,l);
244  // clang-format off
245  Real tmp = R._coords[i1 + 0] * R._coords[j1 + 0] * (*this)(0, 0) +
246  R._coords[i1 + 0] * R._coords[j1 + 1] * (*this)(0, 1) +
247  R._coords[i1 + 0] * R._coords[j1 + 2] * (*this)(0, 2) +
248  R._coords[i1 + 1] * R._coords[j1 + 0] * (*this)(1, 0) +
249  R._coords[i1 + 1] * R._coords[j1 + 1] * (*this)(1, 1) +
250  R._coords[i1 + 1] * R._coords[j1 + 2] * (*this)(1, 2) +
251  R._coords[i1 + 2] * R._coords[j1 + 0] * (*this)(2, 0) +
252  R._coords[i1 + 2] * R._coords[j1 + 1] * (*this)(2, 1) +
253  R._coords[i1 + 2] * R._coords[j1 + 2] * (*this)(2, 2);
254  // clang-format on
255  temp._coords[i1 + j] = tmp;
256  j1 += N;
257  }
258  i1 += N;
259  }
260  for (unsigned int i = 0; i < N2; i++)
261  _coords[i] = temp._coords[i];
262 }
RankTwoTensor is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: RankTwoTensor.h:51
static constexpr unsigned int N
static constexpr unsigned int N2

◆ rotated()

RankTwoTensor RankTwoTensor::rotated ( const RankTwoTensor R) const

Returns a rotated version of the tensor data given a rank two tensor rotation tensor _coords[i][j] = R_ij * R_jl * _coords[k][l].

Parameters
Rrotation matrix as a RealTensorValue

Definition at line 226 of file RankTwoTensor.C.

227 {
228  RankTwoTensor result(*this);
229  result.rotate(R);
230  return result;
231 }
RankTwoTensor is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: RankTwoTensor.h:51

◆ rotateXyPlane()

RankTwoTensor RankTwoTensor::rotateXyPlane ( Real  a)

rotates the tensor data anticlockwise around the z-axis

Parameters
aangle in radians

Definition at line 265 of file RankTwoTensor.C.

266 {
267  Real c = std::cos(a);
268  Real s = std::sin(a);
269  Real x = (*this)(0, 0) * c * c + (*this)(1, 1) * s * s + 2.0 * (*this)(0, 1) * c * s;
270  Real y = (*this)(0, 0) * s * s + (*this)(1, 1) * c * c - 2.0 * (*this)(0, 1) * c * s;
271  Real xy = ((*this)(1, 1) - (*this)(0, 0)) * c * s + (*this)(0, 1) * (c * c - s * s);
272 
273  RankTwoTensor b(*this);
274 
275  b(0, 0) = x;
276  b(1, 1) = y;
277  b(1, 0) = b(0, 1) = xy;
278 
279  return b;
280 }
static PetscErrorCode Vec x
RankTwoTensor is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: RankTwoTensor.h:51

◆ secondInvariant()

Real RankTwoTensor::secondInvariant ( ) const

Calculates the second invariant (I2) of a tensor.

Definition at line 537 of file RankTwoTensor.C.

Referenced by d2sin3Lode(), dsin3Lode(), dthirdInvariant(), and sin3Lode().

538 {
539  Real result = 0.0;
540 
541  // RankTwoTensor deviatoric(*this);
542  // deviatoric.addIa(-1.0/3.0 * tr()); // actually construct deviatoric part
543  // result = 0.5*(deviatoric + deviatoric.transpose()).doubleContraction(deviatoric +
544  // deviatoric.transpose());
545  result = Utility::pow<2>((*this)(0, 0) - (*this)(1, 1)) / 6.0;
546  result += Utility::pow<2>((*this)(0, 0) - (*this)(2, 2)) / 6.0;
547  result += Utility::pow<2>((*this)(1, 1) - (*this)(2, 2)) / 6.0;
548  result += Utility::pow<2>((*this)(0, 1) + (*this)(1, 0)) / 4.0;
549  result += Utility::pow<2>((*this)(0, 2) + (*this)(2, 0)) / 4.0;
550  result += Utility::pow<2>((*this)(1, 2) + (*this)(2, 1)) / 4.0;
551  return result;
552 }

◆ sin3Lode()

Real RankTwoTensor::sin3Lode ( const Real  r0,
const Real  r0_value 
) const

Sin(3*Lode_angle) If secondInvariant() <= r0 then return r0_value This is to gaurd against precision-loss errors.

Note that sin(3*Lode_angle) is not defined for secondInvariant() = 0

Definition at line 724 of file RankTwoTensor.C.

725 {
726  Real bar = secondInvariant();
727  if (bar <= r0)
728  // in this case the Lode angle is not defined
729  return r0_value;
730  else
731  // the min and max here gaurd against precision-loss when bar is tiny but nonzero.
732  return std::max(std::min(-1.5 * std::sqrt(3.0) * thirdInvariant() / std::pow(bar, 1.5), 1.0),
733  -1.0);
734 }
Real thirdInvariant() const
Denote the _coords[i][j] by A_ij, then S_ij = A_ij - de_ij*tr(A)/3 Then this returns det(S + S...
Real pow(Real x, int e)
Definition: MathUtils.C:211
Real secondInvariant() const
Calculates the second invariant (I2) of a tensor.

◆ surfaceFillFromInputVector()

void RankTwoTensor::surfaceFillFromInputVector ( const std::vector< Real > &  input)

sets _coords[0][0], _coords[0][1], _coords[1][0], _coords[1][1] to input, and the remainder to zero

Definition at line 823 of file RankTwoTensor.C.

824 {
825  if (input.size() == 4)
826  {
827  // initialize with zeros
828  this->zero();
829  (*this)(0, 0) = input[0];
830  (*this)(0, 1) = input[1];
831  (*this)(1, 0) = input[2];
832  (*this)(1, 1) = input[3];
833  }
834  else
835  mooseError("please provide correct number of values for surface RankTwoTensor initialization.");
836 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208

◆ syev()

void RankTwoTensor::syev ( const char *  calculation_type,
std::vector< PetscScalar > &  eigvals,
std::vector< PetscScalar > &  a 
) const

Uses the petscblaslapack.h LAPACKsyev_ routine to find, for symmetric _coords: (1) the eigenvalues (if calculation_type == "N") (2) the eigenvalues and eigenvectors (if calculation_type == "V")

Parameters
calculation_typeIf "N" then calculation eigenvalues only
eigvalsEigenvalues are placed in this array, in ascending order
aEigenvectors are placed in this array if calculation_type == "V". See code in dsymmetricEigenvalues for extracting eigenvectors from the a output.

Definition at line 932 of file RankTwoTensor.C.

Referenced by d2symmetricEigenvalues(), dsymmetricEigenvalues(), symmetricEigenvalues(), and symmetricEigenvaluesEigenvectors().

935 {
936  eigvals.resize(N);
937  a.resize(N * N);
938 
939  // prepare data for the LAPACKsyev_ routine (which comes from petscblaslapack.h)
940  int nd = N;
941  int lwork = 66 * nd;
942  int info;
943  std::vector<PetscScalar> work(lwork);
944 
945  for (unsigned int i = 0; i < N; ++i)
946  for (unsigned int j = 0; j < N; ++j)
947  // a is destroyed by dsyev, and if calculation_type == "V" then eigenvectors are placed there
948  // Note the explicit symmeterisation
949  a[i * N + j] = 0.5 * (this->operator()(i, j) + this->operator()(j, i));
950 
951  // compute the eigenvalues only (if calculation_type == "N"),
952  // or both the eigenvalues and eigenvectors (if calculation_type == "V")
953  // assume upper triangle of a is stored (second "U")
954  LAPACKsyev_(calculation_type, "U", &nd, &a[0], &nd, &eigvals[0], &work[0], &lwork, &info);
955 
956  if (info != 0)
957  mooseError("In computing the eigenvalues and eigenvectors for the symmetric rank-2 tensor (",
958  Moose::stringify(a),
959  "), the PETSC LAPACK syev routine returned error code ",
960  info);
961 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
std::string stringify(const T &t)
conversion to string
Definition: Conversion.h:58
static constexpr unsigned int N

◆ symmetricEigenvalues()

void RankTwoTensor::symmetricEigenvalues ( std::vector< Real > &  eigvals) const

computes eigenvalues, assuming tens is symmetric, and places them in ascending order in eigvals

Definition at line 839 of file RankTwoTensor.C.

840 {
841  std::vector<PetscScalar> a;
842  syev("N", eigvals, a);
843 }
void syev(const char *calculation_type, std::vector< PetscScalar > &eigvals, std::vector< PetscScalar > &a) const
Uses the petscblaslapack.h LAPACKsyev_ routine to find, for symmetric _coords: (1) the eigenvalues (i...

◆ symmetricEigenvaluesEigenvectors()

void RankTwoTensor::symmetricEigenvaluesEigenvectors ( std::vector< Real > &  eigvals,
RankTwoTensor eigvecs 
) const

computes eigenvalues and eigenvectors, assuming tens is symmetric, and places them in ascending order in eigvals.

eigvecs is a matrix with the first column being the first eigenvector, the second column being the second, etc.

Definition at line 846 of file RankTwoTensor.C.

Referenced by positiveProjectionEigenDecomposition().

848 {
849  std::vector<PetscScalar> a;
850  syev("V", eigvals, a);
851 
852  for (unsigned int i = 0; i < N; ++i)
853  for (unsigned int j = 0; j < N; ++j)
854  eigvecs(j, i) = a[i * N + j];
855 }
void syev(const char *calculation_type, std::vector< PetscScalar > &eigvals, std::vector< PetscScalar > &a) const
Uses the petscblaslapack.h LAPACKsyev_ routine to find, for symmetric _coords: (1) the eigenvalues (i...
static constexpr unsigned int N

◆ thirdInvariant()

Real RankTwoTensor::thirdInvariant ( ) const

Denote the _coords[i][j] by A_ij, then S_ij = A_ij - de_ij*tr(A)/3 Then this returns det(S + S.transpose())/2 Note the explicit symmeterisation.

Definition at line 596 of file RankTwoTensor.C.

Referenced by d2sin3Lode(), dsin3Lode(), and sin3Lode().

597 {
598  RankTwoTensor s = 0.5 * deviatoric();
599  s += s.transpose();
600 
601  Real result = 0.0;
602 
603  result = s(0, 0) * (s(1, 1) * s(2, 2) - s(2, 1) * s(1, 2));
604  result -= s(1, 0) * (s(0, 1) * s(2, 2) - s(2, 1) * s(0, 2));
605  result += s(2, 0) * (s(0, 1) * s(1, 2) - s(1, 1) * s(0, 2));
606 
607  return result;
608 }
RankTwoTensor transpose() const
Returns a matrix that is the transpose of the matrix this was called on.
RankTwoTensor is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: RankTwoTensor.h:51
RankTwoTensor deviatoric() const
returns A_ij - de_ij*tr(A)/3, where A are the _coords

◆ trace()

Real RankTwoTensor::trace ( ) const

returns the trace of the tensor, ie _coords[i][i] (sum i = 0, 1, 2)

Definition at line 577 of file RankTwoTensor.C.

578 {
579  // deprecate this!
580  return tr();
581 }

◆ transpose()

RankTwoTensor RankTwoTensor::transpose ( ) const

Returns a matrix that is the transpose of the matrix this was called on.

Definition at line 283 of file RankTwoTensor.C.

Referenced by d2thirdInvariant(), dsecondInvariant(), dthirdInvariant(), getRUDecompositionRotation(), and thirdInvariant().

284 {
285  return RealTensorValue::transpose();
286 }

◆ vectorOuterProduct()

void RankTwoTensor::vectorOuterProduct ( const TypeVector< Real > &  v1,
const TypeVector< Real > &  v2 
)

RankTwoTensor from outer product of vectors.

Definition at line 1030 of file RankTwoTensor.C.

Referenced by positiveProjectionEigenDecomposition().

1031 {
1032  for (unsigned int i = 0; i < N; ++i)
1033  for (unsigned int j = 0; j < N; ++j)
1034  (*this)(i, j) = v1(i) * v2(j);
1035 }
static constexpr unsigned int N

Friends And Related Function Documentation

◆ dataLoad

template<class T >
void dataLoad ( std::istream &  stream,
T &  v,
void *   
)
friend

Definition at line 418 of file DataIO.h.

419 {
420  stream.read((char *)&v, sizeof(v));
421 }

◆ dataStore

template<class T >
void dataStore ( std::ostream &  stream,
T &  v,
void *   
)
friend

Definition at line 156 of file DataIO.h.

157 {
158 #ifdef LIBMESH_HAVE_CXX11_TYPE_TRAITS
159  static_assert(std::is_polymorphic<T>::value == false,
160  "Cannot serialize a class that has virtual "
161  "members!\nWrite a custom dataStore() "
162  "template specialization!\n\n");
163  static_assert(std::is_trivially_copyable<T>::value || std::is_same<T, Point>::value,
164  "Cannot serialize a class that is not trivially copyable!\nWrite a custom "
165  "dataStore() template specialization!\n\n");
166 #endif
167 
168  // Moose::out<<"Generic dataStore"<<std::endl;
169  stream.write((char *)&v, sizeof(v));
170 }

◆ RankFourTensor

friend class RankFourTensor
friend

Definition at line 435 of file RankTwoTensor.h.

Referenced by d2sin3Lode(), and d2symmetricEigenvalues().

◆ RankThreeTensor

friend class RankThreeTensor
friend

Definition at line 436 of file RankTwoTensor.h.

Member Data Documentation

◆ N

constexpr unsigned int RankTwoTensor::N = LIBMESH_DIM
staticprivate

◆ N2

constexpr unsigned int RankTwoTensor::N2 = N * N
staticprivate

Definition at line 427 of file RankTwoTensor.h.

Referenced by L2norm(), outerProduct(), RankTwoTensor(), and rotate().


The documentation for this class was generated from the following files: