https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
SymmetricRankTwoTensorTempl< T > Class Template Reference

SymmetricRankTwoTensorTempl is designed to handle the Stress or Strain Tensor for an anisotropic material. More...

#include <SymmetricRankTwoTensor.h>

Public Types

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

Public Member Functions

 SymmetricRankTwoTensorTempl ()
 Default constructor; fills to zero.
 
 SymmetricRankTwoTensorTempl (const InitMethod)
 Select specific initialization pattern.
 
 SymmetricRankTwoTensorTempl (const std::vector< T > &input)
 Constructor that proxies the fillFromInputVector method.
 
 SymmetricRankTwoTensorTempl (const T &S11, const T &S22, const T &S33, const T &S23, const T &S13, const T &S12)
 Initialization list replacement constructors, 6 arguments.
 
 operator RankTwoTensorTempl< T > ()
 
 SymmetricRankTwoTensorTempl (const TensorValue< T > &a)
 Copy constructor from TensorValue<T>
 
 SymmetricRankTwoTensorTempl (const TypeTensor< T > &a)
 Copy constructor from TypeTensor<T>
 
template<typename T2 >
 SymmetricRankTwoTensorTempl (const SymmetricRankTwoTensorTempl< T2 > &a)
 Construct from other template.
 
void fillFromInputVector (const std::vector< T > &input, FillMethod fill_method=autodetect)
 fillFromInputVector takes 1, 3, or 6 inputs to fill in the symmmetric Rank-2 tensor.
 
void fillFromScalarVariable (const VariableValue &scalar_variable)
 fillFromScalarVariable takes FIRST/THIRD/SIXTH order scalar variable to fill in the Rank-2 tensor.
 
T & operator() (unsigned int i)
 Gets the raw value for the index specified. Takes index = 0,1,2,3,4,5.
 
operator() (unsigned int i) const
 Gets the raw value for the index specified.
 
operator() (unsigned int i, unsigned int j) const
 Gets the value for the index specified.
 
libMesh::VectorValue< T > row (const unsigned int n) const
 get the specified row of the tensor
 
libMesh::VectorValue< T > column (const unsigned int n) const
 get the specified column of the tensor
 
SymmetricRankTwoTensorTempl< T > square () const
 Returns the matrix squared.
 
tr () const
 Returns the trace.
 
void zero ()
 Set all components to zero.
 
void rotate (const TypeTensor< T > &R)
 rotates the tensor data given a rank two tensor rotation tensor _vals[i][j] = R_ij * R_jl * _vals[k][l]
 
SymmetricRankTwoTensorTempl< T > transpose () const
 Returns a matrix that is the transpose of the matrix this was called on.
 
template<typename T2 >
SymmetricRankTwoTensorTempl< T > & operator= (const SymmetricRankTwoTensorTempl< T2 > &a)
 sets _vals to a, and returns _vals
 
template<typename Scalar >
std::enable_if< libMesh::ScalarTraits< Scalar >::value, SymmetricRankTwoTensorTempl & >::type operator= (const Scalar &libmesh_dbg_var(p))
 Assignment-from-scalar operator.
 
SymmetricRankTwoTensorTempl< T > & operator+= (const SymmetricRankTwoTensorTempl< T > &a)
 adds a to _vals
 
template<typename T2 >
SymmetricRankTwoTensorTempl< typename libMesh::CompareTypes< T, T2 >::supertype > operator+ (const SymmetricRankTwoTensorTempl< T2 > &a) const
 returns _vals + a
 
SymmetricRankTwoTensorTempl< T > & operator-= (const SymmetricRankTwoTensorTempl< T > &a)
 sets _vals -= a and returns vals
 
template<typename T2 >
SymmetricRankTwoTensorTempl< typename libMesh::CompareTypes< T, T2 >::supertype > operator- (const SymmetricRankTwoTensorTempl< T2 > &a) const
 returns _vals - a
 
SymmetricRankTwoTensorTempl< T > operator- () const
 returns -_vals
 
SymmetricRankTwoTensorTempl< T > & operator*= (const T &a)
 performs _vals *= a
 
template<typename T2 >
auto operator* (const T2 &a) const -> typename std::enable_if< libMesh::ScalarTraits< T2 >::value, SymmetricRankTwoTensorTempl< decltype(T() *T2())> >::type
 returns _vals*a
 
SymmetricRankTwoTensorTempl< T > & operator/= (const T &a)
 performs _vals /= a
 
template<typename T2 >
auto operator/ (const T2 &a) const -> typename std::enable_if< libMesh::ScalarTraits< T2 >::value, SymmetricRankTwoTensorTempl< decltype(T()/T2())> >::type
 returns _vals/a
 
template<typename T2 >
TypeVector< typename libMesh::CompareTypes< T, T2 >::supertype > operator* (const TypeVector< T2 > &a) const
 Defines multiplication with a vector to get a vector.
 
template<typename T2 >
bool operator== (const SymmetricRankTwoTensorTempl< T2 > &a) const
 Defines logical equality with another SymmetricRankTwoTensorTempl<T2>
 
bool isSymmetric () const
 Test for symmetry. Surprisingly this is always true.
 
template<typename T2 >
bool operator!= (const SymmetricRankTwoTensorTempl< T2 > &a) const
 Defines logical inequality with another SymmetricRankTwoTensorTempl<T2>
 
SymmetricRankTwoTensorTempl< T > & operator= (const ColumnMajorMatrixTempl< T > &a)
 Sets _vals to the values in a ColumnMajorMatrix (must be 3x3)
 
doubleContraction (const SymmetricRankTwoTensorTempl< T > &a) const
 returns _vals_ij * a_ij (sum on i, j)
 
SymmetricRankFourTensorTempl< T > outerProduct (const SymmetricRankTwoTensorTempl< T > &a) const
 returns C_ijkl = a_ij * b_kl
 
SymmetricRankFourTensorTempl< T > positiveProjectionEigenDecomposition (std::vector< T > &, RankTwoTensorTempl< T > &) const
 return positive projection tensor of eigen-decomposition
 
SymmetricRankTwoTensorTempl< T > deviatoric () const
 returns A_ij - de_ij*tr(A)/3, where A are the _vals
 
trace () const
 returns the trace of the tensor, ie _vals[i][i] (sum i = 0, 1, 2)
 
SymmetricRankTwoTensorTempl< T > inverse () const
 retuns the inverse of the tensor
 
SymmetricRankTwoTensorTempl< T > dtrace () const
 Denote the _vals[i][j] by A_ij, then this returns d(trace)/dA_ij.
 
generalSecondInvariant () const
 Calculates the second invariant (I2) of a tensor.
 
secondInvariant () const
 Denote the _vals[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.
 
SymmetricRankTwoTensorTempl< T > dsecondInvariant () const
 Denote the _vals[i][j] by A_ij, then this returns d(secondInvariant)/dA_ij.
 
SymmetricRankFourTensorTempl< T > d2secondInvariant () const
 Denote the _vals[i][j] by A_ij, then this returns d^2(secondInvariant)/dA_ij/dA_kl.
 
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.
 
SymmetricRankTwoTensorTempl< T > dsin3Lode (const T &r0) const
 d(sin3Lode)/dA_ij If secondInvariant() <= r0 then return zero This is to gaurd against precision-loss errors.
 
thirdInvariant () const
 Denote the _vals[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.
 
SymmetricRankTwoTensorTempl< T > dthirdInvariant () const
 Denote the _vals[i][j] by A_ij, then this returns d(thirdInvariant()/dA_ij.
 
SymmetricRankFourTensorTempl< T > d2thirdInvariant () const
 Denote the _vals[i][j] by A_ij, then this returns d^2(thirdInvariant)/dA_ij/dA_kl.
 
det () const
 
SymmetricRankTwoTensorTempl< T > ddet () const
 Denote the _vals[i][j] by A_ij, then this returns d(det)/dA_ij.
 
void print (std::ostream &stm=Moose::out) const
 Print the rank two tensor.
 
void printReal (std::ostream &stm=Moose::out) const
 Print the Real part of the ADReal rank two tensor.
 
void printADReal (unsigned int nDual, std::ostream &stm=Moose::out) const
 Print the Real part of the ADReal rank two tensor along with its first nDual dual numbers.
 
void addIa (const T &a)
 Add identity times a to _vals.
 
L2norm () const
 Sqrt(_vals[i][j]*_vals[i][j])
 
void surfaceFillFromInputVector (const std::vector< T > &input)
 sets _vals[0][0], _vals[0][1], _vals[1][0], _vals[1][1] to input, and the remainder to zero
 
void symmetricEigenvalues (std::vector< T > &eigvals) const
 computes eigenvalues, assuming tens is symmetric, and places them in ascending order in eigvals
 
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.
 
SymmetricRankTwoTensorTempl< T > initialContraction (const SymmetricRankFourTensorTempl< T > &b) const
 returns this_ij * b_ijkl
 
void setToIdentity ()
 set the tensor to the identity matrix
 

Static Public Member Functions

static constexpr Real mandelFactor (unsigned int i)
 returns the 1 or sqrt(2) prefactor in the Mandel notation for the index i ranging from 0-5.
 
static SymmetricRankTwoTensorTempl identity ()
 
static SymmetricRankTwoTensorTempl initializeSymmetric (const TypeVector< T > &v0, const TypeVector< T > &v1, const TypeVector< T > &v2)
 named constructor for initializing symmetrically
 
static MooseEnum fillMethodEnum ()
 Static method for use in validParams for getting the "fill_method".
 
static SymmetricRankTwoTensorTempl< T > timesTranspose (const RankTwoTensorTempl< T > &)
 return the matrix multiplied with its transpose A*A^T (guaranteed symmetric)
 
static SymmetricRankTwoTensorTempl< T > timesTranspose (const SymmetricRankTwoTensorTempl< T > &)
 
static SymmetricRankTwoTensorTempl< T > transposeTimes (const RankTwoTensorTempl< T > &)
 return the matrix multiplied with its transpose A^T*A (guaranteed symmetric)
 
static SymmetricRankTwoTensorTempl< T > transposeTimes (const SymmetricRankTwoTensorTempl< T > &)
 
static SymmetricRankTwoTensorTempl< T > plusTranspose (const RankTwoTensorTempl< T > &)
 return the matrix plus its transpose A-A^T (guaranteed symmetric)
 
static SymmetricRankTwoTensorTempl< T > plusTranspose (const SymmetricRankTwoTensorTempl< T > &)
 
static void initRandom (unsigned int)
 This function initializes random seed based on a user-defined number.
 
static SymmetricRankTwoTensorTempl< T > genRandomSymmTensor (T, T)
 This function generates a random symmetric rank two tensor.
 
static SymmetricRankTwoTensorTempl< T > selfOuterProduct (const TypeVector< T > &)
 SymmetricRankTwoTensorTempl<T> from outer product of a vector with itself.
 

Static Public Attributes

static constexpr unsigned int full_index [6][2] = {{0, 0}, {1, 1}, {2, 2}, {1, 2}, {0, 2}, {0, 1}}
 
static constexpr unsigned int reverse_index [3][3] = {{0, 5, 4}, {5, 1, 3}, {4, 3, 2}}
 
static constexpr unsigned int Ndim = Moose::dim
 tensor dimension and Mandel vector length
 
static constexpr unsigned int N = Ndim + (Ndim * (Ndim - 1)) / 2
 

Protected Member Functions

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 _vals: (1) the eigenvalues (if calculation_type == "N") (2) the eigenvalues and eigenvectors (if calculation_type == "V")
 

Private Member Functions

 SymmetricRankTwoTensorTempl (const T &S11, const T &S21, const T &S31, const T &S12, const T &S22, const T &S32, const T &S13, const T &S23, const T &S33)
 Initialization list replacement constructors, 9 arguments (for internal use only)
 

Static Private Member Functions

static SymmetricRankTwoTensorTempl fromRawComponents (const T &S11, const T &S22, const T &S33, const T &S23, const T &S13, const T &S12)
 

Private Attributes

std::array< T, N_vals
 

Static Private Attributes

static constexpr std::array< Real, NidentityCoords = {{1, 1, 1, 0, 0, 0}}
 

Friends

template<class T2 >
class SymmetricRankFourTensorTempl
 
std::ostream & operator<< (std::ostream &os, const SymmetricRankTwoTensorTempl< T > &t)
 
template<class T2 >
void dataStore (std::ostream &, SymmetricRankTwoTensorTempl< T2 > &, void *)
 
template<class T2 >
void dataLoad (std::istream &, SymmetricRankTwoTensorTempl< T2 > &, void *)
 

Detailed Description

template<typename T>
class SymmetricRankTwoTensorTempl< T >

SymmetricRankTwoTensorTempl is designed to handle the Stress or Strain Tensor for an anisotropic material.

It is designed to reduce the redundancies of the Complete tensor classes for regular mechanics problems and to enable use of the Mandel notation.

Definition at line 73 of file SymmetricRankTwoTensor.h.

Member Typedef Documentation

◆ value_type

template<typename T >
typedef T SymmetricRankTwoTensorTempl< T >::value_type

For generic programming.

Definition at line 77 of file SymmetricRankTwoTensor.h.

Member Enumeration Documentation

◆ FillMethod

template<typename T >
enum SymmetricRankTwoTensorTempl::FillMethod

To fill up the 6 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 

Definition at line 111 of file SymmetricRankTwoTensor.h.

◆ InitMethod

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

Definition at line 94 of file SymmetricRankTwoTensor.h.

Constructor & Destructor Documentation

◆ SymmetricRankTwoTensorTempl() [1/8]

Default constructor; fills to zero.

Definition at line 56 of file SymmetricRankTwoTensorImplementation.h.

57{
58 std::fill(_vals.begin(), _vals.end(), 0.0);
59}

Referenced by SymmetricRankTwoTensorTempl< T >::identity().

◆ SymmetricRankTwoTensorTempl() [2/8]

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

Select specific initialization pattern.

Definition at line 62 of file SymmetricRankTwoTensorImplementation.h.

63{
64 switch (init)
65 {
66 case initNone:
67 break;
68
69 case initIdentity:
71 break;
72
73 default:
74 mooseError("Unknown SymmetricRankTwoTensorTempl initialization pattern.");
75 }
76}
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
void setToIdentity()
set the tensor to the identity matrix

◆ SymmetricRankTwoTensorTempl() [3/8]

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

Constructor that proxies the fillFromInputVector method.

Definition at line 120 of file SymmetricRankTwoTensor.h.

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

◆ SymmetricRankTwoTensorTempl() [4/8]

template<typename T >
SymmetricRankTwoTensorTempl< T >::SymmetricRankTwoTensorTempl ( const T &  S11,
const T &  S22,
const T &  S33,
const T &  S23,
const T &  S13,
const T &  S12 
)

Initialization list replacement constructors, 6 arguments.

Definition at line 79 of file SymmetricRankTwoTensorImplementation.h.

81{
82 _vals[0] = S11;
83 _vals[1] = S22;
84 _vals[2] = S33;
85 _vals[3] = mandelFactor(3) * S23;
86 _vals[4] = mandelFactor(4) * S13;
87 _vals[5] = mandelFactor(5) * S12;
88}
static constexpr Real mandelFactor(unsigned int i)
returns the 1 or sqrt(2) prefactor in the Mandel notation for the index i ranging from 0-5.

◆ SymmetricRankTwoTensorTempl() [5/8]

template<typename T >
SymmetricRankTwoTensorTempl< T >::SymmetricRankTwoTensorTempl ( const T &  S11,
const T &  S21,
const T &  S31,
const T &  S12,
const T &  S22,
const T &  S32,
const T &  S13,
const T &  S23,
const T &  S33 
)
private

Initialization list replacement constructors, 9 arguments (for internal use only)

Definition at line 105 of file SymmetricRankTwoTensorImplementation.h.

114{
115 _vals[0] = S11;
116 _vals[1] = S22;
117 _vals[2] = S33;
118 _vals[3] = (S23 + S32) / mandelFactor(3);
119 _vals[4] = (S13 + S31) / mandelFactor(4);
120 _vals[5] = (S12 + S21) / mandelFactor(5);
121}

◆ SymmetricRankTwoTensorTempl() [6/8]

template<typename T >
SymmetricRankTwoTensorTempl< T >::SymmetricRankTwoTensorTempl ( const TensorValue< T > &  a)
explicit

Copy constructor from TensorValue<T>

Definition at line 139 of file SymmetricRankTwoTensorImplementation.h.

140{
141 _vals[0] = a(0, 0);
142 _vals[1] = a(1, 1);
143 _vals[2] = a(2, 2);
144 _vals[3] = (a(1, 2) + a(2, 1)) / mandelFactor(3);
145 _vals[4] = (a(0, 2) + a(2, 0)) / mandelFactor(4);
146 _vals[5] = (a(0, 1) + a(1, 0)) / mandelFactor(5);
147}

◆ SymmetricRankTwoTensorTempl() [7/8]

template<typename T >
SymmetricRankTwoTensorTempl< T >::SymmetricRankTwoTensorTempl ( const TypeTensor< T > &  a)
explicit

Copy constructor from TypeTensor<T>

Definition at line 150 of file SymmetricRankTwoTensorImplementation.h.

151{
152 _vals[0] = a(0, 0);
153 _vals[1] = a(1, 1);
154 _vals[2] = a(2, 2);
155 _vals[3] = (a(1, 2) + a(2, 1)) / mandelFactor(3);
156 _vals[4] = (a(0, 2) + a(2, 0)) / mandelFactor(4);
157 _vals[5] = (a(0, 1) + a(1, 0)) / mandelFactor(5);
158}

◆ SymmetricRankTwoTensorTempl() [8/8]

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

Construct from other template.

Definition at line 154 of file SymmetricRankTwoTensor.h.

155 {
156 for (const auto i : make_range(N))
157 _vals[i] = a(i);
158 }
static constexpr unsigned int N
IntRange< T > make_range(T beg, T end)

Member Function Documentation

◆ addIa()

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

Add identity times a to _vals.

Definition at line 657 of file SymmetricRankTwoTensorImplementation.h.

658{
659 for (unsigned int i = 0; i < 3; ++i)
660 _vals[i] += a;
661}

Referenced by SymmetricRankTwoTensorTempl< Real >::selfOuterProduct().

◆ column()

template<typename T >
libMesh::VectorValue< T > SymmetricRankTwoTensorTempl< T >::column ( const unsigned int  n) const
inline

get the specified column of the tensor

Definition at line 204 of file SymmetricRankTwoTensor.h.

204{ return row(n); }
libMesh::VectorValue< T > row(const unsigned int n) const
get the specified row of the tensor

◆ d2secondInvariant()

template<typename T >
SymmetricRankFourTensorTempl< T > SymmetricRankTwoTensorTempl< T >::d2secondInvariant ( ) const

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

Definition at line 501 of file SymmetricRankTwoTensorImplementation.h.

502{
504
505 for (auto i : make_range(N))
506 for (auto j : make_range(N))
507 result(i, j) = 0.5 * (i == j) + 0.5 * (i == j) - (1.0 / 3.0) * (i < 3) * (j < 3);
508
509 return result;
510}
for(PetscInt i=0;i< nvars;++i)
SymmetricRankFourTensorTempl is designed to handle an N-dimensional fourth order tensor with minor sy...

◆ d2thirdInvariant()

template<typename T >
SymmetricRankFourTensorTempl< T > SymmetricRankTwoTensorTempl< T >::d2thirdInvariant ( ) const

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

Definition at line 571 of file SymmetricRankTwoTensorImplementation.h.

572{
574
576 for (auto i : make_range(N))
577 for (auto j : make_range(N))
578 d2(i, j) = Real(i < 3) * s(j) / 3.0 / (j < 3 ? 1 : MathUtils::sqrt2) +
579 Real(j < 3) * s(i) / 3.0 / (i < 3 ? 1 : MathUtils::sqrt2);
580
581 d2(0, 1) += s(2);
582 d2(0, 2) += s(1);
583 d2(0, 3) -= s(3) / MathUtils::sqrt2;
584
585 d2(1, 0) += s(2);
586 d2(1, 2) += s(0);
587 d2(1, 4) -= s(4) / MathUtils::sqrt2;
588
589 d2(2, 0) += s(1);
590 d2(2, 1) += s(0);
591 d2(2, 5) -= s(5) / MathUtils::sqrt2;
592
593 d2(3, 0) -= s(3) / MathUtils::sqrt2;
594 d2(3, 3) -= s(0) / 2.0;
595 d2(3, 4) += s(5) / 2.0 / MathUtils::sqrt2;
596 d2(3, 5) += s(4) / 2.0 / MathUtils::sqrt2;
597
598 d2(4, 1) -= s(4) / MathUtils::sqrt2;
599 d2(4, 3) += s(5) / 2.0 / MathUtils::sqrt2;
600 d2(4, 4) -= s(1) / 2.0;
601 d2(4, 5) += s(3) / 2.0 / MathUtils::sqrt2;
602
603 d2(5, 2) -= s(5) / MathUtils::sqrt2;
604 d2(5, 3) += s(4) / 2.0 / MathUtils::sqrt2;
605 d2(5, 4) += s(3) / 2.0 / MathUtils::sqrt2;
606 d2(5, 5) -= s(2) / 2.0;
607
608 for (auto i : make_range(N))
609 for (auto j : make_range(N))
610 d2(i, j) *= SymmetricRankFourTensorTempl<T>::mandelFactor(i, j);
611
612 return d2;
613}
SymmetricRankTwoTensorTempl< T > deviatoric() const
returns A_ij - de_ij*tr(A)/3, where A are the _vals
static SymmetricRankTwoTensorTempl< T > plusTranspose(const RankTwoTensorTempl< T > &)
return the matrix plus its transpose A-A^T (guaranteed symmetric)
static constexpr Real sqrt2
std::sqrt is not constexpr, so we add sqrt(2) as a constant (used in Mandel notation)
Definition MathUtils.h:25
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

◆ ddet()

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

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

Definition at line 628 of file SymmetricRankTwoTensorImplementation.h.

629{
631 _vals[2] * _vals[1] - _vals[3] * _vals[3] / 2.0,
632 _vals[0] * _vals[2] - _vals[4] * _vals[4] / 2.0,
633 _vals[0] * _vals[1] - _vals[5] * _vals[5] / 2.0,
634 _vals[4] * _vals[5] / 2.0 - _vals[0] * _vals[3] / MathUtils::sqrt2,
635 _vals[5] * _vals[3] / 2.0 - _vals[4] * _vals[1] / MathUtils::sqrt2,
636 _vals[4] * _vals[3] / 2.0 - _vals[5] * _vals[2] / MathUtils::sqrt2);
637}
SymmetricRankTwoTensorTempl is designed to handle the Stress or Strain Tensor for an anisotropic mate...

◆ det()

template<typename T >
T SymmetricRankTwoTensorTempl< T >::det ( ) const

Definition at line 617 of file SymmetricRankTwoTensorImplementation.h.

618{
619 return _vals[0] * (_vals[2] * _vals[1] - _vals[3] * _vals[3] / 2.0) -
621 (_vals[2] * _vals[5] / MathUtils::sqrt2 - _vals[3] * _vals[4] / 2.0) +
623 (_vals[3] * _vals[5] / 2.0 - _vals[1] * _vals[4] / MathUtils::sqrt2);
624}

◆ deviatoric()

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

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

Definition at line 463 of file SymmetricRankTwoTensorImplementation.h.

464{
466 deviatoric.addIa(-1.0 / 3.0 * this->tr());
467 return deviatoric;
468}
T tr() const
Returns the trace.

◆ doubleContraction()

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

returns _vals_ij * a_ij (sum on i, j)

Definition at line 438 of file SymmetricRankTwoTensorImplementation.h.

439{
440 T sum = 0;
441 for (unsigned int i = 0; i < N; ++i)
442 sum += _vals[i] * b._vals[i];
443 return sum;
444}

◆ dsecondInvariant()

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

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

Definition at line 494 of file SymmetricRankTwoTensorImplementation.h.

◆ dsin3Lode()

template<typename T >
SymmetricRankTwoTensorTempl< T > SymmetricRankTwoTensorTempl< 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 667 of file SymmetricRankTwoTensor.h.

668{
669 using std::sqrt, std::pow;
670 if (MooseUtils::IsLikeReal<T>::value)
671 {
672 T bar = secondInvariant();
673 if (bar <= r0)
675 else
676 return -1.5 * sqrt(3.0) *
677 (dthirdInvariant() / pow(bar, 1.5) -
678 1.5 * dsecondInvariant() * thirdInvariant() / pow(bar, 2.5));
679 }
680 else
681 mooseError("dsin3Lode is only available for ordered tensor component types");
682}
SymmetricRankTwoTensorTempl< T > dsecondInvariant() const
Denote the _vals[i][j] by A_ij, then this returns d(secondInvariant)/dA_ij.
SymmetricRankTwoTensorTempl< T > dthirdInvariant() const
Denote the _vals[i][j] by A_ij, then this returns d(thirdInvariant()/dA_ij.
T thirdInvariant() const
Denote the _vals[i][j] by A_ij, then S_ij = A_ij - de_ij*tr(A)/3 Then this returns det(S + S....
T secondInvariant() const
Denote the _vals[i][j] by A_ij, then S_ij = A_ij - de_ij*tr(A)/3 Then this returns (S_ij + S_ji)*(S_i...
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template * sqrt(_arg)) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(tanh
T pow(const T &x)
MooseUnits pow(const MooseUnits &, int)
Definition Units.C:537

◆ dthirdInvariant()

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

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

Definition at line 557 of file SymmetricRankTwoTensorImplementation.h.

558{
560 const T s3 = secondInvariant() / 3.0;
561 return SymmetricRankTwoTensorTempl<T>(s(1) * s(2) - s(3) * s(3) / 2.0 + s3,
562 s(0) * s(2) - s(4) * s(4) / 2.0 + s3,
563 s(0) * s(1) - s(5) * s(5) / 2.0 + s3,
564 s(5) * s(4) / 2.0 - s(0) * s(3) / MathUtils::sqrt2,
565 s(5) * s(3) / 2.0 - s(1) * s(4) / MathUtils::sqrt2,
566 s(4) * s(3) / 2.0 - s(5) * s(2) / MathUtils::sqrt2);
567}

◆ dtrace()

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

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

Definition at line 538 of file SymmetricRankTwoTensorImplementation.h.

539{
540 return SymmetricRankTwoTensorTempl<T>(1, 1, 1, 0, 0, 0);
541}

◆ fillFromInputVector()

template<typename T >
void SymmetricRankTwoTensorTempl< T >::fillFromInputVector ( const std::vector< T > &  input,
FillMethod  fill_method = autodetect 
)

fillFromInputVector takes 1, 3, or 6 inputs to fill in the symmmetric Rank-2 tensor.

Definition at line 173 of file SymmetricRankTwoTensorImplementation.h.

175{
176 if (fill_method != autodetect && fill_method != input.size())
177 mooseError("Expected an input vector size of ",
178 fill_method,
179 " to fill the SymmetricRankTwoTensorTempl");
180
181 switch (input.size())
182 {
183 case 1:
184 _vals[0] = input[0];
185 _vals[1] = input[0];
186 _vals[2] = input[0];
187 _vals[3] = 0.0;
188 _vals[4] = 0.0;
189 _vals[5] = 0.0;
190 break;
191
192 case 3:
193 _vals[0] = input[0];
194 _vals[1] = input[1];
195 _vals[2] = input[2];
196 _vals[3] = 0.0;
197 _vals[4] = 0.0;
198 _vals[5] = 0.0;
199 break;
200
201 case 6:
202 _vals[0] = input[0];
203 _vals[1] = input[1];
204 _vals[2] = input[2];
205 _vals[3] = mandelFactor(3) * input[3];
206 _vals[4] = mandelFactor(4) * input[4];
207 _vals[5] = mandelFactor(5) * input[5];
208 break;
209
210 default:
211 mooseError("Please check the number of entries in the input vector for building "
212 "a SymmetricRankTwoTensorTempl. It must be 1, 3, 6");
213 }
214}

Referenced by GenericConstantSymmetricRankTwoTensorTempl< is_ad >::GenericConstantSymmetricRankTwoTensorTempl(), and SymmetricRankTwoTensorTempl< T >::SymmetricRankTwoTensorTempl().

◆ fillFromScalarVariable()

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

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

Definition at line 218 of file SymmetricRankTwoTensorImplementation.h.

219{
220 switch (scalar_variable.size())
221 {
222 case 1:
223 _vals[0] = scalar_variable[0];
224 _vals[1] = 0.0;
225 _vals[2] = 0.0;
226 _vals[3] = 0.0;
227 _vals[4] = 0.0;
228 _vals[5] = 0.0;
229 break;
230
231 case 3:
232 _vals[0] = scalar_variable[0];
233 _vals[1] = scalar_variable[1];
234 _vals[2] = 0.0;
235 _vals[3] = 0.0;
236 _vals[4] = 0.0;
237 _vals[5] = mandelFactor(5) * scalar_variable[2];
238 break;
239
240 case 6:
241 _vals[0] = scalar_variable[0];
242 _vals[1] = scalar_variable[1];
243 _vals[2] = scalar_variable[2];
244 _vals[3] = mandelFactor(3) * scalar_variable[3];
245 _vals[4] = mandelFactor(4) * scalar_variable[4];
246 _vals[5] = mandelFactor(5) * scalar_variable[5];
247 break;
248
249 default:
250 mooseError("Only FIRST, THIRD, or SIXTH order scalar variable can be used to build "
251 "a SymmetricRankTwoTensorTempl.");
252 }
253}

◆ fillMethodEnum()

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

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

Definition at line 50 of file SymmetricRankTwoTensorImplementation.h.

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

◆ fromRawComponents()

template<typename T >
SymmetricRankTwoTensorTempl< T > SymmetricRankTwoTensorTempl< T >::fromRawComponents ( const T &  S11,
const T &  S22,
const T &  S33,
const T &  S23,
const T &  S13,
const T &  S12 
)
staticprivate

Definition at line 125 of file SymmetricRankTwoTensorImplementation.h.

127{
129 ret._vals[0] = S11;
130 ret._vals[1] = S22;
131 ret._vals[2] = S33;
132 ret._vals[3] = S23;
133 ret._vals[4] = S13;
134 ret._vals[5] = S12;
135 return ret;
136}

Referenced by SymmetricRankTwoTensorTempl< T >::timesTranspose().

◆ generalSecondInvariant()

template<typename T >
T SymmetricRankTwoTensorTempl< T >::generalSecondInvariant ( ) const

Calculates the second invariant (I2) of a tensor.

Definition at line 472 of file SymmetricRankTwoTensorImplementation.h.

473{
474 return _vals[0] * _vals[1] + _vals[0] * _vals[2] + _vals[1] * _vals[2] -
475 (_vals[3] * _vals[3] + _vals[4] * _vals[4] + _vals[5] * _vals[5]) / 2.0;
476}

◆ genRandomSymmTensor()

template<typename T >
SymmetricRankTwoTensorTempl< T > SymmetricRankTwoTensorTempl< 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 719 of file SymmetricRankTwoTensorImplementation.h.

720{
721 auto r = [&]() { return (MooseRandom::rand() + offset) * scale; };
722 return SymmetricRankTwoTensorTempl<T>(r(), r(), r(), r(), r(), r());
723}
Real scale
Definition MortarUtils.C:62
static Real rand()
This method returns the next random number (Real format) from the generator.
Definition MooseRandom.h:50

◆ identity()

template<typename T >
static SymmetricRankTwoTensorTempl SymmetricRankTwoTensorTempl< T >::identity ( )
inlinestatic

Definition at line 161 of file SymmetricRankTwoTensor.h.

162 {
164 }
SymmetricRankTwoTensorTempl()
Default constructor; fills to zero.

◆ initialContraction()

template<typename T >
SymmetricRankTwoTensorTempl< T > SymmetricRankTwoTensorTempl< T >::initialContraction ( const SymmetricRankFourTensorTempl< T > &  b) const

returns this_ij * b_ijkl

Definition at line 735 of file SymmetricRankTwoTensorImplementation.h.

736{
738 for (auto i : make_range(N))
739 for (auto j : make_range(N))
740 result(j) += (*this)(i)*b(i, j);
741 return result;
742}

◆ initializeSymmetric()

template<typename T >
SymmetricRankTwoTensorTempl< T > SymmetricRankTwoTensorTempl< T >::initializeSymmetric ( const TypeVector< T > &  v0,
const TypeVector< T > &  v1,
const TypeVector< T > &  v2 
)
static

named constructor for initializing symmetrically

Definition at line 163 of file SymmetricRankTwoTensorImplementation.h.

166{
168 v0(0), v1(0), v2(0), v0(1), v1(1), v2(1), v0(2), v1(2), v2(2));
169}

◆ initRandom()

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

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

Definition at line 712 of file SymmetricRankTwoTensorImplementation.h.

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

◆ inverse()

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

retuns the inverse of the tensor

Definition at line 521 of file SymmetricRankTwoTensorImplementation.h.

522{
523 const auto d = det();
524 if (d == 0.0)
525 mooseException("Matrix not invertible");
527 _vals[2] * _vals[1] - _vals[3] * _vals[3] / 2.0,
528 _vals[2] * _vals[0] - _vals[4] * _vals[4] / 2.0,
529 _vals[0] * _vals[1] - _vals[5] * _vals[5] / 2.0,
530 _vals[5] * _vals[4] / 2.0 - _vals[0] * _vals[3] / MathUtils::sqrt2,
531 _vals[5] * _vals[3] / 2.0 - _vals[4] * _vals[1] / MathUtils::sqrt2,
532 _vals[4] * _vals[3] / 2.0 - _vals[2] * _vals[5] / MathUtils::sqrt2);
533 return inv * 1.0 / d;
534}

◆ isSymmetric()

template<typename T >
bool SymmetricRankTwoTensorTempl< T >::isSymmetric ( ) const
inline

Test for symmetry. Surprisingly this is always true.

Definition at line 306 of file SymmetricRankTwoTensor.h.

306{ return true; }

◆ L2norm()

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

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

Definition at line 665 of file SymmetricRankTwoTensorImplementation.h.

666{
667 T norm = _vals[0] * _vals[0];
668 for (unsigned int i = 1; i < N; ++i)
669 norm += _vals[i] * _vals[i];
670 using std::sqrt;
671 return norm == 0.0 ? 0.0 : sqrt(norm);
672}
auto norm(const T &a)

◆ mandelFactor()

template<typename T >
static constexpr Real SymmetricRankTwoTensorTempl< T >::mandelFactor ( unsigned int  i)
inlinestaticconstexpr

returns the 1 or sqrt(2) prefactor in the Mandel notation for the index i ranging from 0-5.

Definition at line 91 of file SymmetricRankTwoTensor.h.

91{ return i < Ndim ? 1.0 : MathUtils::sqrt2; }
static constexpr unsigned int Ndim
tensor dimension and Mandel vector length

Referenced by SymmetricRankFourTensorTempl< T >::mandelFactor(), and SymmetricRankTwoTensorTempl< T >::operator()().

◆ operator RankTwoTensorTempl< T >()

template<typename T >
SymmetricRankTwoTensorTempl< T >::operator RankTwoTensorTempl< T > ( )
explicit

Definition at line 91 of file SymmetricRankTwoTensorImplementation.h.

92{
94 _vals[5] / mandelFactor(5),
95 _vals[4] / mandelFactor(4),
96 _vals[5] / mandelFactor(5),
97 _vals[1],
98 _vals[3] / mandelFactor(3),
99 _vals[4] / mandelFactor(4),
100 _vals[3] / mandelFactor(3),
101 _vals[2]);
102}
RankTwoTensorTempl is designed to handle the Stress or Strain Tensor for a fully anisotropic material...

◆ operator!=()

template<typename T >
template<typename T2 >
bool SymmetricRankTwoTensorTempl< T >::operator!= ( const SymmetricRankTwoTensorTempl< T2 > &  a) const

Defines logical inequality with another SymmetricRankTwoTensorTempl<T2>

Definition at line 570 of file SymmetricRankTwoTensor.h.

571{
572 for (std::size_t i = 0; i < N; ++i)
573 if (_vals[i] != a._vals[i])
574 return true;
575 return false;
576}

◆ operator()() [1/3]

template<typename T >
T & SymmetricRankTwoTensorTempl< T >::operator() ( unsigned int  i)
inline

Gets the raw value for the index specified. Takes index = 0,1,2,3,4,5.

Definition at line 183 of file SymmetricRankTwoTensor.h.

183{ return _vals[i]; }

◆ operator()() [2/3]

template<typename T >
T SymmetricRankTwoTensorTempl< T >::operator() ( unsigned int  i) const
inline

Gets the raw value for the index specified.

Takes index = 0,1,2 used for const

Definition at line 189 of file SymmetricRankTwoTensor.h.

189{ return _vals[i]; }

◆ operator()() [3/3]

template<typename T >
T SymmetricRankTwoTensorTempl< T >::operator() ( unsigned int  i,
unsigned int  j 
) const
inline

Gets the value for the index specified.

Takes index = 0,1,2

Definition at line 194 of file SymmetricRankTwoTensor.h.

195 {
196 const auto a = reverse_index[i][j];
197 return _vals[a] / mandelFactor(a);
198 }
static constexpr unsigned int reverse_index[3][3]

◆ operator*() [1/2]

template<typename T >
template<typename T2 >
auto SymmetricRankTwoTensorTempl< T >::operator* ( const T2 &  a) const -> typename std::enable_if<libMesh::ScalarTraits<T2>::value, SymmetricRankTwoTensorTempl<decltype(T() * T2())>>::type

returns _vals*a

Definition at line 521 of file SymmetricRankTwoTensor.h.

524{
525 SymmetricRankTwoTensorTempl<decltype(T() * T2())> result;
526 for (const auto i : make_range(N))
527 result._vals[i] = _vals[i] * a;
528 return result;
529}

◆ operator*() [2/2]

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

Defines multiplication with a vector to get a vector.

Definition at line 548 of file SymmetricRankTwoTensor.h.

549{
550 TypeVector<typename libMesh::CompareTypes<T, T2>::supertype> ret;
551 ret(0) = a(0) * _vals[0] + a(1) * _vals[5] + a(2) * _vals[4];
552 ret(1) = a(0) * _vals[5] + a(1) * _vals[1] + a(2) * _vals[3];
553 ret(2) = a(0) * _vals[4] + a(1) * _vals[3] + a(2) * _vals[2];
554}

◆ operator*=()

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

performs _vals *= a

Definition at line 420 of file SymmetricRankTwoTensorImplementation.h.

421{
422 for (std::size_t i = 0; i < N; ++i)
423 _vals[i] *= a;
424 return *this;
425}

◆ operator+()

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

returns _vals + a

Definition at line 390 of file SymmetricRankTwoTensorImplementation.h.

391{
393 for (std::size_t i = 0; i < N; ++i)
394 result(i) = _vals[i] + a(i);
395 return result;
396}

◆ operator+=()

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

adds a to _vals

Definition at line 371 of file SymmetricRankTwoTensorImplementation.h.

372{
373 for (std::size_t i = 0; i < N; ++i)
374 _vals[i] += a._vals[i];
375 return *this;
376}

◆ operator-() [1/2]

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

returns -_vals

Definition at line 413 of file SymmetricRankTwoTensorImplementation.h.

414{
415 return (*this) * -1.0;
416}

◆ operator-() [2/2]

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

returns _vals - a

Definition at line 401 of file SymmetricRankTwoTensorImplementation.h.

402{
405 for (std::size_t i = 0; i < N; ++i)
406 result(i) = _vals[i] - a(i);
407 return result;
408}

◆ operator-=()

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

sets _vals -= a and returns vals

Definition at line 380 of file SymmetricRankTwoTensorImplementation.h.

381{
382 for (std::size_t i = 0; i < N; ++i)
383 _vals[i] -= a._vals[i];
384 return *this;
385}

◆ operator/()

template<typename T >
template<typename T2 >
auto SymmetricRankTwoTensorTempl< T >::operator/ ( const T2 &  a) const -> typename std::enable_if<libMesh::ScalarTraits<T2>::value, SymmetricRankTwoTensorTempl<decltype(T() / T2())>>::type

returns _vals/a

Definition at line 534 of file SymmetricRankTwoTensor.h.

537{
538 SymmetricRankTwoTensorTempl<decltype(T() / T2())> result;
539 for (const auto i : make_range(N))
540 result._vals[i] = _vals[i] / a;
541 return result;
542}

◆ operator/=()

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

performs _vals /= a

Definition at line 429 of file SymmetricRankTwoTensorImplementation.h.

430{
431 for (std::size_t i = 0; i < N; ++i)
432 _vals[i] /= a;
433 return *this;
434}

◆ operator=() [1/3]

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

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

◆ operator=() [2/3]

template<typename T >
template<typename Scalar >
std::enable_if< libMesh::ScalarTraits< Scalar >::value, SymmetricRankTwoTensorTempl & >::type SymmetricRankTwoTensorTempl< T >::operator= ( const Scalar &  libmesh_dbg_varp)
inline

Assignment-from-scalar operator.

Used only to zero out vectors.

Definition at line 252 of file SymmetricRankTwoTensor.h.

253 {
254 libmesh_assert_equal_to(p, Scalar(0));
255 this->zero();
256 return *this;
257 }

◆ operator=() [3/3]

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

sets _vals to a, and returns _vals

Definition at line 687 of file SymmetricRankTwoTensor.h.

688{
689 for (const auto i : make_range(N))
690 (*this)(i) = a(i);
691 return *this;
692}

◆ operator==()

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

Defines logical equality with another SymmetricRankTwoTensorTempl<T2>

Definition at line 559 of file SymmetricRankTwoTensor.h.

560{
561 for (std::size_t i = 0; i < N; ++i)
562 if (_vals[i] != a._vals[i])
563 return false;
564 return true;
565}

◆ outerProduct()

template<typename T >
SymmetricRankFourTensorTempl< T > SymmetricRankTwoTensorTempl< T >::outerProduct ( const SymmetricRankTwoTensorTempl< T > &  a) const

returns C_ijkl = a_ij * b_kl

Definition at line 448 of file SymmetricRankTwoTensorImplementation.h.

449{
451 unsigned int index = 0;
452 for (unsigned int i = 0; i < N; ++i)
453 {
454 const T & a = _vals[i];
455 for (unsigned int j = 0; j < N; ++j)
456 result._vals[index++] = a * b._vals[j];
457 }
458 return result;
459}
std::array< T, N2 > _vals
The values of the rank-four tensor.

◆ plusTranspose() [1/2]

template<typename T >
SymmetricRankTwoTensorTempl< T > SymmetricRankTwoTensorTempl< T >::plusTranspose ( const RankTwoTensorTempl< T > &  a)
static

return the matrix plus its transpose A-A^T (guaranteed symmetric)

Definition at line 340 of file SymmetricRankTwoTensorImplementation.h.

341{
343 a(0, 0), a(0, 1), a(0, 2), a(1, 0), a(1, 1), a(1, 2), a(2, 0), a(2, 1), a(2, 2)) *
344 2.0;
345}

Referenced by SymmetricRankTwoTensorTempl< T >::d2thirdInvariant(), SymmetricRankTwoTensorTempl< T >::dsecondInvariant(), SymmetricRankTwoTensorTempl< T >::dthirdInvariant(), and SymmetricRankTwoTensorTempl< T >::thirdInvariant().

◆ plusTranspose() [2/2]

template<typename T >
SymmetricRankTwoTensorTempl< T > SymmetricRankTwoTensorTempl< T >::plusTranspose ( const SymmetricRankTwoTensorTempl< T > &  a)
static

Definition at line 349 of file SymmetricRankTwoTensorImplementation.h.

350{
351 return a * 2.0;
352}

◆ positiveProjectionEigenDecomposition()

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

return positive projection tensor of eigen-decomposition

Definition at line 580 of file SymmetricRankTwoTensor.h.

582{
583 using std::abs;
584
585 // The calculate of projection tensor follows
586 // C. Miehe and M. Lambrecht, Commun. Numer. Meth. Engng 2001; 17:337~353
587
588 // Compute eigenvectors and eigenvalues of this tensor
589 if (MooseUtils::IsLikeReal<T>::value)
590 {
591 this->symmetricEigenvaluesEigenvectors(eigval, eigvec);
592
593 // Separate out positive and negative eigen values
594 std::array<T, N> epos;
595 std::array<T, N> d;
596 for (unsigned int i = 0; i < Ndim; ++i)
597 {
598 epos[i] = (abs(eigval[i]) + eigval[i]) / 2.0;
599 d[i] = 0 < eigval[i] ? 1.0 : 0.0;
600 }
601
602 // projection tensor
604
605 for (unsigned int a = 0; a < Ndim; ++a)
606 {
608 proj_pos += d[a] * Ma.outerProduct(Ma);
609 }
610
611 for (const auto a : make_range(Ndim))
612 for (const auto b : make_range(a))
613 {
616
618 for (const auto aa : make_range(N))
619 for (const auto bb : make_range(N))
620 {
621 const auto i = SymmetricRankFourTensorTempl<T>::full_index[aa][bb][0];
622 const auto j = SymmetricRankFourTensorTempl<T>::full_index[aa][bb][1];
623 const auto k = SymmetricRankFourTensorTempl<T>::full_index[aa][bb][2];
624 const auto l = SymmetricRankFourTensorTempl<T>::full_index[aa][bb][3];
625
626 Gabba(aa, bb) = (Ma(i, k) * Mb(j, l) + Ma(i, l) * Mb(j, k) + Ma(j, l) * Mb(i, k) +
627 Ma(j, k) * Mb(i, l)) *
629 }
630
631 T theta_ab;
632 if (!MooseUtils::relativeFuzzyEqual(eigval[a], eigval[b]))
633 theta_ab = 0.5 * (epos[a] - epos[b]) / (eigval[a] - eigval[b]);
634 else
635 theta_ab = 0.25 * (d[a] + d[b]);
636
637 proj_pos += theta_ab * Gabba;
638 }
639 return proj_pos;
640 }
641 else
642 mooseError("positiveProjectionEigenDecomposition is only available for ordered tensor "
643 "component types");
644}
libMesh::VectorValue< T > column(const unsigned int i) const
Get the i-th column of the second order tensor.
void symmetricEigenvaluesEigenvectors(std::vector< T > &eigvals, RankTwoTensorTempl< T > &eigvecs) const
computes eigenvalues and eigenvectors, assuming tens is symmetric, and places them in ascending order...
static SymmetricRankTwoTensorTempl< T > selfOuterProduct(const TypeVector< T > &)
SymmetricRankTwoTensorTempl<T> from outer product of a vector with itself.
MetaPhysicL::DualNumber< V, D, asd > abs(const MetaPhysicL::DualNumber< V, D, asd > &a)
Definition EigenADReal.h:50

◆ print()

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

Print the rank two tensor.

Definition at line 641 of file SymmetricRankTwoTensorImplementation.h.

642{
643 for (std::size_t i = 0; i < N; ++i)
644 stm << std::setw(15) << _vals[i] << std::endl;
645}

◆ printADReal()

template<typename T >
void SymmetricRankTwoTensorTempl< T >::printADReal ( unsigned int  nDual,
std::ostream &  stm = Moose::out 
) const

Print the Real part of the ADReal rank two tensor along with its first nDual dual numbers.

◆ printReal()

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

Print the Real part of the ADReal rank two tensor.

Definition at line 649 of file SymmetricRankTwoTensorImplementation.h.

650{
651 for (std::size_t i = 0; i < N; ++i)
652 stm << std::setw(15) << MetaPhysicL::raw_value(_vals[i]) << std::endl;
653}
auto raw_value(const Eigen::Map< T > &in)

◆ rotate()

template<typename T >
void SymmetricRankTwoTensorTempl< T >::rotate ( const TypeTensor< T > &  R)

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

Parameters
Rrotation matrix as a TypeTensor

Definition at line 257 of file SymmetricRankTwoTensorImplementation.h.

258{
260 *this = M * (*this);
261}
static SymmetricRankFourTensorTempl< T > rotationMatrix(const TypeTensor< T > &R)
Build a 6x6 rotation matrix MEHRABADI, MORTEZA M.; COWIN, STEPHEN C.

◆ row()

template<typename T >
libMesh::VectorValue< T > SymmetricRankTwoTensorTempl< T >::row ( const unsigned int  n) const

get the specified row of the tensor

multiply vector v with row n of this tensor

Definition at line 273 of file SymmetricRankTwoTensorImplementation.h.

274{
275 switch (n)
276 {
277 case 0:
279 _vals[0], _vals[5] / mandelFactor(5), _vals[4] / mandelFactor(4));
280 case 1:
282 _vals[5] / mandelFactor(5), _vals[1], _vals[3] / mandelFactor(3));
283 case 2:
285 _vals[4] / mandelFactor(4), _vals[3] / mandelFactor(3), _vals[2]);
286 default:
287 mooseError("Invalid row");
288 }
289}

Referenced by SymmetricRankTwoTensorTempl< T >::column().

◆ secondInvariant()

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

Denote the _vals[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 480 of file SymmetricRankTwoTensorImplementation.h.

481{
482 T result;
483 result = Utility::pow<2>(_vals[0] - _vals[1]) / 6.0;
484 result += Utility::pow<2>(_vals[0] - _vals[2]) / 6.0;
485 result += Utility::pow<2>(_vals[1] - _vals[2]) / 6.0;
486 result += Utility::pow<2>(_vals[5]) / 2.0;
487 result += Utility::pow<2>(_vals[4]) / 2.0;
488 result += Utility::pow<2>(_vals[3]) / 2.0;
489 return result;
490}

◆ selfOuterProduct()

template<typename T >
SymmetricRankTwoTensorTempl< T > SymmetricRankTwoTensorTempl< T >::selfOuterProduct ( const TypeVector< T > &  v)
static

SymmetricRankTwoTensorTempl<T> from outer product of a vector with itself.

Definition at line 727 of file SymmetricRankTwoTensorImplementation.h.

728{
730 v(0) * v(0), v(1) * v(1), v(2) * v(2), v(1) * v(2), v(0) * v(2), v(0) * v(1));
731}

Referenced by SymmetricRankTwoTensorTempl< T >::positiveProjectionEigenDecomposition().

◆ setToIdentity()

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

set the tensor to the identity matrix

Definition at line 746 of file SymmetricRankTwoTensorImplementation.h.

747{
748 std::copy(identityCoords.begin(), identityCoords.end(), _vals.begin());
749}
static constexpr std::array< Real, N > identityCoords

◆ sin3Lode()

template<typename T >
T SymmetricRankTwoTensorTempl< 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 648 of file SymmetricRankTwoTensor.h.

649{
650 using std::max, std::min, std::sqrt, std::pow;
651 if (MooseUtils::IsLikeReal<T>::value)
652 {
653 T bar = secondInvariant();
654 if (bar <= r0)
655 // in this case the Lode angle is not defined
656 return r0_value;
657 else
658 // the min and max here gaurd against precision-loss when bar is tiny but nonzero.
659 return max(min(thirdInvariant() * -1.5 * sqrt(3.0) / pow(bar, 1.5), 1.0), -1.0);
660 }
661 else
662 mooseError("sin3Lode is only available for ordered tensor component types");
663}
auto max(const L &left, const R &right)
auto min(const L &left, const R &right)

◆ square()

template<typename T >
SymmetricRankTwoTensorTempl< T > SymmetricRankTwoTensorTempl< T >::square ( ) const

Returns the matrix squared.

Definition at line 356 of file SymmetricRankTwoTensorImplementation.h.

357{
359}
static SymmetricRankTwoTensorTempl< T > timesTranspose(const RankTwoTensorTempl< T > &)
return the matrix multiplied with its transpose A*A^T (guaranteed symmetric)

◆ surfaceFillFromInputVector()

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

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

◆ syev()

template<typename T >
void SymmetricRankTwoTensorTempl< T >::syev ( const char *  calculation_type,
std::vector< T > &  eigvals,
std::vector< T > &  a 
) const
protected

Uses the petscblaslapack.h LAPACKsyev_ routine to find, for symmetric _vals: (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 676 of file SymmetricRankTwoTensorImplementation.h.

677{
678 mooseError("The syev method is only supported for Real valued tensors");
679}

◆ symmetricEigenvalues()

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

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

Definition at line 688 of file SymmetricRankTwoTensorImplementation.h.

689{
692}

◆ symmetricEigenvaluesEigenvectors()

template<typename T >
void SymmetricRankTwoTensorTempl< 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 699 of file SymmetricRankTwoTensorImplementation.h.

701{
703 "symmetricEigenvaluesEigenvectors is only available for ordered tensor component types");
704}

◆ thirdInvariant()

template<typename T >
T SymmetricRankTwoTensorTempl< T >::thirdInvariant ( ) const

Denote the _vals[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 545 of file SymmetricRankTwoTensorImplementation.h.

546{
548 return s(0) * (s(1) * s(2) - s(3) / MathUtils::sqrt2 * s(3) / MathUtils::sqrt2) -
549 s(5) / MathUtils::sqrt2 *
550 (s(5) / MathUtils::sqrt2 * s(2) - s(3) / MathUtils::sqrt2 * s(4) / MathUtils::sqrt2) +
551 s(4) / MathUtils::sqrt2 *
552 (s(5) / MathUtils::sqrt2 * s(3) / MathUtils::sqrt2 - s(1) * s(4) / MathUtils::sqrt2);
553}

◆ timesTranspose() [1/2]

template<typename T >
SymmetricRankTwoTensorTempl< T > SymmetricRankTwoTensorTempl< T >::timesTranspose ( const RankTwoTensorTempl< T > &  a)
static

return the matrix multiplied with its transpose A*A^T (guaranteed symmetric)

Definition at line 293 of file SymmetricRankTwoTensorImplementation.h.

294{
295 return SymmetricRankTwoTensorTempl<T>(a(0, 0) * a(0, 0) + a(0, 1) * a(0, 1) + a(0, 2) * a(0, 2),
296 a(1, 0) * a(1, 0) + a(1, 1) * a(1, 1) + a(1, 2) * a(1, 2),
297 a(2, 0) * a(2, 0) + a(2, 1) * a(2, 1) + a(2, 2) * a(2, 2),
298 a(1, 0) * a(2, 0) + a(1, 1) * a(2, 1) + a(1, 2) * a(2, 2),
299 a(0, 0) * a(2, 0) + a(0, 1) * a(2, 1) + a(0, 2) * a(2, 2),
300 a(0, 0) * a(1, 0) + a(0, 1) * a(1, 1) + a(0, 2) * a(1, 2));
301}

Referenced by SymmetricRankTwoTensorTempl< Real >::dsecondInvariant().

◆ timesTranspose() [2/2]

template<typename T >
SymmetricRankTwoTensorTempl< T > SymmetricRankTwoTensorTempl< T >::timesTranspose ( const SymmetricRankTwoTensorTempl< T > &  a)
static

Definition at line 305 of file SymmetricRankTwoTensorImplementation.h.

306{
308 a._vals[0] * a._vals[0] + a._vals[4] * a._vals[4] / 2.0 + a._vals[5] * a._vals[5] / 2.0,
309 a._vals[1] * a._vals[1] + a._vals[3] * a._vals[3] / 2.0 + a._vals[5] * a._vals[5] / 2.0,
310 a._vals[2] * a._vals[2] + a._vals[3] * a._vals[3] / 2.0 + a._vals[4] * a._vals[4] / 2.0,
311 a._vals[1] * a._vals[3] + a._vals[2] * a._vals[3] +
312 a._vals[4] * a._vals[5] / MathUtils::sqrt2,
313 a._vals[0] * a._vals[4] + a._vals[2] * a._vals[4] +
314 a._vals[3] * a._vals[5] / MathUtils::sqrt2,
315 a._vals[0] * a._vals[5] + a._vals[1] * a._vals[5] +
316 a._vals[3] * a._vals[4] / MathUtils::sqrt2);
317}
static SymmetricRankTwoTensorTempl fromRawComponents(const T &S11, const T &S22, const T &S33, const T &S23, const T &S13, const T &S12)

◆ tr()

template<typename T >
T SymmetricRankTwoTensorTempl< T >::tr ( ) const
inline

Returns the trace.

Definition at line 225 of file SymmetricRankTwoTensor.h.

225{ return _vals[0] + _vals[1] + _vals[2]; }

◆ trace()

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

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

Definition at line 514 of file SymmetricRankTwoTensorImplementation.h.

515{
516 return tr();
517}

◆ transpose()

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

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

This is a non-operation.

Definition at line 265 of file SymmetricRankTwoTensorImplementation.h.

266{
267 return *this;
268}

◆ transposeTimes() [1/2]

template<typename T >
SymmetricRankTwoTensorTempl< T > SymmetricRankTwoTensorTempl< T >::transposeTimes ( const RankTwoTensorTempl< T > &  a)
static

return the matrix multiplied with its transpose A^T*A (guaranteed symmetric)

Definition at line 321 of file SymmetricRankTwoTensorImplementation.h.

322{
323 return SymmetricRankTwoTensorTempl<T>(a(0, 0) * a(0, 0) + a(1, 0) * a(1, 0) + a(2, 0) * a(2, 0),
324 a(0, 1) * a(0, 1) + a(1, 1) * a(1, 1) + a(2, 1) * a(2, 1),
325 a(0, 2) * a(0, 2) + a(1, 2) * a(1, 2) + a(2, 2) * a(2, 2),
326 a(0, 1) * a(0, 2) + a(1, 1) * a(1, 2) + a(2, 1) * a(2, 2),
327 a(0, 0) * a(0, 2) + a(1, 0) * a(1, 2) + a(2, 0) * a(2, 2),
328 a(0, 0) * a(0, 1) + a(1, 0) * a(1, 1) + a(2, 0) * a(2, 1));
329}

◆ transposeTimes() [2/2]

template<typename T >
SymmetricRankTwoTensorTempl< T > SymmetricRankTwoTensorTempl< T >::transposeTimes ( const SymmetricRankTwoTensorTempl< T > &  a)
static

Definition at line 333 of file SymmetricRankTwoTensorImplementation.h.

334{
335 return timesTranspose(a);
336}

◆ zero()

template<typename T >
void SymmetricRankTwoTensorTempl< T >::zero ( )

Set all components to zero.

Definition at line 363 of file SymmetricRankTwoTensorImplementation.h.

364{
365 for (std::size_t i = 0; i < N; ++i)
366 _vals[i] = 0.0;
367}

Referenced by MathUtils::mooseSetToZero< ADSymmetricRankTwoTensor >(), MathUtils::mooseSetToZero< SymmetricRankTwoTensor >(), and SymmetricRankTwoTensorTempl< T >::operator=().

Friends And Related Symbol Documentation

◆ dataLoad

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

◆ dataStore

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

◆ operator<<

template<typename T >
std::ostream & operator<< ( std::ostream &  os,
const SymmetricRankTwoTensorTempl< T > &  t 
)
friend

Definition at line 419 of file SymmetricRankTwoTensor.h.

420 {
421 t.print(os);
422 return os;
423 }
void print(std::ostream &stm=Moose::out) const
Print the rank two tensor.

◆ SymmetricRankFourTensorTempl

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

Definition at line 497 of file SymmetricRankTwoTensor.h.

Member Data Documentation

◆ _vals

template<typename T >
std::array<T, N> SymmetricRankTwoTensorTempl< T >::_vals
private

◆ full_index

template<typename T >
constexpr unsigned int SymmetricRankTwoTensorTempl< T >::full_index[6][2] = {{0, 0}, {1, 1}, {2, 2}, {1, 2}, {0, 2}, {0, 1}}
staticconstexpr

Definition at line 85 of file SymmetricRankTwoTensor.h.

85{{0, 0}, {1, 1}, {2, 2}, {1, 2}, {0, 2}, {0, 1}};

◆ identityCoords

template<typename T >
constexpr std::array< Real, SymmetricRankTwoTensorTempl< T >::N > SymmetricRankTwoTensorTempl< T >::identityCoords = {{1, 1, 1, 0, 0, 0}}
staticconstexprprivate

Definition at line 486 of file SymmetricRankTwoTensor.h.

486{{1, 1, 1, 0, 0, 0}};

◆ N

template<typename T >
constexpr unsigned int SymmetricRankTwoTensorTempl< T >::N = Ndim + (Ndim * (Ndim - 1)) / 2
staticconstexpr

◆ Ndim

template<typename T >
constexpr unsigned int SymmetricRankTwoTensorTempl< T >::Ndim = Moose::dim
staticconstexpr

tensor dimension and Mandel vector length

Definition at line 80 of file SymmetricRankTwoTensor.h.

Referenced by SymmetricRankTwoTensorTempl< T >::mandelFactor().

◆ reverse_index

template<typename T >
constexpr unsigned int SymmetricRankTwoTensorTempl< T >::reverse_index[3][3] = {{0, 5, 4}, {5, 1, 3}, {4, 3, 2}}
staticconstexpr

Definition at line 88 of file SymmetricRankTwoTensor.h.

88{{0, 5, 4}, {5, 1, 3}, {4, 3, 2}};

Referenced by SymmetricRankTwoTensorTempl< T >::operator()().


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