https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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 std::enable_if< ScalarTraits< Scalar >::value, TypeTensor< decltype(T() *scalar)> >::type
 
const TypeTensor< T > & operator*= (const Scalar &factor)
 
const TypeTensor< T > & operator*= (const TypeTensor< T2 > &)
 
std::enable_if< ScalarTraits< Scalar >::value, TypeTensor< typenameCompareTypes< 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
 
auto norm_sq () const
 
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
 
bool is_hpd (Real rel_tol=TOLERANCE *TOLERANCE) const
 
 RankTwoTensorTempl (const InitMethod)
 Select specific initialization pattern.
 
 RankTwoTensorTempl (const libMesh::TypeVector< T > &row1, const libMesh::TypeVector< T > &row2, const libMesh::TypeVector< T > &row3)
 Initialize from row vectors.
 
 RankTwoTensorTempl (const std::vector< T > &input)
 Constructor that proxies the fillFromInputVector() method.
 
 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.
 
 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.
 
 RankTwoTensorTempl (const RankTwoTensorTempl< T > &a)=default
 The copy constructor.
 
 RankTwoTensorTempl (const libMesh::TensorValue< T > &a)
 The conversion operator from a libMesh::TensorValue
 
 RankTwoTensorTempl (const libMesh::TypeTensor< T > &a)
 The conversion operator from a libMesh::TypeTensor
 
template<typename T2 >
 RankTwoTensorTempl (const SymmetricRankTwoTensorTempl< T2 > &a)
 The conversion operator from a SymmetricRankTwoTensorTempl
 
template<typename T2 >
 RankTwoTensorTempl (const RankTwoTensorTempl< T2 > &a)
 The conversion operator from RankTwoTensorTempl<T2> to RankTwoTensorTempl<T> where T2 is convertible to T.
 
libMesh::VectorValue< T > column (const unsigned int i) const
 Get the i-th column of the second order tensor.
 
RankTwoTensorTempl< T > & operator= (const RankTwoTensorTempl< T > &a)=default
 Assignment operator.
 
RankTwoTensorTempl< T > & operator= (const ColumnMajorMatrixTempl< T > &a)
 Assignment operator (from a ColumnMajorMatrixTempl<T>)
 
template<typename Scalar >
std::enable_if< libMesh::ScalarTraits< Scalar >::value, RankTwoTensorTempl & >::type operator= (const Scalar &libmesh_dbg_var(p))
 Assignment-from-scalar operator.
 
RankTwoTensorTempl< T > & operator+= (const RankTwoTensorTempl< T > &a)
 Add another second order tensor to this one.
 
RankTwoTensorTempl< T > & operator-= (const RankTwoTensorTempl< T > &a)
 Subtract another second order tensor from this one.
 
RankTwoTensorTempl< T > & operator*= (const T &a)
 Multiply this tensor by a scalar (component-wise)
 
RankTwoTensorTempl< T > & operator/= (const T &a)
 Divide this tensor by a scalar (component-wise)
 
RankTwoTensorTempl< T > & operator*= (const libMesh::TypeTensor< T > &a)
 Multiplication with another second order tensor.
 
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.
 
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.
 
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
 
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.
 
void fillRow (unsigned int r, const libMesh::TypeVector< T > &v)
 Assign values to a specific row of the second order tensor.
 
void fillColumn (unsigned int c, const libMesh::TypeVector< T > &v)
 Assign values to a specific column of the second order tensor.
 
void setToIdentity ()
 Set the tensor to identity.
 
void addIa (const T &a)
 Add identity times a to _coords.
 
void rotate (const RankTwoTensorTempl< T > &R)
 Rotate the tensor in-place given a rotation tensor \( A_{ij} \leftarrow R_{ij} A_{jk} R_{jk} \).
 
RankTwoTensorTempl< T > square () const
 Return \( A_{ij} = A_{ik}A_{kj} \).
 
RankTwoTensorTempl< T > rotated (const RankTwoTensorTempl< T > &R) const
 Return the rotated tensor given a rotation tensor \( A'_{ij} = R_{ij} A_{jk} R_{jk} \).
 
RankTwoTensorTempl< T > rotateXyPlane (T a)
 Rotate the tensor about the z-axis.
 
RankTwoTensorTempl< T > transpose () const
 Return the tensor transposed.
 
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.
 
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.
 
RankTwoTensorTempl< T > operator- () const
 Return the negation of this tensor.
 
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)
 
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)
 
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.
 
template<typename T2 >
RankTwoTensorTempl< typename libMesh::CompareTypes< T, T2 >::supertype > operator* (const libMesh::TypeTensor< T2 > &a) const
 Multiplication with another second order tensor.
 
doubleContraction (const RankTwoTensorTempl< T > &a) const
 Return the double contraction with another second order tensor \( A_{ij} B_{ij} \).
 
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\} \).
 
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\} \).
 
RankFourTensorTempl< T > outerProduct (const RankTwoTensorTempl< T > &b) const
 Return the outer product \( C_{ijkl} = A_{ij} B_{kl} \).
 
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} \).
 
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} \).
 
RankFourTensorTempl< T > positiveProjectionEigenDecomposition (std::vector< T > &, RankTwoTensorTempl< T > &) const
 Return the positive projection tensor.
 
RankTwoTensorTempl< T > deviatoric () const
 Return the deviatoric part of this tensor \( A_{ij} - \frac{1}{3} A_{kk} \delta_{ij} \).
 
trace () const
 A wrapper for tr()
 
RankTwoTensorTempl< T > dtrace () const
 Return the derivative of the trace w.r.t.
 
RankTwoTensorTempl< T > inverse () const
 Return the inverse of this second order tensor.
 
generalSecondInvariant () const
 Return the principal second invariant of this second order tensor.
 
secondInvariant () const
 Return the main second invariant of this second order tensor.
 
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.
 
sin3Lode (const T &r0, const T &r0_value) const
 Sin(3*Lode_angle)
 
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.
 
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.
 
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.
 
RankTwoTensorTempl< T > dthirdInvariant () const
 Denote the _coords[i][j] by A_ij, then this returns d(thirdInvariant()/dA_ij.
 
RankFourTensorTempl< T > d2thirdInvariant () const
 Denote the _coords[i][j] by A_ij, then this returns d^2(thirdInvariant)/dA_ij/dA_kl.
 
RankTwoTensorTempl< T > ddet () const
 Denote the _coords[i][j] by A_ij, then this returns d(det)/dA_ij.
 
L2norm () const
 Sqrt(_coords[i][j]*_coords[i][j])
 
void symmetricEigenvalues (std::vector< T > &eigvals) const
 computes eigenvalues, assuming tens is symmetric, and places them in ascending order in eigvals
 
void symmetricEigenvaluesEigenvectors (std::vector< T > &eigvals, RankTwoTensorTempl< T > &eigvecs) const
 computes eigenvalues and eigenvectors, assuming tens is symmetric, and places them in ascending order in eigvals.
 
void dsymmetricEigenvalues (std::vector< T > &eigvals, std::vector< RankTwoTensorTempl< T > > &deigvals) const
 computes eigenvalues, and their symmetric derivatives wrt vals, assuming tens is symmetric
 
void d2symmetricEigenvalues (std::vector< RankFourTensorTempl< T > > &deriv) const
 Computes second derivatives of Eigenvalues of a rank two tensor.
 
void getRUDecompositionRotation (RankTwoTensorTempl< T > &rot) const
 Uses the petscblaslapack.h LAPACKsyev_ routine to perform RU decomposition and obtain the rotation tensor.
 
RankTwoTensorTempl< T > initialContraction (const RankFourTensorTempl< T > &b) const
 returns this_ij * b_ijkl
 
bool operator== (const RankTwoTensorTempl< T > &a) const
 Defines logical equality with another RankTwoTensorTempl<T>
 
bool isSymmetric () const
 Test for symmetry.
 

Static Public Member Functions

static TensorValue< Real > intrinsic_rotation_matrix (Real phi, Real theta, Real psi)
 
static TensorValue< Real > inverse_intrinsic_rotation_matrix (Real phi, Real theta, Real psi)
 
static TensorValue< Real > extrinsic_rotation_matrix (Real angle1_deg, Real angle2_deg, Real angle3_deg)
 
static TensorValue< Real > inverse_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.
 
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.
 
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.
 
static RankTwoTensorTempl Identity ()
 Initialize a second order identity tensor.
 
static RankTwoTensorTempl< T > timesTranspose (const RankTwoTensorTempl< T > &)
 Initialize a second order tensor with expression \( B_{ij} = F_{ij} F_{ji} \).
 
static RankTwoTensorTempl< T > transposeTimes (const RankTwoTensorTempl< T > &)
 Initialize a second order tensor with expression \( C_{ij} = F_{ji} F_{ij} \).
 
static RankTwoTensorTempl< T > plusTranspose (const RankTwoTensorTempl< T > &)
 Initialize a second order tensor with expression \( E_{ij} = C_{ij} + C_{ji} \).
 
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.
 
static RankTwoTensorTempl< T > selfOuterProduct (const libMesh::TypeVector< T > &)
 Initialize a second order tensor as the outer product of a vector with itself, i.e.
 
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.
 
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.
 

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")
 

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.
 
static constexpr unsigned int N2 = N * N
 The square of the tensor dimension.
 
static void initRandom (unsigned int)
 Initialize the random seed based on an unsigned integer.
 
static MooseEnum fillMethodEnum ()
 Get the available FillMethod options.
 
void fillRealTensor (libMesh::TensorValue< T > &)
 Fill a libMesh::TensorValue<T> from this second order tensor.
 
void print (std::ostream &stm=Moose::out) const
 Print the rank two tensor.
 
void printReal (std::ostream &stm=Moose::out) const
 Print the Real part of the RankTwoTensorTempl<ADReal>
 
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.
 

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 87 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 118 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 107 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.

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}
static constexpr unsigned int N
Tensor dimension, i.e.
static constexpr unsigned int N2
The square of the tensor dimension.
T _coords[LIBMESH_DIM *LIBMESH_DIM]

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

◆ 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:311
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}
void mooseDeprecated(Args &&... args)
Emit a deprecated code/feature message with the given stringified, concatenated args.
Definition MooseError.h:363

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

219{ 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 270 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 275 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 281 of file RankTwoTensor.h.

283 a(1),
284 a(2),
285 a(3) / MathUtils::sqrt2,
286 a(4) / MathUtils::sqrt2,
287 a(5) / MathUtils::sqrt2)
288 {
289 }
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 296 of file RankTwoTensor.h.

297 {
298 }

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 ]
void addIa(const T &a)
Add identity times a to _coords.

Definition at line 736 of file RankTwoTensorImplementation.h.

737{
738 for (const auto i : make_range(N))
739 (*this)(i, i) += a;
740}

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

◆ 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.

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

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

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

466{
468
469 for (const auto i : make_range(N))
470 for (const auto j : make_range(N))
471 for (const auto k : make_range(N))
472 for (const auto l : make_range(N))
473 result(i, k, l) += (*this)(i, j) * b(j, k, l);
474
475 return result;
476}
for(PetscInt i=0;i< nvars;++i)
RankThreeTensor is designed to handle any N-dimensional third order tensor, r.

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

540{
542 for (const auto i : make_range(N))
543 for (const auto j : make_range(N))
544 for (const auto k : make_range(N))
545 for (const auto l : make_range(N))
546 result(i, j, k, l) = 0.5 * (i == k) * (j == l) + 0.5 * (i == l) * (j == k) -
547 (1.0 / 3.0) * (i == j) * (k == l);
548 return result;
549}
RankFourTensorTempl is designed to handle any N-dimensional fourth order tensor, C.

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

1549{
1550 using std::pow, std::sqrt;
1551 if constexpr (MooseUtils::IsLikeReal<T>::value)
1552 {
1553 T bar = secondInvariant();
1554 if (bar <= r0)
1555 return RankFourTensorTempl<T>();
1556
1557 T J3 = thirdInvariant();
1561 d2thirdInvariant() / pow(bar, 1.5) - 1.5 * d2secondInvariant() * J3 / pow(bar, 2.5);
1562
1563 for (unsigned i = 0; i < N; ++i)
1564 for (unsigned j = 0; j < N; ++j)
1565 for (unsigned k = 0; k < N; ++k)
1566 for (unsigned l = 0; l < N; ++l)
1567 deriv(i, j, k, l) +=
1568 (-1.5 * dII(i, j) * dIII(k, l) - 1.5 * dIII(i, j) * dII(k, l)) / pow(bar, 2.5) +
1569 1.5 * 2.5 * dII(i, j) * dII(k, l) * J3 / pow(bar, 3.5);
1570
1571 deriv *= -1.5 * sqrt(3.0);
1572 return deriv;
1573 }
1574 else
1575 mooseError("d2sin3Lode is only available for ordered tensor component types");
1576}
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....
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.
RankFourTensorTempl< T > d2thirdInvariant() const
Denote the _coords[i][j] by A_ij, then this returns d^2(thirdInvariant)/dA_ij/dA_kl.
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.
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template * sqrt(_arg)) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(tanh
Real deriv(unsigned n, unsigned alpha, unsigned beta, Real x)
T pow(const T &x)
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 855 of file RankTwoTensorImplementation.h.

856{
857 std::vector<T> eigvec;
858 std::vector<T> eigvals;
859 T ev[N][N];
860
861 // reset rank four tensor
862 deriv.assign(N, RankFourTensorTempl<T>());
863
864 // get eigen values and eigen vectors
865 syev("V", eigvals, eigvec);
866
867 for (const auto i : make_range(N))
868 for (const auto j : make_range(N))
869 ev[i][j] = eigvec[i * N + j];
870
871 for (unsigned int alpha = 0; alpha < N; ++alpha)
872 for (unsigned int beta = 0; beta < N; ++beta)
873 {
874 if (eigvals[alpha] == eigvals[beta])
875 continue;
876
877 for (const auto i : make_range(N))
878 for (const auto j : make_range(N))
879 for (const auto k : make_range(N))
880 for (const auto l : make_range(N))
881 {
882 deriv[alpha](i, j, k, l) +=
883 0.5 * (ev[beta][i] * ev[alpha][j] + ev[alpha][i] * ev[beta][j]) *
884 (ev[beta][k] * ev[alpha][l] + ev[beta][l] * ev[alpha][k]) /
885 (eigvals[alpha] - eigvals[beta]);
886 }
887 }
888}
void syev(const char *calculation_type, std::vector< T > &eigvals, std::vector< T > &a) const
Uses the petscblaslapack.h LAPACKsyev_ routine to find, for symmetric _coords: (1) the eigenvalues (i...

◆ d2thirdInvariant()

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

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

Definition at line 605 of file RankTwoTensorImplementation.h.

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

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

696{
698
699 d(0, 0) = (*this)(1, 1) * (*this)(2, 2) - (*this)(2, 1) * (*this)(1, 2);
700 d(0, 1) = (*this)(2, 0) * (*this)(1, 2) - (*this)(1, 0) * (*this)(2, 2);
701 d(0, 2) = (*this)(1, 0) * (*this)(2, 1) - (*this)(2, 0) * (*this)(1, 1);
702 d(1, 0) = (*this)(2, 1) * (*this)(0, 2) - (*this)(0, 1) * (*this)(2, 2);
703 d(1, 1) = (*this)(0, 0) * (*this)(2, 2) - (*this)(2, 0) * (*this)(0, 2);
704 d(1, 2) = (*this)(2, 0) * (*this)(0, 1) - (*this)(0, 0) * (*this)(2, 1);
705 d(2, 0) = (*this)(0, 1) * (*this)(1, 2) - (*this)(1, 1) * (*this)(0, 2);
706 d(2, 1) = (*this)(1, 0) * (*this)(0, 2) - (*this)(0, 0) * (*this)(1, 2);
707 d(2, 2) = (*this)(0, 0) * (*this)(1, 1) - (*this)(1, 0) * (*this)(0, 1);
708
709 return d;
710}

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

495{
497 // actually construct deviatoric part
498 deviatoric.addIa(-1.0 / 3.0 * this->tr());
499 return deviatoric;
500}

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

458{
459 // deprecate this!
461}

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

533{
535}

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

1530{
1531 using std::sqrt, std::pow;
1532 if constexpr (MooseUtils::IsLikeReal<T>::value)
1533 {
1534 T bar = secondInvariant();
1535 if (bar <= r0)
1536 return RankTwoTensorTempl<T>();
1537 else
1538 return -1.5 * sqrt(3.0) *
1539 (dthirdInvariant() / pow(bar, 1.5) -
1540 1.5 * dsecondInvariant() * thirdInvariant() / pow(bar, 2.5));
1541 }
1542 else
1543 mooseError("dsin3Lode is only available for ordered tensor component types");
1544}

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

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

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

586{
587 const auto s = RankTwoTensorTempl<T>::plusTranspose(deviatoric()) * 0.5;
588 const T s3 = secondInvariant() / 3.0;
589
591 d(0, 0) = s(1, 1) * s(2, 2) - s(2, 1) * s(1, 2) + s3;
592 d(0, 1) = s(2, 0) * s(1, 2) - s(1, 0) * s(2, 2);
593 d(0, 2) = s(1, 0) * s(2, 1) - s(2, 0) * s(1, 1);
594 d(1, 0) = s(2, 1) * s(0, 2) - s(0, 1) * s(2, 2);
595 d(1, 1) = s(0, 0) * s(2, 2) - s(2, 0) * s(0, 2) + s3;
596 d(1, 2) = s(2, 0) * s(0, 1) - s(0, 0) * s(2, 1);
597 d(2, 0) = s(0, 1) * s(1, 2) - s(1, 1) * s(0, 2);
598 d(2, 1) = s(1, 0) * s(0, 2) - s(0, 0) * s(1, 2);
599 d(2, 2) = s(0, 0) * s(1, 1) - s(1, 0) * s(0, 1) + s3;
600 return d;
601}

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

562{
563 return RankTwoTensorTempl<T>(1, 0, 0, 0, 1, 0, 0, 0, 1);
564}

◆ 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 ]
void fillColumn(unsigned int c, const libMesh::TypeVector< T > &v)
Assign values to a specific column of the second order tensor.

Definition at line 979 of file RankTwoTensorImplementation.h.

980{
981 for (const auto i : make_range(N))
982 (*this)(i, c) = v(i);
983}

◆ 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.

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}

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

◆ 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 ]
void fillFromScalarVariable(const VariableValue &scalar_variable)
The smart mutator that determines how to fill the second order tensor based on the order of the scala...

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}

◆ 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:55

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

963{
964 for (const auto i : make_range(N))
965 for (const auto j : make_range(N))
966 tensor(i, j) = (*this)(i, j);
967}

◆ 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 ]
void fillRow(unsigned int r, const libMesh::TypeVector< T > &v)
Assign values to a specific row of the second order tensor.

Definition at line 971 of file RankTwoTensorImplementation.h.

972{
973 for (const auto i : make_range(N))
974 (*this)(r, i) = v(i);
975}

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

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

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

921{
922 auto r = [&]() { return (MooseRandom::rand() + mean) * stddev; };
923 return RankTwoTensorTempl<T>(r(), r(), r(), r(), r(), r());
924}
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 909 of file RankTwoTensorImplementation.h.

910{
912 for (const auto i : make_range(N))
913 for (const auto j : make_range(N))
914 result(i, j) = (MooseRandom::rand() + mean) * stddev;
915 return result;
916}
This class encapsulates a useful, consistent, cross-platform random number generator with multiple ut...
Definition MooseRandom.h:38

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

893{
894 mooseError("getRUDecompositionRotation is only supported for Real valued tensors");
895}

◆ 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 ]
static RankTwoTensorTempl Identity()
Initialize a second order identity tensor.

Definition at line 368 of file RankTwoTensor.h.

RankTwoTensorTempl()
Empty constructor; fills to zero.

◆ initialContraction()

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

returns this_ij * b_ijkl

Definition at line 987 of file RankTwoTensorImplementation.h.

988{
990 for (const auto i : make_range(N))
991 for (const auto j : make_range(N))
992 for (const auto k : make_range(N))
993 for (const auto l : make_range(N))
994 result(k, l) += (*this)(i, j) * b(i, j, k, l);
995 return result;
996}

◆ 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 ]
static RankTwoTensorTempl initializeFromColumns(const libMesh::TypeVector< Real > &col0, const libMesh::TypeVector< Real > &col1, const libMesh::TypeVector< Real > &col2)
Named constructor for initializing from row vectors.

Definition at line 147 of file RankTwoTensorImplementation.h.

150{
152 col0(0), col0(1), col0(2), col1(0), col1(1), col1(2), col2(0), col2(1), col2(2));
153}

◆ 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 ]
static RankTwoTensorTempl initializeFromRows(const libMesh::TypeVector< Real > &row0, const libMesh::TypeVector< Real > &row1, const libMesh::TypeVector< Real > &row2)
Named constructor for initializing from row vectors.

Definition at line 137 of file RankTwoTensorImplementation.h.

140{
142 row0(0), row1(0), row2(0), row0(1), row1(1), row2(1), row0(2), row1(2), row2(2));
143}

◆ 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 ]
static RankTwoTensorTempl initializeSymmetric(const libMesh::TypeVector< Real > &v0, const libMesh::TypeVector< Real > &v1, const libMesh::TypeVector< Real > &v2)
Named constructor for initializing symmetrically.

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}

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

903{
904 MooseRandom::seed(rand_seed);
905}
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 568 of file RankTwoTensorImplementation.h.

569{
571}

◆ isSymmetric()

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

Test for symmetry.

Definition at line 434 of file RankTwoTensorImplementation.h.

435{
436 auto test = MetaPhysicL::raw_value(*this - transpose());
437 return MooseUtils::absoluteFuzzyEqual(test.norm_sq(), 0);
438}
RankTwoTensorTempl< T > transpose() const
Return the tensor transposed.
auto raw_value(const Eigen::Map< T > &in)

◆ L2norm()

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

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

Definition at line 744 of file RankTwoTensorImplementation.h.

745{
746 T norm = 0.0;
747 for (const auto i : make_range(N2))
748 {
749 T v = _coords[i];
750 norm += v * v;
751 }
752 using std::sqrt;
753 return norm == 0.0 ? 0.0 : sqrt(norm);
754}

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

481{
483
484 for (const auto i : make_range(N))
485 for (const auto j : make_range(N))
486 for (const auto k : make_range(N))
487 result(i, j, k) += (*this)(j, k) * b(i);
488
489 return result;
490}

◆ operator*() [1/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 1440 of file RankTwoTensor.h.

1441{
1443}

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

1433{
1435}

◆ operator*() [3/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 1424 of file RankTwoTensor.h.

1425{
1427}

◆ operator*=() [1/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 414 of file RankTwoTensorImplementation.h.

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

◆ operator*=() [2/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 398 of file RankTwoTensorImplementation.h.

399{
401 return *this;
402}

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

1409{
1411}

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

376{
378 return *this;
379}

◆ operator-() [1/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 391 of file RankTwoTensorImplementation.h.

392{
394}

◆ operator-() [2/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 1416 of file RankTwoTensor.h.

1417{
1419}

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

384{
386 return *this;
387}

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

1449{
1451}

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

407{
409 return *this;
410}

◆ operator=() [1/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 442 of file RankTwoTensorImplementation.h.

443{
444 if (a.n() != N || a.m() != N)
445 mooseError("Dimensions of ColumnMajorMatrixTempl<T> are incompatible with RankTwoTensorTempl");
446
447 const T * cmm_rawdata = a.rawData();
448 for (const auto i : make_range(N))
449 for (const auto j : make_range(N))
450 _coords[i * N + j] = cmm_rawdata[i + j * N];
451
452 return *this;
453}
unsigned int n() const
Returns the number of rows.
T * rawData()
Returns a reference to the raw data pointer.
unsigned int m() const
Returns the number of columns.

◆ operator=() [2/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=() [3/3]

template<typename T >
template<typename Scalar >
std::enable_if< 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 553 of file RankTwoTensor.h.

554 {
555 libmesh_assert_equal_to(p, Scalar(0));
556 this->zero();
557 return *this;
558 }

◆ operator==()

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

Defines logical equality with another RankTwoTensorTempl<T>

Definition at line 422 of file RankTwoTensorImplementation.h.

423{
424 for (const auto i : make_range(N))
425 for (const auto j : make_range(N))
426 if (!MooseUtils::absoluteFuzzyEqual((*this)(i, j), a(i, j)))
427 return false;
428
429 return true;
430}
if(!dmm->_nl) SETERRQ(PETSC_COMM_WORLD

◆ 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 ]
static RankTwoTensorTempl< Real > outerProduct(const libMesh::TypeVector< Real > &, const libMesh::TypeVector< Real > &)
Initialize a second order tensor as the outer product of two vectors, i.e.

Definition at line 939 of file RankTwoTensorImplementation.h.

941{
943 for (const auto i : make_range(N))
944 for (const auto j : make_range(N))
945 result(i, j) = v1(i) * v2(j);
946 return result;
947}

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

1161 {
1162 usingTensorIndices(i_, j_, k_, l_);
1163 return times<i_, j_, k_, l_>(b);
1164 }

◆ 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.

296{
297 return a + a.transpose();
298}

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

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

1457{
1458 using std::abs;
1459 if constexpr (MooseUtils::IsLikeReal<T>::value)
1460 {
1461 // Compute eigenvectors and eigenvalues of this tensor
1462 this->symmetricEigenvaluesEigenvectors(eigval, eigvec);
1463
1464 // Separate out positive and negative eigen values
1465 std::array<T, N> epos;
1466 std::array<T, N> d;
1467 for (auto i : libMesh::make_range(N))
1468 {
1469 epos[i] = (abs(eigval[i]) + eigval[i]) / 2.0;
1470 d[i] = 0 < eigval[i] ? 1.0 : 0.0;
1471 }
1472
1473 // projection tensor
1474 RankFourTensorTempl<T> proj_pos;
1475 RankFourTensorTempl<T> Gab, Gba;
1476
1477 for (auto a : libMesh::make_range(N))
1478 {
1479 const auto Ma = RankTwoTensorTempl<T>::selfOuterProduct(eigvec.column(a));
1480 proj_pos += d[a] * Ma.outerProduct(Ma);
1481 }
1482
1483 usingTensorIndices(i_, j_, k_, l_);
1484 for (const auto a : libMesh::make_range(N))
1485 for (const auto b : libMesh::make_range(a))
1486 {
1487 const auto Ma = RankTwoTensorTempl<T>::selfOuterProduct(eigvec.column(a));
1488 const auto Mb = RankTwoTensorTempl<T>::selfOuterProduct(eigvec.column(b));
1489
1490 Gab = Ma.template times<i_, k_, j_, l_>(Mb) + Ma.template times<i_, l_, j_, k_>(Mb);
1491 Gba = Mb.template times<i_, k_, j_, l_>(Ma) + Mb.template times<i_, l_, j_, k_>(Ma);
1492
1493 T theta_ab;
1494 if (!MooseUtils::absoluteFuzzyEqual(eigval[a], eigval[b]))
1495 theta_ab = 0.5 * (epos[a] - epos[b]) / (eigval[a] - eigval[b]);
1496 else
1497 theta_ab = 0.25 * (d[a] + d[b]);
1498
1499 proj_pos += theta_ab * (Gab + Gba);
1500 }
1501 return proj_pos;
1502 }
1503 else
1504 mooseError("positiveProjectionEigenDecomposition is only available for ordered tensor "
1505 "component types");
1506}
static RankTwoTensorTempl< T > selfOuterProduct(const libMesh::TypeVector< T > &)
Initialize a second order tensor as the outer product of a vector with itself, i.e.
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...
MetaPhysicL::DualNumber< V, D, asd > abs(const MetaPhysicL::DualNumber< V, D, asd > &a)
Definition EigenADReal.h:50
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...

◆ print()

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

Print the rank two tensor.

Definition at line 714 of file RankTwoTensorImplementation.h.

715{
716 const RankTwoTensorTempl<T> & a = *this;
717 for (const auto i : make_range(N))
718 {
719 for (const auto j : make_range(N))
720 stm << std::setw(15) << a(i, j) << ' ';
721 stm << std::endl;
722 }
723}

◆ 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}

◆ 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}
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)

◆ 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.

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}

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

◆ 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 ]
RankTwoTensorTempl< T > rotated(const RankTwoTensorTempl< T > &R) const
Return the rotated tensor given a rotation tensor .

Definition at line 309 of file RankTwoTensorImplementation.h.

310{
311 RankTwoTensorTempl<T> result(*this);
312 result.rotate(R);
313 return result;
314}

◆ 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 using std::cos, std::sin;
351 T c = cos(a);
352 T s = sin(a);
353 T x = (*this)(0, 0) * c * c + (*this)(1, 1) * s * s + 2.0 * (*this)(0, 1) * c * s;
354 T y = (*this)(0, 0) * s * s + (*this)(1, 1) * c * c - 2.0 * (*this)(0, 1) * c * s;
355 T xy = ((*this)(1, 1) - (*this)(0, 0)) * c * s + (*this)(0, 1) * (c * c - s * s);
356
357 RankTwoTensorTempl<T> b(*this);
358
359 b(0, 0) = x;
360 b(1, 1) = y;
361 b(1, 0) = b(0, 1) = xy;
362
363 return b;
364}
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

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

514{
515 T result;
516
517 // RankTwoTensorTempl<T> deviatoric(*this);
518 // deviatoric.addIa(-1.0/3.0 * this->tr()); // actually construct deviatoric part
519 // result = 0.5*(deviatoric + deviatoric.transpose()).doubleContraction(deviatoric +
520 // deviatoric.transpose());
521 result = Utility::pow<2>((*this)(0, 0) - (*this)(1, 1)) / 6.0;
522 result += Utility::pow<2>((*this)(0, 0) - (*this)(2, 2)) / 6.0;
523 result += Utility::pow<2>((*this)(1, 1) - (*this)(2, 2)) / 6.0;
524 result += Utility::pow<2>((*this)(0, 1) + (*this)(1, 0)) / 4.0;
525 result += Utility::pow<2>((*this)(0, 2) + (*this)(2, 0)) / 4.0;
526 result += Utility::pow<2>((*this)(1, 2) + (*this)(2, 1)) / 4.0;
527 return result;
528}

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

952{
954 for (unsigned int i = 0; i < N; ++i)
955 for (unsigned int j = 0; j < N; ++j)
956 result(i, j) = v(i) * v(j);
957 return result;
958}

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

◆ 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 ]
void setToIdentity()
Set the tensor to identity.

Definition at line 1000 of file RankTwoTensorImplementation.h.

1001{
1002 mooseAssert(N2 == 9, "RankTwoTensorTempl is currently only tested for 3 dimensions.");
1003 for (const auto i : make_range(N2))
1004 _coords[i] = identityCoords[i];
1005}
static constexpr Real identityCoords[N2]

◆ sin3Lode()

template<typename T >
T RankTwoTensorTempl< T >::sin3Lode ( const T &  r0,
const T &  r0_value 
) const

Sin(3*Lode_angle)

If secondInvariant() <= r0 then return r0_value This is to gaurd against precision-loss errors. Note that sin(3*Lode_angle) is not defined for secondInvariant() = 0

Definition at line 1510 of file RankTwoTensor.h.

1511{
1512 using std::pow, std::max, std::sqrt, std::min;
1513 if constexpr (MooseUtils::IsLikeReal<T>::value)
1514 {
1515 T bar = secondInvariant();
1516 if (bar <= r0)
1517 // in this case the Lode angle is not defined
1518 return r0_value;
1519 else
1520 // the min and max here gaurd against precision-loss when bar is tiny but nonzero.
1521 return max(min(-1.5 * sqrt(3.0) * thirdInvariant() / pow(bar, 1.5), 1.0), -1.0);
1522 }
1523 else
1524 mooseError("sin3Lode is only available for ordered tensor component types");
1525}
auto max(const L &left, const R &right)
auto min(const L &left, const R &right)

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

759{
760 if (input.size() == 4)
761 {
762 // initialize with zeros
763 this->zero();
764 (*this)(0, 0) = input[0];
765 (*this)(0, 1) = input[1];
766 (*this)(1, 0) = input[2];
767 (*this)(1, 1) = input[3];
768 }
769 else
770 mooseError("please provide correct number of values for surface RankTwoTensorTempl<T> "
771 "initialization.");
772}

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

777{
778 mooseError("The syev method is only supported for Real valued tensors");
779}

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

789{
792}

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

801{
803 "symmetricEigenvaluesEigenvectors is only available for ordered tensor component types");
804}

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

576{
577 const auto s = RankTwoTensorTempl<T>::plusTranspose(deviatoric()) * 0.5;
578 return s(0, 0) * (s(1, 1) * s(2, 2) - s(2, 1) * s(1, 2)) -
579 s(1, 0) * (s(0, 1) * s(2, 2) - s(2, 1) * s(0, 2)) +
580 s(2, 0) * (s(0, 1) * s(1, 2) - s(1, 1) * s(0, 2));
581}

◆ times() [1/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 1597 of file RankTwoTensor.h.

1598{
1600 std::size_t x[5];
1601 for (x[0] = 0; x[0] < N; ++x[0])
1602 for (x[1] = 0; x[1] < N; ++x[1])
1603 for (x[2] = 0; x[2] < N; ++x[2])
1604 for (x[3] = 0; x[3] < N; ++x[3])
1605 for (x[4] = 0; x[4] < N; ++x[4])
1606 result(x[0], x[1], x[2], x[3]) += (*this)(x[n], x[o]) * b(x[p], x[q], x[r], x[s]);
1607
1608 return result;
1609}

◆ times() [2/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 1581 of file RankTwoTensor.h.

1582{
1584 std::size_t x[4];
1585 for (x[0] = 0; x[0] < N; ++x[0])
1586 for (x[1] = 0; x[1] < N; ++x[1])
1587 for (x[2] = 0; x[2] < N; ++x[2])
1588 for (x[3] = 0; x[3] < N; ++x[3])
1589 result(x[0], x[1], x[2], x[3]) = (*this)(x[n], x[o]) * b(x[p], x[q]);
1590
1591 return result;
1592}

◆ 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 ]
static RankTwoTensorTempl< Real > timesTranspose(const RankTwoTensorTempl< Real > &)
Initialize a second order tensor with expression .

Definition at line 281 of file RankTwoTensorImplementation.h.

282{
283 return a * a.transpose();
284}

◆ trace()

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

A wrapper for tr()

See also
tr()

Definition at line 553 of file RankTwoTensorImplementation.h.

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

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

369{
371}

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

◆ 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 ]
static RankTwoTensorTempl< Real > transposeTimes(const RankTwoTensorTempl< Real > &)
Initialize a second order tensor with expression .

Definition at line 288 of file RankTwoTensorImplementation.h.

289{
290 return a.transpose() * a;
291}

◆ 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 ]
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....

Definition at line 928 of file RankTwoTensorImplementation.h.

930{
931 RankTwoTensorTempl<T> & a = *this;
932 for (const auto i : make_range(N))
933 for (const auto j : make_range(N))
934 a(i, j) = v1(i) * v2(j);
935}

Friends And Related Symbol 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 1381 of file RankTwoTensor.h.

◆ RankThreeTensorTempl

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

Definition at line 1383 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}
staticconstexprprivate

Definition at line 1371 of file RankTwoTensor.h.

1371{1, 0, 0, 0, 1, 0, 0, 0, 1};

◆ N

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

Tensor dimension, i.e.

number of rows/columns of the second order tensor

Definition at line 95 of file RankTwoTensor.h.

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

◆ N2

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

The square of the tensor dimension.

Definition at line 100 of file RankTwoTensor.h.


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