www.mooseframework.org
Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
RankTwoTensor Class Reference

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

#include <RankTwoTensor.h>

Public Types

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

Public Member Functions

 RankTwoTensor ()
 Default constructor; fills to zero. More...
 
 RankTwoTensor (const InitMethod)
 Select specific initialization pattern. More...
 
 RankTwoTensor (const TypeVector< Real > &row1, const TypeVector< Real > &row2, const TypeVector< Real > &row3)
 Constructor that takes in 3 vectors and uses them to create rows _vals[0][i] = row1(i), _vals[1][i] = row2(i), _vals[2][i] = row3(i) More...
 
 RankTwoTensor (const std::vector< Real > &input)
 Constructor that proxies the fillFromInputVector method. More...
 
 RankTwoTensor (Real S11, Real S22, Real S33, Real S23, Real S13, Real S12)
 Initialization list replacement constructors, 6 arguments. More...
 
 RankTwoTensor (Real S11, Real S21, Real S31, Real S12, Real S22, Real S32, Real S13, Real S23, Real S33)
 Initialization list replacement constructors, 9 arguments. More...
 
 RankTwoTensor (const TypeTensor< Real > &a)
 Copy constructor from RealTensorValue. More...
 
Real & operator() (unsigned int i, unsigned int j)
 Gets the value for the index specified. Takes index = 0,1,2. More...
 
Real operator() (unsigned int i, unsigned int j) const
 Gets the value for the index specified. Takes index = 0,1,2, used for const. More...
 
void zero ()
 zeroes all _vals components More...
 
void fillFromInputVector (const std::vector< Real > &input, FillMethod fill_method=autodetect)
 fillFromInputVector takes 6 or 9 inputs to fill in the Rank-2 tensor. More...
 
TypeVector< Real > row (const unsigned int r) const
 returns _vals[r][i], ie, row r, with r = 0, 1, 2 More...
 
TypeVector< Real > column (const unsigned int c) const
 returns _vals[i][c], ie, column c, with c = 0, 1, 2 More...
 
RankTwoTensor rotated (const RealTensorValue &R) const
 Returns a rotated version of the tensor data given a rank two tensor rotation tensor _vals[i][j] = R_ij * R_jl * _vals[k][l]. More...
 
void rotate (const RealTensorValue &R)
 rotates the tensor data given a rank two tensor rotation tensor _vals[i][j] = R_ij * R_jl * _vals[k][l] More...
 
void rotate (const RankTwoTensor &R)
 rotates the tensor data given a rank two tensor rotation tensor _vals[i][j] = R_ij * R_jl * _vals[k][l] More...
 
RankTwoTensor rotateXyPlane (Real a)
 rotates the tensor data anticlockwise around the z-axis More...
 
RankTwoTensor transpose () const
 Returns a matrix that is the transpose of the matrix this was called on. More...
 
RankTwoTensoroperator= (const RankTwoTensor &a)
 sets _vals to a, and returns _vals More...
 
RankTwoTensoroperator+= (const RankTwoTensor &a)
 adds a to _vals More...
 
RankTwoTensor operator+ (const RankTwoTensor &a) const
 returns _vals + a More...
 
RankTwoTensoroperator-= (const RankTwoTensor &a)
 sets _vals -= a and returns vals More...
 
RankTwoTensor operator- (const RankTwoTensor &a) const
 returns _vals - a More...
 
RankTwoTensor operator- () const
 returns -_vals More...
 
RankTwoTensoroperator*= (const Real a)
 performs _vals *= a More...
 
RankTwoTensor operator* (const Real a) const
 returns _vals*a More...
 
RankTwoTensoroperator/= (const Real a)
 performs _vals /= a More...
 
RankTwoTensor operator/ (const Real a) const
 returns _vals/a More...
 
TypeVector< Real > operator* (const TypeVector< Real > &a) const
 Defines multiplication with a vector to get a vector. More...
 
RankTwoTensoroperator*= (const RankTwoTensor &a)
 performs _vals *= a (component by component) and returns the result More...
 
RankTwoTensor operator* (const RankTwoTensor &a) const
 Defines multiplication with another RankTwoTensor. More...
 
RankTwoTensor operator* (const TypeTensor< Real > &a) const
 Defines multiplication with a TypeTensor<Real> More...
 
bool operator== (const RankTwoTensor &a) const
 Defines logical equality with another RankTwoTensor. More...
 
RankTwoTensoroperator= (const ColumnMajorMatrix &a)
 Sets _vals to the values in a ColumnMajorMatrix (must be 3x3) More...
 
Real doubleContraction (const RankTwoTensor &a) const
 returns _vals_ij * a_ij (sum on i, j) More...
 
RankFourTensor outerProduct (const RankTwoTensor &a) const
 returns C_ijkl = a_ij * b_kl More...
 
RankFourTensor mixedProductIkJl (const RankTwoTensor &a) const
 returns C_ijkl = a_ik * b_jl More...
 
RankFourTensor mixedProductJkIl (const RankTwoTensor &a) const
 returns C_ijkl = a_jk * b_il More...
 
RankTwoTensor deviatoric () const
 returns A_ij - de_ij*tr(A)/3, where A are the _vals More...
 
Real trace () const
 returns the trace of the tensor, ie _vals[i][i] (sum i = 0, 1, 2) More...
 
RankTwoTensor dtrace () const
 Denote the _vals[i][j] by A_ij, then this returns d(trace)/dA_ij. More...
 
Real generalSecondInvariant () const
 Denote the _vals[i][j] by A_ij, then S_ij = A_ij - de_ij*tr(A)/3 Then this returns (S_ij + S_ji)*(S_ij + S_ji)/8 Note the explicit symmeterisation. More...
 
Real secondInvariant () const
 Calculates the second invariant (I2) of a tensor. More...
 
RankTwoTensor dsecondInvariant () const
 Denote the _vals[i][j] by A_ij, then this returns d(secondInvariant)/dA_ij. More...
 
RankFourTensor d2secondInvariant () const
 Denote the _vals[i][j] by A_ij, then this returns d^2(secondInvariant)/dA_ij/dA_kl. More...
 
Real sin3Lode (const Real r0, const Real r0_value) const
 Sin(3*Lode_angle) If secondInvariant() <= r0 then return r0_value This is to gaurd against precision-loss errors. More...
 
RankTwoTensor dsin3Lode (const Real r0) const
 d(sin3Lode)/dA_ij If secondInvariant() <= r0 then return zero This is to gaurd against precision-loss errors. More...
 
RankFourTensor d2sin3Lode (const Real r0) const
 d^2(sin3Lode)/dA_ij/dA_kl If secondInvariant() <= r0 then return zero This is to gaurd against precision-loss errors. More...
 
Real thirdInvariant () const
 Denote the _vals[i][j] by A_ij, then S_ij = A_ij - de_ij*tr(A)/3 Then this returns det(S + S.transpose())/2 Note the explicit symmeterisation. More...
 
RankTwoTensor dthirdInvariant () const
 Denote the _vals[i][j] by A_ij, then this returns d(thirdInvariant()/dA_ij. More...
 
RankFourTensor d2thirdInvariant () const
 Denote the _vals[i][j] by A_ij, then this returns d^2(thirdInvariant)/dA_ij/dA_kl. More...
 
Real det () const
 Calculate the determinant of the tensor. More...
 
RankTwoTensor ddet () const
 Denote the _vals[i][j] by A_ij, then this returns d(det)/dA_ij. More...
 
RankTwoTensor inverse () const
 Calculate the inverse of the tensor. More...
 
void print (std::ostream &stm=Moose::out) const
 Print the rank two tensor. More...
 
void addIa (const Real a)
 Add identity times a to _vals. More...
 
Real L2norm () const
 Sqrt(_vals[i][j]*_vals[i][j]) More...
 
void surfaceFillFromInputVector (const std::vector< Real > &input)
 sets _vals[0][0], _vals[0][1], _vals[1][0], _vals[1][1] to input, and the remainder to zero More...
 
void symmetricEigenvalues (std::vector< Real > &eigvals) const
 computes eigenvalues, assuming tens is symmetric, and places them in ascending order in eigvals More...
 
void symmetricEigenvaluesEigenvectors (std::vector< Real > &eigvals, RankTwoTensor &eigvecs) const
 computes eigenvalues and eigenvectors, assuming tens is symmetric, and places them in ascending order in eigvals. More...
 
void dsymmetricEigenvalues (std::vector< Real > &eigvals, std::vector< RankTwoTensor > &deigvals) const
 computes eigenvalues, and their symmetric derivatives wrt vals, assuming tens is symmetric More...
 
void d2symmetricEigenvalues (std::vector< RankFourTensor > &deriv) const
 Computes second derivatives of Eigenvalues of a rank two tensor. More...
 
void syev (const char *calculation_type, std::vector< PetscScalar > &eigvals, std::vector< PetscScalar > &a) const
 Uses the petscblaslapack.h LAPACKsyev_ routine to find, for symmetric _vals: (1) the eigenvalues (if calculation_type == "N") (2) the eigenvalues and eigenvectors (if calculation_type == "V") More...
 
void getRUDecompositionRotation (RankTwoTensor &rot) const
 Uses the petscblaslapack.h LAPACKsyev_ routine to perform RU decomposition and obtain the rotation tensor. More...
 
void vectorOuterProduct (const TypeVector< Real > &, const TypeVector< Real > &)
 RankTwoTensor from outer product of vectors. More...
 
void fillRealTensor (RealTensorValue &)
 Return real tensor of a rank two tensor. More...
 
void fillRow (unsigned int, const TypeVector< Real > &)
 Assigns value to the columns of a specified row. More...
 
void fillColumn (unsigned int, const TypeVector< Real > &)
 Assigns value to the rows of a specified column. More...
 
RankTwoTensor initialContraction (const RankFourTensor &b) const
 returns this_ij * b_ijkl More...
 

Static Public Member Functions

static RankTwoTensor initializeFromRows (const TypeVector< Real > &row0, const TypeVector< Real > &row1, const TypeVector< Real > &row2)
 named constructor for initializing from row vectors More...
 
static RankTwoTensor initializeFromColumns (const TypeVector< Real > &col0, const TypeVector< Real > &col1, const TypeVector< Real > &col2)
 named constructor for initializing from column vectors More...
 
static RankTwoTensor Identity ()
 
static MooseEnum fillMethodEnum ()
 Static method for use in validParams for getting the "fill_method". More...
 
static void initRandom (unsigned int)
 This function initializes random seed based on a user-defined number. More...
 
static RankTwoTensor genRandomTensor (Real, Real)
 This function generates a random unsymmetric rank two tensor. More...
 
static RankTwoTensor genRandomSymmTensor (Real, Real)
 This function generates a random symmetric rank two tensor. More...
 

Private Attributes

Real _vals [N2]
 The values of the rank-two tensor stored by index=(i * LIBMESH_DIM + j) More...
 

Static Private Attributes

static constexpr unsigned int N = LIBMESH_DIM
 
static constexpr unsigned int N2 = N * N
 

Friends

class RankFourTensor
 
class RankThreeTensor
 
template<class T >
void dataStore (std::ostream &, T &, void *)
 
template<class T >
void dataLoad (std::istream &, T &, void *)
 

Detailed Description

RankTwoTensor 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

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

Member Enumeration Documentation

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

Enumerator
initNone 
initIdentity 

Definition at line 49 of file RankTwoTensor.h.

Constructor & Destructor Documentation

RankTwoTensor::RankTwoTensor ( )

Default constructor; fills to zero.

Definition at line 54 of file RankTwoTensor.C.

Referenced by dsin3Lode(), dtrace(), Identity(), initializeFromColumns(), initializeFromRows(), and RankTwoTensor().

55 {
56  mooseAssert(N == 3, "RankTwoTensor is currently only tested for 3 dimensions.");
57 
58  for (unsigned int i = 0; i < N2; i++)
59  _vals[i] = 0.0;
60 }
Real _vals[N2]
The values of the rank-two tensor stored by index=(i * LIBMESH_DIM + j)
static constexpr unsigned int N
static constexpr unsigned int N2
RankTwoTensor::RankTwoTensor ( const InitMethod  init)

Select specific initialization pattern.

Definition at line 62 of file RankTwoTensor.C.

63 {
64  switch (init)
65  {
66  case initNone:
67  break;
68 
69  case initIdentity:
70  zero();
71  for (unsigned int i = 0; i < N; ++i)
72  (*this)(i, i) = 1.0;
73  break;
74 
75  default:
76  mooseError("Unknown RankTwoTensor initialization pattern.");
77  }
78 }
void zero()
zeroes all _vals components
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
static constexpr unsigned int N
RankTwoTensor::RankTwoTensor ( const TypeVector< Real > &  row1,
const TypeVector< Real > &  row2,
const TypeVector< Real > &  row3 
)

Constructor that takes in 3 vectors and uses them to create rows _vals[0][i] = row1(i), _vals[1][i] = row2(i), _vals[2][i] = row3(i)

TODO: deprecate this method in favor of initializeFromRows.

Definition at line 81 of file RankTwoTensor.C.

84 {
85  // Initialize the Tensor matrix from the passed in vectors
86  for (unsigned int i = 0; i < N; i++)
87  _vals[i] = row1(i);
88 
89  for (unsigned int i = 0; i < N; i++)
90  _vals[N + i] = row2(i);
91 
92  const unsigned int two_n = N * 2;
93  for (unsigned int i = 0; i < N; i++)
94  _vals[two_n + i] = row3(i);
95 }
Real _vals[N2]
The values of the rank-two tensor stored by index=(i * LIBMESH_DIM + j)
static constexpr unsigned int N
RankTwoTensor::RankTwoTensor ( const std::vector< Real > &  input)
inline

Constructor that proxies the fillFromInputVector method.

Definition at line 94 of file RankTwoTensor.h.

94 { this->fillFromInputVector(input); };
void fillFromInputVector(const std::vector< Real > &input, FillMethod fill_method=autodetect)
fillFromInputVector takes 6 or 9 inputs to fill in the Rank-2 tensor.
RankTwoTensor::RankTwoTensor ( Real  S11,
Real  S22,
Real  S33,
Real  S23,
Real  S13,
Real  S12 
)

Initialization list replacement constructors, 6 arguments.

Definition at line 128 of file RankTwoTensor.C.

129 {
130  (*this)(0, 0) = S11;
131  (*this)(1, 1) = S22;
132  (*this)(2, 2) = S33;
133  (*this)(1, 2) = (*this)(2, 1) = S23;
134  (*this)(0, 2) = (*this)(2, 0) = S13;
135  (*this)(0, 1) = (*this)(1, 0) = S12;
136 }
RankTwoTensor::RankTwoTensor ( Real  S11,
Real  S21,
Real  S31,
Real  S12,
Real  S22,
Real  S32,
Real  S13,
Real  S23,
Real  S33 
)

Initialization list replacement constructors, 9 arguments.

Definition at line 138 of file RankTwoTensor.C.

140 {
141  (*this)(0, 0) = S11;
142  (*this)(1, 0) = S21;
143  (*this)(2, 0) = S31;
144  (*this)(0, 1) = S12;
145  (*this)(1, 1) = S22;
146  (*this)(2, 1) = S32;
147  (*this)(0, 2) = S13;
148  (*this)(1, 2) = S23;
149  (*this)(2, 2) = S33;
150 }
RankTwoTensor::RankTwoTensor ( const TypeTensor< Real > &  a)

Copy constructor from RealTensorValue.

Definition at line 115 of file RankTwoTensor.C.

116 {
117  (*this)(0, 0) = a(0, 0);
118  (*this)(0, 1) = a(0, 1);
119  (*this)(0, 2) = a(0, 2);
120  (*this)(1, 0) = a(1, 0);
121  (*this)(1, 1) = a(1, 1);
122  (*this)(1, 2) = a(1, 2);
123  (*this)(2, 0) = a(2, 0);
124  (*this)(2, 1) = a(2, 1);
125  (*this)(2, 2) = a(2, 2);
126 }

Member Function Documentation

void RankTwoTensor::addIa ( const Real  a)

Add identity times a to _vals.

Definition at line 904 of file RankTwoTensor.C.

Referenced by deviatoric(), and operator()().

905 {
906  for (unsigned int i = 0; i < N; ++i)
907  (*this)(i, i) += a;
908 }
static constexpr unsigned int N
TypeVector< Real > RankTwoTensor::column ( const unsigned int  c) const

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

Definition at line 220 of file RankTwoTensor.C.

Referenced by operator()().

221 {
222  RealVectorValue result;
223 
224  for (unsigned int i = 0; i < N; ++i)
225  result(i) = (*this)(i, c);
226 
227  return result;
228 }
VectorValue< Real > RealVectorValue
Definition: Assembly.h:40
static constexpr unsigned int N
RankFourTensor RankTwoTensor::d2secondInvariant ( ) const

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

Definition at line 627 of file RankTwoTensor.C.

Referenced by d2sin3Lode(), and operator()().

628 {
629  RankFourTensor result;
630 
631  unsigned int index = 0;
632  for (unsigned int i = 0; i < N; ++i)
633  for (unsigned int j = 0; j < N; ++j)
634  for (unsigned int k = 0; k < N; ++k)
635  for (unsigned int l = 0; l < N; ++l)
636  result._vals[index++] = 0.5 * (i == k) * (j == l) + 0.5 * (i == l) * (j == k) -
637  (1.0 / 3.0) * (i == j) * (k == l);
638 
639  return result;
640 }
Real _vals[N4]
The values of the rank-four tensor stored by index=(((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) * LIBME...
static constexpr unsigned int N
RankFourTensor is designed to handle any N-dimensional fourth order tensor, C.
RankFourTensor RankTwoTensor::d2sin3Lode ( const Real  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 813 of file RankTwoTensor.C.

Referenced by operator()().

814 {
815  Real bar = secondInvariant();
816  if (bar <= r0)
817  return RankFourTensor();
818 
819  Real J3 = thirdInvariant();
822  RankFourTensor deriv =
823  d2thirdInvariant() / std::pow(bar, 1.5) - 1.5 * d2secondInvariant() * J3 / std::pow(bar, 2.5);
824 
825  for (unsigned i = 0; i < N; ++i)
826  for (unsigned j = 0; j < N; ++j)
827  for (unsigned k = 0; k < N; ++k)
828  for (unsigned l = 0; l < N; ++l)
829  deriv(i, j, k, l) +=
830  (-1.5 * dII(i, j) * dIII(k, l) - 1.5 * dIII(i, j) * dII(k, l)) / std::pow(bar, 2.5) +
831  1.5 * 2.5 * dII(i, j) * dII(k, l) * J3 / std::pow(bar, 3.5);
832 
833  deriv *= -1.5 * std::sqrt(3.0);
834  return deriv;
835 }
RankTwoTensor dthirdInvariant() const
Denote the _vals[i][j] by A_ij, then this returns d(thirdInvariant()/dA_ij.
friend class RankFourTensor
RankTwoTensor is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: RankTwoTensor.h:45
RankFourTensor d2secondInvariant() const
Denote the _vals[i][j] by A_ij, then this returns d^2(secondInvariant)/dA_ij/dA_kl.
RankFourTensor d2thirdInvariant() const
Denote the _vals[i][j] by A_ij, then this returns d^2(thirdInvariant)/dA_ij/dA_kl.
Real secondInvariant() const
Calculates the second invariant (I2) of a tensor.
Real 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...
static constexpr unsigned int N
RankTwoTensor dsecondInvariant() const
Denote the _vals[i][j] by A_ij, then this returns d(secondInvariant)/dA_ij.
RankFourTensor is designed to handle any N-dimensional fourth order tensor, C.
void RankTwoTensor::d2symmetricEigenvalues ( std::vector< RankFourTensor > &  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 996 of file RankTwoTensor.C.

Referenced by operator()().

997 {
998  std::vector<PetscScalar> eigvec;
999  std::vector<PetscScalar> eigvals;
1000  Real ev[N][N];
1001 
1002  // reset rank four tensor
1003  deriv.assign(N, RankFourTensor());
1004 
1005  // get eigen values and eigen vectors
1006  syev("V", eigvals, eigvec);
1007 
1008  for (unsigned int i = 0; i < N; ++i)
1009  for (unsigned int j = 0; j < N; ++j)
1010  ev[i][j] = eigvec[i * N + j];
1011 
1012  for (unsigned int alpha = 0; alpha < N; ++alpha)
1013  for (unsigned int beta = 0; beta < N; ++beta)
1014  {
1015  if (eigvals[alpha] == eigvals[beta])
1016  continue;
1017 
1018  for (unsigned int i = 0; i < N; ++i)
1019  for (unsigned int j = 0; j < N; ++j)
1020  for (unsigned int k = 0; k < N; ++k)
1021  for (unsigned int l = 0; l < N; ++l)
1022  {
1023  deriv[alpha](i, j, k, l) +=
1024  0.5 * (ev[beta][i] * ev[alpha][j] + ev[alpha][i] * ev[beta][j]) *
1025  (ev[beta][k] * ev[alpha][l] + ev[beta][l] * ev[alpha][k]) /
1026  (eigvals[alpha] - eigvals[beta]);
1027  }
1028  }
1029 }
friend class RankFourTensor
static constexpr unsigned int N
void syev(const char *calculation_type, std::vector< PetscScalar > &eigvals, std::vector< PetscScalar > &a) const
Uses the petscblaslapack.h LAPACKsyev_ routine to find, for symmetric _vals: (1) the eigenvalues (if ...
RankFourTensor RankTwoTensor::d2thirdInvariant ( ) const

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

Definition at line 697 of file RankTwoTensor.C.

Referenced by d2sin3Lode(), and operator()().

698 {
699  RankTwoTensor s = 0.5 * deviatoric();
700  s += s.transpose();
701 
702  RankFourTensor d2;
703  unsigned int index = 0;
704  for (unsigned int i = 0; i < N; ++i)
705  for (unsigned int j = 0; j < N; ++j)
706  for (unsigned int k = 0; k < N; ++k)
707  for (unsigned int l = 0; l < N; ++l)
708  {
709  d2._vals[index++] = (i == j) * s(k, l) / 3.0 + (k == l) * s(i, j) / 3.0;
710  // for (unsigned int a = 0; a < N; ++a)
711  // for (unsigned int b = 0; b < N; ++b)
712  // d2(i, j, k, l) += 0.5*(PermutationTensor::eps(i, k, a)*PermutationTensor::eps(j, l,
713  // b) + PermutationTensor::eps(i, l, a)*PermutationTensor::eps(j, k, b))*s(a, b);
714  }
715 
716  // I'm not sure which is more readable: the above
717  // PermutationTensor stuff, or the stuff below.
718  // Anyway, they yield the same result, and so i leave
719  // both of them here to enlighten you!
720 
721  d2(0, 0, 1, 1) += s(2, 2);
722  d2(0, 0, 1, 2) -= s(2, 1);
723  d2(0, 0, 2, 1) -= s(1, 2);
724  d2(0, 0, 2, 2) += s(1, 1);
725 
726  d2(0, 1, 0, 1) -= s(2, 2) / 2.0;
727  d2(0, 1, 1, 0) -= s(2, 2) / 2.0;
728  d2(0, 1, 0, 2) += s(1, 2) / 2.0;
729  d2(0, 1, 2, 0) += s(1, 2) / 2.0;
730  d2(0, 1, 1, 2) += s(2, 0) / 2.0;
731  d2(0, 1, 2, 1) += s(2, 0) / 2.0;
732  d2(0, 1, 2, 2) -= s(1, 0);
733 
734  d2(0, 2, 0, 1) += s(2, 1) / 2.0;
735  d2(0, 2, 1, 0) += s(2, 1) / 2.0;
736  d2(0, 2, 0, 2) -= s(1, 1) / 2.0;
737  d2(0, 2, 2, 0) -= s(1, 1) / 2.0;
738  d2(0, 2, 1, 1) -= s(2, 0);
739  d2(0, 2, 1, 2) += s(1, 0) / 2.0;
740  d2(0, 2, 2, 1) += s(1, 0) / 2.0;
741 
742  d2(1, 0, 0, 1) -= s(2, 2) / 2.0;
743  d2(1, 0, 1, 0) -= s(2, 2) / 2.0;
744  d2(1, 0, 0, 2) += s(1, 2) / 2.0;
745  d2(1, 0, 2, 0) += s(1, 2) / 2.0;
746  d2(1, 0, 1, 2) += s(2, 0) / 2.0;
747  d2(1, 0, 2, 1) += s(2, 0) / 2.0;
748  d2(1, 0, 2, 2) -= s(1, 0);
749 
750  d2(1, 1, 0, 0) += s(2, 2);
751  d2(1, 1, 0, 2) -= s(2, 0);
752  d2(1, 1, 2, 0) -= s(2, 0);
753  d2(1, 1, 2, 2) += s(0, 0);
754 
755  d2(1, 2, 0, 0) -= s(2, 1);
756  d2(1, 2, 0, 1) += s(2, 0) / 2.0;
757  d2(1, 2, 1, 0) += s(2, 0) / 2.0;
758  d2(1, 2, 0, 2) += s(0, 1) / 2.0;
759  d2(1, 2, 2, 0) += s(0, 1) / 2.0;
760  d2(1, 2, 1, 2) -= s(0, 0) / 2.0;
761  d2(1, 2, 2, 1) -= s(0, 0) / 2.0;
762 
763  d2(2, 0, 0, 1) += s(2, 1) / 2.0;
764  d2(2, 0, 1, 0) += s(2, 1) / 2.0;
765  d2(2, 0, 0, 2) -= s(1, 1) / 2.0;
766  d2(2, 0, 2, 0) -= s(1, 1) / 2.0;
767  d2(2, 0, 1, 1) -= s(2, 0);
768  d2(2, 0, 1, 2) += s(1, 0) / 2.0;
769  d2(2, 0, 2, 1) += s(1, 0) / 2.0;
770 
771  d2(2, 1, 0, 0) -= s(2, 1);
772  d2(2, 1, 0, 1) += s(2, 0) / 2.0;
773  d2(2, 1, 1, 0) += s(2, 0) / 2.0;
774  d2(2, 1, 0, 2) += s(0, 1) / 2.0;
775  d2(2, 1, 2, 0) += s(0, 1) / 2.0;
776  d2(2, 1, 1, 2) -= s(0, 0) / 2.0;
777  d2(2, 1, 2, 1) -= s(0, 0) / 2.0;
778 
779  d2(2, 2, 0, 0) += s(1, 1);
780  d2(2, 2, 0, 1) -= s(1, 0);
781  d2(2, 2, 1, 0) -= s(1, 0);
782  d2(2, 2, 1, 1) += s(0, 0);
783 
784  return d2;
785 }
RankTwoTensor transpose() const
Returns a matrix that is the transpose of the matrix this was called on.
RankTwoTensor deviatoric() const
returns A_ij - de_ij*tr(A)/3, where A are the _vals
RankTwoTensor is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: RankTwoTensor.h:45
Real _vals[N4]
The values of the rank-four tensor stored by index=(((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) * LIBME...
static constexpr unsigned int N
RankFourTensor is designed to handle any N-dimensional fourth order tensor, C.
RankTwoTensor RankTwoTensor::ddet ( ) const

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

Definition at line 850 of file RankTwoTensor.C.

Referenced by operator()().

851 {
852  RankTwoTensor d;
853 
854  d(0, 0) = (*this)(1, 1) * (*this)(2, 2) - (*this)(2, 1) * (*this)(1, 2);
855  d(0, 1) = (*this)(2, 0) * (*this)(1, 2) - (*this)(1, 0) * (*this)(2, 2);
856  d(0, 2) = (*this)(1, 0) * (*this)(2, 1) - (*this)(2, 0) * (*this)(1, 1);
857  d(1, 0) = (*this)(2, 1) * (*this)(0, 2) - (*this)(0, 1) * (*this)(2, 2);
858  d(1, 1) = (*this)(0, 0) * (*this)(2, 2) - (*this)(2, 0) * (*this)(0, 2);
859  d(1, 2) = (*this)(2, 0) * (*this)(0, 1) - (*this)(0, 0) * (*this)(2, 1);
860  d(2, 0) = (*this)(0, 1) * (*this)(1, 2) - (*this)(1, 1) * (*this)(0, 2);
861  d(2, 1) = (*this)(1, 0) * (*this)(0, 2) - (*this)(0, 0) * (*this)(1, 2);
862  d(2, 2) = (*this)(0, 0) * (*this)(1, 1) - (*this)(1, 0) * (*this)(0, 1);
863 
864  return d;
865 }
RankTwoTensor is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: RankTwoTensor.h:45
Real RankTwoTensor::det ( ) const

Calculate the determinant of the tensor.

Definition at line 838 of file RankTwoTensor.C.

Referenced by inverse(), and operator()().

839 {
840  Real result = 0.0;
841 
842  result = (*this)(0, 0) * ((*this)(1, 1) * (*this)(2, 2) - (*this)(2, 1) * (*this)(1, 2));
843  result -= (*this)(1, 0) * ((*this)(0, 1) * (*this)(2, 2) - (*this)(2, 1) * (*this)(0, 2));
844  result += (*this)(2, 0) * ((*this)(0, 1) * (*this)(1, 2) - (*this)(1, 1) * (*this)(0, 2));
845 
846  return result;
847 }
RankTwoTensor RankTwoTensor::deviatoric ( ) const

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

Definition at line 581 of file RankTwoTensor.C.

Referenced by d2thirdInvariant(), dsecondInvariant(), dthirdInvariant(), operator()(), and thirdInvariant().

582 {
583  RankTwoTensor deviatoric(*this);
584  deviatoric.addIa(-1.0 / 3.0 * trace()); // actually construct deviatoric part
585  return deviatoric;
586 }
RankTwoTensor deviatoric() const
returns A_ij - de_ij*tr(A)/3, where A are the _vals
void addIa(const Real a)
Add identity times a to _vals.
RankTwoTensor is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: RankTwoTensor.h:45
Real trace() const
returns the trace of the tensor, ie _vals[i][i] (sum i = 0, 1, 2)
Real RankTwoTensor::doubleContraction ( const RankTwoTensor a) const

returns _vals_ij * a_ij (sum on i, j)

Definition at line 518 of file RankTwoTensor.C.

Referenced by operator()().

519 {
520  Real result = 0.0;
521 
522  for (unsigned int i = 0; i < N2; ++i)
523  result += _vals[i] * b._vals[i];
524 
525  return result;
526 }
Real _vals[N2]
The values of the rank-two tensor stored by index=(i * LIBMESH_DIM + j)
static constexpr unsigned int N2
RankTwoTensor RankTwoTensor::dsecondInvariant ( ) const

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

Definition at line 621 of file RankTwoTensor.C.

Referenced by d2sin3Lode(), dsin3Lode(), and operator()().

622 {
623  return 0.5 * (deviatoric() + deviatoric().transpose());
624 }
RankTwoTensor transpose() const
Returns a matrix that is the transpose of the matrix this was called on.
RankTwoTensor deviatoric() const
returns A_ij - de_ij*tr(A)/3, where A are the _vals
RankTwoTensor RankTwoTensor::dsin3Lode ( const Real  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 801 of file RankTwoTensor.C.

Referenced by operator()().

802 {
803  Real bar = secondInvariant();
804  if (bar <= r0)
805  return RankTwoTensor();
806  else
807  return -1.5 * std::sqrt(3.0) *
808  (dthirdInvariant() / std::pow(bar, 1.5) -
809  1.5 * dsecondInvariant() * thirdInvariant() / std::pow(bar, 2.5));
810 }
RankTwoTensor dthirdInvariant() const
Denote the _vals[i][j] by A_ij, then this returns d(thirdInvariant()/dA_ij.
RankTwoTensor()
Default constructor; fills to zero.
Definition: RankTwoTensor.C:54
Real secondInvariant() const
Calculates the second invariant (I2) of a tensor.
Real 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...
RankTwoTensor dsecondInvariant() const
Denote the _vals[i][j] by A_ij, then this returns d(secondInvariant)/dA_ij.
void RankTwoTensor::dsymmetricEigenvalues ( std::vector< Real > &  eigvals,
std::vector< RankTwoTensor > &  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 958 of file RankTwoTensor.C.

Referenced by operator()().

960 {
961  deigvals.resize(N);
962 
963  std::vector<PetscScalar> a;
964  syev("V", eigvals, a);
965 
966  // now a contains the eigenvetors
967  // extract these and place appropriately in deigvals
968  std::vector<Real> eig_vec;
969  eig_vec.resize(N);
970 
971  for (unsigned int i = 0; i < N; ++i)
972  {
973  for (unsigned int j = 0; j < N; ++j)
974  eig_vec[j] = a[i * N + j];
975  for (unsigned int j = 0; j < N; ++j)
976  for (unsigned int k = 0; k < N; ++k)
977  deigvals[i](j, k) = eig_vec[j] * eig_vec[k];
978  }
979 
980  // There are discontinuities in the derivative
981  // for equal eigenvalues. The following is
982  // an attempt to make a sensible choice for
983  // the derivative. This agrees with a central-difference
984  // approximation to the derivative.
985  if (eigvals[0] == eigvals[1] && eigvals[0] == eigvals[2])
986  deigvals[0] = deigvals[1] = deigvals[2] = (deigvals[0] + deigvals[1] + deigvals[2]) / 3.0;
987  else if (eigvals[0] == eigvals[1])
988  deigvals[0] = deigvals[1] = (deigvals[0] + deigvals[1]) / 2.0;
989  else if (eigvals[0] == eigvals[2])
990  deigvals[0] = deigvals[2] = (deigvals[0] + deigvals[2]) / 2.0;
991  else if (eigvals[1] == eigvals[2])
992  deigvals[1] = deigvals[2] = (deigvals[1] + deigvals[2]) / 2.0;
993 }
static constexpr unsigned int N
void syev(const char *calculation_type, std::vector< PetscScalar > &eigvals, std::vector< PetscScalar > &a) const
Uses the petscblaslapack.h LAPACKsyev_ routine to find, for symmetric _vals: (1) the eigenvalues (if ...
RankTwoTensor RankTwoTensor::dthirdInvariant ( ) const

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

Definition at line 675 of file RankTwoTensor.C.

Referenced by d2sin3Lode(), dsin3Lode(), and operator()().

676 {
677  RankTwoTensor s = 0.5 * deviatoric();
678  s += s.transpose();
679 
680  RankTwoTensor d;
681  Real sec_over_three = secondInvariant() / 3.0;
682 
683  d(0, 0) = s(1, 1) * s(2, 2) - s(2, 1) * s(1, 2) + sec_over_three;
684  d(0, 1) = s(2, 0) * s(1, 2) - s(1, 0) * s(2, 2);
685  d(0, 2) = s(1, 0) * s(2, 1) - s(2, 0) * s(1, 1);
686  d(1, 0) = s(2, 1) * s(0, 2) - s(0, 1) * s(2, 2);
687  d(1, 1) = s(0, 0) * s(2, 2) - s(2, 0) * s(0, 2) + sec_over_three;
688  d(1, 2) = s(2, 0) * s(0, 1) - s(0, 0) * s(2, 1);
689  d(2, 0) = s(0, 1) * s(1, 2) - s(1, 1) * s(0, 2);
690  d(2, 1) = s(1, 0) * s(0, 2) - s(0, 0) * s(1, 2);
691  d(2, 2) = s(0, 0) * s(1, 1) - s(1, 0) * s(0, 1) + sec_over_three;
692 
693  return d;
694 }
RankTwoTensor transpose() const
Returns a matrix that is the transpose of the matrix this was called on.
RankTwoTensor deviatoric() const
returns A_ij - de_ij*tr(A)/3, where A are the _vals
RankTwoTensor is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: RankTwoTensor.h:45
Real secondInvariant() const
Calculates the second invariant (I2) of a tensor.
RankTwoTensor RankTwoTensor::dtrace ( ) const

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

Definition at line 654 of file RankTwoTensor.C.

Referenced by operator()().

655 {
656  return RankTwoTensor(1, 0, 0, 0, 1, 0, 0, 0, 1);
657 }
RankTwoTensor()
Default constructor; fills to zero.
Definition: RankTwoTensor.C:54
void RankTwoTensor::fillColumn ( unsigned int  c,
const TypeVector< Real > &  v 
)

Assigns value to the rows of a specified column.

Definition at line 1152 of file RankTwoTensor.C.

Referenced by operator()().

1153 {
1154  for (unsigned int i = 0; i < N; ++i)
1155  (*this)(i, c) = v(i);
1156 }
static constexpr unsigned int N
void RankTwoTensor::fillFromInputVector ( const std::vector< Real > &  input,
FillMethod  fill_method = autodetect 
)

fillFromInputVector takes 6 or 9 inputs to fill in the Rank-2 tensor.

If 6 inputs, then symmetry is assumed S_ij = S_ji, and _vals[0][0] = input[0] _vals[1][1] = input[1] _vals[2][2] = input[2] _vals[1][2] = input[3] _vals[0][2] = input[4] _vals[0][1] = input[5] If 9 inputs then input order is [0][0], [1][0], [2][0], [0][1], [1][1], ..., [2][2]

Definition at line 160 of file RankTwoTensor.C.

Referenced by GenericConstantRankTwoTensor::GenericConstantRankTwoTensor(), operator()(), and RankTwoTensor().

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

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

Definition at line 49 of file RankTwoTensor.C.

Referenced by operator()().

50 {
51  return MooseEnum("autodetect=0 isotropic1=1 diagonal3=3 symmetric6=6 general=9", "autodetect");
52 }
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:37
void RankTwoTensor::fillRealTensor ( RealTensorValue &  tensor)

Return real tensor of a rank two tensor.

Definition at line 1137 of file RankTwoTensor.C.

Referenced by operator()().

1138 {
1139  for (unsigned int i = 0; i < N; ++i)
1140  for (unsigned int j = 0; j < N; ++j)
1141  tensor(i, j) = (*this)(i, j);
1142 }
static constexpr unsigned int N
void RankTwoTensor::fillRow ( unsigned int  r,
const TypeVector< Real > &  v 
)

Assigns value to the columns of a specified row.

Definition at line 1145 of file RankTwoTensor.C.

Referenced by operator()().

1146 {
1147  for (unsigned int i = 0; i < N; ++i)
1148  (*this)(r, i) = v(i);
1149 }
static constexpr unsigned int N
Real RankTwoTensor::generalSecondInvariant ( ) const

Denote the _vals[i][j] by A_ij, then S_ij = A_ij - de_ij*tr(A)/3 Then this returns (S_ij + S_ji)*(S_ij + S_ji)/8 Note the explicit symmeterisation.

Definition at line 589 of file RankTwoTensor.C.

Referenced by operator()().

590 {
591  // clang-format off
592  Real result = (*this)(0, 0) * (*this)(1, 1) +
593  (*this)(0, 0) * (*this)(2, 2) +
594  (*this)(1, 1) * (*this)(2, 2) -
595  (*this)(0, 1) * (*this)(1, 0) -
596  (*this)(0, 2) * (*this)(2, 0) -
597  (*this)(1, 2) * (*this)(2, 1);
598  // clang-format on
599  return result;
600 }
RankTwoTensor RankTwoTensor::genRandomSymmTensor ( Real  scale,
Real  offset 
)
static

This function generates a random symmetric rank two tensor.

The first real scales the random number. The second real offsets the uniform random number

Definition at line 1117 of file RankTwoTensor.C.

Referenced by operator()().

1118 {
1119  RankTwoTensor tensor;
1120 
1121  for (unsigned int i = 0; i < N; i++)
1122  for (unsigned int j = i; j < N; j++)
1123  tensor(i, j) = tensor(j, i) = (MooseRandom::rand() + offset) * scale;
1124 
1125  return tensor;
1126 }
static double rand()
This method returns the next random number (double format) from the generator.
Definition: MooseRandom.h:55
RankTwoTensor is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: RankTwoTensor.h:45
static constexpr unsigned int N
RankTwoTensor RankTwoTensor::genRandomTensor ( Real  scale,
Real  offset 
)
static

This function generates a random unsymmetric rank two tensor.

The first real scales the random number. The second real offsets the uniform random number

Definition at line 1105 of file RankTwoTensor.C.

Referenced by operator()().

1106 {
1107  RankTwoTensor tensor;
1108 
1109  for (unsigned int i = 0; i < N; i++)
1110  for (unsigned int j = 0; j < N; j++)
1111  tensor(i, j) = (MooseRandom::rand() + offset) * scale;
1112 
1113  return tensor;
1114 }
static double rand()
This method returns the next random number (double format) from the generator.
Definition: MooseRandom.h:55
RankTwoTensor is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: RankTwoTensor.h:45
static constexpr unsigned int N
void RankTwoTensor::getRUDecompositionRotation ( RankTwoTensor rot) const

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

Definition at line 1063 of file RankTwoTensor.C.

Referenced by operator()().

1064 {
1065  const RankTwoTensor & a = *this;
1066  RankTwoTensor c, diag, evec;
1067  PetscScalar cmat[N][N], work[10];
1068  PetscReal w[N];
1069 
1070  // prepare data for the LAPACKsyev_ routine (which comes from petscblaslapack.h)
1071  PetscBLASInt nd = N, lwork = 10, info;
1072 
1073  c = a.transpose() * a;
1074 
1075  for (unsigned int i = 0; i < N; ++i)
1076  for (unsigned int j = 0; j < N; ++j)
1077  cmat[i][j] = c(i, j);
1078 
1079  LAPACKsyev_("V", "U", &nd, &cmat[0][0], &nd, w, work, &lwork, &info);
1080 
1081  if (info != 0)
1082  mooseError("In computing the eigenvalues and eigenvectors of a symmetric rank-2 tensor, the "
1083  "PETSC LAPACK syev routine returned error code ",
1084  info);
1085 
1086  diag.zero();
1087 
1088  for (unsigned int i = 0; i < N; ++i)
1089  diag(i, i) = std::sqrt(w[i]);
1090 
1091  for (unsigned int i = 0; i < N; ++i)
1092  for (unsigned int j = 0; j < N; ++j)
1093  evec(i, j) = cmat[i][j];
1094 
1095  rot = a * ((evec.transpose() * diag * evec).inverse());
1096 }
void zero()
zeroes all _vals components
RankTwoTensor transpose() const
Returns a matrix that is the transpose of the matrix this was called on.
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
RankTwoTensor inverse() const
Calculate the inverse of the tensor.
RankTwoTensor is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: RankTwoTensor.h:45
static constexpr unsigned int N
static RankTwoTensor RankTwoTensor::Identity ( )
inlinestatic

Definition at line 107 of file RankTwoTensor.h.

107 { return RankTwoTensor(initIdentity); }
RankTwoTensor()
Default constructor; fills to zero.
Definition: RankTwoTensor.C:54
RankTwoTensor RankTwoTensor::initialContraction ( const RankFourTensor b) const

returns this_ij * b_ijkl

Definition at line 1159 of file RankTwoTensor.C.

Referenced by operator()().

1160 {
1161  RankTwoTensor result;
1162 
1163  unsigned int index = 0;
1164  for (unsigned int i = 0; i < N; ++i)
1165  for (unsigned int j = 0; j < N; ++j)
1166  {
1167  const Real a = (*this)(i, j);
1168  for (unsigned int k = 0; k < N; ++k)
1169  for (unsigned int l = 0; l < N; ++l)
1170  result(k, l) += a * b._vals[index++];
1171  }
1172 
1173  return result;
1174 }
RankTwoTensor is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: RankTwoTensor.h:45
Real _vals[N4]
The values of the rank-four tensor stored by index=(((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) * LIBME...
static constexpr unsigned int N
RankTwoTensor RankTwoTensor::initializeFromColumns ( const TypeVector< Real > &  col0,
const TypeVector< Real > &  col1,
const TypeVector< Real > &  col2 
)
static

named constructor for initializing from column vectors

Definition at line 107 of file RankTwoTensor.C.

110 {
111  return RankTwoTensor(
112  col0(0), col0(1), col0(2), col1(0), col1(1), col1(2), col2(0), col2(1), col2(2));
113 }
RankTwoTensor()
Default constructor; fills to zero.
Definition: RankTwoTensor.C:54
RankTwoTensor RankTwoTensor::initializeFromRows ( const TypeVector< Real > &  row0,
const TypeVector< Real > &  row1,
const TypeVector< Real > &  row2 
)
static

named constructor for initializing from row vectors

Definition at line 98 of file RankTwoTensor.C.

101 {
102  return RankTwoTensor(
103  row0(0), row1(0), row2(0), row0(1), row1(1), row2(1), row0(2), row1(2), row2(2));
104 }
RankTwoTensor()
Default constructor; fills to zero.
Definition: RankTwoTensor.C:54
void RankTwoTensor::initRandom ( unsigned int  rand_seed)
static

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

Definition at line 1099 of file RankTwoTensor.C.

Referenced by operator()().

1100 {
1101  MooseRandom::seed(rand_seed);
1102 }
static void seed(unsigned int seed)
The method seeds the random number generator.
Definition: MooseRandom.h:49
RankTwoTensor RankTwoTensor::inverse ( ) const

Calculate the inverse of the tensor.

Definition at line 868 of file RankTwoTensor.C.

Referenced by getRUDecompositionRotation(), and operator()().

869 {
870  RankTwoTensor inv;
871 
872  inv(0, 0) = (*this)(1, 1) * (*this)(2, 2) - (*this)(2, 1) * (*this)(1, 2);
873  inv(0, 1) = (*this)(0, 2) * (*this)(2, 1) - (*this)(0, 1) * (*this)(2, 2);
874  inv(0, 2) = (*this)(0, 1) * (*this)(1, 2) - (*this)(0, 2) * (*this)(1, 1);
875  inv(1, 0) = (*this)(1, 2) * (*this)(2, 0) - (*this)(1, 0) * (*this)(2, 2);
876  inv(1, 1) = (*this)(0, 0) * (*this)(2, 2) - (*this)(0, 2) * (*this)(2, 0);
877  inv(1, 2) = (*this)(0, 2) * (*this)(1, 0) - (*this)(0, 0) * (*this)(1, 2);
878  inv(2, 0) = (*this)(1, 0) * (*this)(2, 1) - (*this)(1, 1) * (*this)(2, 0);
879  inv(2, 1) = (*this)(0, 1) * (*this)(2, 0) - (*this)(0, 0) * (*this)(2, 1);
880  inv(2, 2) = (*this)(0, 0) * (*this)(1, 1) - (*this)(0, 1) * (*this)(1, 0);
881 
882  Real det = (*this).det();
883 
884  if (det == 0)
885  mooseError("Rank Two Tensor is singular");
886 
887  inv /= det;
888  return inv;
889 }
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
RankTwoTensor is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: RankTwoTensor.h:45
Real det() const
Calculate the determinant of the tensor.
Real RankTwoTensor::L2norm ( ) const

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

Definition at line 911 of file RankTwoTensor.C.

Referenced by operator()().

912 {
913  Real norm = 0.0;
914  for (unsigned int i = 0; i < N2; ++i)
915  {
916  Real v = _vals[i];
917  norm += v * v;
918  }
919  return std::sqrt(norm);
920 }
Real _vals[N2]
The values of the rank-two tensor stored by index=(i * LIBMESH_DIM + j)
static constexpr unsigned int N2
RankFourTensor RankTwoTensor::mixedProductIkJl ( const RankTwoTensor a) const

returns C_ijkl = a_ik * b_jl

Definition at line 545 of file RankTwoTensor.C.

Referenced by operator()().

546 {
547  RankFourTensor result;
548 
549  unsigned int index = 0;
550  for (unsigned int i = 0; i < N; ++i)
551  for (unsigned int j = 0; j < N; ++j)
552  for (unsigned int k = 0; k < N; ++k)
553  {
554  const Real a = (*this)(i, k);
555  for (unsigned int l = 0; l < N; ++l)
556  result._vals[index++] = a * b(j, l);
557  }
558 
559  return result;
560 }
Real _vals[N4]
The values of the rank-four tensor stored by index=(((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) * LIBME...
static constexpr unsigned int N
RankFourTensor is designed to handle any N-dimensional fourth order tensor, C.
RankFourTensor RankTwoTensor::mixedProductJkIl ( const RankTwoTensor a) const

returns C_ijkl = a_jk * b_il

Definition at line 563 of file RankTwoTensor.C.

Referenced by operator()().

564 {
565  RankFourTensor result;
566 
567  unsigned int index = 0;
568  for (unsigned int i = 0; i < N; ++i)
569  for (unsigned int j = 0; j < N; ++j)
570  for (unsigned int k = 0; k < N; ++k)
571  {
572  const Real a = (*this)(j, k);
573  for (unsigned int l = 0; l < N; ++l)
574  result._vals[index++] = a * b(i, l);
575  }
576 
577  return result;
578 }
Real _vals[N4]
The values of the rank-four tensor stored by index=(((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) * LIBME...
static constexpr unsigned int N
RankFourTensor is designed to handle any N-dimensional fourth order tensor, C.
Real& RankTwoTensor::operator() ( unsigned int  i,
unsigned int  j 
)
inline

Gets the value for the index specified. Takes index = 0,1,2.

Definition at line 110 of file RankTwoTensor.h.

110 { return _vals[i * N + j]; }
Real _vals[N2]
The values of the rank-two tensor stored by index=(i * LIBMESH_DIM + j)
static constexpr unsigned int N
Real RankTwoTensor::operator() ( unsigned int  i,
unsigned int  j 
) const
inline

Gets the value for the index specified. Takes index = 0,1,2, used for const.

Definition at line 113 of file RankTwoTensor.h.

113 { return _vals[i * N + j]; }
Real _vals[N2]
The values of the rank-two tensor stored by index=(i * LIBMESH_DIM + j)
static constexpr unsigned int N
RankTwoTensor RankTwoTensor::operator* ( const Real  a) const

returns _vals*a

Definition at line 390 of file RankTwoTensor.C.

Referenced by operator()().

391 {
392  RankTwoTensor result;
393  for (unsigned int i = 0; i < N2; ++i)
394  result._vals[i] = _vals[i] * b;
395  return result;
396 }
Real _vals[N2]
The values of the rank-two tensor stored by index=(i * LIBMESH_DIM + j)
RankTwoTensor is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: RankTwoTensor.h:45
static constexpr unsigned int N2
TypeVector< Real > RankTwoTensor::operator* ( const TypeVector< Real > &  a) const

Defines multiplication with a vector to get a vector.

Definition at line 419 of file RankTwoTensor.C.

420 {
421  RealVectorValue result;
422 
423  for (unsigned int i = 0; i < N; ++i)
424  {
425  unsigned int i1 = i * N;
426  for (unsigned int j = 0; j < N; ++j)
427  result(i) += _vals[i1 + j] * b(j);
428  }
429 
430  return result;
431 }
VectorValue< Real > RealVectorValue
Definition: Assembly.h:40
Real _vals[N2]
The values of the rank-two tensor stored by index=(i * LIBMESH_DIM + j)
static constexpr unsigned int N
RankTwoTensor RankTwoTensor::operator* ( const RankTwoTensor a) const

Defines multiplication with another RankTwoTensor.

Definition at line 455 of file RankTwoTensor.C.

456 {
457  RankTwoTensor result;
458 
459  unsigned int i1 = 0;
460  for (unsigned int i = 0; i < N; ++i)
461  {
462  unsigned int j1 = 0;
463  for (unsigned int j = 0; j < N; ++j)
464  {
465  for (unsigned int k = 0; k < N; ++k)
466  result._vals[i1 + k] += _vals[i1 + j] * b._vals[j1 + k];
467  j1 += N;
468  }
469  i1 += N;
470  }
471  return result;
472 }
Real _vals[N2]
The values of the rank-two tensor stored by index=(i * LIBMESH_DIM + j)
RankTwoTensor is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: RankTwoTensor.h:45
static constexpr unsigned int N
RankTwoTensor RankTwoTensor::operator* ( const TypeTensor< Real > &  a) const

Defines multiplication with a TypeTensor<Real>

Definition at line 474 of file RankTwoTensor.C.

475 {
476  RankTwoTensor result;
477 
478  unsigned int i1 = 0;
479  for (unsigned int i = 0; i < N; ++i)
480  {
481  for (unsigned int j = 0; j < N; ++j)
482  {
483  for (unsigned int k = 0; k < N; ++k)
484  result._vals[i1 + k] += _vals[i1 + j] * b(j, k);
485  }
486  i1 += N;
487  }
488 
489  return result;
490 }
Real _vals[N2]
The values of the rank-two tensor stored by index=(i * LIBMESH_DIM + j)
RankTwoTensor is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: RankTwoTensor.h:45
static constexpr unsigned int N
RankTwoTensor & RankTwoTensor::operator*= ( const Real  a)

performs _vals *= a

Definition at line 383 of file RankTwoTensor.C.

Referenced by operator()().

384 {
385  for (unsigned int i = 0; i < N2; ++i)
386  _vals[i] *= a;
387  return *this;
388 }
Real _vals[N2]
The values of the rank-two tensor stored by index=(i * LIBMESH_DIM + j)
static constexpr unsigned int N2
RankTwoTensor & RankTwoTensor::operator*= ( const RankTwoTensor a)

performs _vals *= a (component by component) and returns the result

Definition at line 434 of file RankTwoTensor.C.

435 {
436  RankTwoTensor s(*this);
437  this->zero();
438 
439  unsigned int i1 = 0;
440  for (unsigned int i = 0; i < N; ++i)
441  {
442  unsigned int j1 = 0;
443  for (unsigned int j = 0; j < N; ++j)
444  {
445  for (unsigned int k = 0; k < N; ++k)
446  _vals[i1 + k] += s._vals[i1 + j] * a._vals[j1 + k];
447  j1 += N;
448  }
449  i1 += N;
450  }
451 
452  return *this;
453 }
void zero()
zeroes all _vals components
Real _vals[N2]
The values of the rank-two tensor stored by index=(i * LIBMESH_DIM + j)
RankTwoTensor is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: RankTwoTensor.h:45
static constexpr unsigned int N
RankTwoTensor RankTwoTensor::operator+ ( const RankTwoTensor a) const

returns _vals + a

Definition at line 347 of file RankTwoTensor.C.

Referenced by operator()().

348 {
349  RankTwoTensor result;
350  for (unsigned int i = 0; i < N2; ++i)
351  result._vals[i] = _vals[i] + b._vals[i];
352  return result;
353 }
Real _vals[N2]
The values of the rank-two tensor stored by index=(i * LIBMESH_DIM + j)
RankTwoTensor is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: RankTwoTensor.h:45
static constexpr unsigned int N2
RankTwoTensor & RankTwoTensor::operator+= ( const RankTwoTensor a)

adds a to _vals

Definition at line 338 of file RankTwoTensor.C.

Referenced by operator()().

339 {
340  for (unsigned int i = 0; i < N2; ++i)
341  _vals[i] += a._vals[i];
342 
343  return *this;
344 }
Real _vals[N2]
The values of the rank-two tensor stored by index=(i * LIBMESH_DIM + j)
static constexpr unsigned int N2
RankTwoTensor RankTwoTensor::operator- ( const RankTwoTensor a) const

returns _vals - a

Definition at line 365 of file RankTwoTensor.C.

366 {
367  RankTwoTensor result;
368  for (unsigned int i = 0; i < N2; ++i)
369  result._vals[i] = _vals[i] - b._vals[i];
370  return result;
371 }
Real _vals[N2]
The values of the rank-two tensor stored by index=(i * LIBMESH_DIM + j)
RankTwoTensor is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: RankTwoTensor.h:45
static constexpr unsigned int N2
RankTwoTensor RankTwoTensor::operator- ( ) const

returns -_vals

Definition at line 374 of file RankTwoTensor.C.

Referenced by operator()().

375 {
376  RankTwoTensor result;
377  for (unsigned int i = 0; i < N2; ++i)
378  result._vals[i] = -_vals[i];
379  return result;
380 }
Real _vals[N2]
The values of the rank-two tensor stored by index=(i * LIBMESH_DIM + j)
RankTwoTensor is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: RankTwoTensor.h:45
static constexpr unsigned int N2
RankTwoTensor & RankTwoTensor::operator-= ( const RankTwoTensor a)

sets _vals -= a and returns vals

Definition at line 356 of file RankTwoTensor.C.

Referenced by operator()().

357 {
358  for (unsigned int i = 0; i < N2; ++i)
359  _vals[i] -= a._vals[i];
360 
361  return *this;
362 }
Real _vals[N2]
The values of the rank-two tensor stored by index=(i * LIBMESH_DIM + j)
static constexpr unsigned int N2
RankTwoTensor RankTwoTensor::operator/ ( const Real  a) const

returns _vals/a

Definition at line 409 of file RankTwoTensor.C.

Referenced by operator()().

410 {
411  RankTwoTensor result;
412 
413  for (unsigned int i = 0; i < N2; ++i)
414  result._vals[i] = _vals[i] / b;
415 
416  return result;
417 }
Real _vals[N2]
The values of the rank-two tensor stored by index=(i * LIBMESH_DIM + j)
RankTwoTensor is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: RankTwoTensor.h:45
static constexpr unsigned int N2
RankTwoTensor & RankTwoTensor::operator/= ( const Real  a)

performs _vals /= a

Definition at line 399 of file RankTwoTensor.C.

Referenced by operator()().

400 {
401  for (unsigned int i = 0; i < N; ++i)
402  for (unsigned int j = 0; j < N; ++j)
403  (*this)(i, j) /= a;
404 
405  return *this;
406 }
static constexpr unsigned int N
RankTwoTensor & RankTwoTensor::operator= ( const RankTwoTensor a)

sets _vals to a, and returns _vals

Definition at line 329 of file RankTwoTensor.C.

Referenced by operator()().

330 {
331  for (unsigned int i = 0; i < N2; ++i)
332  _vals[i] = a._vals[i];
333 
334  return *this;
335 }
Real _vals[N2]
The values of the rank-two tensor stored by index=(i * LIBMESH_DIM + j)
static constexpr unsigned int N2
RankTwoTensor & RankTwoTensor::operator= ( const ColumnMajorMatrix a)

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

Definition at line 504 of file RankTwoTensor.C.

505 {
506  if (a.n() != N || a.m() != N)
507  mooseError("Dimensions of ColumnMajorMatrix are incompatible with RankTwoTensor");
508 
509  const Real * cmm_rawdata = a.rawData();
510  for (unsigned int i = 0; i < N; ++i)
511  for (unsigned int j = 0; j < N; ++j)
512  _vals[i * N + j] = cmm_rawdata[i + j * N];
513 
514  return *this;
515 }
unsigned int n() const
Returns the number of rows.
Real * rawData()
Returns a reference to the raw data pointer.
Real _vals[N2]
The values of the rank-two tensor stored by index=(i * LIBMESH_DIM + j)
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
static constexpr unsigned int N
unsigned int m() const
Returns the number of columns.
bool RankTwoTensor::operator== ( const RankTwoTensor a) const

Defines logical equality with another RankTwoTensor.

Definition at line 493 of file RankTwoTensor.C.

Referenced by operator()().

494 {
495  for (unsigned int i = 0; i < N; ++i)
496  for (unsigned int j = 0; j < N; ++j)
497  if (!MooseUtils::absoluteFuzzyEqual((*this)(i, j), a(i, j)))
498  return false;
499 
500  return true;
501 }
static constexpr unsigned int N
bool absoluteFuzzyEqual(const libMesh::Real &var1, const libMesh::Real &var2, const libMesh::Real &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
Function to check whether two variables are equal within an absolute tolerance.
RankFourTensor RankTwoTensor::outerProduct ( const RankTwoTensor a) const

returns C_ijkl = a_ij * b_kl

Definition at line 529 of file RankTwoTensor.C.

Referenced by operator()().

530 {
531  RankFourTensor result;
532 
533  unsigned int index = 0;
534  for (unsigned int ij = 0; ij < N2; ++ij)
535  {
536  const Real a = _vals[ij];
537  for (unsigned int kl = 0; kl < N2; ++kl)
538  result._vals[index++] = a * b._vals[kl];
539  }
540 
541  return result;
542 }
Real _vals[N2]
The values of the rank-two tensor stored by index=(i * LIBMESH_DIM + j)
Real _vals[N4]
The values of the rank-four tensor stored by index=(((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) * LIBME...
static constexpr unsigned int N2
RankFourTensor is designed to handle any N-dimensional fourth order tensor, C.
void RankTwoTensor::print ( std::ostream &  stm = Moose::out) const

Print the rank two tensor.

Definition at line 892 of file RankTwoTensor.C.

Referenced by operator()().

893 {
894  const RankTwoTensor & a = *this;
895  for (unsigned int i = 0; i < N; ++i)
896  {
897  for (unsigned int j = 0; j < N; ++j)
898  stm << std::setw(15) << a(i, j) << ' ';
899  stm << std::endl;
900  }
901 }
RankTwoTensor is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: RankTwoTensor.h:45
static constexpr unsigned int N
void RankTwoTensor::rotate ( const RealTensorValue &  R)

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

Parameters
Rrotation matrix as a RealTensorValue

Definition at line 239 of file RankTwoTensor.C.

Referenced by operator()(), and rotated().

240 {
241  RankTwoTensor temp;
242  for (unsigned int i = 0; i < N; i++)
243  for (unsigned int j = 0; j < N; j++)
244  {
245  // tmp += R(i,k)*R(j,l)*(*this)(k,l);
246  // clang-format off
247  Real tmp = R(i, 0) * R(j, 0) * (*this)(0, 0) +
248  R(i, 0) * R(j, 1) * (*this)(0, 1) +
249  R(i, 0) * R(j, 2) * (*this)(0, 2) +
250  R(i, 1) * R(j, 0) * (*this)(1, 0) +
251  R(i, 1) * R(j, 1) * (*this)(1, 1) +
252  R(i, 1) * R(j, 2) * (*this)(1, 2) +
253  R(i, 2) * R(j, 0) * (*this)(2, 0) +
254  R(i, 2) * R(j, 1) * (*this)(2, 1) +
255  R(i, 2) * R(j, 2) * (*this)(2, 2);
256  // clang-format on
257  temp(i, j) = tmp;
258  }
259  for (unsigned int i = 0; i < N2; i++)
260  _vals[i] = temp._vals[i];
261 }
Real _vals[N2]
The values of the rank-two tensor stored by index=(i * LIBMESH_DIM + j)
RankTwoTensor is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: RankTwoTensor.h:45
static constexpr unsigned int N
static constexpr unsigned int N2
void RankTwoTensor::rotate ( const RankTwoTensor R)

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

Parameters
Rrotation matrix as a RankTwoTensor

Definition at line 264 of file RankTwoTensor.C.

265 {
266  RankTwoTensor temp;
267  unsigned int i1 = 0;
268  for (unsigned int i = 0; i < N; i++)
269  {
270  unsigned int j1 = 0;
271  for (unsigned int j = 0; j < N; j++)
272  {
273  // tmp += R(i,k)*R(j,l)*(*this)(k,l);
274  // clang-format off
275  Real tmp = R._vals[i1 + 0] * R._vals[j1 + 0] * (*this)(0, 0) +
276  R._vals[i1 + 0] * R._vals[j1 + 1] * (*this)(0, 1) +
277  R._vals[i1 + 0] * R._vals[j1 + 2] * (*this)(0, 2) +
278  R._vals[i1 + 1] * R._vals[j1 + 0] * (*this)(1, 0) +
279  R._vals[i1 + 1] * R._vals[j1 + 1] * (*this)(1, 1) +
280  R._vals[i1 + 1] * R._vals[j1 + 2] * (*this)(1, 2) +
281  R._vals[i1 + 2] * R._vals[j1 + 0] * (*this)(2, 0) +
282  R._vals[i1 + 2] * R._vals[j1 + 1] * (*this)(2, 1) +
283  R._vals[i1 + 2] * R._vals[j1 + 2] * (*this)(2, 2);
284  // clang-format on
285  temp._vals[i1 + j] = tmp;
286  j1 += N;
287  }
288  i1 += N;
289  }
290  for (unsigned int i = 0; i < N2; i++)
291  _vals[i] = temp._vals[i];
292 }
Real _vals[N2]
The values of the rank-two tensor stored by index=(i * LIBMESH_DIM + j)
RankTwoTensor is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: RankTwoTensor.h:45
static constexpr unsigned int N
static constexpr unsigned int N2
RankTwoTensor RankTwoTensor::rotated ( const RealTensorValue &  R) const

Returns a rotated version of the tensor data given a rank two tensor rotation tensor _vals[i][j] = R_ij * R_jl * _vals[k][l].

Parameters
Rrotation matrix as a RealTensorValue

Definition at line 231 of file RankTwoTensor.C.

Referenced by operator()().

232 {
233  RankTwoTensor result(*this);
234  result.rotate(R);
235  return result;
236 }
RankTwoTensor is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: RankTwoTensor.h:45
RankTwoTensor RankTwoTensor::rotateXyPlane ( Real  a)

rotates the tensor data anticlockwise around the z-axis

Parameters
aangle in radians

Definition at line 295 of file RankTwoTensor.C.

Referenced by operator()().

296 {
297  Real c = std::cos(a);
298  Real s = std::sin(a);
299  Real x = (*this)(0, 0) * c * c + (*this)(1, 1) * s * s + 2.0 * (*this)(0, 1) * c * s;
300  Real y = (*this)(0, 0) * s * s + (*this)(1, 1) * c * c - 2.0 * (*this)(0, 1) * c * s;
301  Real xy = ((*this)(1, 1) - (*this)(0, 0)) * c * s + (*this)(0, 1) * (c * c - s * s);
302 
303  RankTwoTensor b(*this);
304 
305  b(0, 0) = x;
306  b(1, 1) = y;
307  b(1, 0) = b(0, 1) = xy;
308 
309  return b;
310 }
static PetscErrorCode Vec x
RankTwoTensor is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: RankTwoTensor.h:45
TypeVector< Real > RankTwoTensor::row ( const unsigned int  r) const

returns _vals[r][i], ie, row r, with r = 0, 1, 2

Definition at line 209 of file RankTwoTensor.C.

Referenced by operator()().

210 {
211  RealVectorValue result;
212 
213  for (unsigned int i = 0; i < N; i++)
214  result(i) = (*this)(r, i);
215 
216  return result;
217 }
VectorValue< Real > RealVectorValue
Definition: Assembly.h:40
static constexpr unsigned int N
Real RankTwoTensor::secondInvariant ( ) const

Calculates the second invariant (I2) of a tensor.

Definition at line 603 of file RankTwoTensor.C.

Referenced by d2sin3Lode(), dsin3Lode(), dthirdInvariant(), operator()(), and sin3Lode().

604 {
605  Real result = 0.0;
606 
607  // RankTwoTensor deviatoric(*this);
608  // deviatoric.addIa(-1.0/3.0 * trace()); // actually construct deviatoric part
609  // result = 0.5*(deviatoric + deviatoric.transpose()).doubleContraction(deviatoric +
610  // deviatoric.transpose());
611  result = Utility::pow<2>((*this)(0, 0) - (*this)(1, 1)) / 6.0;
612  result += Utility::pow<2>((*this)(0, 0) - (*this)(2, 2)) / 6.0;
613  result += Utility::pow<2>((*this)(1, 1) - (*this)(2, 2)) / 6.0;
614  result += Utility::pow<2>((*this)(0, 1) + (*this)(1, 0)) / 4.0;
615  result += Utility::pow<2>((*this)(0, 2) + (*this)(2, 0)) / 4.0;
616  result += Utility::pow<2>((*this)(1, 2) + (*this)(2, 1)) / 4.0;
617  return result;
618 }
Real RankTwoTensor::sin3Lode ( const Real  r0,
const Real  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 788 of file RankTwoTensor.C.

Referenced by operator()().

789 {
790  Real bar = secondInvariant();
791  if (bar <= r0)
792  // in this case the Lode angle is not defined
793  return r0_value;
794  else
795  // the min and max here gaurd against precision-loss when bar is tiny but nonzero.
796  return std::max(std::min(-1.5 * std::sqrt(3.0) * thirdInvariant() / std::pow(bar, 1.5), 1.0),
797  -1.0);
798 }
Real secondInvariant() const
Calculates the second invariant (I2) of a tensor.
Real 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 RankTwoTensor::surfaceFillFromInputVector ( const std::vector< Real > &  input)

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

Definition at line 923 of file RankTwoTensor.C.

Referenced by operator()().

924 {
925  if (input.size() == 4)
926  {
927  // initialize with zeros
928  this->zero();
929  (*this)(0, 0) = input[0];
930  (*this)(0, 1) = input[1];
931  (*this)(1, 0) = input[2];
932  (*this)(1, 1) = input[3];
933  }
934  else
935  mooseError("please provide correct number of values for surface RankTwoTensor initialization.");
936 }
void zero()
zeroes all _vals components
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
void RankTwoTensor::syev ( const char *  calculation_type,
std::vector< PetscScalar > &  eigvals,
std::vector< PetscScalar > &  a 
) const

Uses the petscblaslapack.h LAPACKsyev_ routine to find, for symmetric _vals: (1) the eigenvalues (if calculation_type == "N") (2) the eigenvalues and eigenvectors (if calculation_type == "V")

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 1032 of file RankTwoTensor.C.

Referenced by d2symmetricEigenvalues(), dsymmetricEigenvalues(), operator()(), symmetricEigenvalues(), and symmetricEigenvaluesEigenvectors().

1035 {
1036  eigvals.resize(N);
1037  a.resize(N * N);
1038 
1039  // prepare data for the LAPACKsyev_ routine (which comes from petscblaslapack.h)
1040  int nd = N;
1041  int lwork = 66 * nd;
1042  int info;
1043  std::vector<PetscScalar> work(lwork);
1044 
1045  for (unsigned int i = 0; i < N; ++i)
1046  for (unsigned int j = 0; j < N; ++j)
1047  // a is destroyed by dsyev, and if calculation_type == "V" then eigenvectors are placed there
1048  // Note the explicit symmeterisation
1049  a[i * N + j] = 0.5 * (this->operator()(i, j) + this->operator()(j, i));
1050 
1051  // compute the eigenvalues only (if calculation_type == "N"),
1052  // or both the eigenvalues and eigenvectors (if calculation_type == "V")
1053  // assume upper triangle of a is stored (second "U")
1054  LAPACKsyev_(calculation_type, "U", &nd, &a[0], &nd, &eigvals[0], &work[0], &lwork, &info);
1055 
1056  if (info != 0)
1057  mooseError("In computing the eigenvalues and eigenvectors of a symmetric rank-2 tensor, the "
1058  "PETSC LAPACK syev routine returned error code ",
1059  info);
1060 }
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
static constexpr unsigned int N
void RankTwoTensor::symmetricEigenvalues ( std::vector< Real > &  eigvals) const

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

Definition at line 939 of file RankTwoTensor.C.

Referenced by operator()().

940 {
941  std::vector<PetscScalar> a;
942  syev("N", eigvals, a);
943 }
void syev(const char *calculation_type, std::vector< PetscScalar > &eigvals, std::vector< PetscScalar > &a) const
Uses the petscblaslapack.h LAPACKsyev_ routine to find, for symmetric _vals: (1) the eigenvalues (if ...
void RankTwoTensor::symmetricEigenvaluesEigenvectors ( std::vector< Real > &  eigvals,
RankTwoTensor 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 946 of file RankTwoTensor.C.

Referenced by operator()().

948 {
949  std::vector<PetscScalar> a;
950  syev("V", eigvals, a);
951 
952  for (unsigned int i = 0; i < N; ++i)
953  for (unsigned int j = 0; j < N; ++j)
954  eigvecs(j, i) = a[i * N + j];
955 }
static constexpr unsigned int N
void syev(const char *calculation_type, std::vector< PetscScalar > &eigvals, std::vector< PetscScalar > &a) const
Uses the petscblaslapack.h LAPACKsyev_ routine to find, for symmetric _vals: (1) the eigenvalues (if ...
Real RankTwoTensor::thirdInvariant ( ) const

Denote the _vals[i][j] by A_ij, then S_ij = A_ij - de_ij*tr(A)/3 Then this returns det(S + S.transpose())/2 Note the explicit symmeterisation.

Definition at line 660 of file RankTwoTensor.C.

Referenced by d2sin3Lode(), dsin3Lode(), operator()(), and sin3Lode().

661 {
662  RankTwoTensor s = 0.5 * deviatoric();
663  s += s.transpose();
664 
665  Real result = 0.0;
666 
667  result = s(0, 0) * (s(1, 1) * s(2, 2) - s(2, 1) * s(1, 2));
668  result -= s(1, 0) * (s(0, 1) * s(2, 2) - s(2, 1) * s(0, 2));
669  result += s(2, 0) * (s(0, 1) * s(1, 2) - s(1, 1) * s(0, 2));
670 
671  return result;
672 }
RankTwoTensor transpose() const
Returns a matrix that is the transpose of the matrix this was called on.
RankTwoTensor deviatoric() const
returns A_ij - de_ij*tr(A)/3, where A are the _vals
RankTwoTensor is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: RankTwoTensor.h:45
Real RankTwoTensor::trace ( ) const

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

Definition at line 643 of file RankTwoTensor.C.

Referenced by deviatoric(), and operator()().

644 {
645  Real result = 0.0;
646 
647  for (unsigned int i = 0; i < N; ++i)
648  result += (*this)(i, i);
649 
650  return result;
651 }
static constexpr unsigned int N
RankTwoTensor RankTwoTensor::transpose ( ) const

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

Definition at line 313 of file RankTwoTensor.C.

Referenced by d2thirdInvariant(), dsecondInvariant(), dthirdInvariant(), getRUDecompositionRotation(), operator()(), and thirdInvariant().

314 {
315  RankTwoTensor result;
316 
317  unsigned int i1 = 0;
318  for (unsigned int i = 0; i < N; ++i)
319  {
320  for (unsigned int j = 0; j < N; ++j)
321  result._vals[i1 + j] = (*this)(j, i);
322  i1 += N;
323  }
324 
325  return result;
326 }
Real _vals[N2]
The values of the rank-two tensor stored by index=(i * LIBMESH_DIM + j)
RankTwoTensor is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: RankTwoTensor.h:45
static constexpr unsigned int N
void RankTwoTensor::vectorOuterProduct ( const TypeVector< Real > &  v1,
const TypeVector< Real > &  v2 
)

RankTwoTensor from outer product of vectors.

Definition at line 1129 of file RankTwoTensor.C.

Referenced by operator()().

1130 {
1131  for (unsigned int i = 0; i < N; ++i)
1132  for (unsigned int j = 0; j < N; ++j)
1133  (*this)(i, j) = v1(i) * v2(j);
1134 }
static constexpr unsigned int N
void RankTwoTensor::zero ( )

zeroes all _vals components

Definition at line 153 of file RankTwoTensor.C.

Referenced by fillFromInputVector(), getRUDecompositionRotation(), operator()(), operator*=(), RankTwoTensor(), and surfaceFillFromInputVector().

154 {
155  for (unsigned int i(0); i < N2; i++)
156  _vals[i] = 0.0;
157 }
Real _vals[N2]
The values of the rank-two tensor stored by index=(i * LIBMESH_DIM + j)
static constexpr unsigned int N2

Friends And Related Function Documentation

template<class T >
void dataLoad ( std::istream &  stream,
T &  v,
void *   
)
friend

Definition at line 351 of file DataIO.h.

Referenced by operator*().

352 {
353  stream.read((char *)&v, sizeof(v));
354 }
template<class T >
void dataStore ( std::ostream &  stream,
T &  v,
void *   
)
friend

Definition at line 155 of file DataIO.h.

Referenced by operator*().

156 {
157 #ifdef LIBMESH_HAVE_CXX11_TYPE_TRAITS
158  static_assert(std::is_polymorphic<T>::value == false,
159  "Cannot serialize a class that has virtual "
160  "members!\nWrite a custom dataStore() "
161  "template specialization!\n\n");
162  static_assert(std::is_trivially_copyable<T>::value || std::is_same<T, Point>::value,
163  "Cannot serialize a class that is not trivially copyable!\nWrite a custom "
164  "dataStore() template specialization!\n\n");
165 #endif
166 
167  // Moose::out<<"Generic dataStore"<<std::endl;
168  stream.write((char *)&v, sizeof(v));
169 }
friend class RankFourTensor
friend

Definition at line 440 of file RankTwoTensor.h.

Referenced by d2sin3Lode(), and d2symmetricEigenvalues().

friend class RankThreeTensor
friend

Definition at line 441 of file RankTwoTensor.h.

Member Data Documentation

Real RankTwoTensor::_vals[N2]
private
constexpr unsigned int RankTwoTensor::N = LIBMESH_DIM
staticprivate
constexpr unsigned int RankTwoTensor::N2 = N * N
staticprivate

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