www.mooseframework.org
Public Types | Public Member Functions | Static Public Member Functions | Static Private Attributes | Friends | List of all members
RankTwoTensorTempl< T > Class Template Reference

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

#include <MooseTypes.h>

Inheritance diagram for RankTwoTensorTempl< T >:
[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

 RankTwoTensorTempl ()
 Default constructor; fills to zero. More...
 
 RankTwoTensorTempl (const InitMethod)
 Select specific initialization pattern. More...
 
 RankTwoTensorTempl (const TypeVector< T > &row1, const TypeVector< T > &row2, const TypeVector< T > &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...
 
 RankTwoTensorTempl (const std::vector< T > &input)
 Constructor that proxies the fillFromInputVector method. More...
 
 RankTwoTensorTempl (T S11, T S22, T S33, T S23, T S13, T S12)
 Initialization list replacement constructors, 6 arguments. More...
 
 RankTwoTensorTempl (T S11, T S21, T S31, T S12, T S22, T S32, T S13, T S23, T S33)
 Initialization list replacement constructors, 9 arguments. More...
 
 RankTwoTensorTempl (const TensorValue< T > &a)
 Copy constructor from TensorValue<T> More...
 
 RankTwoTensorTempl (const TypeTensor< T > &a)
 Copy constructor from TypeTensor<T> More...
 
template<typename T2 >
 RankTwoTensorTempl (const RankTwoTensorTempl< T2 > &a)
 Construct from other template. More...
 
void fillFromInputVector (const std::vector< T > &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< T > column (const unsigned int c) const
 returns _coords[i][c], ie, column c, with c = 0, 1, 2 More...
 
RankTwoTensorTempl< T > rotated (const RankTwoTensorTempl< T > &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 RankTwoTensorTempl< T > &R)
 rotates the tensor data given a rank two tensor rotation tensor _coords[i][j] = R_ij * R_jl * _coords[k][l] More...
 
RankTwoTensorTempl< T > rotateXyPlane (T a)
 rotates the tensor data anticlockwise around the z-axis More...
 
RankTwoTensorTempl< T > transpose () const
 Returns a matrix that is the transpose of the matrix this was called on. More...
 
RankTwoTensorTempl< T > & operator= (const RankTwoTensorTempl< T > &a)
 sets _coords to a, and returns _coords More...
 
template<typename Scalar >
boostcopy::enable_if_c< ScalarTraits< Scalar >::value, RankTwoTensorTempl & >::type operator= (const Scalar &libmesh_dbg_var(p))
 Assignment-from-scalar operator. More...
 
RankTwoTensorTempl< T > & operator+= (const RankTwoTensorTempl< T > &a)
 adds a to _coords More...
 
template<typename T2 >
RankTwoTensorTempl< typename CompareTypes< T, T2 >::supertype > operator+ (const TypeTensor< T2 > &a) const
 returns _coords + a More...
 
RankTwoTensorTempl< T > & operator-= (const RankTwoTensorTempl< T > &a)
 sets _coords -= a and returns vals More...
 
template<typename T2 >
RankTwoTensorTempl< typename CompareTypes< T, T2 >::supertype > operator- (const TypeTensor< T2 > &a) const
 returns _coords - a More...
 
RankTwoTensorTempl< T > operator- () const
 returns -_coords More...
 
RankTwoTensorTempl< T > & operator*= (const T &a)
 performs _coords *= a More...
 
template<typename T2 , typename std::enable_if< ScalarTraits< T2 >::value, int >::type = 0>
RankTwoTensorTempl< typename CompareTypes< T, T2 >::supertype > operator* (const T2 &a) const
 returns _coords*a More...
 
RankTwoTensorTempl< T > & operator/= (const T &a)
 performs _coords /= a More...
 
template<typename T2 , typename std::enable_if< ScalarTraits< T2 >::value, int >::type = 0>
RankTwoTensorTempl< typename CompareTypes< T, T2 >::supertype > operator/ (const T2 &a) const
 returns _coords/a More...
 
template<typename T2 >
TypeVector< typename CompareTypes< T, T2 >::supertype > operator* (const TypeVector< T2 > &a) const
 Defines multiplication with a vector to get a vector. More...
 
template<typename T2 >
RankTwoTensorTempl< typename CompareTypes< T, T2 >::supertype > operator* (const TypeTensor< T2 > &a) const
 Defines multiplication with a TypeTensor<T> More...
 
RankTwoTensorTempl< T > & operator*= (const TypeTensor< T > &a)
 Defines multiplication with a TypeTensor<T> More...
 
bool operator== (const RankTwoTensorTempl< T > &a) const
 Defines logical equality with another RankTwoTensorTempl<T> More...
 
RankTwoTensorTempl< T > & operator= (const ColumnMajorMatrixTempl< T > &a)
 Sets _coords to the values in a ColumnMajorMatrix (must be 3x3) More...
 
doubleContraction (const RankTwoTensorTempl< T > &a) const
 returns _coords_ij * a_ij (sum on i, j) More...
 
RankFourTensorTempl< T > outerProduct (const RankTwoTensorTempl< T > &a) const
 returns C_ijkl = a_ij * b_kl More...
 
RankFourTensorTempl< T > mixedProductIkJl (const RankTwoTensorTempl< T > &a) const
 returns C_ijkl = a_ik * b_jl More...
 
RankFourTensorTempl< T > mixedProductJkIl (const RankTwoTensorTempl< T > &a) const
 returns C_ijkl = a_jk * b_il More...
 
RankFourTensorTempl< T > mixedProductIlJk (const RankTwoTensorTempl< T > &a) const
 returns C_ijkl = a_il * b_jk More...
 
RankFourTensorTempl< T > positiveProjectionEigenDecomposition (std::vector< T > &eigval, RankTwoTensorTempl< T > &eigvec) const
 return positive projection tensor of eigen-decomposition More...
 
RankTwoTensorTempl< T > deviatoric () const
 returns A_ij - de_ij*tr(A)/3, where A are the _coords More...
 
trace () const
 returns the trace of the tensor, ie _coords[i][i] (sum i = 0, 1, 2) More...
 
RankTwoTensorTempl< T > inverse () const
 retuns the inverse of the tensor More...
 
RankTwoTensorTempl< T > dtrace () const
 Denote the _coords[i][j] by A_ij, then this returns d(trace)/dA_ij. More...
 
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...
 
secondInvariant () const
 Calculates the second invariant (I2) of a tensor. More...
 
RankTwoTensorTempl< T > dsecondInvariant () const
 Denote the _coords[i][j] by A_ij, then this returns d(secondInvariant)/dA_ij. More...
 
RankFourTensorTempl< T > d2secondInvariant () const
 Denote the _coords[i][j] by A_ij, then this returns d^2(secondInvariant)/dA_ij/dA_kl. More...
 
sin3Lode (const T &r0, const T &r0_value) const
 Sin(3*Lode_angle) If secondInvariant() <= r0 then return r0_value This is to gaurd against precision-loss errors. More...
 
RankTwoTensorTempl< T > dsin3Lode (const T &r0) const
 d(sin3Lode)/dA_ij If secondInvariant() <= r0 then return zero This is to gaurd against precision-loss errors. More...
 
RankFourTensorTempl< T > d2sin3Lode (const T &r0) const
 d^2(sin3Lode)/dA_ij/dA_kl If secondInvariant() <= r0 then return zero This is to gaurd against precision-loss errors. More...
 
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...
 
RankTwoTensorTempl< T > dthirdInvariant () const
 Denote the _coords[i][j] by A_ij, then this returns d(thirdInvariant()/dA_ij. More...
 
RankFourTensorTempl< T > d2thirdInvariant () const
 Denote the _coords[i][j] by A_ij, then this returns d^2(thirdInvariant)/dA_ij/dA_kl. More...
 
RankTwoTensorTempl< T > 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 T &a)
 Add identity times a to _coords. More...
 
L2norm () const
 Sqrt(_coords[i][j]*_coords[i][j]) More...
 
void surfaceFillFromInputVector (const std::vector< T > &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< T > &eigvals) const
 computes eigenvalues, assuming tens is symmetric, and places them in ascending order in eigvals More...
 
void symmetricEigenvaluesEigenvectors (std::vector< T > &eigvals, RankTwoTensorTempl< T > &eigvecs) const
 computes eigenvalues and eigenvectors, assuming tens is symmetric, and places them in ascending order in eigvals. More...
 
void dsymmetricEigenvalues (std::vector< T > &eigvals, std::vector< RankTwoTensorTempl< T >> &deigvals) const
 computes eigenvalues, and their symmetric derivatives wrt vals, assuming tens is symmetric More...
 
void d2symmetricEigenvalues (std::vector< RankFourTensorTempl< T >> &deriv) const
 Computes second derivatives of Eigenvalues of a rank two tensor. More...
 
void syev (const char *calculation_type, std::vector< T > &eigvals, std::vector< T > &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 (RankTwoTensorTempl< T > &rot) const
 Uses the petscblaslapack.h LAPACKsyev_ routine to perform RU decomposition and obtain the rotation tensor. More...
 
void vectorOuterProduct (const TypeVector< T > &, const TypeVector< T > &)
 RankTwoTensorTempl<T> from outer product of vectors. More...
 
void fillRealTensor (TensorValue< T > &)
 Return real tensor of a rank two tensor. More...
 
void fillRow (unsigned int, const TypeVector< T > &)
 Assigns value to the columns of a specified row. More...
 
void fillColumn (unsigned int, const TypeVector< T > &)
 Assigns value to the rows of a specified column. More...
 
RankTwoTensorTempl< T > initialContraction (const RankFourTensorTempl< T > &b) const
 returns this_ij * b_ijkl More...
 
void setToIdentity ()
 set the tensor to the identity matrix More...
 
template<>
void syev (const char *, std::vector< DualReal > &, std::vector< DualReal > &) const
 
template<>
void getRUDecompositionRotation (RankTwoTensorTempl< DualReal > &) const
 

Static Public Member Functions

static RankTwoTensorTempl initializeFromRows (const TypeVector< T > &row0, const TypeVector< T > &row1, const TypeVector< T > &row2)
 named constructor for initializing from row vectors More...
 
static RankTwoTensorTempl initializeFromColumns (const TypeVector< T > &col0, const TypeVector< T > &col1, const TypeVector< T > &col2)
 named constructor for initializing from column vectors More...
 
static RankTwoTensorTempl 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 RankTwoTensorTempl< T > genRandomTensor (T, T)
 This function generates a random unsymmetric rank two tensor. More...
 
static RankTwoTensorTempl< T > genRandomSymmTensor (T, T)
 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
 
static constexpr Real identityCoords [N2] = {1, 0, 0, 0, 1, 0, 0, 0, 1}
 

Friends

template<class T2 >
class RankFourTensorTempl
 
template<class T2 >
class RankThreeTensorTempl
 
template<class T2 >
void dataStore (std::ostream &, RankTwoTensorTempl< T2 > &, void *)
 
template<class T2 >
void dataLoad (std::istream &, RankTwoTensorTempl< T2 > &, void *)
 

Detailed Description

template<typename T>
class RankTwoTensorTempl< T >

RankTwoTensorTempl 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

RankTwoTensorTempl 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 111 of file MooseTypes.h.

Member Enumeration Documentation

◆ FillMethod

template<typename T>
enum RankTwoTensorTempl::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 92 of file RankTwoTensor.h.

◆ InitMethod

template<typename T>
enum RankTwoTensorTempl::InitMethod
Enumerator
initNone 
initIdentity 

Definition at line 75 of file RankTwoTensor.h.

Constructor & Destructor Documentation

◆ RankTwoTensorTempl() [1/9]

template<typename T >
RankTwoTensorTempl< T >::RankTwoTensorTempl ( )

Default constructor; fills to zero.

Definition at line 63 of file RankTwoTensor.C.

Referenced by RankTwoTensorTempl< Real >::Identity().

64 {
65  mooseAssert(N == 3, "RankTwoTensorTempl is currently only tested for 3 dimensions.");
66 
67  for (unsigned int i = 0; i < N2; i++)
68  this->_coords[i] = 0.0;
69 }
static constexpr unsigned int N
static constexpr unsigned int N2

◆ RankTwoTensorTempl() [2/9]

template<typename T >
RankTwoTensorTempl< T >::RankTwoTensorTempl ( const InitMethod  init)

Select specific initialization pattern.

Definition at line 72 of file RankTwoTensor.C.

73 {
74  switch (init)
75  {
76  case initNone:
77  break;
78 
79  case initIdentity:
80  this->zero();
81  for (unsigned int i = 0; i < N; ++i)
82  (*this)(i, i) = 1.0;
83  break;
84 
85  default:
86  mooseError("Unknown RankTwoTensorTempl initialization pattern.");
87  }
88 }
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

◆ RankTwoTensorTempl() [3/9]

template<typename T>
RankTwoTensorTempl< T >::RankTwoTensorTempl ( const TypeVector< T > &  row1,
const TypeVector< T > &  row2,
const TypeVector< T > &  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 92 of file RankTwoTensor.C.

95 {
96  // Initialize the Tensor matrix from the passed in vectors
97  for (unsigned int i = 0; i < N; i++)
98  this->_coords[i] = row1(i);
99 
100  for (unsigned int i = 0; i < N; i++)
101  this->_coords[N + i] = row2(i);
102 
103  const unsigned int two_n = N * 2;
104  for (unsigned int i = 0; i < N; i++)
105  this->_coords[two_n + i] = row3(i);
106 }
static constexpr unsigned int N

◆ RankTwoTensorTempl() [4/9]

template<typename T>
RankTwoTensorTempl< T >::RankTwoTensorTempl ( const std::vector< T > &  input)
inline

Constructor that proxies the fillFromInputVector method.

Definition at line 120 of file RankTwoTensor.h.

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

◆ RankTwoTensorTempl() [5/9]

template<typename T>
RankTwoTensorTempl< T >::RankTwoTensorTempl ( S11,
S22,
S33,
S23,
S13,
S12 
)

Initialization list replacement constructors, 6 arguments.

Definition at line 129 of file RankTwoTensor.C.

130 {
131  (*this)(0, 0) = S11;
132  (*this)(1, 1) = S22;
133  (*this)(2, 2) = S33;
134  (*this)(1, 2) = (*this)(2, 1) = S23;
135  (*this)(0, 2) = (*this)(2, 0) = S13;
136  (*this)(0, 1) = (*this)(1, 0) = S12;
137 }

◆ RankTwoTensorTempl() [6/9]

template<typename T>
RankTwoTensorTempl< T >::RankTwoTensorTempl ( S11,
S21,
S31,
S12,
S22,
S32,
S13,
S23,
S33 
)

Initialization list replacement constructors, 9 arguments.

Definition at line 140 of file RankTwoTensor.C.

142 {
143  (*this)(0, 0) = S11;
144  (*this)(1, 0) = S21;
145  (*this)(2, 0) = S31;
146  (*this)(0, 1) = S12;
147  (*this)(1, 1) = S22;
148  (*this)(2, 1) = S32;
149  (*this)(0, 2) = S13;
150  (*this)(1, 2) = S23;
151  (*this)(2, 2) = S33;
152 }

◆ RankTwoTensorTempl() [7/9]

template<typename T>
RankTwoTensorTempl< T >::RankTwoTensorTempl ( const TensorValue< T > &  a)
inline

Copy constructor from TensorValue<T>

Definition at line 129 of file RankTwoTensor.h.

129 : TensorValue<T>(a) {}

◆ RankTwoTensorTempl() [8/9]

template<typename T>
RankTwoTensorTempl< T >::RankTwoTensorTempl ( const TypeTensor< T > &  a)
inline

Copy constructor from TypeTensor<T>

Definition at line 132 of file RankTwoTensor.h.

132 : TensorValue<T>(a) {}

◆ RankTwoTensorTempl() [9/9]

template<typename T>
template<typename T2 >
RankTwoTensorTempl< T >::RankTwoTensorTempl ( const RankTwoTensorTempl< T2 > &  a)
inline

Construct from other template.

Definition at line 136 of file RankTwoTensor.h.

136  : TensorValue<T>(a)
137  {
138  }

Member Function Documentation

◆ addIa()

template<typename T>
void RankTwoTensorTempl< T >::addIa ( const T &  a)

Add identity times a to _coords.

Definition at line 834 of file RankTwoTensor.C.

Referenced by RankTwoTensorTempl< Real >::deviatoric().

835 {
836  for (unsigned int i = 0; i < N; ++i)
837  (*this)(i, i) += a;
838 }
static constexpr unsigned int N

◆ column()

template<typename T >
TypeVector< T > RankTwoTensorTempl< T >::column ( const unsigned int  c) const

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

Definition at line 239 of file RankTwoTensor.C.

Referenced by RankTwoTensorTempl< Real >::positiveProjectionEigenDecomposition().

240 {
241  VectorValue<T> result;
242 
243  for (unsigned int i = 0; i < N; ++i)
244  result(i) = (*this)(i, c);
245 
246  return result;
247 }
static constexpr unsigned int N

◆ d2secondInvariant()

template<typename T >
RankFourTensorTempl< T > RankTwoTensorTempl< T >::d2secondInvariant ( ) const

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

Definition at line 579 of file RankTwoTensor.C.

580 {
581  RankFourTensorTempl<T> result;
582 
583  unsigned int index = 0;
584  for (unsigned int i = 0; i < N; ++i)
585  for (unsigned int j = 0; j < N; ++j)
586  for (unsigned int k = 0; k < N; ++k)
587  for (unsigned int l = 0; l < N; ++l)
588  result._vals[index++] = 0.5 * (i == k) * (j == l) + 0.5 * (i == l) * (j == k) -
589  (1.0 / 3.0) * (i == j) * (k == l);
590 
591  return result;
592 }
RankFourTensorTempl is designed to handle any N-dimensional fourth order tensor, C.
Definition: MooseTypes.h:115
static constexpr unsigned int N
T _vals[N4]
The values of the rank-four tensor stored by index=(((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) * LIBME...

◆ d2sin3Lode()

template<typename T>
RankFourTensorTempl< T > RankTwoTensorTempl< T >::d2sin3Lode ( const T &  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 776 of file RankTwoTensor.C.

777 {
778  T bar = secondInvariant();
779  if (bar <= r0)
780  return RankFourTensorTempl<T>();
781 
782  T J3 = thirdInvariant();
785  RankFourTensorTempl<T> deriv =
786  d2thirdInvariant() / std::pow(bar, 1.5) - 1.5 * d2secondInvariant() * J3 / std::pow(bar, 2.5);
787 
788  for (unsigned i = 0; i < N; ++i)
789  for (unsigned j = 0; j < N; ++j)
790  for (unsigned k = 0; k < N; ++k)
791  for (unsigned l = 0; l < N; ++l)
792  deriv(i, j, k, l) +=
793  (-1.5 * dII(i, j) * dIII(k, l) - 1.5 * dIII(i, j) * dII(k, l)) / std::pow(bar, 2.5) +
794  1.5 * 2.5 * dII(i, j) * dII(k, l) * J3 / std::pow(bar, 3.5);
795 
796  deriv *= -1.5 * std::sqrt(3.0);
797  return deriv;
798 }
RankFourTensorTempl is designed to handle any N-dimensional fourth order tensor, C.
Definition: MooseTypes.h:115
RankTwoTensorTempl< T > dsecondInvariant() const
Denote the _coords[i][j] by A_ij, then this returns d(secondInvariant)/dA_ij.
RankFourTensorTempl< T > d2secondInvariant() const
Denote the _coords[i][j] by A_ij, then this returns d^2(secondInvariant)/dA_ij/dA_kl.
T secondInvariant() const
Calculates the second invariant (I2) of a tensor.
RankTwoTensorTempl< T > dthirdInvariant() const
Denote the _coords[i][j] by A_ij, then this returns d(thirdInvariant()/dA_ij.
static constexpr unsigned int N
Real pow(Real x, int e)
Definition: MathUtils.C:211
RankFourTensorTempl< T > d2thirdInvariant() const
Denote the _coords[i][j] by A_ij, then this returns d^2(thirdInvariant)/dA_ij/dA_kl.
T 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...
RankTwoTensorTempl is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: MooseTypes.h:111

◆ d2symmetricEigenvalues()

template<typename T>
void RankTwoTensorTempl< T >::d2symmetricEigenvalues ( std::vector< RankFourTensorTempl< T >> &  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 933 of file RankTwoTensor.C.

934 {
935  std::vector<T> eigvec;
936  std::vector<T> eigvals;
937  T ev[N][N];
938 
939  // reset rank four tensor
940  deriv.assign(N, RankFourTensorTempl<T>());
941 
942  // get eigen values and eigen vectors
943  syev("V", eigvals, eigvec);
944 
945  for (unsigned int i = 0; i < N; ++i)
946  for (unsigned int j = 0; j < N; ++j)
947  ev[i][j] = eigvec[i * N + j];
948 
949  for (unsigned int alpha = 0; alpha < N; ++alpha)
950  for (unsigned int beta = 0; beta < N; ++beta)
951  {
952  if (eigvals[alpha] == eigvals[beta])
953  continue;
954 
955  for (unsigned int i = 0; i < N; ++i)
956  for (unsigned int j = 0; j < N; ++j)
957  for (unsigned int k = 0; k < N; ++k)
958  for (unsigned int l = 0; l < N; ++l)
959  {
960  deriv[alpha](i, j, k, l) +=
961  0.5 * (ev[beta][i] * ev[alpha][j] + ev[alpha][i] * ev[beta][j]) *
962  (ev[beta][k] * ev[alpha][l] + ev[beta][l] * ev[alpha][k]) /
963  (eigvals[alpha] - eigvals[beta]);
964  }
965  }
966 }
RankFourTensorTempl is designed to handle any N-dimensional fourth order tensor, C.
Definition: MooseTypes.h:115
static constexpr unsigned int N
void syev(const char *calculation_type, std::vector< T > &eigvals, std::vector< T > &a) const
Uses the petscblaslapack.h LAPACKsyev_ routine to find, for symmetric _coords: (1) the eigenvalues (i...

◆ d2thirdInvariant()

template<typename T >
RankFourTensorTempl< T > RankTwoTensorTempl< T >::d2thirdInvariant ( ) const

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

Definition at line 657 of file RankTwoTensor.C.

658 {
659  RankTwoTensorTempl<T> s = 0.5 * deviatoric();
660  s += s.transpose();
661 
663  unsigned int index = 0;
664  for (unsigned int i = 0; i < N; ++i)
665  for (unsigned int j = 0; j < N; ++j)
666  for (unsigned int k = 0; k < N; ++k)
667  for (unsigned int l = 0; l < N; ++l)
668  {
669  d2._vals[index++] = (i == j) * s(k, l) / 3.0 + (k == l) * s(i, j) / 3.0;
670  // for (unsigned int a = 0; a < N; ++a)
671  // for (unsigned int b = 0; b < N; ++b)
672  // d2(i, j, k, l) += 0.5*(PermutationTensor::eps(i, k, a)*PermutationTensor::eps(j, l,
673  // b) + PermutationTensor::eps(i, l, a)*PermutationTensor::eps(j, k, b))*s(a, b);
674  }
675 
676  // I'm not sure which is more readable: the above
677  // PermutationTensor stuff, or the stuff below.
678  // Anyway, they yield the same result, and so i leave
679  // both of them here to enlighten you!
680 
681  d2(0, 0, 1, 1) += s(2, 2);
682  d2(0, 0, 1, 2) -= s(2, 1);
683  d2(0, 0, 2, 1) -= s(1, 2);
684  d2(0, 0, 2, 2) += s(1, 1);
685 
686  d2(0, 1, 0, 1) -= s(2, 2) / 2.0;
687  d2(0, 1, 1, 0) -= s(2, 2) / 2.0;
688  d2(0, 1, 0, 2) += s(1, 2) / 2.0;
689  d2(0, 1, 2, 0) += s(1, 2) / 2.0;
690  d2(0, 1, 1, 2) += s(2, 0) / 2.0;
691  d2(0, 1, 2, 1) += s(2, 0) / 2.0;
692  d2(0, 1, 2, 2) -= s(1, 0);
693 
694  d2(0, 2, 0, 1) += s(2, 1) / 2.0;
695  d2(0, 2, 1, 0) += s(2, 1) / 2.0;
696  d2(0, 2, 0, 2) -= s(1, 1) / 2.0;
697  d2(0, 2, 2, 0) -= s(1, 1) / 2.0;
698  d2(0, 2, 1, 1) -= s(2, 0);
699  d2(0, 2, 1, 2) += s(1, 0) / 2.0;
700  d2(0, 2, 2, 1) += s(1, 0) / 2.0;
701 
702  d2(1, 0, 0, 1) -= s(2, 2) / 2.0;
703  d2(1, 0, 1, 0) -= s(2, 2) / 2.0;
704  d2(1, 0, 0, 2) += s(1, 2) / 2.0;
705  d2(1, 0, 2, 0) += s(1, 2) / 2.0;
706  d2(1, 0, 1, 2) += s(2, 0) / 2.0;
707  d2(1, 0, 2, 1) += s(2, 0) / 2.0;
708  d2(1, 0, 2, 2) -= s(1, 0);
709 
710  d2(1, 1, 0, 0) += s(2, 2);
711  d2(1, 1, 0, 2) -= s(2, 0);
712  d2(1, 1, 2, 0) -= s(2, 0);
713  d2(1, 1, 2, 2) += s(0, 0);
714 
715  d2(1, 2, 0, 0) -= s(2, 1);
716  d2(1, 2, 0, 1) += s(2, 0) / 2.0;
717  d2(1, 2, 1, 0) += s(2, 0) / 2.0;
718  d2(1, 2, 0, 2) += s(0, 1) / 2.0;
719  d2(1, 2, 2, 0) += s(0, 1) / 2.0;
720  d2(1, 2, 1, 2) -= s(0, 0) / 2.0;
721  d2(1, 2, 2, 1) -= s(0, 0) / 2.0;
722 
723  d2(2, 0, 0, 1) += s(2, 1) / 2.0;
724  d2(2, 0, 1, 0) += s(2, 1) / 2.0;
725  d2(2, 0, 0, 2) -= s(1, 1) / 2.0;
726  d2(2, 0, 2, 0) -= s(1, 1) / 2.0;
727  d2(2, 0, 1, 1) -= s(2, 0);
728  d2(2, 0, 1, 2) += s(1, 0) / 2.0;
729  d2(2, 0, 2, 1) += s(1, 0) / 2.0;
730 
731  d2(2, 1, 0, 0) -= s(2, 1);
732  d2(2, 1, 0, 1) += s(2, 0) / 2.0;
733  d2(2, 1, 1, 0) += s(2, 0) / 2.0;
734  d2(2, 1, 0, 2) += s(0, 1) / 2.0;
735  d2(2, 1, 2, 0) += s(0, 1) / 2.0;
736  d2(2, 1, 1, 2) -= s(0, 0) / 2.0;
737  d2(2, 1, 2, 1) -= s(0, 0) / 2.0;
738 
739  d2(2, 2, 0, 0) += s(1, 1);
740  d2(2, 2, 0, 1) -= s(1, 0);
741  d2(2, 2, 1, 0) -= s(1, 0);
742  d2(2, 2, 1, 1) += s(0, 0);
743 
744  return d2;
745 }
RankFourTensorTempl is designed to handle any N-dimensional fourth order tensor, C.
Definition: MooseTypes.h:115
static constexpr unsigned int N
RankTwoTensorTempl< T > deviatoric() const
returns A_ij - de_ij*tr(A)/3, where A are the _coords
T _vals[N4]
The values of the rank-four tensor stored by index=(((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) * LIBME...
RankTwoTensorTempl< T > transpose() const
Returns a matrix that is the transpose of the matrix this was called on.
RankTwoTensorTempl is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: MooseTypes.h:111

◆ ddet()

template<typename T >
RankTwoTensorTempl< T > RankTwoTensorTempl< T >::ddet ( ) const

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

Definition at line 802 of file RankTwoTensor.C.

803 {
805 
806  d(0, 0) = (*this)(1, 1) * (*this)(2, 2) - (*this)(2, 1) * (*this)(1, 2);
807  d(0, 1) = (*this)(2, 0) * (*this)(1, 2) - (*this)(1, 0) * (*this)(2, 2);
808  d(0, 2) = (*this)(1, 0) * (*this)(2, 1) - (*this)(2, 0) * (*this)(1, 1);
809  d(1, 0) = (*this)(2, 1) * (*this)(0, 2) - (*this)(0, 1) * (*this)(2, 2);
810  d(1, 1) = (*this)(0, 0) * (*this)(2, 2) - (*this)(2, 0) * (*this)(0, 2);
811  d(1, 2) = (*this)(2, 0) * (*this)(0, 1) - (*this)(0, 0) * (*this)(2, 1);
812  d(2, 0) = (*this)(0, 1) * (*this)(1, 2) - (*this)(1, 1) * (*this)(0, 2);
813  d(2, 1) = (*this)(1, 0) * (*this)(0, 2) - (*this)(0, 0) * (*this)(1, 2);
814  d(2, 2) = (*this)(0, 0) * (*this)(1, 1) - (*this)(1, 0) * (*this)(0, 1);
815 
816  return d;
817 }
RankTwoTensorTempl is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: MooseTypes.h:111

◆ deviatoric()

template<typename T >
RankTwoTensorTempl< T > RankTwoTensorTempl< T >::deviatoric ( ) const

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

Definition at line 529 of file RankTwoTensor.C.

530 {
532  deviatoric.addIa(-1.0 / 3.0 * this->tr()); // actually construct deviatoric part
533  return deviatoric;
534 }
RankTwoTensorTempl< T > deviatoric() const
returns A_ij - de_ij*tr(A)/3, where A are the _coords
RankTwoTensorTempl is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: MooseTypes.h:111

◆ doubleContraction()

template<typename T>
T RankTwoTensorTempl< T >::doubleContraction ( const RankTwoTensorTempl< T > &  a) const

returns _coords_ij * a_ij (sum on i, j)

Definition at line 400 of file RankTwoTensor.C.

401 {
402  // deprecate this!
403  return TensorValue<T>::contract(b);
404 }

◆ dsecondInvariant()

template<typename T >
RankTwoTensorTempl< T > RankTwoTensorTempl< T >::dsecondInvariant ( ) const

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

Definition at line 572 of file RankTwoTensor.C.

573 {
574  return 0.5 * (deviatoric() + deviatoric().transpose());
575 }
RankTwoTensorTempl< T > deviatoric() const
returns A_ij - de_ij*tr(A)/3, where A are the _coords

◆ dsin3Lode()

template<typename T>
RankTwoTensorTempl< T > RankTwoTensorTempl< T >::dsin3Lode ( const T &  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 763 of file RankTwoTensor.C.

764 {
765  T bar = secondInvariant();
766  if (bar <= r0)
767  return RankTwoTensorTempl<T>();
768  else
769  return -1.5 * std::sqrt(3.0) *
770  (dthirdInvariant() / std::pow(bar, 1.5) -
771  1.5 * dsecondInvariant() * thirdInvariant() / std::pow(bar, 2.5));
772 }
RankTwoTensorTempl< T > dsecondInvariant() const
Denote the _coords[i][j] by A_ij, then this returns d(secondInvariant)/dA_ij.
T secondInvariant() const
Calculates the second invariant (I2) of a tensor.
RankTwoTensorTempl< T > dthirdInvariant() const
Denote the _coords[i][j] by A_ij, then this returns d(thirdInvariant()/dA_ij.
Real pow(Real x, int e)
Definition: MathUtils.C:211
T 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...
RankTwoTensorTempl is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: MooseTypes.h:111

◆ dsymmetricEigenvalues()

template<typename T>
void RankTwoTensorTempl< T >::dsymmetricEigenvalues ( std::vector< T > &  eigvals,
std::vector< RankTwoTensorTempl< T >> &  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 894 of file RankTwoTensor.C.

896 {
897  deigvals.resize(N);
898 
899  std::vector<T> a;
900  syev("V", eigvals, a);
901 
902  // now a contains the eigenvetors
903  // extract these and place appropriately in deigvals
904  std::vector<T> eig_vec;
905  eig_vec.resize(N);
906 
907  for (unsigned int i = 0; i < N; ++i)
908  {
909  for (unsigned int j = 0; j < N; ++j)
910  eig_vec[j] = a[i * N + j];
911  for (unsigned int j = 0; j < N; ++j)
912  for (unsigned int k = 0; k < N; ++k)
913  deigvals[i](j, k) = eig_vec[j] * eig_vec[k];
914  }
915 
916  // There are discontinuities in the derivative
917  // for equal eigenvalues. The following is
918  // an attempt to make a sensible choice for
919  // the derivative. This agrees with a central-difference
920  // approximation to the derivative.
921  if (eigvals[0] == eigvals[1] && eigvals[0] == eigvals[2])
922  deigvals[0] = deigvals[1] = deigvals[2] = (deigvals[0] + deigvals[1] + deigvals[2]) / 3.0;
923  else if (eigvals[0] == eigvals[1])
924  deigvals[0] = deigvals[1] = (deigvals[0] + deigvals[1]) / 2.0;
925  else if (eigvals[0] == eigvals[2])
926  deigvals[0] = deigvals[2] = (deigvals[0] + deigvals[2]) / 2.0;
927  else if (eigvals[1] == eigvals[2])
928  deigvals[1] = deigvals[2] = (deigvals[1] + deigvals[2]) / 2.0;
929 }
static constexpr unsigned int N
void syev(const char *calculation_type, std::vector< T > &eigvals, std::vector< T > &a) const
Uses the petscblaslapack.h LAPACKsyev_ routine to find, for symmetric _coords: (1) the eigenvalues (i...

◆ dthirdInvariant()

template<typename T >
RankTwoTensorTempl< T > RankTwoTensorTempl< T >::dthirdInvariant ( ) const

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

Definition at line 634 of file RankTwoTensor.C.

635 {
636  RankTwoTensorTempl<T> s = 0.5 * deviatoric();
637  s += s.transpose();
638 
640  T sec_over_three = secondInvariant() / 3.0;
641 
642  d(0, 0) = s(1, 1) * s(2, 2) - s(2, 1) * s(1, 2) + sec_over_three;
643  d(0, 1) = s(2, 0) * s(1, 2) - s(1, 0) * s(2, 2);
644  d(0, 2) = s(1, 0) * s(2, 1) - s(2, 0) * s(1, 1);
645  d(1, 0) = s(2, 1) * s(0, 2) - s(0, 1) * s(2, 2);
646  d(1, 1) = s(0, 0) * s(2, 2) - s(2, 0) * s(0, 2) + sec_over_three;
647  d(1, 2) = s(2, 0) * s(0, 1) - s(0, 0) * s(2, 1);
648  d(2, 0) = s(0, 1) * s(1, 2) - s(1, 1) * s(0, 2);
649  d(2, 1) = s(1, 0) * s(0, 2) - s(0, 0) * s(1, 2);
650  d(2, 2) = s(0, 0) * s(1, 1) - s(1, 0) * s(0, 1) + sec_over_three;
651 
652  return d;
653 }
T secondInvariant() const
Calculates the second invariant (I2) of a tensor.
RankTwoTensorTempl< T > deviatoric() const
returns A_ij - de_ij*tr(A)/3, where A are the _coords
RankTwoTensorTempl< T > transpose() const
Returns a matrix that is the transpose of the matrix this was called on.
RankTwoTensorTempl is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: MooseTypes.h:111

◆ dtrace()

template<typename T >
RankTwoTensorTempl< T > RankTwoTensorTempl< T >::dtrace ( ) const

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

Definition at line 611 of file RankTwoTensor.C.

612 {
613  return RankTwoTensorTempl<T>(1, 0, 0, 0, 1, 0, 0, 0, 1);
614 }
RankTwoTensorTempl is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: MooseTypes.h:111

◆ fillColumn()

template<typename T>
void RankTwoTensorTempl< T >::fillColumn ( unsigned int  c,
const TypeVector< T > &  v 
)

Assigns value to the rows of a specified column.

Definition at line 1115 of file RankTwoTensor.C.

1116 {
1117  for (unsigned int i = 0; i < N; ++i)
1118  (*this)(i, c) = v(i);
1119 }
static constexpr unsigned int N

◆ fillFromInputVector()

template<typename T>
void RankTwoTensorTempl< T >::fillFromInputVector ( const std::vector< T > &  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 156 of file RankTwoTensor.C.

Referenced by GenericConstantRankTwoTensor::GenericConstantRankTwoTensor(), and RankTwoTensorTempl< Real >::RankTwoTensorTempl().

157 {
158  if (fill_method != autodetect && fill_method != input.size())
159  mooseError("Expected an input vector size of ", fill_method, " to fill the RankTwoTensorTempl");
160 
161  switch (input.size())
162  {
163  case 1:
164  this->zero();
165  (*this)(0, 0) = input[0]; // S11
166  (*this)(1, 1) = input[0]; // S22
167  (*this)(2, 2) = input[0]; // S33
168  break;
169 
170  case 3:
171  this->zero();
172  (*this)(0, 0) = input[0]; // S11
173  (*this)(1, 1) = input[1]; // S22
174  (*this)(2, 2) = input[2]; // S33
175  break;
176 
177  case 6:
178  (*this)(0, 0) = input[0]; // S11
179  (*this)(1, 1) = input[1]; // S22
180  (*this)(2, 2) = input[2]; // S33
181  (*this)(1, 2) = (*this)(2, 1) = input[3]; // S23
182  (*this)(0, 2) = (*this)(2, 0) = input[4]; // S13
183  (*this)(0, 1) = (*this)(1, 0) = input[5]; // S12
184  break;
185 
186  case 9:
187  (*this)(0, 0) = input[0]; // S11
188  (*this)(1, 0) = input[1]; // S21
189  (*this)(2, 0) = input[2]; // S31
190  (*this)(0, 1) = input[3]; // S12
191  (*this)(1, 1) = input[4]; // S22
192  (*this)(2, 1) = input[5]; // S32
193  (*this)(0, 2) = input[6]; // S13
194  (*this)(1, 2) = input[7]; // S23
195  (*this)(2, 2) = input[8]; // S33
196  break;
197 
198  default:
199  mooseError("Please check the number of entries in the input vector for building "
200  "a RankTwoTensorTempl. It must be 1, 3, 6, or 9");
201  }
202 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208

◆ fillFromScalarVariable()

template<typename T >
void RankTwoTensorTempl< T >::fillFromScalarVariable ( const VariableValue scalar_variable)

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

Definition at line 206 of file RankTwoTensor.C.

207 {
208  switch (scalar_variable.size())
209  {
210  case 1:
211  this->zero();
212  (*this)(0, 0) = scalar_variable[0]; // S11
213  break;
214 
215  case 3:
216  this->zero();
217  (*this)(0, 0) = scalar_variable[0]; // S11
218  (*this)(1, 1) = scalar_variable[1]; // S22
219  (*this)(0, 1) = (*this)(1, 0) = scalar_variable[2]; // S12
220  break;
221 
222  case 6:
223  (*this)(0, 0) = scalar_variable[0]; // S11
224  (*this)(1, 1) = scalar_variable[1]; // S22
225  (*this)(2, 2) = scalar_variable[2]; // S33
226  (*this)(1, 2) = (*this)(2, 1) = scalar_variable[3]; // S23
227  (*this)(0, 2) = (*this)(2, 0) = scalar_variable[4]; // S13
228  (*this)(0, 1) = (*this)(1, 0) = scalar_variable[5]; // S12
229  break;
230 
231  default:
232  mooseError("Only FIRST, THIRD, or SIXTH order scalar variable can be used to build "
233  "a RankTwoTensorTempl.");
234  }
235 }
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:260

◆ fillMethodEnum()

template<typename T >
MooseEnum RankTwoTensorTempl< T >::fillMethodEnum ( )
static

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

Definition at line 57 of file RankTwoTensor.C.

58 {
59  return MooseEnum("autodetect=0 isotropic1=1 diagonal3=3 symmetric6=6 general=9", "autodetect");
60 }
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()

template<typename T>
void RankTwoTensorTempl< T >::fillRealTensor ( TensorValue< T > &  tensor)

Return real tensor of a rank two tensor.

Definition at line 1098 of file RankTwoTensor.C.

1099 {
1100  for (unsigned int i = 0; i < N; ++i)
1101  for (unsigned int j = 0; j < N; ++j)
1102  tensor(i, j) = (*this)(i, j);
1103 }
static constexpr unsigned int N

◆ fillRow()

template<typename T>
void RankTwoTensorTempl< T >::fillRow ( unsigned int  r,
const TypeVector< T > &  v 
)

Assigns value to the columns of a specified row.

Definition at line 1107 of file RankTwoTensor.C.

1108 {
1109  for (unsigned int i = 0; i < N; ++i)
1110  (*this)(r, i) = v(i);
1111 }
static constexpr unsigned int N

◆ generalSecondInvariant()

template<typename T >
T RankTwoTensorTempl< T >::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 538 of file RankTwoTensor.C.

539 {
540  // clang-format off
541  T result = (*this)(0, 0) * (*this)(1, 1) +
542  (*this)(0, 0) * (*this)(2, 2) +
543  (*this)(1, 1) * (*this)(2, 2) -
544  (*this)(0, 1) * (*this)(1, 0) -
545  (*this)(0, 2) * (*this)(2, 0) -
546  (*this)(1, 2) * (*this)(2, 1);
547  // clang-format on
548  return result;
549 }

◆ genRandomSymmTensor()

template<typename T>
RankTwoTensorTempl< T > RankTwoTensorTempl< T >::genRandomSymmTensor ( scale,
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 1076 of file RankTwoTensor.C.

1077 {
1078  RankTwoTensorTempl<T> tensor;
1079 
1080  for (unsigned int i = 0; i < N; i++)
1081  for (unsigned int j = i; j < N; j++)
1082  tensor(i, j) = tensor(j, i) = (MooseRandom::rand() + offset) * scale;
1083 
1084  return tensor;
1085 }
static double rand()
This method returns the next random number (double format) from the generator.
Definition: MooseRandom.h:50
static constexpr unsigned int N
RankTwoTensorTempl is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: MooseTypes.h:111

◆ genRandomTensor()

template<typename T>
RankTwoTensorTempl< T > RankTwoTensorTempl< T >::genRandomTensor ( scale,
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 1063 of file RankTwoTensor.C.

1064 {
1065  RankTwoTensorTempl<T> tensor;
1066 
1067  for (unsigned int i = 0; i < N; i++)
1068  for (unsigned int j = 0; j < N; j++)
1069  tensor(i, j) = (MooseRandom::rand() + offset) * scale;
1070 
1071  return tensor;
1072 }
static double rand()
This method returns the next random number (double format) from the generator.
Definition: MooseRandom.h:50
static constexpr unsigned int N
RankTwoTensorTempl is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: MooseTypes.h:111

◆ getRUDecompositionRotation() [1/2]

template<typename T>
void RankTwoTensorTempl< T >::getRUDecompositionRotation ( RankTwoTensorTempl< T > &  rot) const

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

Definition at line 1012 of file RankTwoTensor.C.

1013 {
1014  const RankTwoTensorTempl<T> & a = *this;
1015  RankTwoTensorTempl<T> c, diag, evec;
1016  PetscScalar cmat[N][N], work[10];
1017  PetscReal w[N];
1018 
1019  // prepare data for the LAPACKsyev_ routine (which comes from petscblaslapack.h)
1020  PetscBLASInt nd = N, lwork = 10, info;
1021 
1022  c = a.transpose() * a;
1023 
1024  for (unsigned int i = 0; i < N; ++i)
1025  for (unsigned int j = 0; j < N; ++j)
1026  cmat[i][j] = c(i, j);
1027 
1028  LAPACKsyev_("V", "U", &nd, &cmat[0][0], &nd, w, work, &lwork, &info);
1029 
1030  if (info != 0)
1031  mooseError("In computing the eigenvalues and eigenvectors of a symmetric rank-2 tensor, the "
1032  "PETSC LAPACK syev routine returned error code ",
1033  info);
1034 
1035  diag.zero();
1036 
1037  for (unsigned int i = 0; i < N; ++i)
1038  diag(i, i) = std::sqrt(w[i]);
1039 
1040  for (unsigned int i = 0; i < N; ++i)
1041  for (unsigned int j = 0; j < N; ++j)
1042  evec(i, j) = cmat[i][j];
1043 
1044  rot = a * ((evec.transpose() * diag * evec).inverse());
1045 }
RankTwoTensorTempl< T > inverse() const
retuns the inverse of the tensor
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
RankTwoTensorTempl< T > transpose() const
Returns a matrix that is the transpose of the matrix this was called on.
RankTwoTensorTempl is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: MooseTypes.h:111

◆ getRUDecompositionRotation() [2/2]

template<>
void RankTwoTensorTempl< DualReal >::getRUDecompositionRotation ( RankTwoTensorTempl< DualReal > &  ) const

Definition at line 1049 of file RankTwoTensor.C.

1050 {
1051  mooseError("DualRankTwoTensor does not support getRUDecompositionRotation");
1052 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208

◆ Identity()

template<typename T>
static RankTwoTensorTempl RankTwoTensorTempl< T >::Identity ( )
inlinestatic

Definition at line 141 of file RankTwoTensor.h.

141 { return RankTwoTensorTempl(initIdentity); }
RankTwoTensorTempl()
Default constructor; fills to zero.
Definition: RankTwoTensor.C:63

◆ initialContraction()

template<typename T>
RankTwoTensorTempl< T > RankTwoTensorTempl< T >::initialContraction ( const RankFourTensorTempl< T > &  b) const

returns this_ij * b_ijkl

Definition at line 1123 of file RankTwoTensor.C.

1124 {
1125  RankTwoTensorTempl<T> result;
1126 
1127  unsigned int index = 0;
1128  for (unsigned int i = 0; i < N; ++i)
1129  for (unsigned int j = 0; j < N; ++j)
1130  {
1131  const T & a = (*this)(i, j);
1132  for (unsigned int k = 0; k < N; ++k)
1133  for (unsigned int l = 0; l < N; ++l)
1134  result(k, l) += a * b._vals[index++];
1135  }
1136 
1137  return result;
1138 }
static constexpr unsigned int N
T _vals[N4]
The values of the rank-four tensor stored by index=(((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) * LIBME...
RankTwoTensorTempl is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: MooseTypes.h:111

◆ initializeFromColumns()

template<typename T>
RankTwoTensorTempl< T > RankTwoTensorTempl< T >::initializeFromColumns ( const TypeVector< T > &  col0,
const TypeVector< T > &  col1,
const TypeVector< T > &  col2 
)
static

named constructor for initializing from column vectors

Definition at line 120 of file RankTwoTensor.C.

123 {
124  return RankTwoTensorTempl<T>(
125  col0(0), col0(1), col0(2), col1(0), col1(1), col1(2), col2(0), col2(1), col2(2));
126 }
RankTwoTensorTempl is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: MooseTypes.h:111

◆ initializeFromRows()

template<typename T>
RankTwoTensorTempl< T > RankTwoTensorTempl< T >::initializeFromRows ( const TypeVector< T > &  row0,
const TypeVector< T > &  row1,
const TypeVector< T > &  row2 
)
static

named constructor for initializing from row vectors

Definition at line 110 of file RankTwoTensor.C.

113 {
114  return RankTwoTensorTempl<T>(
115  row0(0), row1(0), row2(0), row0(1), row1(1), row2(1), row0(2), row1(2), row2(2));
116 }
RankTwoTensorTempl is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: MooseTypes.h:111

◆ initRandom()

template<typename T >
void RankTwoTensorTempl< T >::initRandom ( unsigned int  rand_seed)
static

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

Definition at line 1056 of file RankTwoTensor.C.

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

◆ inverse()

template<typename T >
RankTwoTensorTempl< T > RankTwoTensorTempl< T >::inverse ( ) const

retuns the inverse of the tensor

Definition at line 604 of file RankTwoTensor.C.

605 {
606  return TensorValue<T>::inverse();
607 }
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()

template<typename T >
T RankTwoTensorTempl< T >::L2norm ( ) const

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

Definition at line 842 of file RankTwoTensor.C.

843 {
844  T norm = 0.0;
845  for (unsigned int i = 0; i < N2; ++i)
846  {
847  T v = this->_coords[i];
848  norm += v * v;
849  }
850  return norm == 0.0 ? 0.0 : std::sqrt(norm);
851 }
static constexpr unsigned int N2

◆ mixedProductIkJl()

template<typename T>
RankFourTensorTempl< T > RankTwoTensorTempl< T >::mixedProductIkJl ( const RankTwoTensorTempl< T > &  a) const

returns C_ijkl = a_ik * b_jl

Definition at line 425 of file RankTwoTensor.C.

Referenced by RankTwoTensorTempl< Real >::positiveProjectionEigenDecomposition().

426 {
427  RankFourTensorTempl<T> result;
428 
429  unsigned int index = 0;
430  for (unsigned int i = 0; i < N; ++i)
431  for (unsigned int j = 0; j < N; ++j)
432  for (unsigned int k = 0; k < N; ++k)
433  {
434  const T & a = (*this)(i, k);
435  for (unsigned int l = 0; l < N; ++l)
436  result._vals[index++] = a * b(j, l);
437  }
438 
439  return result;
440 }
RankFourTensorTempl is designed to handle any N-dimensional fourth order tensor, C.
Definition: MooseTypes.h:115
static constexpr unsigned int N
T _vals[N4]
The values of the rank-four tensor stored by index=(((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) * LIBME...

◆ mixedProductIlJk()

template<typename T>
RankFourTensorTempl< T > RankTwoTensorTempl< T >::mixedProductIlJk ( const RankTwoTensorTempl< T > &  a) const

returns C_ijkl = a_il * b_jk

Definition at line 444 of file RankTwoTensor.C.

Referenced by RankTwoTensorTempl< Real >::positiveProjectionEigenDecomposition().

445 {
446  RankFourTensorTempl<T> result;
447 
448  for (unsigned int i = 0; i < N; ++i)
449  for (unsigned int j = 0; j < N; ++j)
450  for (unsigned int k = 0; k < N; ++k)
451  for (unsigned int l = 0; l < N; ++l)
452  result(i, j, k, l) = (*this)(i, l) * b(j, k);
453 
454  return result;
455 }
RankFourTensorTempl is designed to handle any N-dimensional fourth order tensor, C.
Definition: MooseTypes.h:115
static constexpr unsigned int N

◆ mixedProductJkIl()

template<typename T>
RankFourTensorTempl< T > RankTwoTensorTempl< T >::mixedProductJkIl ( const RankTwoTensorTempl< T > &  a) const

returns C_ijkl = a_jk * b_il

Definition at line 459 of file RankTwoTensor.C.

460 {
461  RankFourTensorTempl<T> result;
462 
463  unsigned int index = 0;
464  for (unsigned int i = 0; i < N; ++i)
465  for (unsigned int j = 0; j < N; ++j)
466  for (unsigned int k = 0; k < N; ++k)
467  {
468  const T & a = (*this)(j, k);
469  for (unsigned int l = 0; l < N; ++l)
470  result._vals[index++] = a * b(i, l);
471  }
472 
473  return result;
474 }
RankFourTensorTempl is designed to handle any N-dimensional fourth order tensor, C.
Definition: MooseTypes.h:115
static constexpr unsigned int N
T _vals[N4]
The values of the rank-four tensor stored by index=(((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) * LIBME...

◆ operator*() [1/3]

template<typename T >
template<typename T2 , typename std::enable_if< ScalarTraits< T2 >::value, int >::type >
RankTwoTensorTempl< typename CompareTypes< T, T2 >::supertype > RankTwoTensorTempl< T >::operator* ( const T2 &  a) const

returns _coords*a

Definition at line 511 of file RankTwoTensor.h.

512 {
513  return TensorValue<T>::operator*(b);
514 }
auto operator*(const T1 &a, const RankFourTensorTempl< T2 > &b) -> typename std::enable_if< ScalarTraits< T1 >::value, RankFourTensorTempl< decltype(T1() *T2())>>::type

◆ operator*() [2/3]

template<typename T >
template<typename T2 >
TypeVector< typename CompareTypes< T, T2 >::supertype > RankTwoTensorTempl< T >::operator* ( const TypeVector< T2 > &  a) const

Defines multiplication with a vector to get a vector.

Definition at line 519 of file RankTwoTensor.h.

520 {
521  return TensorValue<T>::operator*(b);
522 }
auto operator*(const T1 &a, const RankFourTensorTempl< T2 > &b) -> typename std::enable_if< ScalarTraits< T1 >::value, RankFourTensorTempl< decltype(T1() *T2())>>::type

◆ operator*() [3/3]

template<typename T >
template<typename T2 >
RankTwoTensorTempl< typename CompareTypes< T, T2 >::supertype > RankTwoTensorTempl< T >::operator* ( const TypeTensor< T2 > &  a) const

Defines multiplication with a TypeTensor<T>

Definition at line 527 of file RankTwoTensor.h.

528 {
529  return TensorValue<T>::operator*(b);
530 }
auto operator*(const T1 &a, const RankFourTensorTempl< T2 > &b) -> typename std::enable_if< ScalarTraits< T1 >::value, RankFourTensorTempl< decltype(T1() *T2())>>::type

◆ operator*=() [1/2]

template<typename T>
RankTwoTensorTempl< T > & RankTwoTensorTempl< T >::operator*= ( const T &  a)

performs _coords *= a

Definition at line 349 of file RankTwoTensor.C.

350 {
351  TensorValue<T>::operator*=(a);
352  return *this;
353 }

◆ operator*=() [2/2]

template<typename T>
RankTwoTensorTempl< T > & RankTwoTensorTempl< T >::operator*= ( const TypeTensor< T > &  a)

Defines multiplication with a TypeTensor<T>

Definition at line 365 of file RankTwoTensor.C.

366 {
367  *this = *this * a;
368  return *this;
369 }

◆ operator+()

template<typename T >
template<typename T2 >
RankTwoTensorTempl< typename CompareTypes< T, T2 >::supertype > RankTwoTensorTempl< T >::operator+ ( const TypeTensor< T2 > &  a) const

returns _coords + a

Definition at line 495 of file RankTwoTensor.h.

496 {
497  return TensorValue<T>::operator+(b);
498 }

◆ operator+=()

template<typename T>
RankTwoTensorTempl< T > & RankTwoTensorTempl< T >::operator+= ( const RankTwoTensorTempl< T > &  a)

adds a to _coords

Definition at line 326 of file RankTwoTensor.C.

327 {
328  TensorValue<T>::operator+=(a);
329  return *this;
330 }

◆ operator-() [1/2]

template<typename T >
template<typename T2 >
RankTwoTensorTempl< typename CompareTypes< T, T2 >::supertype > RankTwoTensorTempl< T >::operator- ( const TypeTensor< T2 > &  a) const

returns _coords - a

Definition at line 503 of file RankTwoTensor.h.

504 {
505  return TensorValue<T>::operator-(b);
506 }

◆ operator-() [2/2]

template<typename T >
RankTwoTensorTempl< T > RankTwoTensorTempl< T >::operator- ( ) const

returns -_coords

Definition at line 342 of file RankTwoTensor.C.

343 {
344  return TensorValue<T>::operator-();
345 }

◆ operator-=()

template<typename T>
RankTwoTensorTempl< T > & RankTwoTensorTempl< T >::operator-= ( const RankTwoTensorTempl< T > &  a)

sets _coords -= a and returns vals

Definition at line 334 of file RankTwoTensor.C.

335 {
336  TensorValue<T>::operator-=(a);
337  return *this;
338 }

◆ operator/()

template<typename T >
template<typename T2 , typename std::enable_if< ScalarTraits< T2 >::value, int >::type >
RankTwoTensorTempl< typename CompareTypes< T, T2 >::supertype > RankTwoTensorTempl< T >::operator/ ( const T2 &  a) const

returns _coords/a

Definition at line 535 of file RankTwoTensor.h.

536 {
537  return TensorValue<T>::operator/(b);
538 }

◆ operator/=()

template<typename T>
RankTwoTensorTempl< T > & RankTwoTensorTempl< T >::operator/= ( const T &  a)

performs _coords /= a

Definition at line 357 of file RankTwoTensor.C.

358 {
359  TensorValue<T>::operator/=(a);
360  return *this;
361 }

◆ operator=() [1/3]

template<typename T>
RankTwoTensorTempl< T > & RankTwoTensorTempl< T >::operator= ( const RankTwoTensorTempl< T > &  a)

sets _coords to a, and returns _coords

Definition at line 318 of file RankTwoTensor.C.

319 {
320  TensorValue<T>::operator=(a);
321  return *this;
322 }

◆ operator=() [2/3]

template<typename T>
template<typename Scalar >
boostcopy::enable_if_c<ScalarTraits<Scalar>::value, RankTwoTensorTempl &>::type RankTwoTensorTempl< T >::operator= ( const Scalar &  libmesh_dbg_varp)
inline

Assignment-from-scalar operator.

Used only to zero out vectors.

Definition at line 203 of file RankTwoTensor.h.

204  {
205  libmesh_assert_equal_to(p, Scalar(0));
206  this->zero();
207  return *this;
208  }

◆ operator=() [3/3]

template<typename T>
RankTwoTensorTempl< T > & RankTwoTensorTempl< T >::operator= ( const ColumnMajorMatrixTempl< T > &  a)

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

Definition at line 385 of file RankTwoTensor.C.

386 {
387  if (a.n() != N || a.m() != N)
388  mooseError("Dimensions of ColumnMajorMatrixTempl<T> are incompatible with RankTwoTensorTempl");
389 
390  const T * cmm_rawdata = a.rawData();
391  for (unsigned int i = 0; i < N; ++i)
392  for (unsigned int j = 0; j < N; ++j)
393  this->_coords[i * N + j] = cmm_rawdata[i + j * N];
394 
395  return *this;
396 }
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
T * rawData()
Returns a reference to the raw data pointer.
unsigned int m() const
Returns the number of columns.
unsigned int n() const
Returns the number of rows.

◆ operator==()

template<typename T>
bool RankTwoTensorTempl< T >::operator== ( const RankTwoTensorTempl< T > &  a) const

Defines logical equality with another RankTwoTensorTempl<T>

Definition at line 373 of file RankTwoTensor.C.

374 {
375  for (unsigned int i = 0; i < N; ++i)
376  for (unsigned int j = 0; j < N; ++j)
377  if (!MooseUtils::absoluteFuzzyEqual((*this)(i, j), a(i, j)))
378  return false;
379 
380  return true;
381 }
bool absoluteFuzzyEqual(const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
Function to check whether two variables are equal within an absolute tolerance.
Definition: MooseUtils.h:231
static constexpr unsigned int N

◆ outerProduct()

template<typename T>
RankFourTensorTempl< T > RankTwoTensorTempl< T >::outerProduct ( const RankTwoTensorTempl< T > &  a) const

returns C_ijkl = a_ij * b_kl

Definition at line 408 of file RankTwoTensor.C.

Referenced by RankTwoTensorTempl< Real >::positiveProjectionEigenDecomposition().

409 {
410  RankFourTensorTempl<T> result;
411 
412  unsigned int index = 0;
413  for (unsigned int ij = 0; ij < N2; ++ij)
414  {
415  const T & a = this->_coords[ij];
416  for (unsigned int kl = 0; kl < N2; ++kl)
417  result._vals[index++] = a * b._coords[kl];
418  }
419 
420  return result;
421 }
RankFourTensorTempl is designed to handle any N-dimensional fourth order tensor, C.
Definition: MooseTypes.h:115
static constexpr unsigned int N2
T _vals[N4]
The values of the rank-four tensor stored by index=(((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) * LIBME...

◆ positiveProjectionEigenDecomposition()

template<typename T>
RankFourTensorTempl< T > RankTwoTensorTempl< T >::positiveProjectionEigenDecomposition ( std::vector< T > &  eigval,
RankTwoTensorTempl< T > &  eigvec 
) const

return positive projection tensor of eigen-decomposition

Definition at line 478 of file RankTwoTensor.C.

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

◆ print()

template<typename T >
void RankTwoTensorTempl< T >::print ( std::ostream &  stm = Moose::out) const

Print the rank two tensor.

Definition at line 821 of file RankTwoTensor.C.

822 {
823  const RankTwoTensorTempl<T> & a = *this;
824  for (unsigned int i = 0; i < N; ++i)
825  {
826  for (unsigned int j = 0; j < N; ++j)
827  stm << std::setw(15) << a(i, j) << ' ';
828  stm << std::endl;
829  }
830 }
static constexpr unsigned int N
RankTwoTensorTempl is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: MooseTypes.h:111

◆ rotate()

template<typename T>
void RankTwoTensorTempl< T >::rotate ( const RankTwoTensorTempl< T > &  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 RankTwoTensorTempl

Definition at line 260 of file RankTwoTensor.C.

Referenced by RankTwoTensorTempl< Real >::rotated().

261 {
263  unsigned int i1 = 0;
264  for (unsigned int i = 0; i < N; i++)
265  {
266  unsigned int j1 = 0;
267  for (unsigned int j = 0; j < N; j++)
268  {
269  // tmp += R(i,k)*R(j,l)*(*this)(k,l);
270  // clang-format off
271  T tmp = R._coords[i1 + 0] * R._coords[j1 + 0] * (*this)(0, 0) +
272  R._coords[i1 + 0] * R._coords[j1 + 1] * (*this)(0, 1) +
273  R._coords[i1 + 0] * R._coords[j1 + 2] * (*this)(0, 2) +
274  R._coords[i1 + 1] * R._coords[j1 + 0] * (*this)(1, 0) +
275  R._coords[i1 + 1] * R._coords[j1 + 1] * (*this)(1, 1) +
276  R._coords[i1 + 1] * R._coords[j1 + 2] * (*this)(1, 2) +
277  R._coords[i1 + 2] * R._coords[j1 + 0] * (*this)(2, 0) +
278  R._coords[i1 + 2] * R._coords[j1 + 1] * (*this)(2, 1) +
279  R._coords[i1 + 2] * R._coords[j1 + 2] * (*this)(2, 2);
280  // clang-format on
281  temp._coords[i1 + j] = tmp;
282  j1 += N;
283  }
284  i1 += N;
285  }
286  for (unsigned int i = 0; i < N2; i++)
287  this->_coords[i] = temp._coords[i];
288 }
static constexpr unsigned int N
static constexpr unsigned int N2
RankTwoTensorTempl is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: MooseTypes.h:111

◆ rotated()

template<typename T>
RankTwoTensorTempl< T > RankTwoTensorTempl< T >::rotated ( const RankTwoTensorTempl< T > &  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 another RankTwoTensorTempl

Definition at line 251 of file RankTwoTensor.C.

252 {
253  RankTwoTensorTempl<T> result(*this);
254  result.rotate(R);
255  return result;
256 }
RankTwoTensorTempl is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: MooseTypes.h:111

◆ rotateXyPlane()

template<typename T>
RankTwoTensorTempl< T > RankTwoTensorTempl< T >::rotateXyPlane ( a)

rotates the tensor data anticlockwise around the z-axis

Parameters
aangle in radians

Definition at line 292 of file RankTwoTensor.C.

293 {
294  T c = std::cos(a);
295  T s = std::sin(a);
296  T x = (*this)(0, 0) * c * c + (*this)(1, 1) * s * s + 2.0 * (*this)(0, 1) * c * s;
297  T y = (*this)(0, 0) * s * s + (*this)(1, 1) * c * c - 2.0 * (*this)(0, 1) * c * s;
298  T xy = ((*this)(1, 1) - (*this)(0, 0)) * c * s + (*this)(0, 1) * (c * c - s * s);
299 
300  RankTwoTensorTempl<T> b(*this);
301 
302  b(0, 0) = x;
303  b(1, 1) = y;
304  b(1, 0) = b(0, 1) = xy;
305 
306  return b;
307 }
static PetscErrorCode Vec x
RankTwoTensorTempl is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: MooseTypes.h:111

◆ secondInvariant()

template<typename T >
T RankTwoTensorTempl< T >::secondInvariant ( ) const

Calculates the second invariant (I2) of a tensor.

Definition at line 553 of file RankTwoTensor.C.

554 {
555  T result = 0.0;
556 
557  // RankTwoTensorTempl<T> deviatoric(*this);
558  // deviatoric.addIa(-1.0/3.0 * this->tr()); // actually construct deviatoric part
559  // result = 0.5*(deviatoric + deviatoric.transpose()).doubleContraction(deviatoric +
560  // deviatoric.transpose());
561  result = Utility::pow<2>((*this)(0, 0) - (*this)(1, 1)) / 6.0;
562  result += Utility::pow<2>((*this)(0, 0) - (*this)(2, 2)) / 6.0;
563  result += Utility::pow<2>((*this)(1, 1) - (*this)(2, 2)) / 6.0;
564  result += Utility::pow<2>((*this)(0, 1) + (*this)(1, 0)) / 4.0;
565  result += Utility::pow<2>((*this)(0, 2) + (*this)(2, 0)) / 4.0;
566  result += Utility::pow<2>((*this)(1, 2) + (*this)(2, 1)) / 4.0;
567  return result;
568 }

◆ setToIdentity()

template<typename T >
void RankTwoTensorTempl< T >::setToIdentity ( )

set the tensor to the identity matrix

Definition at line 1142 of file RankTwoTensor.C.

1143 {
1144  mooseAssert(N2 == 9, "RankTwoTensorTempl is currently only tested for 3 dimensions.");
1145  for (unsigned int i = 0; i < N2; ++i)
1146  this->_coords[i] = identityCoords[i];
1147 }
static constexpr unsigned int N2
static constexpr Real identityCoords[N2]

◆ sin3Lode()

template<typename T>
T RankTwoTensorTempl< T >::sin3Lode ( const T &  r0,
const T &  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 749 of file RankTwoTensor.C.

750 {
751  T bar = secondInvariant();
752  if (bar <= r0)
753  // in this case the Lode angle is not defined
754  return r0_value;
755  else
756  // the min and max here gaurd against precision-loss when bar is tiny but nonzero.
757  return std::max(std::min(-1.5 * std::sqrt(3.0) * thirdInvariant() / std::pow(bar, 1.5), 1.0),
758  -1.0);
759 }
T secondInvariant() const
Calculates the second invariant (I2) of a tensor.
Real pow(Real x, int e)
Definition: MathUtils.C:211
T 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...

◆ surfaceFillFromInputVector()

template<typename T>
void RankTwoTensorTempl< T >::surfaceFillFromInputVector ( const std::vector< T > &  input)

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

Definition at line 855 of file RankTwoTensor.C.

856 {
857  if (input.size() == 4)
858  {
859  // initialize with zeros
860  this->zero();
861  (*this)(0, 0) = input[0];
862  (*this)(0, 1) = input[1];
863  (*this)(1, 0) = input[2];
864  (*this)(1, 1) = input[3];
865  }
866  else
867  mooseError("please provide correct number of values for surface RankTwoTensorTempl<T> "
868  "initialization.");
869 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208

◆ syev() [1/2]

template<typename T>
void RankTwoTensorTempl< T >::syev ( const char *  calculation_type,
std::vector< T > &  eigvals,
std::vector< T > &  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 970 of file RankTwoTensor.C.

973 {
974  eigvals.resize(N);
975  a.resize(N * N);
976 
977  // prepare data for the LAPACKsyev_ routine (which comes from petscblaslapack.h)
978  int nd = N;
979  int lwork = 66 * nd;
980  int info;
981  std::vector<PetscScalar> work(lwork);
982 
983  for (unsigned int i = 0; i < N; ++i)
984  for (unsigned int j = 0; j < N; ++j)
985  // a is destroyed by dsyev, and if calculation_type == "V" then eigenvectors are placed there
986  // Note the explicit symmeterisation
987  a[i * N + j] = 0.5 * (this->operator()(i, j) + this->operator()(j, i));
988 
989  // compute the eigenvalues only (if calculation_type == "N"),
990  // or both the eigenvalues and eigenvectors (if calculation_type == "V")
991  // assume upper triangle of a is stored (second "U")
992  LAPACKsyev_(calculation_type, "U", &nd, &a[0], &nd, &eigvals[0], &work[0], &lwork, &info);
993 
994  if (info != 0)
995  mooseError("In computing the eigenvalues and eigenvectors for the symmetric rank-2 tensor (",
996  Moose::stringify(a),
997  "), the PETSC LAPACK syev routine returned error code ",
998  info);
999 }
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
std::string stringify(const T &t)
conversion to string
Definition: Conversion.h:61

◆ syev() [2/2]

template<>
void RankTwoTensorTempl< DualReal >::syev ( const char *  ,
std::vector< DualReal > &  ,
std::vector< DualReal > &   
) const

Definition at line 1003 of file RankTwoTensor.C.

1006 {
1007  mooseError("DualRankTwoTensor does not sypport the syev method");
1008 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208

◆ symmetricEigenvalues()

template<typename T>
void RankTwoTensorTempl< T >::symmetricEigenvalues ( std::vector< T > &  eigvals) const

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

Definition at line 873 of file RankTwoTensor.C.

874 {
875  std::vector<T> a;
876  syev("N", eigvals, a);
877 }
void syev(const char *calculation_type, std::vector< T > &eigvals, std::vector< T > &a) const
Uses the petscblaslapack.h LAPACKsyev_ routine to find, for symmetric _coords: (1) the eigenvalues (i...

◆ symmetricEigenvaluesEigenvectors()

template<typename T>
void RankTwoTensorTempl< T >::symmetricEigenvaluesEigenvectors ( std::vector< T > &  eigvals,
RankTwoTensorTempl< T > &  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 881 of file RankTwoTensor.C.

883 {
884  std::vector<T> a;
885  syev("V", eigvals, a);
886 
887  for (unsigned int i = 0; i < N; ++i)
888  for (unsigned int j = 0; j < N; ++j)
889  eigvecs(j, i) = a[i * N + j];
890 }
static constexpr unsigned int N
void syev(const char *calculation_type, std::vector< T > &eigvals, std::vector< T > &a) const
Uses the petscblaslapack.h LAPACKsyev_ routine to find, for symmetric _coords: (1) the eigenvalues (i...

◆ thirdInvariant()

template<typename T >
T RankTwoTensorTempl< T >::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 618 of file RankTwoTensor.C.

619 {
620  RankTwoTensorTempl<T> s = 0.5 * deviatoric();
621  s += s.transpose();
622 
623  T result = 0.0;
624 
625  result = s(0, 0) * (s(1, 1) * s(2, 2) - s(2, 1) * s(1, 2));
626  result -= s(1, 0) * (s(0, 1) * s(2, 2) - s(2, 1) * s(0, 2));
627  result += s(2, 0) * (s(0, 1) * s(1, 2) - s(1, 1) * s(0, 2));
628 
629  return result;
630 }
RankTwoTensorTempl< T > deviatoric() const
returns A_ij - de_ij*tr(A)/3, where A are the _coords
RankTwoTensorTempl< T > transpose() const
Returns a matrix that is the transpose of the matrix this was called on.
RankTwoTensorTempl is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: MooseTypes.h:111

◆ trace()

template<typename T >
T RankTwoTensorTempl< T >::trace ( ) const

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

Definition at line 596 of file RankTwoTensor.C.

597 {
598  // deprecate this!
599  return this->tr();
600 }

◆ transpose()

template<typename T >
RankTwoTensorTempl< T > RankTwoTensorTempl< T >::transpose ( ) const

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

Definition at line 311 of file RankTwoTensor.C.

Referenced by RankTwoTensorTempl< Real >::d2thirdInvariant(), RankTwoTensorTempl< Real >::dthirdInvariant(), RankTwoTensorTempl< Real >::getRUDecompositionRotation(), and RankTwoTensorTempl< Real >::thirdInvariant().

312 {
313  return TensorValue<T>::transpose();
314 }

◆ vectorOuterProduct()

template<typename T>
void RankTwoTensorTempl< T >::vectorOuterProduct ( const TypeVector< T > &  v1,
const TypeVector< T > &  v2 
)

RankTwoTensorTempl<T> from outer product of vectors.

Definition at line 1089 of file RankTwoTensor.C.

Referenced by RankTwoTensorTempl< Real >::positiveProjectionEigenDecomposition().

1090 {
1091  for (unsigned int i = 0; i < N; ++i)
1092  for (unsigned int j = 0; j < N; ++j)
1093  (*this)(i, j) = v1(i) * v2(j);
1094 }
static constexpr unsigned int N

Friends And Related Function Documentation

◆ dataLoad

template<typename T>
template<class T2 >
void dataLoad ( std::istream &  ,
RankTwoTensorTempl< T2 > &  ,
void *   
)
friend

◆ dataStore

template<typename T>
template<class T2 >
void dataStore ( std::ostream &  ,
RankTwoTensorTempl< T2 > &  ,
void *   
)
friend

◆ RankFourTensorTempl

template<typename T>
template<class T2 >
friend class RankFourTensorTempl
friend

Definition at line 484 of file RankTwoTensor.h.

◆ RankThreeTensorTempl

template<typename T>
template<class T2 >
friend class RankThreeTensorTempl
friend

Definition at line 486 of file RankTwoTensor.h.

Member Data Documentation

◆ identityCoords

template<typename T>
constexpr Real RankTwoTensorTempl< T >::identityCoords = {1, 0, 0, 0, 1, 0, 0, 0, 1}
staticprivate

Definition at line 476 of file RankTwoTensor.h.

◆ N

template<typename T>
constexpr unsigned int RankTwoTensorTempl< T >::N = LIBMESH_DIM
staticprivate

Definition at line 474 of file RankTwoTensor.h.

◆ N2

template<typename T>
constexpr unsigned int RankTwoTensorTempl< T >::N2 = N * N
staticprivate

Definition at line 475 of file RankTwoTensor.h.


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