Loading [MathJax]/extensions/tex2jax.js
https://mooseframework.inl.gov
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | 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 <RankTwoTensor.h>

Inheritance diagram for RankTwoTensorTempl< T >:
[legend]

Public Types

typedef T value_type
 
typedef std::tuple< unsigned int, unsigned intindex_type
 

Public Member Functions

void assign (const TypeTensor< T2 > &)
 
const T & operator() (const unsigned int i, const unsigned int j) const
 
T & operator() (const unsigned int i, const unsigned int j)
 
ConstTypeTensorColumn< T > slice (const unsigned int i) const
 
TypeTensorColumn< T > slice (const unsigned int i)
 
TypeVector< T > row (const unsigned int r) const
 
const TypeTensor< T > & operator+= (const TypeTensor< T2 > &)
 
void add (const TypeTensor< T2 > &)
 
void add_scaled (const TypeTensor< T2 > &, const T &)
 
const TypeTensor< T > & operator-= (const TypeTensor< T2 > &)
 
void subtract (const TypeTensor< T2 > &)
 
void subtract_scaled (const TypeTensor< T2 > &, const T &)
 
auto operator* (const Scalar &scalar) const -> typename boostcopy::enable_if_c< ScalarTraits< Scalar >::value, TypeTensor< decltype(T() *scalar)>>::type
 
const TypeTensor< T > & operator*= (const Scalar &factor)
 
const TypeTensor< T > & operator*= (const TypeTensor< T2 > &)
 
boostcopy::enable_if_c< ScalarTraits< Scalar >::value, TypeTensor< typename CompareTypes< T, Scalar >::supertype > >::type operator/ (const Scalar &) const
 
CompareTypes< T, T2 >::supertype contract (const TypeTensor< T2 > &) const
 
TypeVector< typename CompareTypes< T, T2 >::supertype > left_multiply (const TypeVector< T2 > &p) const
 
void solve (const TypeVector< T > &b, TypeVector< T > &x) const
 
auto norm () const -> decltype(std::norm(T()))
 
auto norm_sq () const -> decltype(std::norm(T()))
 
bool is_zero () const
 
det () const
 
tr () const
 
void zero ()
 
bool operator== (const TypeTensor< T > &rhs) const
 
bool operator< (const TypeTensor< T > &rhs) const
 
bool operator< (const TypeTensor< Real > &rhs) const
 
bool operator< (const TypeTensor< Complex > &rhs) const
 
bool operator> (const TypeTensor< T > &rhs) const
 
bool operator> (const TypeTensor< Real > &rhs) const
 
bool operator> (const TypeTensor< Complex > &rhs) const
 
void write_unformatted (std::ostream &out_stream, const bool newline=true) const
 
 RankTwoTensorTempl ()
 Empty constructor; fills to zero. More...
 
 RankTwoTensorTempl (const InitMethod)
 Select specific initialization pattern. More...
 
 RankTwoTensorTempl (const libMesh::TypeVector< T > &row1, const libMesh::TypeVector< T > &row2, const libMesh::TypeVector< T > &row3)
 Initialize from row vectors. More...
 
 RankTwoTensorTempl (const std::vector< T > &input)
 Constructor that proxies the fillFromInputVector() method. More...
 
 RankTwoTensorTempl (const T &S11, const T &S22, const T &S33, const T &S23, const T &S13, const T &S12)
 Initialize a symmetric second order tensor using the 6 arguments. More...
 
 RankTwoTensorTempl (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)
 Initialize a second order tensor using the 9 arguments in a column-major fashion. More...
 
 RankTwoTensorTempl (const RankTwoTensorTempl< T > &a)=default
 The copy constructor. More...
 
 RankTwoTensorTempl (const libMesh::TensorValue< T > &a)
 The conversion operator from a libMesh::TensorValue More...
 
 RankTwoTensorTempl (const libMesh::TypeTensor< T > &a)
 The conversion operator from a libMesh::TypeTensor More...
 
template<typename T2 >
 RankTwoTensorTempl (const SymmetricRankTwoTensorTempl< T2 > &a)
 The conversion operator from a SymmetricRankTwoTensorTempl More...
 
template<typename T2 >
 RankTwoTensorTempl (const RankTwoTensorTempl< T2 > &a)
 The conversion operator from RankTwoTensorTempl<T2> to RankTwoTensorTempl<T> where T2 is convertible to T. More...
 
libMesh::VectorValue< T > column (const unsigned int i) const
 Get the i-th column of the second order tensor. More...
 
RankTwoTensorTempl< T > & operator= (const RankTwoTensorTempl< T > &a)=default
 Assignment operator. More...
 
RankTwoTensorTempl< T > & operator= (const ColumnMajorMatrixTempl< T > &a)
 Assignment operator (from a ColumnMajorMatrixTempl<T>) More...
 
template<typename Scalar >
libMesh::boostcopy::enable_if_c< libMesh::ScalarTraits< Scalar >::value, RankTwoTensorTempl & >::type operator= (const Scalar &libmesh_dbg_var(p))
 Assignment-from-scalar operator. More...
 
RankTwoTensorTempl< T > & operator+= (const RankTwoTensorTempl< T > &a)
 Add another second order tensor to this one. More...
 
RankTwoTensorTempl< T > & operator-= (const RankTwoTensorTempl< T > &a)
 Subtract another second order tensor from this one. More...
 
RankTwoTensorTempl< T > & operator*= (const T &a)
 Multiply this tensor by a scalar (component-wise) More...
 
RankTwoTensorTempl< T > & operator/= (const T &a)
 Divide this tensor by a scalar (component-wise) More...
 
RankTwoTensorTempl< T > & operator*= (const libMesh::TypeTensor< T > &a)
 Multiplication with another second order tensor. More...
 
void fillFromInputVector (const std::vector< T > &input, FillMethod fill_method=autodetect)
 The smart mutator that determines how to fill the second order tensor based on the size of the input vector. More...
 
void fillFromScalarVariable (const VariableValue &scalar_variable)
 
The smart mutator that determines how to fill the second order tensor based on the order of the scalar_variable. 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 vectorOuterProduct (const libMesh::TypeVector< T > &, const libMesh::TypeVector< T > &)
 Set the values of the second order tensor to be the outer product of two vectors, i.e. More...
 
void fillRow (unsigned int r, const libMesh::TypeVector< T > &v)
 Assign values to a specific row of the second order tensor. More...
 
void fillColumn (unsigned int c, const libMesh::TypeVector< T > &v)
 Assign values to a specific column of the second order tensor. More...
 
void setToIdentity ()
 Set the tensor to identity. More...
 
void addIa (const T &a)
 Add identity times a to _coords. More...
 
void rotate (const RankTwoTensorTempl< T > &R)
 Rotate the tensor in-place given a rotation tensor \( A_{ij} \leftarrow R_{ij} A_{jk} R_{jk} \). More...
 
RankTwoTensorTempl< T > square () const
 Return \( A_{ij} = A_{ik}A_{kj} \). More...
 
RankTwoTensorTempl< T > rotated (const RankTwoTensorTempl< T > &R) const
 Return the rotated tensor given a rotation tensor \( A'_{ij} = R_{ij} A_{jk} R_{jk} \). More...
 
RankTwoTensorTempl< T > rotateXyPlane (T a)
 Rotate the tensor about the z-axis. More...
 
RankTwoTensorTempl< T > transpose () const
 Return the tensor transposed. More...
 
template<typename T2 >
RankTwoTensorTempl< typename libMesh::CompareTypes< T, T2 >::supertype > operator+ (const libMesh::TypeTensor< T2 > &a) const
 Return the sum of two second order tensors. More...
 
template<typename T2 >
RankTwoTensorTempl< typename libMesh::CompareTypes< T, T2 >::supertype > operator- (const libMesh::TypeTensor< T2 > &a) const
 Return the subtraction of two second order tensors. More...
 
RankTwoTensorTempl< T > operator- () const
 Return the negation of this tensor. More...
 
template<typename T2 , typename std::enable_if< libMesh::ScalarTraits< T2 >::value, int >::type = 0>
RankTwoTensorTempl< typename libMesh::CompareTypes< T, T2 >::supertype > operator* (const T2 &a) const
 Return this tensor multiplied by a scalar (component-wise) More...
 
template<typename T2 , typename std::enable_if< libMesh::ScalarTraits< T2 >::value, int >::type = 0>
RankTwoTensorTempl< typename libMesh::CompareTypes< T, T2 >::supertype > operator/ (const T2 &a) const
 Return this tensor divided by a scalar (component-wise) More...
 
template<typename T2 >
libMesh::TypeVector< typename libMesh::CompareTypes< T, T2 >::supertype > operator* (const libMesh::TypeVector< T2 > &a) const
 Return this tensor multiplied by a vector. More...
 
template<typename T2 >
RankTwoTensorTempl< typename libMesh::CompareTypes< T, T2 >::supertype > operator* (const libMesh::TypeTensor< T2 > &a) const
 Multiplication with another second order tensor. More...
 
doubleContraction (const RankTwoTensorTempl< T > &a) const
 Return the double contraction with another second order tensor \( A_{ij} B_{ij} \). More...
 
template<int n, int o, int p, int q>
RankFourTensorTempl< T > times (const RankTwoTensorTempl< T > &b) const
 Return the general tensor product of this second order tensor and another second order tensor defined as \( C_{ijkl} = A_{\mathcal{M}(n)\mathcal{M}(o)} B_{\mathcal{M}(p)\mathcal{M}(q)} \) where the multiplication order is defined by the index map \( \mathcal{M}: \{n,o,p,q\} \to \{i,j,k,l\} \). More...
 
template<int n, int o, int p, int q, int r, int s>
RankFourTensorTempl< T > times (const RankFourTensorTempl< T > &b) const
 Return the single contraction of this second order tensor with a fourth order tensor defined as \( C_{ijkl} = A_{\mathcal{M}(m)\mathcal{M}(n)} B_{\mathcal{M}(p)\mathcal{M}(q)\mathcal{M}(r)\mathcal{M}(s)} \) where the multiplication order is defined by the index map \( \mathcal{M}: \{m,n,p,q,r,s\} \to \{i,j,k,l\} \). More...
 
RankFourTensorTempl< T > outerProduct (const RankTwoTensorTempl< T > &b) const
 Return the outer product \( C_{ijkl} = A_{ij} B_{kl} \). More...
 
RankThreeTensorTempl< T > contraction (const RankThreeTensorTempl< T > &b) const
 Return the single contraction of this second order tensor with a third order tensor \( C_{ikl} = A_{ij} B_{jkl} \). More...
 
RankThreeTensorTempl< T > mixedProductJkI (const libMesh::VectorValue< T > &b) const
 Return the tensor product of this second order tensor with a vector \( C_{ijk} = A_{jk} b_{i} \). More...
 
RankFourTensorTempl< T > positiveProjectionEigenDecomposition (std::vector< T > &, RankTwoTensorTempl< T > &) const
 Return the positive projection tensor. More...
 
RankTwoTensorTempl< T > deviatoric () const
 Return the deviatoric part of this tensor \( A_{ij} - \frac{1}{3} A_{kk} \delta_{ij} \). More...
 
trace () const
 A wrapper for tr() More...
 
RankTwoTensorTempl< T > dtrace () const
 Return the derivative of the trace w.r.t. More...
 
RankTwoTensorTempl< T > inverse () const
 Return the inverse of this second order tensor. More...
 
generalSecondInvariant () const
 Return the principal second invariant of this second order tensor. More...
 
secondInvariant () const
 Return the main second invariant of this second order tensor. More...
 
RankTwoTensorTempl< T > dsecondInvariant () const
 Return the derivative of the main second invariant w.r.t. More...
 
RankFourTensorTempl< T > d2secondInvariant () const
 Return the second derivative of the main second invariant w.r.t. More...
 
sin3Lode (const T &r0, const T &r0_value) const
 Sin(3*Lode_angle) 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...
 
L2norm () const
 Sqrt(_coords[i][j]*_coords[i][j]) 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 getRUDecompositionRotation (RankTwoTensorTempl< T > &rot) const
 Uses the petscblaslapack.h LAPACKsyev_ routine to perform RU decomposition and obtain the rotation tensor. More...
 
RankTwoTensorTempl< T > initialContraction (const RankFourTensorTempl< T > &b) const
 returns this_ij * b_ijkl More...
 
bool operator== (const RankTwoTensorTempl< T > &a) const
 Defines logical equality with another RankTwoTensorTempl<T> More...
 
bool isSymmetric () const
 Test for symmetry. More...
 

Static Public Member Functions

static TensorValue< Realintrinsic_rotation_matrix (Real phi, Real theta, Real psi)
 
static TensorValue< Realinverse_intrinsic_rotation_matrix (Real phi, Real theta, Real psi)
 
static TensorValue< Realextrinsic_rotation_matrix (Real angle1_deg, Real angle2_deg, Real angle3_deg)
 
static TensorValue< Realinverse_extrinsic_rotation_matrix (Real angle1_deg, Real angle2_deg, Real angle3_deg)
 
static RankTwoTensorTempl initializeSymmetric (const libMesh::TypeVector< T > &v0, const libMesh::TypeVector< T > &v1, const libMesh::TypeVector< T > &v2)
 Named constructor for initializing symmetrically. More...
 
static RankTwoTensorTempl initializeFromRows (const libMesh::TypeVector< T > &row0, const libMesh::TypeVector< T > &row1, const libMesh::TypeVector< T > &row2)
 Named constructor for initializing from row vectors. More...
 
static RankTwoTensorTempl initializeFromColumns (const libMesh::TypeVector< T > &col0, const libMesh::TypeVector< T > &col1, const libMesh::TypeVector< T > &col2)
 Named constructor for initializing from row vectors. More...
 
static RankTwoTensorTempl Identity ()
 Initialize a second order identity tensor. More...
 
static RankTwoTensorTempl< T > timesTranspose (const RankTwoTensorTempl< T > &)
 Initialize a second order tensor with expression \( B_{ij} = F_{ij} F_{ji} \). More...
 
static RankTwoTensorTempl< T > transposeTimes (const RankTwoTensorTempl< T > &)
 Initialize a second order tensor with expression \( C_{ij} = F_{ji} F_{ij} \). More...
 
static RankTwoTensorTempl< T > plusTranspose (const RankTwoTensorTempl< T > &)
 Initialize a second order tensor with expression \( E_{ij} = C_{ij} + C_{ji} \). More...
 
static RankTwoTensorTempl< T > outerProduct (const libMesh::TypeVector< T > &, const libMesh::TypeVector< T > &)
 Initialize a second order tensor as the outer product of two vectors, i.e. More...
 
static RankTwoTensorTempl< T > selfOuterProduct (const libMesh::TypeVector< T > &)
 Initialize a second order tensor as the outer product of a vector with itself, i.e. More...
 
static RankTwoTensorTempl< T > genRandomTensor (T stddev, T mean)
 Generate a random second order tensor with all 9 components treated as independent random variables following a Gaussian distribution. More...
 
static RankTwoTensorTempl< T > genRandomSymmTensor (T stddev, T mean)
 Generate a random symmetric second order tensor with the 6 upper-triangular components treated as independent random variables following a Gaussian distribution. More...
 

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

Protected Attributes

_coords [LIBMESH_DIM *LIBMESH_DIM]
 

Static Private Attributes

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 *)
 
enum  InitMethod { initNone, initIdentity }
 The initialization method. More...
 
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...
 
static constexpr unsigned int N = Moose::dim
 Tensor dimension, i.e. More...
 
static constexpr unsigned int N2 = N * N
 The square of the tensor dimension. More...
 
static void initRandom (unsigned int)
 Initialize the random seed based on an unsigned integer. More...
 
static MooseEnum fillMethodEnum ()
 Get the available FillMethod options. More...
 
void fillRealTensor (libMesh::TensorValue< T > &)
 Fill a libMesh::TensorValue<T> from this second order tensor. More...
 
void print (std::ostream &stm=Moose::out) const
 Print the rank two tensor. More...
 
void printReal (std::ostream &stm=Moose::out) const
 Print the Real part of the RankTwoTensorTempl<ADReal> More...
 
void printADReal (unsigned int nDual, std::ostream &stm=Moose::out) const
 Print the Real part of the RankTwoTensorTempl<ADReal> along with its first nDual dual numbers. More...
 

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 79 of file RankTwoTensor.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 110 of file RankTwoTensor.h.

◆ InitMethod

template<typename T>
enum RankTwoTensorTempl::InitMethod

The initialization method.

See also
fillFromInputVector()
RankTwoTensorTempl(const std::vector<T> &)
Enumerator
initNone 
initIdentity 

Definition at line 99 of file RankTwoTensor.h.

Constructor & Destructor Documentation

◆ RankTwoTensorTempl() [1/11]

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

Empty constructor; fills to zero.

\( A_{ij} = 0 \)

// A = [ 0 0 0
// 0 0 0
// 0 0 0 ]

Definition at line 72 of file RankTwoTensorImplementation.h.

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

73 {
74  mooseAssert(N == 3, "RankTwoTensorTempl is currently only tested for 3 dimensions.");
75 
76  for (unsigned int i = 0; i < N2; i++)
77  _coords[i] = 0.0;
78 }
T _coords[LIBMESH_DIM *LIBMESH_DIM]
static constexpr unsigned int N
Tensor dimension, i.e.
Definition: RankTwoTensor.h:87
static constexpr unsigned int N2
The square of the tensor dimension.
Definition: RankTwoTensor.h:92

◆ RankTwoTensorTempl() [2/11]

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

Select specific initialization pattern.

initNone initializes an empty second order tensor.

// A = [ 0 0 0
// 0 0 0
// 0 0 0 ]

initIdentity initializes a second order identity tensor.

// A = [ 1 0 0
// 0 1 0
// 0 0 1 ]

Definition at line 81 of file RankTwoTensorImplementation.h.

82 {
83  switch (init)
84  {
85  case initNone:
86  break;
87 
88  case initIdentity:
89  this->zero();
90  for (const auto i : make_range(N))
91  (*this)(i, i) = 1.0;
92  break;
93 
94  default:
95  mooseError("Unknown RankTwoTensorTempl initialization pattern.");
96  }
97 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:302
static constexpr unsigned int N
Tensor dimension, i.e.
Definition: RankTwoTensor.h:87
IntRange< T > make_range(T beg, T end)

◆ RankTwoTensorTempl() [3/11]

template<typename T>
RankTwoTensorTempl< T >::RankTwoTensorTempl ( const libMesh::TypeVector< T > &  row1,
const libMesh::TypeVector< T > &  row2,
const libMesh::TypeVector< T > &  row3 
)

Initialize from row vectors.

See also
initializeFromRows()

Deprecated in favor of initializeFromRows()

RealVectorValue row1(1, 2, 3);
RealVectorValue row2(4, 5, 6);
RealVectorValue row3(7, 8, 9);
RankTwoTensor A(row1, row2, row3);
// A = [ 1 2 3
// 4 5 6
// 7 8 9 ]

Definition at line 100 of file RankTwoTensorImplementation.h.

103 {
105  "This constructor is deprecated in favor of RankTwoTensorTempl<T>::initializeFromRows");
106 
107  // Initialize the Tensor matrix from the passed in vectors
108  for (const auto i : make_range(N))
109  _coords[i] = row1(i);
110 
111  for (const auto i : make_range(N))
112  _coords[N + i] = row2(i);
113 
114  for (const auto i : make_range(N))
115  _coords[2 * N + i] = row3(i);
116 }
T _coords[LIBMESH_DIM *LIBMESH_DIM]
static constexpr unsigned int N
Tensor dimension, i.e.
Definition: RankTwoTensor.h:87
void mooseDeprecated(Args &&... args)
Emit a deprecated code/feature message with the given stringified, concatenated args.
Definition: MooseError.h:353
IntRange< T > make_range(T beg, T end)

◆ RankTwoTensorTempl() [4/11]

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

Constructor that proxies the fillFromInputVector() method.

See also
fillFromInputVector()

Definition at line 211 of file RankTwoTensor.h.

211 { this->fillFromInputVector(input); };
void fillFromInputVector(const std::vector< T > &input, FillMethod fill_method=autodetect)
The smart mutator that determines how to fill the second order tensor based on the size of the input ...

◆ RankTwoTensorTempl() [5/11]

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

Initialize a symmetric second order tensor using the 6 arguments.

RankTwoTensor A(1, 2, 3, 4, 5, 6);
// A = [ 1 6 5
// 6 2 4
// 5 4 3 ]

Definition at line 156 of file RankTwoTensorImplementation.h.

158 {
159  (*this)(0, 0) = S11;
160  (*this)(1, 1) = S22;
161  (*this)(2, 2) = S33;
162  (*this)(1, 2) = (*this)(2, 1) = S23;
163  (*this)(0, 2) = (*this)(2, 0) = S13;
164  (*this)(0, 1) = (*this)(1, 0) = S12;
165 }

◆ RankTwoTensorTempl() [6/11]

template<typename T>
RankTwoTensorTempl< T >::RankTwoTensorTempl ( 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 
)

Initialize a second order tensor using the 9 arguments in a column-major fashion.

RankTwoTensor A(1, 2, 3, 4, 5, 6, 7, 8, 9);
// A = [ 1 4 7
// 2 5 8
// 3 6 9 ]

Definition at line 168 of file RankTwoTensorImplementation.h.

177 {
178  (*this)(0, 0) = S11;
179  (*this)(1, 0) = S21;
180  (*this)(2, 0) = S31;
181  (*this)(0, 1) = S12;
182  (*this)(1, 1) = S22;
183  (*this)(2, 1) = S32;
184  (*this)(0, 2) = S13;
185  (*this)(1, 2) = S23;
186  (*this)(2, 2) = S33;
187 }

◆ RankTwoTensorTempl() [7/11]

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

The copy constructor.

RankTwoTensor A(1, 2, 3, 4, 5, 6, 7, 8, 9);
// A = B = [ 1 4 7
// 2 5 8
// 3 6 9 ]

◆ RankTwoTensorTempl() [8/11]

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

The conversion operator from a libMesh::TensorValue

Definition at line 262 of file RankTwoTensor.h.

◆ RankTwoTensorTempl() [9/11]

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

The conversion operator from a libMesh::TypeTensor

Definition at line 267 of file RankTwoTensor.h.

◆ RankTwoTensorTempl() [10/11]

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

The conversion operator from a SymmetricRankTwoTensorTempl

Definition at line 273 of file RankTwoTensor.h.

274  : RankTwoTensorTempl<T>(a(0),
275  a(1),
276  a(2),
277  a(3) / MathUtils::sqrt2,
278  a(4) / MathUtils::sqrt2,
279  a(5) / MathUtils::sqrt2)
280  {
281  }
RankTwoTensorTempl is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: RankTwoTensor.h:79
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

◆ RankTwoTensorTempl() [11/11]

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

The conversion operator from RankTwoTensorTempl<T2> to RankTwoTensorTempl<T> where T2 is convertible to T.

Definition at line 288 of file RankTwoTensor.h.

Member Function Documentation

◆ addIa()

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

Add identity times a to _coords.

Add a scalar to diagonal components \( A_{ij} + a\delta_{ij} \)

// A = [ 0 0 0
// 0 0 0
// 0 0 0 ]
A.addIa(1.5);
// A = [ 1.5 0 0
// 0 1.5 0
// 0 0 1.5 ]

Definition at line 735 of file RankTwoTensorImplementation.h.

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

736 {
737  for (const auto i : make_range(N))
738  (*this)(i, i) += a;
739 }
static constexpr unsigned int N
Tensor dimension, i.e.
Definition: RankTwoTensor.h:87
IntRange< T > make_range(T beg, T end)

◆ column()

template<typename T >
libMesh::VectorValue< T > RankTwoTensorTempl< T >::column ( const unsigned int  i) const

Get the i-th column of the second order tensor.

Parameters
iThe column number, i = 0, 1, 2
Returns
The i-th column of the second order tensor.
RankTwoTensor A(1, 2, 3, 4, 5, 6, 7, 8, 9);
RealVectorValue col = A.column(1);
// col = [ 4
// 5
// 6 ]

Definition at line 274 of file RankTwoTensorImplementation.h.

Referenced by FactorizedRankTwoTensorTempl< T >::assemble(), SymmetricRankTwoTensorTempl< Real >::positiveProjectionEigenDecomposition(), and RankTwoTensorTempl< Real >::positiveProjectionEigenDecomposition().

275 {
276  return libMesh::VectorValue<T>((*this)(0, c), (*this)(1, c), (*this)(2, c));
277 }

◆ contraction()

template<typename T>
RankThreeTensorTempl< T > RankTwoTensorTempl< T >::contraction ( const RankThreeTensorTempl< T > &  b) const

Return the single contraction of this second order tensor with a third order tensor \( C_{ikl} = A_{ij} B_{jkl} \).

Definition at line 464 of file RankTwoTensorImplementation.h.

465 {
467 
468  for (const auto i : make_range(N))
469  for (const auto j : make_range(N))
470  for (const auto k : make_range(N))
471  for (const auto l : make_range(N))
472  result(i, k, l) += (*this)(i, j) * b(j, k, l);
473 
474  return result;
475 }
static constexpr unsigned int N
Tensor dimension, i.e.
Definition: RankTwoTensor.h:87
RankThreeTensor is designed to handle any N-dimensional third order tensor, r.
IntRange< T > make_range(T beg, T end)

◆ d2secondInvariant()

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

Return the second derivative of the main second invariant w.r.t.

this second order tensor itself \( \frac{\partial^2 J_2}{\partial A_{ij}A_{kl}} = \delta_{ik}\delta_{jl} - \frac{1}{3}\delta_{ij}\delta_{kl} \)

Definition at line 538 of file RankTwoTensorImplementation.h.

539 {
540  RankFourTensorTempl<T> result;
541  for (const auto i : make_range(N))
542  for (const auto j : make_range(N))
543  for (const auto k : make_range(N))
544  for (const auto l : make_range(N))
545  result(i, j, k, l) = 0.5 * (i == k) * (j == l) + 0.5 * (i == l) * (j == k) -
546  (1.0 / 3.0) * (i == j) * (k == l);
547  return result;
548 }
RankFourTensorTempl is designed to handle any N-dimensional fourth order tensor, C.
static constexpr unsigned int N
Tensor dimension, i.e.
Definition: RankTwoTensor.h:87
IntRange< T > make_range(T beg, T end)

◆ 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 1539 of file RankTwoTensor.h.

1540 {
1541  if constexpr (MooseUtils::IsLikeReal<T>::value)
1542  {
1543  T bar = secondInvariant();
1544  if (bar <= r0)
1545  return RankFourTensorTempl<T>();
1546 
1547  T J3 = thirdInvariant();
1551  1.5 * d2secondInvariant() * J3 / std::pow(bar, 2.5);
1552 
1553  for (unsigned i = 0; i < N; ++i)
1554  for (unsigned j = 0; j < N; ++j)
1555  for (unsigned k = 0; k < N; ++k)
1556  for (unsigned l = 0; l < N; ++l)
1557  deriv(i, j, k, l) += (-1.5 * dII(i, j) * dIII(k, l) - 1.5 * dIII(i, j) * dII(k, l)) /
1558  std::pow(bar, 2.5) +
1559  1.5 * 2.5 * dII(i, j) * dII(k, l) * J3 / std::pow(bar, 3.5);
1560 
1561  deriv *= -1.5 * std::sqrt(3.0);
1562  return deriv;
1563  }
1564  else
1565  mooseError("d2sin3Lode is only available for ordered tensor component types");
1566 }
RankFourTensorTempl is designed to handle any N-dimensional fourth order tensor, C.
RankTwoTensorTempl< T > dsecondInvariant() const
Return the derivative of the main second invariant w.r.t.
RankFourTensorTempl< T > d2secondInvariant() const
Return the second derivative of the main second invariant w.r.t.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:302
T secondInvariant() const
Return the main second invariant of this second order 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
Tensor dimension, i.e.
Definition: RankTwoTensor.h:87
Custom type trait that has a value of true for types that cam be use interchangeably with Real...
Definition: MooseUtils.h:972
Real deriv(unsigned n, unsigned alpha, unsigned beta, Real x)
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...
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template * sqrt(_arg)) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(tanh
RankTwoTensorTempl is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: RankTwoTensor.h:79
MooseUnits pow(const MooseUnits &, int)
Definition: Units.C:537

◆ 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 853 of file RankTwoTensorImplementation.h.

854 {
855  std::vector<T> eigvec;
856  std::vector<T> eigvals;
857  T ev[N][N];
858 
859  // reset rank four tensor
860  deriv.assign(N, RankFourTensorTempl<T>());
861 
862  // get eigen values and eigen vectors
863  syev("V", eigvals, eigvec);
864 
865  for (const auto i : make_range(N))
866  for (const auto j : make_range(N))
867  ev[i][j] = eigvec[i * N + j];
868 
869  for (unsigned int alpha = 0; alpha < N; ++alpha)
870  for (unsigned int beta = 0; beta < N; ++beta)
871  {
872  if (eigvals[alpha] == eigvals[beta])
873  continue;
874 
875  for (const auto i : make_range(N))
876  for (const auto j : make_range(N))
877  for (const auto k : make_range(N))
878  for (const auto l : make_range(N))
879  {
880  deriv[alpha](i, j, k, l) +=
881  0.5 * (ev[beta][i] * ev[alpha][j] + ev[alpha][i] * ev[beta][j]) *
882  (ev[beta][k] * ev[alpha][l] + ev[beta][l] * ev[alpha][k]) /
883  (eigvals[alpha] - eigvals[beta]);
884  }
885  }
886 }
RankFourTensorTempl is designed to handle any N-dimensional fourth order tensor, C.
static constexpr unsigned int N
Tensor dimension, i.e.
Definition: RankTwoTensor.h:87
Real deriv(unsigned n, unsigned alpha, unsigned beta, Real x)
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...
IntRange< T > make_range(T beg, T end)

◆ 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 604 of file RankTwoTensorImplementation.h.

605 {
606  const auto s = RankTwoTensorTempl<T>::plusTranspose(deviatoric()) * 0.5;
607 
609  for (const auto i : make_range(N))
610  for (const auto j : make_range(N))
611  for (const auto k : make_range(N))
612  for (const auto l : make_range(N))
613  {
614  d2(i, j, k, l) = Real(i == j) * s(k, l) / 3.0 + Real(k == l) * s(i, j) / 3.0;
615  // for (const auto a: make_range(N))
616  // for (const auto b: make_range(N))
617  // d2(i, j, k, l) += 0.5*(PermutationTensor::eps(i, k, a)*PermutationTensor::eps(j, l,
618  // b) + PermutationTensor::eps(i, l, a)*PermutationTensor::eps(j, k, b))*s(a, b);
619  }
620 
621  // I'm not sure which is more readable: the above
622  // PermutationTensor stuff, or the stuff below.
623  // Anyway, they yield the same result, and so i leave
624  // both of them here to enlighten you!
625 
626  d2(0, 0, 1, 1) += s(2, 2);
627  d2(0, 0, 1, 2) -= s(2, 1);
628  d2(0, 0, 2, 1) -= s(1, 2);
629  d2(0, 0, 2, 2) += s(1, 1);
630 
631  d2(0, 1, 0, 1) -= s(2, 2) / 2.0;
632  d2(0, 1, 1, 0) -= s(2, 2) / 2.0;
633  d2(0, 1, 0, 2) += s(1, 2) / 2.0;
634  d2(0, 1, 2, 0) += s(1, 2) / 2.0;
635  d2(0, 1, 1, 2) += s(2, 0) / 2.0;
636  d2(0, 1, 2, 1) += s(2, 0) / 2.0;
637  d2(0, 1, 2, 2) -= s(1, 0);
638 
639  d2(0, 2, 0, 1) += s(2, 1) / 2.0;
640  d2(0, 2, 1, 0) += s(2, 1) / 2.0;
641  d2(0, 2, 0, 2) -= s(1, 1) / 2.0;
642  d2(0, 2, 2, 0) -= s(1, 1) / 2.0;
643  d2(0, 2, 1, 1) -= s(2, 0);
644  d2(0, 2, 1, 2) += s(1, 0) / 2.0;
645  d2(0, 2, 2, 1) += s(1, 0) / 2.0;
646 
647  d2(1, 0, 0, 1) -= s(2, 2) / 2.0;
648  d2(1, 0, 1, 0) -= s(2, 2) / 2.0;
649  d2(1, 0, 0, 2) += s(1, 2) / 2.0;
650  d2(1, 0, 2, 0) += s(1, 2) / 2.0;
651  d2(1, 0, 1, 2) += s(2, 0) / 2.0;
652  d2(1, 0, 2, 1) += s(2, 0) / 2.0;
653  d2(1, 0, 2, 2) -= s(1, 0);
654 
655  d2(1, 1, 0, 0) += s(2, 2);
656  d2(1, 1, 0, 2) -= s(2, 0);
657  d2(1, 1, 2, 0) -= s(2, 0);
658  d2(1, 1, 2, 2) += s(0, 0);
659 
660  d2(1, 2, 0, 0) -= s(2, 1);
661  d2(1, 2, 0, 1) += s(2, 0) / 2.0;
662  d2(1, 2, 1, 0) += s(2, 0) / 2.0;
663  d2(1, 2, 0, 2) += s(0, 1) / 2.0;
664  d2(1, 2, 2, 0) += s(0, 1) / 2.0;
665  d2(1, 2, 1, 2) -= s(0, 0) / 2.0;
666  d2(1, 2, 2, 1) -= s(0, 0) / 2.0;
667 
668  d2(2, 0, 0, 1) += s(2, 1) / 2.0;
669  d2(2, 0, 1, 0) += s(2, 1) / 2.0;
670  d2(2, 0, 0, 2) -= s(1, 1) / 2.0;
671  d2(2, 0, 2, 0) -= s(1, 1) / 2.0;
672  d2(2, 0, 1, 1) -= s(2, 0);
673  d2(2, 0, 1, 2) += s(1, 0) / 2.0;
674  d2(2, 0, 2, 1) += s(1, 0) / 2.0;
675 
676  d2(2, 1, 0, 0) -= s(2, 1);
677  d2(2, 1, 0, 1) += s(2, 0) / 2.0;
678  d2(2, 1, 1, 0) += s(2, 0) / 2.0;
679  d2(2, 1, 0, 2) += s(0, 1) / 2.0;
680  d2(2, 1, 2, 0) += s(0, 1) / 2.0;
681  d2(2, 1, 1, 2) -= s(0, 0) / 2.0;
682  d2(2, 1, 2, 1) -= s(0, 0) / 2.0;
683 
684  d2(2, 2, 0, 0) += s(1, 1);
685  d2(2, 2, 0, 1) -= s(1, 0);
686  d2(2, 2, 1, 0) -= s(1, 0);
687  d2(2, 2, 1, 1) += s(0, 0);
688 
689  return d2;
690 }
RankFourTensorTempl is designed to handle any N-dimensional fourth order tensor, C.
static RankTwoTensorTempl< T > plusTranspose(const RankTwoTensorTempl< T > &)
Initialize a second order tensor with expression .
static constexpr unsigned int N
Tensor dimension, i.e.
Definition: RankTwoTensor.h:87
RankTwoTensorTempl< T > deviatoric() const
Return the deviatoric part of this tensor .
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
IntRange< T > make_range(T beg, T end)

◆ 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 694 of file RankTwoTensorImplementation.h.

695 {
697 
698  d(0, 0) = (*this)(1, 1) * (*this)(2, 2) - (*this)(2, 1) * (*this)(1, 2);
699  d(0, 1) = (*this)(2, 0) * (*this)(1, 2) - (*this)(1, 0) * (*this)(2, 2);
700  d(0, 2) = (*this)(1, 0) * (*this)(2, 1) - (*this)(2, 0) * (*this)(1, 1);
701  d(1, 0) = (*this)(2, 1) * (*this)(0, 2) - (*this)(0, 1) * (*this)(2, 2);
702  d(1, 1) = (*this)(0, 0) * (*this)(2, 2) - (*this)(2, 0) * (*this)(0, 2);
703  d(1, 2) = (*this)(2, 0) * (*this)(0, 1) - (*this)(0, 0) * (*this)(2, 1);
704  d(2, 0) = (*this)(0, 1) * (*this)(1, 2) - (*this)(1, 1) * (*this)(0, 2);
705  d(2, 1) = (*this)(1, 0) * (*this)(0, 2) - (*this)(0, 0) * (*this)(1, 2);
706  d(2, 2) = (*this)(0, 0) * (*this)(1, 1) - (*this)(1, 0) * (*this)(0, 1);
707 
708  return d;
709 }
RankTwoTensorTempl is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: RankTwoTensor.h:79

◆ deviatoric()

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

Return the deviatoric part of this tensor \( A_{ij} - \frac{1}{3} A_{kk} \delta_{ij} \).

Definition at line 493 of file RankTwoTensorImplementation.h.

494 {
496  // actually construct deviatoric part
497  deviatoric.addIa(-1.0 / 3.0 * this->tr());
498  return deviatoric;
499 }
RankTwoTensorTempl< T > deviatoric() const
Return the deviatoric part of this tensor .
RankTwoTensorTempl is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: RankTwoTensor.h:79

◆ doubleContraction()

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

Return the double contraction with another second order tensor \( A_{ij} B_{ij} \).

RankTwoTensor A(1, 2, 3, 4, 5, 6, 7, 8, 9);
// A = [ 1 2 3
// 2 4 6
// 3 6 9 ]
RankTwoTensor B(9, 8, 7, 6, 5, 4, 3, 2, 1);
// B = [ 9 6 3
// 8 5 2
// 7 4 1 ]
Real result = A.doubleContraction(B);
// result = 143

Definition at line 456 of file RankTwoTensorImplementation.h.

457 {
458  // deprecate this!
460 }
CompareTypes< T, T2 >::supertype contract(const TypeTensor< T2 > &) const

◆ dsecondInvariant()

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

Return the derivative of the main second invariant w.r.t.

this second order tensor itself \( \frac{\partial J_2}{\partial A_{ij}} = S_{ij} = A_{ij} - \frac{1}{3}A_{kk}\delta_{ij} \)

Definition at line 531 of file RankTwoTensorImplementation.h.

532 {
534 }
static RankTwoTensorTempl< T > plusTranspose(const RankTwoTensorTempl< T > &)
Initialize a second order tensor with expression .
RankTwoTensorTempl< T > deviatoric() const
Return the deviatoric part of this tensor .

◆ 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 1521 of file RankTwoTensor.h.

1522 {
1523  if constexpr (MooseUtils::IsLikeReal<T>::value)
1524  {
1525  T bar = secondInvariant();
1526  if (bar <= r0)
1527  return RankTwoTensorTempl<T>();
1528  else
1529  return -1.5 * std::sqrt(3.0) *
1530  (dthirdInvariant() / std::pow(bar, 1.5) -
1531  1.5 * dsecondInvariant() * thirdInvariant() / std::pow(bar, 2.5));
1532  }
1533  else
1534  mooseError("dsin3Lode is only available for ordered tensor component types");
1535 }
RankTwoTensorTempl< T > dsecondInvariant() const
Return the derivative of the main second invariant w.r.t.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:302
T secondInvariant() const
Return the main second invariant of this second order tensor.
RankTwoTensorTempl< T > dthirdInvariant() const
Denote the _coords[i][j] by A_ij, then this returns d(thirdInvariant()/dA_ij.
Custom type trait that has a value of true for types that cam be use interchangeably with Real...
Definition: MooseUtils.h:972
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...
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template * sqrt(_arg)) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(tanh
RankTwoTensorTempl is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: RankTwoTensor.h:79
MooseUnits pow(const MooseUnits &, int)
Definition: Units.C:537

◆ 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 814 of file RankTwoTensorImplementation.h.

816 {
817  deigvals.resize(N);
818 
819  std::vector<T> a;
820  syev("V", eigvals, a);
821 
822  // now a contains the eigenvetors
823  // extract these and place appropriately in deigvals
824  std::vector<T> eig_vec;
825  eig_vec.resize(N);
826 
827  for (const auto i : make_range(N))
828  {
829  for (const auto j : make_range(N))
830  eig_vec[j] = a[i * N + j];
831  for (const auto j : make_range(N))
832  for (const auto k : make_range(N))
833  deigvals[i](j, k) = eig_vec[j] * eig_vec[k];
834  }
835 
836  // There are discontinuities in the derivative
837  // for equal eigenvalues. The following is
838  // an attempt to make a sensible choice for
839  // the derivative. This agrees with a central-difference
840  // approximation to the derivative.
841  if (eigvals[0] == eigvals[1] && eigvals[0] == eigvals[2])
842  deigvals[0] = deigvals[1] = deigvals[2] = (deigvals[0] + deigvals[1] + deigvals[2]) / 3.0;
843  else if (eigvals[0] == eigvals[1])
844  deigvals[0] = deigvals[1] = (deigvals[0] + deigvals[1]) / 2.0;
845  else if (eigvals[0] == eigvals[2])
846  deigvals[0] = deigvals[2] = (deigvals[0] + deigvals[2]) / 2.0;
847  else if (eigvals[1] == eigvals[2])
848  deigvals[1] = deigvals[2] = (deigvals[1] + deigvals[2]) / 2.0;
849 }
static constexpr unsigned int N
Tensor dimension, i.e.
Definition: RankTwoTensor.h:87
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...
IntRange< T > make_range(T beg, T end)

◆ 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 584 of file RankTwoTensorImplementation.h.

585 {
586  const auto s = RankTwoTensorTempl<T>::plusTranspose(deviatoric()) * 0.5;
587  const T s3 = secondInvariant() / 3.0;
588 
590  d(0, 0) = s(1, 1) * s(2, 2) - s(2, 1) * s(1, 2) + s3;
591  d(0, 1) = s(2, 0) * s(1, 2) - s(1, 0) * s(2, 2);
592  d(0, 2) = s(1, 0) * s(2, 1) - s(2, 0) * s(1, 1);
593  d(1, 0) = s(2, 1) * s(0, 2) - s(0, 1) * s(2, 2);
594  d(1, 1) = s(0, 0) * s(2, 2) - s(2, 0) * s(0, 2) + s3;
595  d(1, 2) = s(2, 0) * s(0, 1) - s(0, 0) * s(2, 1);
596  d(2, 0) = s(0, 1) * s(1, 2) - s(1, 1) * s(0, 2);
597  d(2, 1) = s(1, 0) * s(0, 2) - s(0, 0) * s(1, 2);
598  d(2, 2) = s(0, 0) * s(1, 1) - s(1, 0) * s(0, 1) + s3;
599  return d;
600 }
static RankTwoTensorTempl< T > plusTranspose(const RankTwoTensorTempl< T > &)
Initialize a second order tensor with expression .
T secondInvariant() const
Return the main second invariant of this second order tensor.
RankTwoTensorTempl< T > deviatoric() const
Return the deviatoric part of this tensor .
RankTwoTensorTempl is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: RankTwoTensor.h:79

◆ dtrace()

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

Return the derivative of the trace w.r.t.

this second order tensor itself \( \frac{\partial A_{kk}}{\partial A_{ij}} = \delta_{ij} \)

Definition at line 560 of file RankTwoTensorImplementation.h.

561 {
562  return RankTwoTensorTempl<T>(1, 0, 0, 0, 1, 0, 0, 0, 1);
563 }
RankTwoTensorTempl is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: RankTwoTensor.h:79

◆ fillColumn()

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

Assign values to a specific column of the second order tensor.

Parameters
cThe column number, c = 0, 1, 2
vThe values to be set
RealVectorValue a(1, 2, 3);
// A = [ 0 0 0
// 0 0 0
// 0 0 0 ]
A.fillColumn(1, a);
// A = [ 0 1 0
// 0 2 0
// 0 3 0 ]

Definition at line 977 of file RankTwoTensorImplementation.h.

978 {
979  for (const auto i : make_range(N))
980  (*this)(i, c) = v(i);
981 }
static constexpr unsigned int N
Tensor dimension, i.e.
Definition: RankTwoTensor.h:87
IntRange< T > make_range(T beg, T end)

◆ fillFromInputVector()

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

The smart mutator that determines how to fill the second order tensor based on the size of the input vector.

Parameters
inputThe input vector, can be of size 1, 3, 6, or 9
fill_methodThe fill method, default to autodetect.

When input.size() == 1, the vector value is used to fill the diagonal components of the second order tensor:

// A = [ 1.5 0 0
// 0 1.5 0
// 0 0 1.5 ]

When input.size() == 3, the vector values are used to fill the diagonal components of the second order tensor:

A.fillFromInputVector({1, 2, 3});
// A = [ 1 0 0
// 0 2 0
// 0 0 3 ]

When input.size() == 6, the second order tensor is filled symmetrically using the Voigt notation:

A.fillFromInputVector({1, 2, 3, 4, 5, 6});
// A = [ 1 6 5
// 6 2 4
// 5 4 3 ]

When input.size() == 9, all components of the second order tensor are filled in a column-major fashion:

A.fillFromInputVector({1, 2, 3, 4, 5, 6, 7, 8, 9});
// A = [ 1 4 7
// 2 5 8
// 3 6 9 ]

Definition at line 191 of file RankTwoTensorImplementation.h.

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

192 {
193  if (fill_method != autodetect && fill_method != input.size())
194  mooseError("Expected an input vector size of ", fill_method, " to fill the RankTwoTensorTempl");
195 
196  switch (input.size())
197  {
198  case 1:
199  this->zero();
200  (*this)(0, 0) = input[0]; // S11
201  (*this)(1, 1) = input[0]; // S22
202  (*this)(2, 2) = input[0]; // S33
203  break;
204 
205  case 3:
206  this->zero();
207  (*this)(0, 0) = input[0]; // S11
208  (*this)(1, 1) = input[1]; // S22
209  (*this)(2, 2) = input[2]; // S33
210  break;
211 
212  case 6:
213  (*this)(0, 0) = input[0]; // S11
214  (*this)(1, 1) = input[1]; // S22
215  (*this)(2, 2) = input[2]; // S33
216  (*this)(1, 2) = (*this)(2, 1) = input[3]; // S23
217  (*this)(0, 2) = (*this)(2, 0) = input[4]; // S13
218  (*this)(0, 1) = (*this)(1, 0) = input[5]; // S12
219  break;
220 
221  case 9:
222  (*this)(0, 0) = input[0]; // S11
223  (*this)(1, 0) = input[1]; // S21
224  (*this)(2, 0) = input[2]; // S31
225  (*this)(0, 1) = input[3]; // S12
226  (*this)(1, 1) = input[4]; // S22
227  (*this)(2, 1) = input[5]; // S32
228  (*this)(0, 2) = input[6]; // S13
229  (*this)(1, 2) = input[7]; // S23
230  (*this)(2, 2) = input[8]; // S33
231  break;
232 
233  default:
234  mooseError("Please check the number of entries in the input vector for building "
235  "a RankTwoTensorTempl. It must be 1, 3, 6, or 9");
236  }
237 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:302

◆ fillFromScalarVariable()

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


The smart mutator that determines how to fill the second order tensor based on the order of the scalar_variable.

Parameters
scalar_variableThe input scalar variable. Supported orders are FIRST, THIRD, and SIXTH.

When scalar_variable.size() == 1, the scalar value is used to fill the very first component of the second order tensor:

& // Suppose v[0] = 1
// A = [ 1 0 0
// 0 0 0
// 0 0 0 ]

When scalar_variable.size() == 3, the scalar values are used to fill the in-plane components of the second order tensor using the Voigt notation:

// Suppose v[0] = 1
// v[1] = 2
// v[2] = 3
// A = [ 1 3 0
// 3 2 0
// 0 0 0 ]

When scalar_variable.size() == 6, the second order tensor is filled symmetrically using the Voigt notation:

// Suppose v[0] = 1
// v[1] = 2
// v[2] = 3
// v[3] = 4
// v[4] = 5
// v[5] = 6
// A = [ 1 6 5
// 6 2 4
// 5 4 3 ]

Definition at line 241 of file RankTwoTensorImplementation.h.

242 {
243  switch (scalar_variable.size())
244  {
245  case 1:
246  this->zero();
247  (*this)(0, 0) = scalar_variable[0]; // S11
248  break;
249 
250  case 3:
251  this->zero();
252  (*this)(0, 0) = scalar_variable[0]; // S11
253  (*this)(1, 1) = scalar_variable[1]; // S22
254  (*this)(0, 1) = (*this)(1, 0) = scalar_variable[2]; // S12
255  break;
256 
257  case 6:
258  (*this)(0, 0) = scalar_variable[0]; // S11
259  (*this)(1, 1) = scalar_variable[1]; // S22
260  (*this)(2, 2) = scalar_variable[2]; // S33
261  (*this)(1, 2) = (*this)(2, 1) = scalar_variable[3]; // S23
262  (*this)(0, 2) = (*this)(2, 0) = scalar_variable[4]; // S13
263  (*this)(0, 1) = (*this)(1, 0) = scalar_variable[5]; // S12
264  break;
265 
266  default:
267  mooseError("Only FIRST, THIRD, or SIXTH order scalar variable can be used to build "
268  "a RankTwoTensorTempl.");
269  }
270 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:302

◆ fillMethodEnum()

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

Get the available FillMethod options.

This method is useful in validParams().

Definition at line 66 of file RankTwoTensorImplementation.h.

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

◆ fillRealTensor()

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

Fill a libMesh::TensorValue<T> from this second order tensor.

Definition at line 960 of file RankTwoTensorImplementation.h.

961 {
962  for (const auto i : make_range(N))
963  for (const auto j : make_range(N))
964  tensor(i, j) = (*this)(i, j);
965 }
static constexpr unsigned int N
Tensor dimension, i.e.
Definition: RankTwoTensor.h:87
IntRange< T > make_range(T beg, T end)

◆ fillRow()

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

Assign values to a specific row of the second order tensor.

Parameters
rThe row number, r = 0, 1, 2
vThe values to be set
RealVectorValue a(1, 2, 3);
// A = [ 0 0 0
// 0 0 0
// 0 0 0 ]
A.fillRow(1, a);
// A = [ 0 0 0
// 1 2 3
// 0 0 0 ]

Definition at line 969 of file RankTwoTensorImplementation.h.

970 {
971  for (const auto i : make_range(N))
972  (*this)(r, i) = v(i);
973 }
static constexpr unsigned int N
Tensor dimension, i.e.
Definition: RankTwoTensor.h:87
IntRange< T > make_range(T beg, T end)

◆ generalSecondInvariant()

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

Return the principal second invariant of this second order tensor.

\( I_2 = \frac{1}{2} \left( A_{kk}^2 - A_{ij}A_{ij} \right) \)

Definition at line 503 of file RankTwoTensorImplementation.h.

504 {
505  return (*this)(0, 0) * (*this)(1, 1) + (*this)(0, 0) * (*this)(2, 2) +
506  (*this)(1, 1) * (*this)(2, 2) - (*this)(0, 1) * (*this)(1, 0) -
507  (*this)(0, 2) * (*this)(2, 0) - (*this)(1, 2) * (*this)(2, 1);
508 }

◆ genRandomSymmTensor()

template<typename T>
RankTwoTensorTempl< T > RankTwoTensorTempl< T >::genRandomSymmTensor ( stddev,
mean 
)
static

Generate a random symmetric second order tensor with the 6 upper-triangular components treated as independent random variables following a Gaussian distribution.

Parameters
stddevThe standard deviation of the Gaussian distribution
meanThe mean of the Gaussian distribution

Definition at line 918 of file RankTwoTensorImplementation.h.

919 {
920  auto r = [&]() { return (MooseRandom::rand() + mean) * stddev; };
921  return RankTwoTensorTempl<T>(r(), r(), r(), r(), r(), r());
922 }
RankTwoTensorTempl is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: RankTwoTensor.h:79
static Real rand()
This method returns the next random number (Real format) from the generator.
Definition: MooseRandom.h:50

◆ genRandomTensor()

template<typename T>
RankTwoTensorTempl< T > RankTwoTensorTempl< T >::genRandomTensor ( stddev,
mean 
)
static

Generate a random second order tensor with all 9 components treated as independent random variables following a Gaussian distribution.

Parameters
stddevThe standard deviation of the Gaussian distribution
meanThe mean of the Gaussian distribution

Definition at line 907 of file RankTwoTensorImplementation.h.

908 {
909  RankTwoTensorTempl<T> result;
910  for (const auto i : make_range(N))
911  for (const auto j : make_range(N))
912  result(i, j) = (MooseRandom::rand() + mean) * stddev;
913  return result;
914 }
static constexpr unsigned int N
Tensor dimension, i.e.
Definition: RankTwoTensor.h:87
RankTwoTensorTempl is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: RankTwoTensor.h:79
IntRange< T > make_range(T beg, T end)
static Real rand()
This method returns the next random number (Real format) from the generator.
Definition: MooseRandom.h:50

◆ getRUDecompositionRotation()

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 890 of file RankTwoTensorImplementation.h.

891 {
892  mooseError("getRUDecompositionRotation is only supported for Real valued tensors");
893 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:302

◆ Identity()

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

Initialize a second order identity tensor.

// A = [ 1 0 0
// 0 1 0
// 0 0 1 ]

Definition at line 360 of file RankTwoTensor.h.

◆ initialContraction()

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

returns this_ij * b_ijkl

Definition at line 985 of file RankTwoTensorImplementation.h.

986 {
987  RankTwoTensorTempl<T> result;
988  for (const auto i : make_range(N))
989  for (const auto j : make_range(N))
990  for (const auto k : make_range(N))
991  for (const auto l : make_range(N))
992  result(k, l) += (*this)(i, j) * b(i, j, k, l);
993  return result;
994 }
static constexpr unsigned int N
Tensor dimension, i.e.
Definition: RankTwoTensor.h:87
RankTwoTensorTempl is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: RankTwoTensor.h:79
IntRange< T > make_range(T beg, T end)

◆ initializeFromColumns()

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

Named constructor for initializing from row vectors.

RealVectorValue col1(1, 2, 3);
RealVectorValue col2(4, 5, 6);
RealVectorValue col3(7, 8, 9);
auto A = RankTwoTensor::initializeFromColumns(col1, col2, col3);
// A = [ 1 4 7
// 2 5 8
// 3 6 9 ]

Definition at line 147 of file RankTwoTensorImplementation.h.

150 {
151  return RankTwoTensorTempl<T>(
152  col0(0), col0(1), col0(2), col1(0), col1(1), col1(2), col2(0), col2(1), col2(2));
153 }
RankTwoTensorTempl is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: RankTwoTensor.h:79

◆ initializeFromRows()

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

Named constructor for initializing from row vectors.

RealVectorValue row1(1, 2, 3);
RealVectorValue row2(4, 5, 6);
RealVectorValue row3(7, 8, 9);
auto A = RankTwoTensor::initializeFromRows(row1, row2, row3);
// A = [ 1 2 3
// 4 5 6
// 7 8 9 ]

Definition at line 137 of file RankTwoTensorImplementation.h.

140 {
141  return RankTwoTensorTempl<T>(
142  row0(0), row1(0), row2(0), row0(1), row1(1), row2(1), row0(2), row1(2), row2(2));
143 }
RankTwoTensorTempl is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: RankTwoTensor.h:79

◆ initializeSymmetric()

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

Named constructor for initializing symmetrically.

The supplied vectors are used as row and column vectors to construct two tensors respectively, that are averaged to create a symmetric tensor.

RealVectorValue row1(1, 2, 3);
RealVectorValue row2(4, 5, 6);
RealVectorValue row3(7, 8, 9);
auto A = RankTwoTensor::initializeSymmetric(row1, row2, row3);
// A = [ 1 3 5
// 3 5 7
// 5 7 9 ]

Definition at line 120 of file RankTwoTensorImplementation.h.

123 {
124  return RankTwoTensorTempl<T>(v0(0),
125  (v1(0) + v0(1)) / 2.0,
126  (v2(0) + v0(2)) / 2.0,
127  (v1(0) + v0(1)) / 2.0,
128  v1(1),
129  (v2(1) + v1(2)) / 2.0,
130  (v2(0) + v0(2)) / 2.0,
131  (v2(1) + v1(2)) / 2.0,
132  v2(2));
133 }
RankTwoTensorTempl is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: RankTwoTensor.h:79

◆ initRandom()

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

Initialize the random seed based on an unsigned integer.

Deprecated in favor of MooseRandom::seed().

Definition at line 900 of file RankTwoTensorImplementation.h.

901 {
902  MooseRandom::seed(rand_seed);
903 }
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

Return the inverse of this second order tensor.

Definition at line 567 of file RankTwoTensorImplementation.h.

568 {
570 }
TypeTensor< T > inverse() const

◆ isSymmetric()

template<typename T >
bool RankTwoTensorTempl< T >::isSymmetric ( ) const

Test for symmetry.

Definition at line 433 of file RankTwoTensorImplementation.h.

434 {
435  auto test = MetaPhysicL::raw_value(*this - transpose());
436  return MooseUtils::absoluteFuzzyEqual(test.norm_sq(), 0);
437 }
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:368
auto raw_value(const Eigen::Map< T > &in)
Definition: EigenADReal.h:73
RankTwoTensorTempl< T > transpose() const
Return the tensor transposed.

◆ L2norm()

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

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

Definition at line 743 of file RankTwoTensorImplementation.h.

744 {
745  T norm = 0.0;
746  for (const auto i : make_range(N2))
747  {
748  T v = _coords[i];
749  norm += v * v;
750  }
751  return norm == 0.0 ? 0.0 : std::sqrt(norm);
752 }
T _coords[LIBMESH_DIM *LIBMESH_DIM]
static constexpr unsigned int N2
The square of the tensor dimension.
Definition: RankTwoTensor.h:92
auto norm() const -> decltype(std::norm(T()))
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template * sqrt(_arg)) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(tanh
IntRange< T > make_range(T beg, T end)

◆ mixedProductJkI()

template<typename T>
RankThreeTensorTempl< T > RankTwoTensorTempl< T >::mixedProductJkI ( const libMesh::VectorValue< T > &  b) const

Return the tensor product of this second order tensor with a vector \( C_{ijk} = A_{jk} b_{i} \).

Definition at line 479 of file RankTwoTensorImplementation.h.

480 {
482 
483  for (const auto i : make_range(N))
484  for (const auto j : make_range(N))
485  for (const auto k : make_range(N))
486  result(i, j, k) += (*this)(j, k) * b(i);
487 
488  return result;
489 }
static constexpr unsigned int N
Tensor dimension, i.e.
Definition: RankTwoTensor.h:87
RankThreeTensor is designed to handle any N-dimensional third order tensor, r.
IntRange< T > make_range(T beg, T end)

◆ operator*() [1/3]

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

Return this tensor multiplied by a scalar (component-wise)

RankTwoTensor A(1, 2, 3, 4, 5, 6, 7, 8, 9);
// A = [ 1 2 3
// 2 4 6
// 3 6 9 ]
RankTwoTensor B = A * 2;
// B = [ 2 4 6
// 4 8 12
// 6 12 18 ]

Definition at line 1417 of file RankTwoTensor.h.

1418 {
1420 }
auto operator*(const Scalar &scalar) const -> typename boostcopy::enable_if_c< ScalarTraits< Scalar >::value, TypeTensor< decltype(T() *scalar)>>::type

◆ operator*() [2/3]

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

Return this tensor multiplied by a vector.

\( b_i = A_{ij} a_j \)

RankTwoTensor A(1, 2, 3, 4, 5, 6, 7, 8, 9);
// A = [ 1 2 3
// 2 4 6
// 3 6 9 ]
RealVectorValue a(1, 2, 3);
// a = [ 1
// 2
// 3 ]
RealVectorValue b = A * a;
// b = [ 30
// 36
// 42 ]

Definition at line 1425 of file RankTwoTensor.h.

1426 {
1428 }
auto operator*(const Scalar &scalar) const -> typename boostcopy::enable_if_c< ScalarTraits< Scalar >::value, TypeTensor< decltype(T() *scalar)>>::type

◆ operator*() [3/3]

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

Multiplication with another second order tensor.

RankTwoTensor A(1, 2, 3, 4, 5, 6, 7, 8, 9);
// A = [ 1 2 3
// 2 4 6
// 3 6 9 ]
RankTwoTensor B(9, 8, 7, 6, 5, 4, 3, 2, 1);
// B = [ 9 6 3
// 8 5 2
// 7 4 1 ]
RankTwoTensor C = A * B;
// C = [ 90 54 18
// 114 69 24
// 138 84 30 ]

Definition at line 1433 of file RankTwoTensor.h.

1434 {
1436 }
auto operator*(const Scalar &scalar) const -> typename boostcopy::enable_if_c< ScalarTraits< Scalar >::value, TypeTensor< decltype(T() *scalar)>>::type

◆ operator*=() [1/2]

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

Multiply this tensor by a scalar (component-wise)

RankTwoTensor A(1, 2, 3, 4, 5, 6, 7, 8, 9);
// A = [ 1 2 3
// 2 4 6
// 3 6 9 ]
A *= 2;
// A = [ 2 4 6
// 4 8 12
// 6 12 18 ]

Definition at line 397 of file RankTwoTensorImplementation.h.

398 {
400  return *this;
401 }
const TypeTensor< T > & operator*=(const Scalar &factor)

◆ operator*=() [2/2]

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

Multiplication with another second order tensor.

RankTwoTensor A(1, 2, 3, 4, 5, 6, 7, 8, 9);
// A = [ 1 2 3
// 2 4 6
// 3 6 9 ]
RankTwoTensor B(9, 8, 7, 6, 5, 4, 3, 2, 1);
// B = [ 9 6 3
// 8 5 2
// 7 4 1 ]
A *= B;
// A = [ 90 54 18
// 114 69 24
// 138 84 30 ]

Definition at line 413 of file RankTwoTensorImplementation.h.

414 {
415  *this = *this * a;
416  return *this;
417 }

◆ operator+()

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

Return the sum of two second order tensors.

RankTwoTensor A(1, 2, 3, 4, 5, 6, 7, 8, 9);
// A = [ 1 2 3
// 2 4 6
// 3 6 9 ]
RankTwoTensor B(9, 8, 7, 6, 5, 4, 3, 2, 1);
// B = [ 9 6 3
// 8 5 2
// 7 4 1 ]
RankTwoTensor C = A + B;
// C = [ 10 8 6
// 10 9 8
// 10 10 10 ]

Definition at line 1401 of file RankTwoTensor.h.

1402 {
1404 }
TypeTensor< typename CompareTypes< T, T2 >::supertype > operator+(const TypeTensor< T2 > &) const

◆ operator+=()

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

Add another second order tensor to this one.

RankTwoTensor A(1, 2, 3, 4, 5, 6, 7, 8, 9);
// A = [ 1 2 3
// 2 4 6
// 3 6 9 ]
RankTwoTensor B(9, 8, 7, 6, 5, 4, 3, 2, 1);
// B = [ 9 6 3
// 8 5 2
// 7 4 1 ]
A += B;
// A = [ 10 8 6
// 10 9 8
// 10 10 10 ]

Definition at line 374 of file RankTwoTensorImplementation.h.

375 {
377  return *this;
378 }
const TypeTensor< T > & operator+=(const TypeTensor< T2 > &)

◆ operator-() [1/2]

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

Return the subtraction of two second order tensors.

RankTwoTensor A(1, 2, 3, 4, 5, 6, 7, 8, 9);
// A = [ 1 2 3
// 2 4 6
// 3 6 9 ]
RankTwoTensor B(9, 8, 7, 6, 5, 4, 3, 2, 1);
// B = [ 9 6 3
// 8 5 2
// 7 4 1 ]
RankTwoTensor C = A - B;
// C = [ -8 -4 0
// -6 -1 4
// -4 2 8 ]

Definition at line 1409 of file RankTwoTensor.h.

1410 {
1412 }
TypeTensor< T > operator-() const

◆ operator-() [2/2]

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

Return the negation of this tensor.

RankTwoTensor A(1, 2, 3, 4, 5, 6, 7, 8, 9);
// A = [ 1 2 3
// 2 4 6
// 3 6 9 ]
// B = [ -1 -2 -3
// -2 -4 -6
// -3 -6 -9 ]

Definition at line 390 of file RankTwoTensorImplementation.h.

391 {
393 }
TypeTensor< T > operator-() const

◆ operator-=()

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

Subtract another second order tensor from this one.

RankTwoTensor A(1, 2, 3, 4, 5, 6, 7, 8, 9);
// A = [ 1 2 3
// 2 4 6
// 3 6 9 ]
RankTwoTensor B(9, 8, 7, 6, 5, 4, 3, 2, 1);
// B = [ 9 6 3
// 8 5 2
// 7 4 1 ]
A -= B;
// A = [ -8 -4 0
// -6 -1 4
// -4 2 8 ]

Definition at line 382 of file RankTwoTensorImplementation.h.

383 {
385  return *this;
386 }
const TypeTensor< T > & operator-=(const TypeTensor< T2 > &)

◆ operator/()

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

Return this tensor divided by a scalar (component-wise)

RankTwoTensor A(1, 2, 3, 4, 5, 6, 7, 8, 9);
// A = [ 1 2 3
// 2 4 6
// 3 6 9 ]
RankTwoTensor B = A / 2;
// B = [ 0.5 1.0 1.5
// 1.0 2.0 3.0
// 1.5 3.0 4.5 ]

Definition at line 1441 of file RankTwoTensor.h.

1442 {
1444 }
boostcopy::enable_if_c< ScalarTraits< Scalar >::value, TypeTensor< typename CompareTypes< T, Scalar >::supertype > >::type operator/(const Scalar &) const

◆ operator/=()

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

Divide this tensor by a scalar (component-wise)

RankTwoTensor A(1, 2, 3, 4, 5, 6, 7, 8, 9);
// A = [ 1 2 3
// 2 4 6
// 3 6 9 ]
A /= 2;
// A = [ 0.5 1.0 1.5
// 1.0 2.0 3.0
// 1.5 3.0 4.5 ]

Definition at line 405 of file RankTwoTensorImplementation.h.

406 {
408  return *this;
409 }
const TypeTensor< T > & operator/=(const T &)

◆ operator=() [1/3]

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

Assignment operator.

// A = [ 0 0 0
// 0 0 0
// 0 0 0 ]
RankTwoTensor B(9, 8, 7, 6, 5, 4, 3, 2, 1);
// B = [ 9 6 3
// 8 5 2
// 7 4 1 ]
A = B;
// A = [ 9 6 3
// 8 5 2
// 7 4 1 ]

◆ operator=() [2/3]

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

Assignment operator (from a ColumnMajorMatrixTempl<T>)

// A = [ 0 0 0
// 0 0 0
// 0 0 0 ]
RealVectorValue col1(1, 2, 3);
RealVectorValue col2(4, 5, 6);
RealVectorValue col3(7, 8, 9);
ColumnMajorMatrix B(col1, col2, col3);
// B = [ 1 4 7
// 2 5 8
// 3 6 9 ]
A = B;
// A = [ 1 4 7
// 2 5 8
// 3 6 9 ]

Definition at line 441 of file RankTwoTensorImplementation.h.

442 {
443  if (a.n() != N || a.m() != N)
444  mooseError("Dimensions of ColumnMajorMatrixTempl<T> are incompatible with RankTwoTensorTempl");
445 
446  const T * cmm_rawdata = a.rawData();
447  for (const auto i : make_range(N))
448  for (const auto j : make_range(N))
449  _coords[i * N + j] = cmm_rawdata[i + j * N];
450 
451  return *this;
452 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:302
T _coords[LIBMESH_DIM *LIBMESH_DIM]
static constexpr unsigned int N
Tensor dimension, i.e.
Definition: RankTwoTensor.h:87
T * rawData()
Returns a reference to the raw data pointer.
unsigned int m() const
Returns the number of columns.
IntRange< T > make_range(T beg, T end)
unsigned int n() const
Returns the number of rows.

◆ operator=() [3/3]

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

Assignment-from-scalar operator.

Used only to zero out the tensor.

RankTwoTensor A(1, 2, 3, 4, 5, 6, 7, 8, 9);
// A = [ 1 2 3
// 2 4 6
// 3 6 9 ]
A = 0;
// A = [ 0 0 0
// 0 0 0
// 0 0 0 ]
A = 1;
// This triggers an assertion failure.
A = 0.0;
// This triggers an assertion failure.

Definition at line 546 of file RankTwoTensor.h.

547  {
548  libmesh_assert_equal_to(p, Scalar(0));
549  this->zero();
550  return *this;
551  }

◆ operator==()

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

Defines logical equality with another RankTwoTensorTempl<T>

Definition at line 421 of file RankTwoTensorImplementation.h.

422 {
423  for (const auto i : make_range(N))
424  for (const auto j : make_range(N))
425  if (!MooseUtils::absoluteFuzzyEqual((*this)(i, j), a(i, j)))
426  return false;
427 
428  return true;
429 }
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:368
static constexpr unsigned int N
Tensor dimension, i.e.
Definition: RankTwoTensor.h:87
IntRange< T > make_range(T beg, T end)

◆ outerProduct() [1/2]

template<typename T>
RankTwoTensorTempl< T > RankTwoTensorTempl< T >::outerProduct ( const libMesh::TypeVector< T > &  v1,
const libMesh::TypeVector< T > &  v2 
)
static

Initialize a second order tensor as the outer product of two vectors, i.e.

\( A_{ij} = a_i b_j \).

RealVectorValue a(1, 2, 3);
RealVectorValue b(4, 5, 6);
// A = [ 4 5 6
// 8 10 12
// 12 15 18 ]

Definition at line 937 of file RankTwoTensorImplementation.h.

939 {
940  RankTwoTensorTempl<T> result;
941  for (const auto i : make_range(N))
942  for (const auto j : make_range(N))
943  result(i, j) = v1(i) * v2(j);
944  return result;
945 }
static constexpr unsigned int N
Tensor dimension, i.e.
Definition: RankTwoTensor.h:87
RankTwoTensorTempl is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: RankTwoTensor.h:79
IntRange< T > make_range(T beg, T end)

◆ outerProduct() [2/2]

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

Return the outer product \( C_{ijkl} = A_{ij} B_{kl} \).

Definition at line 1153 of file RankTwoTensor.h.

1154  {
1155  usingTensorIndices(i_, j_, k_, l_);
1156  return times<i_, j_, k_, l_>(b);
1157  }

◆ plusTranspose()

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

Initialize a second order tensor with expression \( E_{ij} = C_{ij} + C_{ji} \).

RankTwoTensor C(1, 2, 3, 4, 5, 6, 7, 8, 9);
// C = [ 1 4 7
// 2 5 8
// 3 6 9 ]
// E = [ 2 6 10
// 6 10 14
// 10 14 18 ]

Definition at line 295 of file RankTwoTensorImplementation.h.

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

296 {
297  return a + a.transpose();
298 }
RankTwoTensorTempl< T > transpose() const
Return the tensor transposed.

◆ positiveProjectionEigenDecomposition()

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

Return the positive projection tensor.

Consider the eigenvalue decomposition of this second order tensor \( A = V D V^T \), the part of this tensor that lies on the positive spectrum is defined as \( A_+ = V \left<D\right> V^T \) where the angled brackets are the Macaulay brackets. The positive projection tensor is the linear projection from the full spectrum to the positive spectrum, i.e. \( A_+ = P A \). The derivation of this positive projection tensor can be found in C. Miehe and M. Lambrecht, Commun. Numer. Meth. Engng 2001; 17:337~353

Parameters
eigvalsThe three eigenvalues of this second order tensor will be filled into this vector.
eigvecsThe three eigenvectors of this second order tensor will be filled into this tensor.
Returns
The fourth order positive projection tensor.

Definition at line 1448 of file RankTwoTensor.h.

1450 {
1451  if constexpr (MooseUtils::IsLikeReal<T>::value)
1452  {
1453  // Compute eigenvectors and eigenvalues of this tensor
1454  this->symmetricEigenvaluesEigenvectors(eigval, eigvec);
1455 
1456  // Separate out positive and negative eigen values
1457  std::array<T, N> epos;
1458  std::array<T, N> d;
1459  for (auto i : libMesh::make_range(N))
1460  {
1461  epos[i] = (std::abs(eigval[i]) + eigval[i]) / 2.0;
1462  d[i] = 0 < eigval[i] ? 1.0 : 0.0;
1463  }
1464 
1465  // projection tensor
1466  RankFourTensorTempl<T> proj_pos;
1467  RankFourTensorTempl<T> Gab, Gba;
1468 
1469  for (auto a : libMesh::make_range(N))
1470  {
1471  const auto Ma = RankTwoTensorTempl<T>::selfOuterProduct(eigvec.column(a));
1472  proj_pos += d[a] * Ma.outerProduct(Ma);
1473  }
1474 
1475  usingTensorIndices(i_, j_, k_, l_);
1476  for (const auto a : libMesh::make_range(N))
1477  for (const auto b : libMesh::make_range(a))
1478  {
1479  const auto Ma = RankTwoTensorTempl<T>::selfOuterProduct(eigvec.column(a));
1480  const auto Mb = RankTwoTensorTempl<T>::selfOuterProduct(eigvec.column(b));
1481 
1482  Gab = Ma.template times<i_, k_, j_, l_>(Mb) + Ma.template times<i_, l_, j_, k_>(Mb);
1483  Gba = Mb.template times<i_, k_, j_, l_>(Ma) + Mb.template times<i_, l_, j_, k_>(Ma);
1484 
1485  T theta_ab;
1486  if (!MooseUtils::absoluteFuzzyEqual(eigval[a], eigval[b]))
1487  theta_ab = 0.5 * (epos[a] - epos[b]) / (eigval[a] - eigval[b]);
1488  else
1489  theta_ab = 0.25 * (d[a] + d[b]);
1490 
1491  proj_pos += theta_ab * (Gab + Gba);
1492  }
1493  return proj_pos;
1494  }
1495  else
1496  mooseError("positiveProjectionEigenDecomposition is only available for ordered tensor "
1497  "component types");
1498 }
RankFourTensorTempl is designed to handle any N-dimensional fourth order tensor, C.
MetaPhysicL::DualNumber< V, D, asd > abs(const MetaPhysicL::DualNumber< V, D, asd > &a)
Definition: EigenADReal.h:42
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:368
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:302
static constexpr unsigned int N
Tensor dimension, i.e.
Definition: RankTwoTensor.h:87
static RankTwoTensorTempl< T > selfOuterProduct(const libMesh::TypeVector< T > &)
Initialize a second order tensor as the outer product of a vector with itself, i.e.
Custom type trait that has a value of true for types that cam be use interchangeably with Real...
Definition: MooseUtils.h:972
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...
IntRange< T > make_range(T beg, T end)

◆ print()

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

Print the rank two tensor.

Definition at line 713 of file RankTwoTensorImplementation.h.

714 {
715  const RankTwoTensorTempl<T> & a = *this;
716  for (const auto i : make_range(N))
717  {
718  for (const auto j : make_range(N))
719  stm << std::setw(15) << a(i, j) << ' ';
720  stm << std::endl;
721  }
722 }
static constexpr unsigned int N
Tensor dimension, i.e.
Definition: RankTwoTensor.h:87
RankTwoTensorTempl is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: RankTwoTensor.h:79
IntRange< T > make_range(T beg, T end)

◆ printADReal()

void ADRankTwoTensor::printADReal ( unsigned int  nDual,
std::ostream &  stm = Moose::out 
) const

Print the Real part of the RankTwoTensorTempl<ADReal> along with its first nDual dual numbers.

Definition at line 34 of file RankTwoTensorImplementation.C.

35 {
36  const ADRankTwoTensor & a = *this;
37  for (const auto i : make_range(N))
38  {
39  for (const auto j : make_range(N))
40  {
41  stm << std::setw(15) << a(i, j).value() << " {";
42  for (const auto k : make_range(nDual))
43  stm << std::setw(5) << a(i, j).derivatives()[k] << ' ';
44  stm << " }";
45  }
46  stm << std::endl;
47  }
48 }
static constexpr unsigned int N
Tensor dimension, i.e.
Definition: RankTwoTensor.h:87
RankTwoTensorTempl is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: RankTwoTensor.h:79
IntRange< T > make_range(T beg, T end)

◆ printReal()

void ADRankTwoTensor::printReal ( std::ostream &  stm = Moose::out) const

Print the Real part of the RankTwoTensorTempl<ADReal>

Definition at line 21 of file RankTwoTensorImplementation.C.

22 {
23  const ADRankTwoTensor & a = *this;
24  for (const auto i : make_range(N))
25  {
26  for (const auto j : make_range(N))
27  stm << std::setw(15) << a(i, j).value() << ' ';
28  stm << std::endl;
29  }
30 }
static constexpr unsigned int N
Tensor dimension, i.e.
Definition: RankTwoTensor.h:87
RankTwoTensorTempl is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: RankTwoTensor.h:79
IntRange< T > make_range(T beg, T end)

◆ rotate()

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

Rotate the tensor in-place given a rotation tensor \( A_{ij} \leftarrow R_{ij} A_{jk} R_{jk} \).

Parameters
RThe rotation tensor
RankTwoTensor A(1, 2, 3, 4, 5, 6, 7, 8, 9);
// A = [ 1 4 7
// 2 5 8
// 3 6 9 ]
RankTwoTensor R(0, 1, 0, 1, 0, 0, 0, 0, 1);
// R = [ 0 1 0
// 1 0 0
// 0 0 1 ]
A.rotate(R);
// A = [ 5 2 8
// 4 1 7
// 6 3 9 ]

Definition at line 318 of file RankTwoTensorImplementation.h.

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

319 {
321  for (const auto i : make_range(N))
322  {
323  const auto i1 = i * N;
324  for (const auto j : make_range(N))
325  {
326  // tmp += R(i,k)*R(j,l)*(*this)(k,l);
327  // clang-format off
328  const auto j1 = j * N;
329  T tmp = R._coords[i1 + 0] * R._coords[j1 + 0] * (*this)(0, 0) +
330  R._coords[i1 + 0] * R._coords[j1 + 1] * (*this)(0, 1) +
331  R._coords[i1 + 0] * R._coords[j1 + 2] * (*this)(0, 2) +
332  R._coords[i1 + 1] * R._coords[j1 + 0] * (*this)(1, 0) +
333  R._coords[i1 + 1] * R._coords[j1 + 1] * (*this)(1, 1) +
334  R._coords[i1 + 1] * R._coords[j1 + 2] * (*this)(1, 2) +
335  R._coords[i1 + 2] * R._coords[j1 + 0] * (*this)(2, 0) +
336  R._coords[i1 + 2] * R._coords[j1 + 1] * (*this)(2, 1) +
337  R._coords[i1 + 2] * R._coords[j1 + 2] * (*this)(2, 2);
338  // clang-format on
339  temp._coords[i1 + j] = tmp;
340  }
341  }
342  for (unsigned int i = 0; i < N2; i++)
343  _coords[i] = temp._coords[i];
344 }
T _coords[LIBMESH_DIM *LIBMESH_DIM]
static constexpr unsigned int N
Tensor dimension, i.e.
Definition: RankTwoTensor.h:87
static constexpr unsigned int N2
The square of the tensor dimension.
Definition: RankTwoTensor.h:92
RankTwoTensorTempl is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: RankTwoTensor.h:79
IntRange< T > make_range(T beg, T end)

◆ rotated()

template<typename T>
RankTwoTensorTempl< T > RankTwoTensorTempl< T >::rotated ( const RankTwoTensorTempl< T > &  R) const

Return the rotated tensor given a rotation tensor \( A'_{ij} = R_{ij} A_{jk} R_{jk} \).

Parameters
RThe rotation tensor
RankTwoTensor A(1, 2, 3, 4, 5, 6, 7, 8, 9);
// A = [ 1 4 7
// 2 5 8
// 3 6 9 ]
RankTwoTensor R(0, 1, 0, 1, 0, 0, 0, 0, 1);
// R = [ 0 1 0
// 1 0 0
// 0 0 1 ]
RankTwoTensor A_rotated = A.rotated(R);
// A_rotated = [ 5 2 8
// 4 1 7
// 6 3 9 ]

Definition at line 309 of file RankTwoTensorImplementation.h.

310 {
311  RankTwoTensorTempl<T> result(*this);
312  result.rotate(R);
313  return result;
314 }
RankTwoTensorTempl is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: RankTwoTensor.h:79

◆ rotateXyPlane()

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

Rotate the tensor about the z-axis.

Parameters
aThe rotation angle in radians

Definition at line 348 of file RankTwoTensorImplementation.h.

349 {
350  T c = std::cos(a);
351  T s = std::sin(a);
352  T x = (*this)(0, 0) * c * c + (*this)(1, 1) * s * s + 2.0 * (*this)(0, 1) * c * s;
353  T y = (*this)(0, 0) * s * s + (*this)(1, 1) * c * c - 2.0 * (*this)(0, 1) * c * s;
354  T xy = ((*this)(1, 1) - (*this)(0, 0)) * c * s + (*this)(0, 1) * (c * c - s * s);
355 
356  RankTwoTensorTempl<T> b(*this);
357 
358  b(0, 0) = x;
359  b(1, 1) = y;
360  b(1, 0) = b(0, 1) = xy;
361 
362  return b;
363 }
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template * sin(_arg) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(tan
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template cos(_arg) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(cos
RankTwoTensorTempl is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: RankTwoTensor.h:79

◆ secondInvariant()

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

Return the main second invariant of this second order tensor.

\( J_2 = \frac{1}{2} \left( S_{ij}S_{ij} \right) \), where \( S_{ij} = A_{ij} - \frac{1}{3}A_{kk}\delta_{ij} \)

Definition at line 512 of file RankTwoTensorImplementation.h.

513 {
514  T result;
515 
516  // RankTwoTensorTempl<T> deviatoric(*this);
517  // deviatoric.addIa(-1.0/3.0 * this->tr()); // actually construct deviatoric part
518  // result = 0.5*(deviatoric + deviatoric.transpose()).doubleContraction(deviatoric +
519  // deviatoric.transpose());
520  result = Utility::pow<2>((*this)(0, 0) - (*this)(1, 1)) / 6.0;
521  result += Utility::pow<2>((*this)(0, 0) - (*this)(2, 2)) / 6.0;
522  result += Utility::pow<2>((*this)(1, 1) - (*this)(2, 2)) / 6.0;
523  result += Utility::pow<2>((*this)(0, 1) + (*this)(1, 0)) / 4.0;
524  result += Utility::pow<2>((*this)(0, 2) + (*this)(2, 0)) / 4.0;
525  result += Utility::pow<2>((*this)(1, 2) + (*this)(2, 1)) / 4.0;
526  return result;
527 }
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template pow< 2 >(tan(_arg))+1.0) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(sqrt

◆ selfOuterProduct()

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

Initialize a second order tensor as the outer product of a vector with itself, i.e.

\( A_{ij} = a_i a_j \).

RealVectorValue a(1, 2, 3);
// A = [ 1 2 3
// 2 4 6
// 3 6 9 ]

Definition at line 949 of file RankTwoTensorImplementation.h.

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

950 {
952  for (unsigned int i = 0; i < N; ++i)
953  for (unsigned int j = 0; j < N; ++j)
954  result(i, j) = v(i) * v(j);
955  return result;
956 }
static constexpr unsigned int N
Tensor dimension, i.e.
Definition: RankTwoTensor.h:87
RankTwoTensorTempl is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: RankTwoTensor.h:79

◆ setToIdentity()

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

Set the tensor to identity.

// A = [ 0 0 0
// 0 0 0
// 0 0 0 ]
// A = [ 1 0 0
// 0 1 0
// 0 0 1 ]

Definition at line 998 of file RankTwoTensorImplementation.h.

999 {
1000  mooseAssert(N2 == 9, "RankTwoTensorTempl is currently only tested for 3 dimensions.");
1001  for (const auto i : make_range(N2))
1002  _coords[i] = identityCoords[i];
1003 }
T _coords[LIBMESH_DIM *LIBMESH_DIM]
static constexpr unsigned int N2
The square of the tensor dimension.
Definition: RankTwoTensor.h:92
static constexpr Real identityCoords[N2]
IntRange< T > make_range(T beg, T end)

◆ 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 1502 of file RankTwoTensor.h.

1503 {
1504  if constexpr (MooseUtils::IsLikeReal<T>::value)
1505  {
1506  T bar = secondInvariant();
1507  if (bar <= r0)
1508  // in this case the Lode angle is not defined
1509  return r0_value;
1510  else
1511  // the min and max here gaurd against precision-loss when bar is tiny but nonzero.
1512  return std::max(std::min(-1.5 * std::sqrt(3.0) * thirdInvariant() / std::pow(bar, 1.5), 1.0),
1513  -1.0);
1514  }
1515  else
1516  mooseError("sin3Lode is only available for ordered tensor component types");
1517 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:302
T secondInvariant() const
Return the main second invariant of this second order tensor.
auto max(const L &left, const R &right)
Custom type trait that has a value of true for types that cam be use interchangeably with Real...
Definition: MooseUtils.h:972
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...
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template * sqrt(_arg)) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(tanh
auto min(const L &left, const R &right)
MooseUnits pow(const MooseUnits &, int)
Definition: Units.C:537

◆ square()

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

Return \( A_{ij} = A_{ik}A_{kj} \).

RankTwoTensor A(1, 2, 3, 4, 5, 6, 7, 8, 9);
// A = [ 1 4 7
// 2 5 8
// 3 6 9 ]
RankTwoTensor B = A.square();
// B = [ 30 66 102
// 36 81 126
// 42 96 150 ]

Definition at line 302 of file RankTwoTensorImplementation.h.

303 {
304  return *this * *this;
305 }

◆ 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 756 of file RankTwoTensorImplementation.h.

757 {
758  if (input.size() == 4)
759  {
760  // initialize with zeros
761  this->zero();
762  (*this)(0, 0) = input[0];
763  (*this)(0, 1) = input[1];
764  (*this)(1, 0) = input[2];
765  (*this)(1, 1) = input[3];
766  }
767  else
768  mooseError("please provide correct number of values for surface RankTwoTensorTempl<T> "
769  "initialization.");
770 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:302

◆ syev()

template<typename T>
void RankTwoTensorTempl< 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 _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 774 of file RankTwoTensorImplementation.h.

775 {
776  mooseError("The syev method is only supported for Real valued tensors");
777 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:302

◆ 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 786 of file RankTwoTensorImplementation.h.

787 {
790 }
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: RankTwoTensor.h:79

◆ 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 797 of file RankTwoTensorImplementation.h.

799 {
800  mooseError(
801  "symmetricEigenvaluesEigenvectors is only available for ordered tensor component types");
802 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:302

◆ 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 574 of file RankTwoTensorImplementation.h.

575 {
576  const auto s = RankTwoTensorTempl<T>::plusTranspose(deviatoric()) * 0.5;
577  return s(0, 0) * (s(1, 1) * s(2, 2) - s(2, 1) * s(1, 2)) -
578  s(1, 0) * (s(0, 1) * s(2, 2) - s(2, 1) * s(0, 2)) +
579  s(2, 0) * (s(0, 1) * s(1, 2) - s(1, 1) * s(0, 2));
580 }
static RankTwoTensorTempl< T > plusTranspose(const RankTwoTensorTempl< T > &)
Initialize a second order tensor with expression .
RankTwoTensorTempl< T > deviatoric() const
Return the deviatoric part of this tensor .

◆ times() [1/2]

template<typename T>
template<int n, int o, int p, int q>
RankFourTensorTempl< T > RankTwoTensorTempl< T >::times ( const RankTwoTensorTempl< T > &  b) const

Return the general tensor product of this second order tensor and another second order tensor defined as \( C_{ijkl} = A_{\mathcal{M}(n)\mathcal{M}(o)} B_{\mathcal{M}(p)\mathcal{M}(q)} \) where the multiplication order is defined by the index map \( \mathcal{M}: \{n,o,p,q\} \to \{i,j,k,l\} \).

The index map is specified using the template parameters. See examples below for detailed explanation.

Suppose we have two second order tensors A and B, and we denote the output indices as i, j, k, l:

usingTensorIndices(i, j, k, l);

The outer product of A and B is defined as \( A_{ij} B_{kl} \), hence the template specialization should be times<i, j, k, l>

RankFourTensor C = A.times<i, j, k, l>(B);

The tensor product of A and B, i.e. \( A_{ik} B_{jl} \) can be expressed using the template specialization times<i, k, j, l>

RankFourTensor C = A.times<i, k, j, l>(B);

Similarly, another tensor product of A and B, i.e. \( A_{il} B_{jk} \) can be expressed using the template specialization times<i, l, j, k>

RankFourTensor C = A.times<i, l, j, k>(B);

The combination goes on...

Definition at line 1571 of file RankTwoTensor.h.

1572 {
1573  RankFourTensorTempl<T> result;
1574  std::size_t x[4];
1575  for (x[0] = 0; x[0] < N; ++x[0])
1576  for (x[1] = 0; x[1] < N; ++x[1])
1577  for (x[2] = 0; x[2] < N; ++x[2])
1578  for (x[3] = 0; x[3] < N; ++x[3])
1579  result(x[0], x[1], x[2], x[3]) = (*this)(x[n], x[o]) * b(x[p], x[q]);
1580 
1581  return result;
1582 }
RankFourTensorTempl is designed to handle any N-dimensional fourth order tensor, C.
static constexpr unsigned int N
Tensor dimension, i.e.
Definition: RankTwoTensor.h:87

◆ times() [2/2]

template<typename T>
template<int n, int o, int p, int q, int r, int s>
RankFourTensorTempl< T > RankTwoTensorTempl< T >::times ( const RankFourTensorTempl< T > &  b) const

Return the single contraction of this second order tensor with a fourth order tensor defined as \( C_{ijkl} = A_{\mathcal{M}(m)\mathcal{M}(n)} B_{\mathcal{M}(p)\mathcal{M}(q)\mathcal{M}(r)\mathcal{M}(s)} \) where the multiplication order is defined by the index map \( \mathcal{M}: \{m,n,p,q,r,s\} \to \{i,j,k,l\} \).

The index map is specified using the template parameters. See examples below for detailed explanation.

Suppose we have a second order tensors A and a fourth order tensor B, and we denote the indices (four output indices and a dummy index to be contracted) as i, j, k, l, m:

usingTensorIndices(i, j, k, l, m);

The single contraction of A and B defined as \( A_{im} B_{mjkl} \) can be expressed using the template specialization times<i, m, m, j, k, l>

RankFourTensor C = A.times<i, m, m, j, k, l>(B);

Similarly, another single contraction of A and B, i.e. \( A_{m, i} A_{j, k, m, l} \) can be expressed using the template specialization times<m, i, j, k, m, l>

RankFourTensor C = A.times<m, i, j, k, m, l>(B);

The combination goes on. Note that this method assumes exactly one repeated index.

Definition at line 1587 of file RankTwoTensor.h.

1588 {
1589  RankFourTensorTempl<T> result;
1590  std::size_t x[5];
1591  for (x[0] = 0; x[0] < N; ++x[0])
1592  for (x[1] = 0; x[1] < N; ++x[1])
1593  for (x[2] = 0; x[2] < N; ++x[2])
1594  for (x[3] = 0; x[3] < N; ++x[3])
1595  for (x[4] = 0; x[4] < N; ++x[4])
1596  result(x[0], x[1], x[2], x[3]) += (*this)(x[n], x[o]) * b(x[p], x[q], x[r], x[s]);
1597 
1598  return result;
1599 }
RankFourTensorTempl is designed to handle any N-dimensional fourth order tensor, C.
static constexpr unsigned int N
Tensor dimension, i.e.
Definition: RankTwoTensor.h:87

◆ timesTranspose()

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

Initialize a second order tensor with expression \( B_{ij} = F_{ij} F_{ji} \).

RankTwoTensor F(1, 2, 3, 4, 5, 6, 7, 8, 9);
// F = [ 1 4 7
// 2 5 8
// 3 6 9 ]
// B = [ 66 78 90
// 78 93 108
// 90 108 126 ]

Definition at line 281 of file RankTwoTensorImplementation.h.

282 {
283  return a * a.transpose();
284 }
RankTwoTensorTempl< T > transpose() const
Return the tensor transposed.

◆ trace()

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

A wrapper for tr()

See also
tr()

Definition at line 552 of file RankTwoTensorImplementation.h.

553 {
554  // deprecate this!
555  return this->tr();
556 }

◆ transpose()

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

Return the tensor transposed.

RankTwoTensor A(1, 2, 3, 4, 5, 6, 7, 8, 9);
// A = [ 1 4 7
// 2 5 8
// 3 6 9 ]
// At = [ 1 2 3
// 4 5 6
// 7 8 9 ]

Definition at line 367 of file RankTwoTensorImplementation.h.

Referenced by RankTwoTensorTempl< Real >::plusTranspose(), RankTwoTensorTempl< Real >::timesTranspose(), and RankTwoTensorTempl< Real >::transposeTimes().

368 {
370 }
TypeTensor< T > transpose() const

◆ transposeTimes()

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

Initialize a second order tensor with expression \( C_{ij} = F_{ji} F_{ij} \).

RankTwoTensor F(1, 2, 3, 4, 5, 6, 7, 8, 9);
// F = [ 1 4 7
// 2 5 8
// 3 6 9 ]
// C = [ 14 32 50
// 32 77 122
// 50 122 194 ]

Definition at line 288 of file RankTwoTensorImplementation.h.

289 {
290  return a.transpose() * a;
291 }
RankTwoTensorTempl< T > transpose() const
Return the tensor transposed.

◆ vectorOuterProduct()

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

Set the values of the second order tensor to be the outer product of two vectors, i.e.

\( A_{ij} = a_i b_j \).

Deprecated in favor of outerProduct()

RealVectorValue a(1, 2, 3);
RealVectorValue b(4, 5, 6);
// A = [ 4 5 6
// 8 10 12
// 12 15 18 ]

Definition at line 926 of file RankTwoTensorImplementation.h.

928 {
929  RankTwoTensorTempl<T> & a = *this;
930  for (const auto i : make_range(N))
931  for (const auto j : make_range(N))
932  a(i, j) = v1(i) * v2(j);
933 }
static constexpr unsigned int N
Tensor dimension, i.e.
Definition: RankTwoTensor.h:87
RankTwoTensorTempl is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: RankTwoTensor.h:79
IntRange< T > make_range(T beg, T end)

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 1374 of file RankTwoTensor.h.

◆ RankThreeTensorTempl

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

Definition at line 1376 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 1364 of file RankTwoTensor.h.

◆ N

template<typename T>
constexpr unsigned int RankTwoTensorTempl< T >::N = Moose::dim
static

Tensor dimension, i.e.

number of rows/columns of the second order tensor

Definition at line 87 of file RankTwoTensor.h.

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

◆ N2

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

The square of the tensor dimension.

Definition at line 92 of file RankTwoTensor.h.


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