20 #include "libmesh/libmesh.h" 21 #include "libmesh/tuple_of.h" 22 #include "libmesh/int_range.h" 24 #include "metaphysicl/raw_type.h" 30 #include <Eigen/Dense> 73 static constexpr
unsigned int Ndim = LIBMESH_DIM;
75 static constexpr
unsigned int N2 =
N *
N;
80 {{0, 0, 0, 0}, {0, 0, 1, 1}, {0, 0, 2, 2}, {0, 0, 1, 2}, {0, 0, 0, 2}, {0, 0, 0, 1}},
81 {{1, 1, 0, 0}, {1, 1, 1, 1}, {1, 1, 2, 2}, {1, 1, 1, 2}, {1, 1, 0, 2}, {1, 1, 0, 1}},
82 {{2, 2, 0, 0}, {2, 2, 1, 1}, {2, 2, 2, 2}, {2, 2, 1, 2}, {2, 2, 0, 2}, {2, 2, 0, 1}},
83 {{1, 2, 0, 0}, {1, 2, 1, 1}, {1, 2, 2, 2}, {1, 2, 1, 2}, {1, 2, 0, 2}, {1, 2, 0, 1}},
84 {{0, 2, 0, 0}, {0, 2, 1, 1}, {0, 2, 2, 2}, {0, 2, 1, 2}, {0, 2, 0, 2}, {0, 2, 0, 1}},
85 {{0, 1, 0, 0}, {0, 1, 1, 1}, {0, 1, 2, 2}, {0, 1, 1, 2}, {0, 1, 0, 2}, {0, 1, 0, 1}}};
118 template <
template <
typename>
class Tensor,
typename Scalar>
123 template <
typename Scalar>
128 template <
typename Scalar>
133 template <
typename Scalar>
154 template <
typename T2>
180 inline const T &
operator()(
unsigned int i,
unsigned int j)
const {
return _vals[i *
N + j]; }
186 void print(std::ostream & stm = Moose::out)
const;
189 void printReal(std::ostream & stm = Moose::out)
const;
191 friend std::ostream & operator<<(std::ostream & os, const SymmetricRankFourTensorTempl<T> & t)
205 template <
typename Scalar>
210 libmesh_assert_equal_to(p, Scalar(0));
216 template <
typename T2>
221 template <
typename T2>
223 typename std::enable_if<libMesh::ScalarTraits<T2>::value,
230 template <
typename T2>
232 typename std::enable_if<libMesh::ScalarTraits<T2>::value,
242 template <
typename T2>
250 template <
typename T2>
258 template <
typename T2>
283 void rotate(
const TypeTensor<T> & R);
323 template <
typename T2>
334 template <
typename T2>
412 template <
typename T2>
414 template <
typename T2>
416 template <
typename T2>
422 template <
typename T>
439 template <
typename T1,
typename T2>
442 typename std::enable_if<libMesh::ScalarTraits<T1>::value,
448 template <
typename T>
449 template <
typename T2>
454 _vals[i] = copy.
_vals[i];
457 template <
typename T>
458 template <
typename T2>
461 typename std::enable_if<libMesh::ScalarTraits<T2>::value,
464 typedef decltype(T() * T2()) ValueType;
468 result.
_vals[i] = _vals[i] * b;
473 template <
typename T>
474 template <
typename T2>
479 typedef decltype(T() * T2()) ValueType;
482 std::size_t index = 0;
487 tmp += _vals[index++] * b.
_vals[j];
488 result.
_vals[i] = tmp;
494 template <
typename T>
495 template <
typename T2>
498 typename std::enable_if<libMesh::ScalarTraits<T2>::value,
503 result.
_vals[i] = _vals[i] / b;
507 template <
typename T>
508 template <
typename T2>
512 mooseAssert(LIBMESH_DIM == 3,
"This method assumes LIBMESH_DIM == 3");
513 mooseAssert(input.size() == 9,
514 "To use fillSymmetric9FromInputVector, your input must have size 9.");
519 _vals[14] = input[5];
521 _vals[1] = _vals[6] = input[1];
522 _vals[2] = _vals[12] = input[2];
523 _vals[8] = _vals[13] = input[4];
525 static constexpr std::size_t C2323 = 21;
526 static constexpr std::size_t C1313 = 28;
527 static constexpr std::size_t C1212 = 35;
529 _vals[C2323] = 2.0 * input[6];
530 _vals[C1313] = 2.0 * input[7];
531 _vals[C1212] = 2.0 * input[8];
534 template <
typename T>
535 template <
typename T2>
546 mooseAssert(LIBMESH_DIM == 3,
"This method assumes LIBMESH_DIM == 3");
547 mooseAssert(input.size() == 21,
548 "To use fillSymmetric21FromInputVector, your input must have size 21.");
549 std::size_t index = 0;
553 _vals[i +
N * j] = mandelFactor(i, j) * input[index];
554 _vals[j +
N * i] = mandelFactor(j, i) * input[index];
559 template <
typename T>
567 Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> mat(
N,
N);
570 mat(i, j) = (*this)(i, j);
574 result(i, j) = mat(i, j);
578 const Eigen::Map<const Eigen::Matrix<T, N, N, Eigen::RowMajor>> mat(&_vals[0]);
579 Eigen::Map<Eigen::Matrix<T, N, N, Eigen::RowMajor>> res(&result.
_vals[0]);
void fillAxisymmetricRZFromInputVector(const std::vector< T > &input)
fillAxisymmetricRZFromInputVector takes 5 inputs to fill the axisymmetric Rank-4 tensor with the appr...
RankFourTensorTempl is designed to handle any N-dimensional fourth order tensor, C.
std::array< T, N2 > _vals
The values of the rank-four tensor.
libMesh::VectorValue< T > sum3x1() const
Calculates the vector a[i] = sum over j Ciijj for i and j varying from 0 to 2.
void fillSymmetricIsotropicEandNu(const T &E, const T &nu)
const T & operator()(unsigned int i, unsigned int j) const
Gets the value for the indices specified.
static MooseEnum fillMethodEnum()
Static method for use in validParams for getting the "fill_method".
T & operator()(unsigned int i, unsigned int j)
Gets the value for the indices specified. Takes indices ranging from 0-5 for i and j...
bool isIsotropic() const
checks if the tensor is isotropic
auto operator+(const SymmetricRankFourTensorTempl< T2 > &a) const -> SymmetricRankFourTensorTempl< decltype(T()+T2())>
C_ijkl + a_ijkl.
FillMethod
To fill up the 36 entries in the 4th-order tensor, fillFromInputVector is called with one of the foll...
void fillSymmetricIsotropic(const T &i0, const T &i1)
Vector-less fill API functions. See docs of the corresponding ...FromInputVector methods.
SymmetricRankFourTensorTempl< T > & operator-=(const SymmetricRankFourTensorTempl< T > &a)
C_ijkl -= a_ijkl.
void mooseSetToZero< SymmetricRankFourTensor >(SymmetricRankFourTensor &v)
Helper function template specialization to set an object to zero.
auto operator*(const SymmetricRankTwoTensorTempl< T2 > &b) const -> SymmetricRankTwoTensorTempl< decltype(T() *T2())>
C_ijkl*a_kl.
void fillSymmetric21FromInputVector(const T2 &input)
fillSymmetric21FromInputVector takes 21 inputs to fill in the Rank-4 tensor with the appropriate crys...
static constexpr Real mandelFactor(unsigned int i, unsigned int j)
returns the 1, sqrt(2), or 2 prefactor in the Mandel notation for the indices i,j ranging from 0-5...
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
std::basic_ostream< charT, traits > * os
static constexpr unsigned int N
T sum3x3() const
Calculates the sum of Ciijj for i and j varying from 0 to 2.
T L2norm() const
sqrt(C_ijkl*C_ijkl)
static SymmetricRankFourTensorTempl< T > rotationMatrix(const TypeTensor< T > &R)
Build a 6x6 rotation matrix MEHRABADI, MORTEZA M.
RankThreeTensor is designed to handle any N-dimensional third order tensor, r.
auto operator/(const T2 &a) const -> typename std::enable_if< libMesh::ScalarTraits< T2 >::value, SymmetricRankFourTensorTempl< decltype(T()/T2())>>::type
C_ijkl/a.
typename tuple_n< Index, T >::template type<> tuple_of
SymmetricRankFourTensorTempl< T > & operator+=(const SymmetricRankFourTensorTempl< T > &a)
C_ijkl += a_ijkl for all i, j, k, l.
SymmetricRankTwoTensorTempl is designed to handle the Stress or Strain Tensor for an anisotropic mate...
void fillSymmetricIsotropicEandNuFromInputVector(const std::vector< T > &input)
fillSymmetricIsotropicEandNuFromInputVector is a variation of the fillSymmetricIsotropicFromInputVect...
InitMethod
Initialization method.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
void rotate(const TypeTensor< T > &R)
Rotate the tensor using C_ijkl = R_im R_jn R_ko R_lp C_mnop.
SymmetricRankFourTensorTempl< T > & operator*=(const T &a)
C_ijkl *= a.
static SymmetricRankFourTensorTempl< T > identitySymmetricFour()
void fillPrincipalFromInputVector(const std::vector< T > &input)
fillPrincipalFromInputVector takes 9 inputs to fill a Rank-4 tensor C1111 = input0 C1122 = input1 C11...
void printReal(std::ostream &stm=Moose::out) const
Print the values of the rank four tensor.
void fillSymmetricIsotropicFromInputVector(const std::vector< T > &input)
fillSymmetricIsotropicFromInputVector takes 2 inputs to fill the the symmetric Rank-4 tensor with the...
friend void dataStore(std::ostream &, SymmetricRankFourTensorTempl< T2 > &, void *)
void mooseSetToZero< ADSymmetricRankFourTensor >(ADSymmetricRankFourTensor &v)
SymmetricRankFourTensorTempl< T > transposeMajor() const
Transpose the tensor by swapping the first pair with the second pair of indices This amounts to a reg...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
SymmetricRankFourTensorTempl< T > & operator=(const SymmetricRankFourTensorTempl< T > &a)=default
copies values from a into this tensor
void print(std::ostream &stm=Moose::out) const
Print the rank four tensor.
void fillFromInputVector(const std::vector< T > &input, FillMethod fill_method)
fillFromInputVector takes some number of inputs to fill the Rank-4 tensor.
SymmetricRankFourTensorTempl< T > operator-() const
-C_ijkl
friend void dataLoad(std::istream &, SymmetricRankFourTensorTempl< T2 > &, void *)
void fillGeneralOrthotropicFromInputVector(const std::vector< T > &input)
fillGeneralOrhotropicFromInputVector takes 10 inputs to fill the Rank-4 tensor It defines a general o...
static constexpr unsigned int full_index[6][6][4]
void zero()
Zeros out the tensor.
SymmetricRankFourTensorTempl is designed to handle an N-dimensional fourth order tensor with minor sy...
IntRange< T > make_range(T beg, T end)
boostcopy::enable_if_c< libMesh::ScalarTraits< Scalar >::value, SymmetricRankFourTensorTempl & >::type operator=(const Scalar &libmesh_dbg_var(p))
Assignment-from-scalar operator.
SymmetricRankFourTensorTempl< T > invSymm() const
This returns A_ijkl such that C_ijkl*A_klmn = 0.5*(de_im de_jn + de_in de_jm) This routine assumes th...
static SymmetricRankFourTensorTempl< T > identity()
bool isSymmetric() const
checks if the tensor is symmetric
static constexpr Real mandelFactor(unsigned int i)
returns the 1 or sqrt(2) prefactor in the Mandel notation for the index i ranging from 0-5...
static constexpr unsigned int Ndim
tensor dimension, Mandel matrix dimension, and Mandel matrix size
SymmetricRankFourTensorTempl< T > & operator/=(const T &a)
C_ijkl /= a for all i, j, k, l.
SymmetricRankFourTensorTempl()
Default constructor; fills to zero.
void fillSymmetric9FromInputVector(const T2 &input)
fillSymmetric9FromInputVector takes 9 inputs to fill in the Rank-4 tensor with the appropriate crysta...
auto operator*(const T1 &a, const SymmetricRankFourTensorTempl< T2 > &b) -> typename std::enable_if< libMesh::ScalarTraits< T1 >::value, SymmetricRankFourTensorTempl< decltype(T1() *T2())>>::type
SymmetricRankFourTensorTempl< T > transposeIj() const
Transpose the tensor by swapping the first two indices - a no-op.
static constexpr unsigned int N2