19 #include "libmesh/libmesh.h"    20 #include "libmesh/tensor_value.h"    22 #include "metaphysicl/raw_type.h"    87   static constexpr 
unsigned int full_index[6][2] = {{0, 0}, {1, 1}, {2, 2}, {1, 2}, {0, 2}, {0, 1}};
    90   static constexpr 
unsigned int reverse_index[3][3] = {{0, 5, 4}, {5, 1, 3}, {4, 3, 2}};
   126       const T & S11, 
const T & S22, 
const T & S33, 
const T & S23, 
const T & S13, 
const T & S12);
   145       const T & S11, 
const T & S22, 
const T & S33, 
const T & S23, 
const T & S13, 
const T & S12);
   155   template <
typename T2>
   170   initializeSymmetric(
const TypeVector<T> & v0, 
const TypeVector<T> & v1, 
const TypeVector<T> & v2);
   237   void rotate(
const TypeTensor<T> & R);
   246   template <
typename T2>
   252   template <
typename Scalar>
   257     libmesh_assert_equal_to(p, Scalar(0));
   266   template <
typename T2>
   274   template <
typename T2>
   285   template <
typename T2>
   287       typename std::enable_if<libMesh::ScalarTraits<T2>::value,
   294   template <
typename T2>
   296       typename std::enable_if<libMesh::ScalarTraits<T2>::value,
   300   template <
typename T2>
   301   TypeVector<typename libMesh::CompareTypes<T, T2>::supertype>
   302   operator*(
const TypeVector<T2> & a) 
const;
   305   template <
typename T2>
   312   template <
typename T2>
   374   T 
sin3Lode(
const T & r0, 
const T & r0_value) 
const;
   414   void print(std::ostream & stm = Moose::out) 
const;
   417   void printReal(std::ostream & stm = Moose::out) 
const;
   420   void printADReal(
unsigned int nDual, std::ostream & stm = Moose::out) 
const;
   422   friend std::ostream & operator<<(std::ostream & os, const SymmetricRankTwoTensorTempl<T> & t)
   429   void addIa(
const T & a);
   486   void syev(
const char * calculation_type, std::vector<T> & eigvals, std::vector<T> & a) 
const;
   505 template <
typename T>
   521 template <
typename T>
   522 template <
typename T2>
   525     typename std::enable_if<libMesh::ScalarTraits<T2>::value,
   530     result.
_vals[i] = _vals[i] * a;
   534 template <
typename T>
   535 template <
typename T2>
   538     typename std::enable_if<libMesh::ScalarTraits<T2>::value,
   543     result.
_vals[i] = _vals[i] / a;
   548 template <
typename T>
   549 template <
typename T2>
   550 TypeVector<typename libMesh::CompareTypes<T, T2>::supertype>
   553   TypeVector<typename libMesh::CompareTypes<T, T2>::supertype> ret;
   554   ret(0) = a(0) * _vals[0] + a(1) * _vals[5] + a(2) * _vals[4];
   555   ret(1) = a(0) * _vals[5] + a(1) * _vals[1] + a(2) * _vals[3];
   556   ret(2) = a(0) * _vals[4] + a(1) * _vals[3] + a(2) * _vals[2];
   559 template <
typename T>
   560 template <
typename T2>
   564   for (std::size_t i = 0; i < 
N; ++i)
   565     if (_vals[i] != a.
_vals[i])
   570 template <
typename T>
   571 template <
typename T2>
   575   for (std::size_t i = 0; i < 
N; ++i)
   576     if (_vals[i] != a.
_vals[i])
   581 template <
typename T>
   592     this->symmetricEigenvaluesEigenvectors(eigval, eigvec);
   595     std::array<T, N> epos;
   597     for (
unsigned int i = 0; i < Ndim; ++i)
   599       epos[i] = (
std::abs(eigval[i]) + eigval[i]) / 2.0;
   600       d[i] = 0 < eigval[i] ? 1.0 : 0.0;
   606     for (
unsigned int a = 0; a < Ndim; ++a)
   609       proj_pos += d[a] * Ma.outerProduct(Ma);
   627             Gabba(aa, bb) = (Ma(i, k) * Mb(j, l) + Ma(i, l) * Mb(j, k) + Ma(j, l) * Mb(i, k) +
   628                              Ma(j, k) * Mb(i, l)) *
   634           theta_ab = 0.5 * (epos[a] - epos[b]) / (eigval[a] - eigval[b]);
   636           theta_ab = 0.25 * (d[a] + d[b]);
   638         proj_pos += theta_ab * Gabba;
   643     mooseError(
"positiveProjectionEigenDecomposition is only available for ordered tensor "   647 template <
typename T>
   653     T bar = secondInvariant();
   663     mooseError(
"sin3Lode is only available for ordered tensor component types");
   666 template <
typename T>
   672     T bar = secondInvariant();
   677              (dthirdInvariant() / 
std::pow(bar, 1.5) -
   678               1.5 * dsecondInvariant() * thirdInvariant() / 
std::pow(bar, 2.5));
   681     mooseError(
"dsin3Lode is only available for ordered tensor component types");
   684 template <
typename T>
   685 template <
typename T2>
   696 template <
typename T, 
typename Scalar>
   697 inline typename std::enable_if_t<
 SymmetricRankTwoTensorTempl< T > dsecondInvariant() const
Denote the _vals[i][j] by A_ij, then this returns d(secondInvariant)/dA_ij. 
MetaPhysicL::DualNumber< V, D, asd > abs(const MetaPhysicL::DualNumber< V, D, asd > &a)
void mooseSetToZero(T &v)
Helper function templates to set a variable to zero. 
void fillFromScalarVariable(const VariableValue &scalar_variable)
fillFromScalarVariable takes FIRST/THIRD/SIXTH order scalar variable to fill in the Rank-2 tensor...
static SymmetricRankTwoTensorTempl< T > timesTranspose(const RankTwoTensorTempl< T > &)
return the matrix multiplied with its transpose A*A^T (guaranteed symmetric) 
SymmetricRankTwoTensorTempl(const std::vector< T > &input)
Constructor that proxies the fillFromInputVector method. 
static constexpr unsigned int reverse_index[3][3]
friend void dataLoad(std::istream &, SymmetricRankTwoTensorTempl< T2 > &, void *)
SymmetricRankTwoTensorTempl< T > & operator*=(const T &a)
performs _vals *= a 
static constexpr std::array< Real, N > identityCoords
This class defines a Tensor that can change its shape. 
FillMethod
To fill up the 6 entries in the 2nd-order tensor, fillFromInputVector is called with one of the follo...
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-...
T thirdInvariant() const
Denote the _vals[i][j] by A_ij, then S_ij = A_ij - de_ij*tr(A)/3 Then this returns det(S + S...
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
void addIa(const T &a)
Add identity times a to _vals. 
void printReal(std::ostream &stm=Moose::out) const
Print the Real part of the ADReal rank two tensor. 
T generalSecondInvariant() const
Calculates the second invariant (I2) of a tensor. 
SymmetricRankTwoTensorTempl< typename libMesh::CompareTypes< T, T2 >::supertype > operator+(const SymmetricRankTwoTensorTempl< T2 > &a) const
returns _vals + a 
SymmetricRankFourTensorTempl< T > d2thirdInvariant() const
Denote the _vals[i][j] by A_ij, then this returns d^2(thirdInvariant)/dA_ij/dA_kl. 
libMesh::VectorValue< T > column(const unsigned int n) const
get the specified column of the tensor 
auto operator*(const T2 &a) const -> typename std::enable_if< libMesh::ScalarTraits< T2 >::value, SymmetricRankTwoTensorTempl< decltype(T() *T2())>>::type
returns _vals*a 
void rotate(const TypeTensor< T > &R)
rotates the tensor data given a rank two tensor rotation tensor _vals[i][j] = R_ij * R_jl * _vals[k][...
static void initRandom(unsigned int)
This function initializes random seed based on a user-defined number. 
static SymmetricRankTwoTensorTempl identity()
static SymmetricRankTwoTensorTempl< T > transposeTimes(const RankTwoTensorTempl< T > &)
return the matrix multiplied with its transpose A^T*A (guaranteed symmetric) 
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE. 
T trace() const
returns the trace of the tensor, ie _vals[i][i] (sum i = 0, 1, 2) 
void symmetricEigenvaluesEigenvectors(std::vector< T > &eigvals, RankTwoTensorTempl< T > &eigvecs) const
computes eigenvalues and eigenvectors, assuming tens is symmetric, and places them in ascending order...
T & operator()(unsigned int i)
Gets the raw value for the index specified. Takes index = 0,1,2,3,4,5. 
SymmetricRankFourTensorTempl< T > positiveProjectionEigenDecomposition(std::vector< T > &, RankTwoTensorTempl< T > &) const
return positive projection tensor of eigen-decomposition 
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
std::basic_ostream< charT, traits > * os
T value_type
For generic programming. 
SymmetricRankTwoTensorTempl< T > ddet() const
Denote the _vals[i][j] by A_ij, then this returns d(det)/dA_ij. 
bool operator==(const SymmetricRankTwoTensorTempl< T2 > &a) const
Defines logical equality with another SymmetricRankTwoTensorTempl<T2> 
SymmetricRankFourTensorTempl< T > d2secondInvariant() const
Denote the _vals[i][j] by A_ij, then this returns d^2(secondInvariant)/dA_ij/dA_kl. 
std::enable_if_t< libMesh::ScalarTraits< Scalar >::value, SymmetricRankTwoTensorTempl< typename libMesh::CompareTypes< T, Scalar >::supertype > > operator*(const Scalar &factor, const SymmetricRankTwoTensorTempl< T > &t)
auto max(const L &left, const R &right)
SymmetricRankTwoTensorTempl(const SymmetricRankTwoTensorTempl< T2 > &a)
Construct from other template. 
MooseArray< Real > VariableValue
static constexpr unsigned int Ndim
tensor dimension and Mandel vector length 
SymmetricRankTwoTensorTempl< T > initialContraction(const SymmetricRankFourTensorTempl< T > &b) const
returns this_ij * b_ijkl 
void fillFromInputVector(const std::vector< T > &input, FillMethod fill_method=autodetect)
fillFromInputVector takes 1, 3, or 6 inputs to fill in the symmmetric Rank-2 tensor. 
void print(std::ostream &stm=Moose::out) const
Print the rank two tensor. 
Custom type trait that has a value of true for types that cam be use interchangeably with Real...
T secondInvariant() const
Denote the _vals[i][j] by A_ij, then S_ij = A_ij - de_ij*tr(A)/3 Then this returns (S_ij + S_ji)*(S_i...
T tr() const
Returns the trace. 
SymmetricRankTwoTensorTempl< T > square() const
Returns the matrix squared. 
SymmetricRankTwoTensorTempl()
Default constructor; fills to zero. 
T L2norm() const
Sqrt(_vals[i][j]*_vals[i][j]) 
SymmetricRankTwoTensorTempl is designed to handle the Stress or Strain Tensor for an anisotropic mate...
libMesh::VectorValue< T > column(const unsigned int i) const
Get the i-th column of the second order tensor. 
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
SymmetricRankTwoTensorTempl< T > deviatoric() const
returns A_ij - de_ij*tr(A)/3, where A are the _vals 
T doubleContraction(const SymmetricRankTwoTensorTempl< T > &a) const
returns _vals_ij * a_ij (sum on i, j) 
SymmetricRankTwoTensorTempl< T > & operator/=(const T &a)
performs _vals /= a 
SymmetricRankTwoTensorTempl< T > dthirdInvariant() const
Denote the _vals[i][j] by A_ij, then this returns d(thirdInvariant()/dA_ij. 
void setToIdentity()
set the tensor to the identity matrix 
OutputTools< Real >::VariableValue VariableValue
SymmetricRankTwoTensorTempl< T > & operator=(const SymmetricRankTwoTensorTempl< T2 > &a)
sets _vals to a, and returns _vals 
static SymmetricRankTwoTensorTempl< T > selfOuterProduct(const TypeVector< T > &)
SymmetricRankTwoTensorTempl<T> from outer product of a vector with itself. 
void symmetricEigenvalues(std::vector< T > &eigvals) const
computes eigenvalues, assuming tens is symmetric, and places them in ascending order in eigvals ...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
bool isSymmetric() const
Test for symmetry. Surprisingly this is always true. 
SymmetricRankTwoTensorTempl< T > dsin3Lode(const T &r0) const
d(sin3Lode)/dA_ij If secondInvariant() <= r0 then return zero This is to gaurd against precision-loss...
boostcopy::enable_if_c< libMesh::ScalarTraits< Scalar >::value, SymmetricRankTwoTensorTempl & >::type operator=(const Scalar &libmesh_dbg_var(p))
Assignment-from-scalar operator. 
T operator()(unsigned int i) const
Gets the raw value for the index specified. 
SymmetricRankTwoTensorTempl< T > & operator-=(const SymmetricRankTwoTensorTempl< T > &a)
sets _vals -= a and returns vals 
static SymmetricRankTwoTensorTempl< T > genRandomSymmTensor(T, T)
This function generates a random symmetric rank two tensor. 
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template * sqrt(_arg)) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(tanh
static SymmetricRankTwoTensorTempl< T > plusTranspose(const RankTwoTensorTempl< T > &)
return the matrix plus its transpose A-A^T (guaranteed symmetric) 
RankTwoTensorTempl is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
SymmetricRankTwoTensorTempl< T > dtrace() const
Denote the _vals[i][j] by A_ij, then this returns d(trace)/dA_ij. 
bool relativeFuzzyEqual(const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
Function to check whether two variables are equal within a relative tolerance. 
static MooseEnum fillMethodEnum()
Static method for use in validParams for getting the "fill_method". 
friend void dataStore(std::ostream &, SymmetricRankTwoTensorTempl< T2 > &, void *)
static SymmetricRankTwoTensorTempl initializeSymmetric(const TypeVector< T > &v0, const TypeVector< T > &v1, const TypeVector< T > &v2)
named constructor for initializing symmetrically 
SymmetricRankFourTensorTempl is designed to handle an N-dimensional fourth order tensor with minor sy...
IntRange< T > make_range(T beg, T end)
void mooseSetToZero< SymmetricRankTwoTensor >(SymmetricRankTwoTensor &v)
Helper function template specialization to set an object to zero. 
bool operator!=(const SymmetricRankTwoTensorTempl< T2 > &a) const
Defines logical inequality with another SymmetricRankTwoTensorTempl<T2> 
void syev(const char *calculation_type, std::vector< T > &eigvals, std::vector< T > &a) const
Uses the petscblaslapack.h LAPACKsyev_ routine to find, for symmetric _vals: (1) the eigenvalues (if ...
SymmetricRankFourTensorTempl< T > outerProduct(const SymmetricRankTwoTensorTempl< T > &a) const
returns C_ijkl = a_ij * b_kl 
void mooseSetToZero< ADSymmetricRankTwoTensor >(ADSymmetricRankTwoTensor &v)
Helper function template specialization to set an object to zero. 
static constexpr Real mandelFactor(unsigned int i)
returns the 1 or sqrt(2) prefactor in the Mandel notation for the index i ranging from 0-5...
SymmetricRankTwoTensorTempl< T > & operator+=(const SymmetricRankTwoTensorTempl< T > &a)
adds a to _vals 
auto operator/(const T2 &a) const -> typename std::enable_if< libMesh::ScalarTraits< T2 >::value, SymmetricRankTwoTensorTempl< decltype(T()/T2())>>::type
returns _vals/a 
libMesh::VectorValue< T > row(const unsigned int n) const
get the specified row of the tensor 
static constexpr unsigned int full_index[6][2]
void surfaceFillFromInputVector(const std::vector< T > &input)
sets _vals[0][0], _vals[0][1], _vals[1][0], _vals[1][1] to input, and the remainder to zero ...
static constexpr unsigned int N
auto min(const L &left, const R &right)
static SymmetricRankTwoTensorTempl fromRawComponents(const T &S11, const T &S22, const T &S33, const T &S23, const T &S13, const T &S12)
MooseUnits pow(const MooseUnits &, int)
SymmetricRankTwoTensorTempl< T > transpose() const
Returns a matrix that is the transpose of the matrix this was called on. 
static constexpr Real sqrt2
std::sqrt is not constexpr, so we add sqrt(2) as a constant (used in Mandel notation) ...
void printADReal(unsigned int nDual, std::ostream &stm=Moose::out) const
Print the Real part of the ADReal rank two tensor along with its first nDual dual numbers...
SymmetricRankTwoTensorTempl< T > operator-() const
returns -_vals 
T operator()(unsigned int i, unsigned int j) const
Gets the value for the index specified. 
void zero()
Set all components to zero. 
SymmetricRankTwoTensorTempl< T > inverse() const
retuns the inverse of the tensor