www.mooseframework.org
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | Friends | List of all members
RankFourTensorTempl< T > Class Template Reference

RankFourTensorTempl is designed to handle any N-dimensional fourth order tensor, C. More...

#include <MooseTypes.h>

Classes

struct  TwoTensorMultTraits
 
struct  TwoTensorMultTraits< RankTwoTensorTempl, Scalar >
 
struct  TwoTensorMultTraits< TensorValue, Scalar >
 
struct  TwoTensorMultTraits< TypeTensor, Scalar >
 

Public Types

enum  InitMethod { initNone, initIdentity, initIdentityFour, initIdentitySymmetricFour }
 Initialization method. More...
 
enum  FillMethod {
  antisymmetric, symmetric9, symmetric21, general_isotropic,
  symmetric_isotropic, symmetric_isotropic_E_nu, antisymmetric_isotropic, axisymmetric_rz,
  general, principal
}
 To fill up the 81 entries in the 4th-order tensor, fillFromInputVector is called with one of the following fill_methods. More...
 
typedef tuple_of< 4, unsigned int > index_type
 

Public Member Functions

 RankFourTensorTempl ()
 Default constructor; fills to zero. More...
 
 RankFourTensorTempl (const InitMethod)
 Select specific initialization pattern. More...
 
 RankFourTensorTempl (const std::vector< T > &, FillMethod)
 Fill from vector. More...
 
template<typename T2 >
 RankFourTensorTempl (const RankFourTensorTempl< T2 > &copy)
 Copy constructor. More...
 
T & operator() (unsigned int i, unsigned int j, unsigned int k, unsigned int l)
 Gets the value for the index specified. Takes index = 0,1,2. More...
 
operator() (unsigned int i, unsigned int j, unsigned int k, unsigned int l) const
 Gets the value for the index specified. More...
 
void zero ()
 Zeros out the tensor. More...
 
void print (std::ostream &stm=Moose::out) const
 Print the rank four tensor. More...
 
RankFourTensorTempl< T > & operator= (const RankFourTensorTempl< T > &a)
 copies values from a into this tensor More...
 
template<typename Scalar >
boostcopy::enable_if_c< ScalarTraits< Scalar >::value, RankFourTensorTempl & >::type operator= (const Scalar &libmesh_dbg_var(p))
 Assignment-from-scalar operator. More...
 
template<template< typename > class Tensor, typename T2 >
auto operator* (const Tensor< T2 > &a) const -> typename std::enable_if< TwoTensorMultTraits< Tensor, T2 >::value, RankTwoTensorTempl< decltype(T() *T2())>>::type
 C_ijkl*a_kl. More...
 
template<typename T2 >
auto operator* (const T2 &a) const -> typename std::enable_if< ScalarTraits< T2 >::value, RankFourTensorTempl< decltype(T() *T2())>>::type
 C_ijkl*a. More...
 
RankFourTensorTempl< T > & operator*= (const T &a)
 C_ijkl *= a. More...
 
template<typename T2 >
auto operator/ (const T2 &a) const -> typename std::enable_if< ScalarTraits< T2 >::value, RankFourTensorTempl< decltype(T()/T2())>>::type
 C_ijkl/a. More...
 
RankFourTensorTempl< T > & operator/= (const T &a)
 C_ijkl /= a for all i, j, k, l. More...
 
RankFourTensorTempl< T > & operator+= (const RankFourTensorTempl< T > &a)
 C_ijkl += a_ijkl for all i, j, k, l. More...
 
template<typename T2 >
auto operator+ (const RankFourTensorTempl< T2 > &a) const -> RankFourTensorTempl< decltype(T()+T2())>
 C_ijkl + a_ijkl. More...
 
RankFourTensorTempl< T > & operator-= (const RankFourTensorTempl< T > &a)
 C_ijkl -= a_ijkl. More...
 
template<typename T2 >
auto operator- (const RankFourTensorTempl< T2 > &a) const -> RankFourTensorTempl< decltype(T() - T2())>
 C_ijkl - a_ijkl. More...
 
RankFourTensorTempl< T > operator- () const
 -C_ijkl More...
 
template<typename T2 >
auto operator* (const RankFourTensorTempl< T2 > &a) const -> RankFourTensorTempl< decltype(T() *T2())>
 C_ijpq*a_pqkl. More...
 
L2norm () const
 sqrt(C_ijkl*C_ijkl) More...
 
RankFourTensorTempl< 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 that C_ijkl = C_jikl = C_ijlk. More...
 
void rotate (const TypeTensor< T > &R)
 Rotate the tensor using C_ijkl = R_im R_in R_ko R_lp C_mnop. More...
 
RankFourTensorTempl< T > transposeMajor () const
 Transpose the tensor by swapping the first pair with the second pair of indices. More...
 
void surfaceFillFromInputVector (const std::vector< T > &input)
 Fills the tensor entries ignoring the last dimension (ie, C_ijkl=0 if any of i, j, k, or l = 3). More...
 
void fillFromInputVector (const std::vector< T > &input, FillMethod fill_method)
 fillFromInputVector takes some number of inputs to fill the Rank-4 tensor. More...
 
RankTwoTensorTempl< T > innerProductTranspose (const RankTwoTensorTempl< T > &) const
 Inner product of the major transposed tensor with a rank two tensor. More...
 
sum3x3 () const
 Calculates the sum of Ciijj for i and j varying from 0 to 2. More...
 
VectorValue< T > sum3x1 () const
 Calculates the vector a[i] = sum over j Ciijj for i and j varying from 0 to 2. More...
 
bool isSymmetric () const
 checks if the tensor is symmetric More...
 
bool isIsotropic () const
 checks if the tensor is isotropic More...
 
template<>
RankFourTensorTempl< DualRealinvSymm () const
 
void fillGeneralIsotropic (T i0, T i1, T i2)
 Vector-less fill API functions. See docs of the corresponding ...FromInputVector methods. More...
 
void fillAntisymmetricIsotropic (T i0)
 
void fillSymmetricIsotropic (T i0, T i1)
 
void fillSymmetricIsotropicEandNu (T E, T nu)
 

Static Public Member Functions

static RankFourTensorTempl< T > Identity ()
 
static RankFourTensorTempl< T > IdentityFour ()
 
static MooseEnum fillMethodEnum ()
 Static method for use in validParams for getting the "fill_method". More...
 

Protected Member Functions

void fillSymmetricFromInputVector (const std::vector< T > &input, bool all)
 fillSymmetricFromInputVector takes either 21 (all=true) or 9 (all=false) inputs to fill in the Rank-4 tensor with the appropriate crystal symmetries maintained. More...
 
void fillAntisymmetricFromInputVector (const std::vector< T > &input)
 fillAntisymmetricFromInputVector takes 6 inputs to fill the the antisymmetric Rank-4 tensor with the appropriate symmetries maintained. More...
 
void fillGeneralIsotropicFromInputVector (const std::vector< T > &input)
 fillGeneralIsotropicFromInputVector takes 3 inputs to fill the Rank-4 tensor with symmetries C_ijkl = C_klij, and isotropy, ie C_ijkl = la*de_ij*de_kl + mu*(de_ik*de_jl + de_il*de_jk) + a*ep_ijm*ep_klm where la is the first Lame modulus, mu is the second (shear) Lame modulus, and a is the antisymmetric shear modulus, and ep is the permutation tensor More...
 
void fillAntisymmetricIsotropicFromInputVector (const std::vector< T > &input)
 fillAntisymmetricIsotropicFromInputVector takes 1 input to fill the the antisymmetric Rank-4 tensor with the appropriate symmetries maintained. More...
 
void fillSymmetricIsotropicFromInputVector (const std::vector< T > &input)
 fillSymmetricIsotropicFromInputVector takes 2 inputs to fill the the symmetric Rank-4 tensor with the appropriate symmetries maintained. More...
 
void fillSymmetricIsotropicEandNuFromInputVector (const std::vector< T > &input)
 fillSymmetricIsotropicEandNuFromInputVector is a variation of the fillSymmetricIsotropicFromInputVector which takes as inputs the more commonly used Young's modulus (E) and Poisson's ratio (nu) constants to fill the isotropic elasticity tensor. More...
 
void fillAxisymmetricRZFromInputVector (const std::vector< T > &input)
 fillAxisymmetricRZFromInputVector takes 5 inputs to fill the axisymmetric Rank-4 tensor with the appropriate symmetries maintatined for use with axisymmetric problems using coord_type = RZ. More...
 
void fillGeneralFromInputVector (const std::vector< T > &input)
 fillGeneralFromInputVector takes 81 inputs to fill the Rank-4 tensor No symmetries are explicitly maintained More...
 
void fillPrincipalFromInputVector (const std::vector< T > &input)
 fillPrincipalFromInputVector takes 9 inputs to fill a Rank-4 tensor C1111 = input0 C1122 = input1 C1133 = input2 C2211 = input3 C2222 = input4 C2233 = input5 C3311 = input6 C3322 = input7 C3333 = input8 with all other components being zero More...
 

Protected Attributes

_vals [N4]
 The values of the rank-four tensor stored by index=(((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) * LIBMESH_DIM + l) More...
 

Static Protected Attributes

static constexpr unsigned int N = LIBMESH_DIM
 Dimensionality of rank-four tensor. More...
 
static constexpr unsigned int N2 = N * N
 
static constexpr unsigned int N3 = N * N * N
 
static constexpr unsigned int N4 = N * N * N * N
 

Friends

template<typename T2 >
class RankTwoTensorTempl
 
template<typename T2 >
class RankFourTensorTempl
 
template<typename T2 >
class RankThreeTensorTempl
 
template<class T2 >
void dataStore (std::ostream &, RankFourTensorTempl< T2 > &, void *)
 
template<class T2 >
void dataLoad (std::istream &, RankFourTensorTempl< T2 > &, void *)
 

Detailed Description

template<typename T>
class RankFourTensorTempl< T >

RankFourTensorTempl is designed to handle any N-dimensional fourth order tensor, C.

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

Since N is hard-coded to 3, RankFourTensorTempl holds 81 separate C_ijkl entries. Within the code i = 0, 1, 2, but this object provides methods to extract the entries with i = 1, 2, 3, and some of the documentation is also written in this way.

Definition at line 115 of file MooseTypes.h.

Member Typedef Documentation

◆ index_type

template<typename T>
typedef tuple_of<4, unsigned int> RankFourTensorTempl< T >::index_type

Definition at line 65 of file RankFourTensor.h.

Member Enumeration Documentation

◆ FillMethod

template<typename T>
enum RankFourTensorTempl::FillMethod

To fill up the 81 entries in the 4th-order tensor, fillFromInputVector is called with one of the following fill_methods.

See the fill*FromInputVector functions for more details

Enumerator
antisymmetric 
symmetric9 
symmetric21 
general_isotropic 
symmetric_isotropic 
symmetric_isotropic_E_nu 
antisymmetric_isotropic 
axisymmetric_rz 
general 
principal 

Definition at line 81 of file RankFourTensor.h.

◆ InitMethod

template<typename T>
enum RankFourTensorTempl::InitMethod

Initialization method.

Enumerator
initNone 
initIdentity 
initIdentityFour 
initIdentitySymmetricFour 

Definition at line 68 of file RankFourTensor.h.

Constructor & Destructor Documentation

◆ RankFourTensorTempl() [1/4]

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

Default constructor; fills to zero.

Definition at line 54 of file RankFourTensor.C.

55 {
56  mooseAssert(N == 3, "RankFourTensorTempl<T> is currently only tested for 3 dimensions.");
57 
58  unsigned int index = 0;
59  for (unsigned int i = 0; i < N4; ++i)
60  _vals[index++] = 0.0;
61 }
static constexpr unsigned int N4
T _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
Dimensionality of rank-four tensor.

◆ RankFourTensorTempl() [2/4]

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

Select specific initialization pattern.

Definition at line 64 of file RankFourTensor.C.

65 {
66  unsigned int index = 0;
67  switch (init)
68  {
69  case initNone:
70  break;
71 
72  case initIdentity:
73  zero();
74  for (unsigned int i = 0; i < N; ++i)
75  (*this)(i, i, i, i) = 1.0;
76  break;
77 
78  case initIdentityFour:
79  for (unsigned int i = 0; i < N; ++i)
80  for (unsigned int j = 0; j < N; ++j)
81  for (unsigned int k = 0; k < N; ++k)
82  for (unsigned int l = 0; l < N; ++l)
83  _vals[index++] = (i == k) && (j == l);
84  break;
85 
87  for (unsigned int i = 0; i < N; ++i)
88  for (unsigned int j = 0; j < N; ++j)
89  for (unsigned int k = 0; k < N; ++k)
90  for (unsigned int l = 0; l < N; ++l)
91  _vals[index++] = 0.5 * ((i == k) && (j == l)) + 0.5 * ((i == l) && (j == k));
92  break;
93 
94  default:
95  mooseError("Unknown RankFourTensorTempl<T> initialization pattern.");
96  }
97 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:207
void zero()
Zeros out the tensor.
T _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
Dimensionality of rank-four tensor.

◆ RankFourTensorTempl() [3/4]

template<typename T>
RankFourTensorTempl< T >::RankFourTensorTempl ( const std::vector< T > &  input,
FillMethod  fill_method 
)

Fill from vector.

Definition at line 100 of file RankFourTensor.C.

101 {
102  fillFromInputVector(input, fill_method);
103 }
void fillFromInputVector(const std::vector< T > &input, FillMethod fill_method)
fillFromInputVector takes some number of inputs to fill the Rank-4 tensor.

◆ RankFourTensorTempl() [4/4]

template<typename T >
template<typename T2 >
RankFourTensorTempl< T >::RankFourTensorTempl ( const RankFourTensorTempl< T2 > &  copy)

Copy constructor.

Definition at line 429 of file RankFourTensor.h.

430 {
431  for (unsigned int i = 0; i < N4; ++i)
432  _vals[i] = copy._vals[i];
433 }
static constexpr unsigned int N4
T _vals[N4]
The values of the rank-four tensor stored by index=(((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) * LIBME...

Member Function Documentation

◆ fillAntisymmetricFromInputVector()

template<typename T>
void RankFourTensorTempl< T >::fillAntisymmetricFromInputVector ( const std::vector< T > &  input)
protected

fillAntisymmetricFromInputVector takes 6 inputs to fill the the antisymmetric Rank-4 tensor with the appropriate symmetries maintained.

I.e., B_ijkl = -B_jikl = -B_ijlk = B_klij

Parameters
inputthis is B1212, B1213, B1223, B1313, B1323, B2323.

Definition at line 622 of file RankFourTensor.C.

623 {
624  if (input.size() != 6)
625  mooseError(
626  "To use fillAntisymmetricFromInputVector, your input must have size 6. Yours has size ",
627  input.size());
628 
629  zero();
630 
631  (*this)(0, 1, 0, 1) = input[0]; // B1212
632  (*this)(0, 1, 0, 2) = input[1]; // B1213
633  (*this)(0, 1, 1, 2) = input[2]; // B1223
634 
635  (*this)(0, 2, 0, 2) = input[3]; // B1313
636  (*this)(0, 2, 1, 2) = input[4]; // B1323
637 
638  (*this)(1, 2, 1, 2) = input[5]; // B2323
639 
640  // symmetry on the two pairs
641  (*this)(0, 2, 0, 1) = (*this)(0, 1, 0, 2);
642  (*this)(1, 2, 0, 1) = (*this)(0, 1, 1, 2);
643  (*this)(1, 2, 0, 2) = (*this)(0, 2, 1, 2);
644  // have now got the upper parts of vals[0][1], vals[0][2] and vals[1][2]
645 
646  // fill in from antisymmetry relations
647  for (unsigned int i = 0; i < N; ++i)
648  for (unsigned int j = 0; j < N; ++j)
649  {
650  (*this)(0, 1, j, i) = -(*this)(0, 1, i, j);
651  (*this)(0, 2, j, i) = -(*this)(0, 2, i, j);
652  (*this)(1, 2, j, i) = -(*this)(1, 2, i, j);
653  }
654  // have now got all of vals[0][1], vals[0][2] and vals[1][2]
655 
656  // fill in from antisymmetry relations
657  for (unsigned int i = 0; i < N; ++i)
658  for (unsigned int j = 0; j < N; ++j)
659  {
660  (*this)(1, 0, i, j) = -(*this)(0, 1, i, j);
661  (*this)(2, 0, i, j) = -(*this)(0, 2, i, j);
662  (*this)(2, 1, i, j) = -(*this)(1, 2, i, j);
663  }
664 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:207
void zero()
Zeros out the tensor.
static constexpr unsigned int N
Dimensionality of rank-four tensor.

◆ fillAntisymmetricIsotropic()

template<typename T>
void RankFourTensorTempl< T >::fillAntisymmetricIsotropic ( i0)

Definition at line 708 of file RankFourTensor.C.

709 {
710  fillGeneralIsotropic(0.0, 0.0, i0);
711 }
void fillGeneralIsotropic(T i0, T i1, T i2)
Vector-less fill API functions. See docs of the corresponding ...FromInputVector methods.

◆ fillAntisymmetricIsotropicFromInputVector()

template<typename T>
void RankFourTensorTempl< T >::fillAntisymmetricIsotropicFromInputVector ( const std::vector< T > &  input)
protected

fillAntisymmetricIsotropicFromInputVector takes 1 input to fill the the antisymmetric Rank-4 tensor with the appropriate symmetries maintained.

I.e., C_ijkl = a * ep_ijm * ep_klm, where epsilon is the permutation tensor (and sum on m)

Parameters
inputthis is a in the above formula

Definition at line 697 of file RankFourTensor.C.

698 {
699  if (input.size() != 1)
700  mooseError("To use fillAntisymmetricIsotropicFromInputVector, your input must have size 1. "
701  "Yours has size ",
702  input.size());
703  fillGeneralIsotropic(0.0, 0.0, input[0]);
704 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:207
void fillGeneralIsotropic(T i0, T i1, T i2)
Vector-less fill API functions. See docs of the corresponding ...FromInputVector methods.

◆ fillAxisymmetricRZFromInputVector()

template<typename T>
void RankFourTensorTempl< T >::fillAxisymmetricRZFromInputVector ( const std::vector< T > &  input)
protected

fillAxisymmetricRZFromInputVector takes 5 inputs to fill the axisymmetric Rank-4 tensor with the appropriate symmetries maintatined for use with axisymmetric problems using coord_type = RZ.

I.e. C1111 = C2222, C1133 = C2233, C2323 = C3131 and C1212 = 0.5*(C1111-C1122)

Parameters
inputthis is C1111, C1122, C1133, C3333, C2323.

Definition at line 757 of file RankFourTensor.C.

758 {
759  if (input.size() != 5)
760  mooseError("To use fillAxisymmetricRZFromInputVector, your input must have size 5. Your "
761  "vector has size ",
762  input.size());
763 
764  // C1111 C1122 C1133 C2222 C2233=C1133
766  input[1],
767  input[2],
768  input[0],
769  input[2],
770  // C3333 C2323 C3131=C2323 C1212
771  input[3],
772  input[4],
773  input[4],
774  (input[0] - input[1]) * 0.5},
775  false);
776 }
void fillSymmetricFromInputVector(const std::vector< T > &input, bool all)
fillSymmetricFromInputVector takes either 21 (all=true) or 9 (all=false) inputs to fill in the Rank-4...
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:207

◆ fillFromInputVector()

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

fillFromInputVector takes some number of inputs to fill the Rank-4 tensor.

Parameters
inputthe numbers that will be placed in the tensor
fill_methodthis can be: antisymmetric (use fillAntisymmetricFromInputVector) symmetric9 (use fillSymmetricFromInputVector with all=false) symmetric21 (use fillSymmetricFromInputVector with all=true) general_isotropic (use fillGeneralIsotropicFrominputVector) symmetric_isotropic (use fillSymmetricIsotropicFromInputVector) antisymmetric_isotropic (use fillAntisymmetricIsotropicFromInputVector) axisymmetric_rz (use fillAxisymmetricRZFromInputVector) general (use fillGeneralFromInputVector) principal (use fillPrincipalFromInputVector)

Definition at line 519 of file RankFourTensor.C.

520 {
521  zero();
522 
523  switch (fill_method)
524  {
525  case antisymmetric:
527  break;
528  case symmetric9:
529  fillSymmetricFromInputVector(input, false);
530  break;
531  case symmetric21:
532  fillSymmetricFromInputVector(input, true);
533  break;
534  case general_isotropic:
536  break;
537  case symmetric_isotropic:
539  break;
542  break;
545  break;
546  case axisymmetric_rz:
548  break;
549  case general:
551  break;
552  case principal:
554  break;
555  default:
556  mooseError("fillFromInputVector called with unknown fill_method of ", fill_method);
557  }
558 }
void fillGeneralFromInputVector(const std::vector< T > &input)
fillGeneralFromInputVector takes 81 inputs to fill the Rank-4 tensor No symmetries are explicitly mai...
void fillAntisymmetricFromInputVector(const std::vector< T > &input)
fillAntisymmetricFromInputVector takes 6 inputs to fill the the antisymmetric Rank-4 tensor with the ...
void fillSymmetricFromInputVector(const std::vector< T > &input, bool all)
fillSymmetricFromInputVector takes either 21 (all=true) or 9 (all=false) inputs to fill in the Rank-4...
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:207
void fillPrincipalFromInputVector(const std::vector< T > &input)
fillPrincipalFromInputVector takes 9 inputs to fill a Rank-4 tensor C1111 = input0 C1122 = input1 C11...
void fillGeneralIsotropicFromInputVector(const std::vector< T > &input)
fillGeneralIsotropicFromInputVector takes 3 inputs to fill the Rank-4 tensor with symmetries C_ijkl =...
void zero()
Zeros out the tensor.
void fillAxisymmetricRZFromInputVector(const std::vector< T > &input)
fillAxisymmetricRZFromInputVector takes 5 inputs to fill the axisymmetric Rank-4 tensor with the appr...
void fillSymmetricIsotropicEandNuFromInputVector(const std::vector< T > &input)
fillSymmetricIsotropicEandNuFromInputVector is a variation of the fillSymmetricIsotropicFromInputVect...
void fillSymmetricIsotropicFromInputVector(const std::vector< T > &input)
fillSymmetricIsotropicFromInputVector takes 2 inputs to fill the the symmetric Rank-4 tensor with the...
void fillAntisymmetricIsotropicFromInputVector(const std::vector< T > &input)
fillAntisymmetricIsotropicFromInputVector takes 1 input to fill the the antisymmetric Rank-4 tensor w...

◆ fillGeneralFromInputVector()

template<typename T>
void RankFourTensorTempl< T >::fillGeneralFromInputVector ( const std::vector< T > &  input)
protected

fillGeneralFromInputVector takes 81 inputs to fill the Rank-4 tensor No symmetries are explicitly maintained

Parameters
inputC(i,j,k,l) = input[i*N*N*N + j*N*N + k*N + l]

Definition at line 780 of file RankFourTensor.C.

781 {
782  if (input.size() != 81)
783  mooseError("To use fillGeneralFromInputVector, your input must have size 81. Yours has size ",
784  input.size());
785 
786  for (unsigned int i = 0; i < N4; ++i)
787  _vals[i] = input[i];
788 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:207
static constexpr unsigned int N4
T _vals[N4]
The values of the rank-four tensor stored by index=(((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) * LIBME...

◆ fillGeneralIsotropic()

template<typename T>
void RankFourTensorTempl< T >::fillGeneralIsotropic ( i0,
i1,
i2 
)

Vector-less fill API functions. See docs of the corresponding ...FromInputVector methods.

Definition at line 680 of file RankFourTensor.C.

681 {
682  for (unsigned int i = 0; i < N; ++i)
683  for (unsigned int j = 0; j < N; ++j)
684  for (unsigned int k = 0; k < N; ++k)
685  for (unsigned int l = 0; l < N; ++l)
686  {
687  (*this)(i, j, k, l) =
688  i0 * (i == j) * (k == l) + i1 * (i == k) * (j == l) + i1 * (i == l) * (j == k);
689  for (unsigned int m = 0; m < N; ++m)
690  (*this)(i, j, k, l) +=
691  i2 * PermutationTensor::eps(i, j, m) * PermutationTensor::eps(k, l, m);
692  }
693 }
int eps(unsigned int i, unsigned int j)
2D version
PetscInt m
static constexpr unsigned int N
Dimensionality of rank-four tensor.

◆ fillGeneralIsotropicFromInputVector()

template<typename T>
void RankFourTensorTempl< T >::fillGeneralIsotropicFromInputVector ( const std::vector< T > &  input)
protected

fillGeneralIsotropicFromInputVector takes 3 inputs to fill the Rank-4 tensor with symmetries C_ijkl = C_klij, and isotropy, ie C_ijkl = la*de_ij*de_kl + mu*(de_ik*de_jl + de_il*de_jk) + a*ep_ijm*ep_klm where la is the first Lame modulus, mu is the second (shear) Lame modulus, and a is the antisymmetric shear modulus, and ep is the permutation tensor

Parameters
inputthis is la, mu, a in the above formula

Definition at line 668 of file RankFourTensor.C.

669 {
670  if (input.size() != 3)
671  mooseError(
672  "To use fillGeneralIsotropicFromInputVector, your input must have size 3. Yours has size ",
673  input.size());
674 
675  fillGeneralIsotropic(input[0], input[1], input[2]);
676 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:207
void fillGeneralIsotropic(T i0, T i1, T i2)
Vector-less fill API functions. See docs of the corresponding ...FromInputVector methods.

◆ fillMethodEnum()

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

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

Definition at line 46 of file RankFourTensor.C.

47 {
48  return MooseEnum("antisymmetric symmetric9 symmetric21 general_isotropic symmetric_isotropic "
49  "symmetric_isotropic_E_nu antisymmetric_isotropic axisymmetric_rz general "
50  "principal");
51 }
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:31

◆ fillPrincipalFromInputVector()

template<typename T>
void RankFourTensorTempl< T >::fillPrincipalFromInputVector ( const std::vector< T > &  input)
protected

fillPrincipalFromInputVector takes 9 inputs to fill a Rank-4 tensor C1111 = input0 C1122 = input1 C1133 = input2 C2211 = input3 C2222 = input4 C2233 = input5 C3311 = input6 C3322 = input7 C3333 = input8 with all other components being zero

Definition at line 792 of file RankFourTensor.C.

793 {
794  if (input.size() != 9)
795  mooseError("To use fillPrincipalFromInputVector, your input must have size 9. Yours has size ",
796  input.size());
797 
798  zero();
799 
800  (*this)(0, 0, 0, 0) = input[0];
801  (*this)(0, 0, 1, 1) = input[1];
802  (*this)(0, 0, 2, 2) = input[2];
803  (*this)(1, 1, 0, 0) = input[3];
804  (*this)(1, 1, 1, 1) = input[4];
805  (*this)(1, 1, 2, 2) = input[5];
806  (*this)(2, 2, 0, 0) = input[6];
807  (*this)(2, 2, 1, 1) = input[7];
808  (*this)(2, 2, 2, 2) = input[8];
809 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:207
void zero()
Zeros out the tensor.

◆ fillSymmetricFromInputVector()

template<typename T>
void RankFourTensorTempl< T >::fillSymmetricFromInputVector ( const std::vector< T > &  input,
bool  all 
)
protected

fillSymmetricFromInputVector takes either 21 (all=true) or 9 (all=false) inputs to fill in the Rank-4 tensor with the appropriate crystal symmetries maintained.

I.e., C_ijkl = C_klij, C_ijkl = C_ijlk, C_ijkl = C_jikl

Parameters
inputIf all==true then this is C1111 C1122 C1133 C2222 C2233 C3333 C2323 C1313 C1212 In the isotropic case this is (la is first Lame constant, mu is second (shear) Lame constant) la+2mu la la la+2mu la la+2mu mu mu mu If all==false then this is C1111 C1122 C1133 C1123 C1113 C1112 C2222 C2233 C2223 C2213 C2212 C3333 C3323 C3313 C3312 C2323 C2313 C2312 C1313 C1312 C1212
allDetermines the compoinents passed in vis the input parameter

Definition at line 562 of file RankFourTensor.C.

563 {
564  if ((all == true && input.size() != 21) || (all == false && input.size() != 9))
565  mooseError("Please check the number of entries in the stiffness input vector.");
566 
567  zero();
568 
569  if (all == true)
570  {
571  (*this)(0, 0, 0, 0) = input[0]; // C1111
572  (*this)(0, 0, 1, 1) = input[1]; // C1122
573  (*this)(0, 0, 2, 2) = input[2]; // C1133
574  (*this)(0, 0, 1, 2) = input[3]; // C1123
575  (*this)(0, 0, 0, 2) = input[4]; // C1113
576  (*this)(0, 0, 0, 1) = input[5]; // C1112
577 
578  (*this)(1, 1, 1, 1) = input[6]; // C2222
579  (*this)(1, 1, 2, 2) = input[7]; // C2233
580  (*this)(1, 1, 1, 2) = input[8]; // C2223
581  (*this)(0, 2, 1, 1) = input[9]; // C2213 //flipped for filling purposes
582  (*this)(0, 1, 1, 1) = input[10]; // C2212 //flipped for filling purposes
583 
584  (*this)(2, 2, 2, 2) = input[11]; // C3333
585  (*this)(1, 2, 2, 2) = input[12]; // C3323 //flipped for filling purposes
586  (*this)(0, 2, 2, 2) = input[13]; // C3313 //flipped for filling purposes
587  (*this)(0, 1, 2, 2) = input[14]; // C3312 //flipped for filling purposes
588 
589  (*this)(1, 2, 1, 2) = input[15]; // C2323
590  (*this)(0, 2, 1, 2) = input[16]; // C2313 //flipped for filling purposes
591  (*this)(0, 1, 1, 2) = input[17]; // C2312 //flipped for filling purposes
592 
593  (*this)(0, 2, 0, 2) = input[18]; // C1313
594  (*this)(0, 1, 0, 2) = input[19]; // C1312 //flipped for filling purposes
595 
596  (*this)(0, 1, 0, 1) = input[20]; // C1212
597  }
598  else
599  {
600  (*this)(0, 0, 0, 0) = input[0]; // C1111
601  (*this)(0, 0, 1, 1) = input[1]; // C1122
602  (*this)(0, 0, 2, 2) = input[2]; // C1133
603  (*this)(1, 1, 1, 1) = input[3]; // C2222
604  (*this)(1, 1, 2, 2) = input[4]; // C2233
605  (*this)(2, 2, 2, 2) = input[5]; // C3333
606  (*this)(1, 2, 1, 2) = input[6]; // C2323
607  (*this)(0, 2, 0, 2) = input[7]; // C1313
608  (*this)(0, 1, 0, 1) = input[8]; // C1212
609  }
610 
611  // fill in from symmetry relations
612  for (unsigned int i = 0; i < N; ++i)
613  for (unsigned int j = 0; j < N; ++j)
614  for (unsigned int k = 0; k < N; ++k)
615  for (unsigned int l = 0; l < N; ++l)
616  (*this)(i, j, l, k) = (*this)(j, i, k, l) = (*this)(j, i, l, k) = (*this)(k, l, i, j) =
617  (*this)(l, k, j, i) = (*this)(k, l, j, i) = (*this)(l, k, i, j) = (*this)(i, j, k, l);
618 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:207
void zero()
Zeros out the tensor.
static constexpr unsigned int N
Dimensionality of rank-four tensor.

◆ fillSymmetricIsotropic()

template<typename T>
void RankFourTensorTempl< T >::fillSymmetricIsotropic ( i0,
i1 
)

Definition at line 726 of file RankFourTensor.C.

727 {
728  fillGeneralIsotropic(i0, i1, 0.0);
729 }
void fillGeneralIsotropic(T i0, T i1, T i2)
Vector-less fill API functions. See docs of the corresponding ...FromInputVector methods.

◆ fillSymmetricIsotropicEandNu()

template<typename T>
void RankFourTensorTempl< T >::fillSymmetricIsotropicEandNu ( E,
nu 
)

Definition at line 746 of file RankFourTensor.C.

747 {
748  // Calculate lambda and the shear modulus from the given young's modulus and poisson's ratio
749  const T & lambda = E * nu / ((1.0 + nu) * (1.0 - 2.0 * nu));
750  const T & G = E / (2.0 * (1.0 + nu));
751 
752  fillGeneralIsotropic(lambda, G, 0.0);
753 }
void fillGeneralIsotropic(T i0, T i1, T i2)
Vector-less fill API functions. See docs of the corresponding ...FromInputVector methods.

◆ fillSymmetricIsotropicEandNuFromInputVector()

template<typename T>
void RankFourTensorTempl< T >::fillSymmetricIsotropicEandNuFromInputVector ( const std::vector< T > &  input)
protected

fillSymmetricIsotropicEandNuFromInputVector is a variation of the fillSymmetricIsotropicFromInputVector which takes as inputs the more commonly used Young's modulus (E) and Poisson's ratio (nu) constants to fill the isotropic elasticity tensor.

Using well-known formulas, E and nu are used to calculate lambda and mu and then the vector is passed to fillSymmetricIsotropicFromInputVector.

Parameters
inputYoung's modulus (E) and Poisson's ratio (nu)

Definition at line 733 of file RankFourTensor.C.

734 {
735  if (input.size() != 2)
736  mooseError(
737  "To use fillSymmetricIsotropicEandNuFromInputVector, your input must have size 2. Yours "
738  "has size ",
739  input.size());
740 
741  fillSymmetricIsotropicEandNu(input[0], input[1]);
742 }
void fillSymmetricIsotropicEandNu(T E, T nu)
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:207

◆ fillSymmetricIsotropicFromInputVector()

template<typename T>
void RankFourTensorTempl< T >::fillSymmetricIsotropicFromInputVector ( const std::vector< T > &  input)
protected

fillSymmetricIsotropicFromInputVector takes 2 inputs to fill the the symmetric Rank-4 tensor with the appropriate symmetries maintained.

C_ijkl = lambda*de_ij*de_kl + mu*(de_ik*de_jl + de_il*de_jk) where lambda is the first Lame modulus, mu is the second (shear) Lame modulus,

Parameters
inputthis is lambda and mu in the above formula

Definition at line 715 of file RankFourTensor.C.

716 {
717  if (input.size() != 2)
718  mooseError("To use fillSymmetricIsotropicFromInputVector, your input must have size 2. Yours "
719  "has size ",
720  input.size());
721  fillGeneralIsotropic(input[0], input[1], 0.0);
722 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:207
void fillGeneralIsotropic(T i0, T i1, T i2)
Vector-less fill API functions. See docs of the corresponding ...FromInputVector methods.

◆ Identity()

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

Definition at line 132 of file RankFourTensor.h.

RankFourTensorTempl is designed to handle any N-dimensional fourth order tensor, C.
Definition: MooseTypes.h:115

◆ IdentityFour()

template<typename T>
static RankFourTensorTempl<T> RankFourTensorTempl< T >::IdentityFour ( )
inlinestatic

Definition at line 133 of file RankFourTensor.h.

RankFourTensorTempl is designed to handle any N-dimensional fourth order tensor, C.
Definition: MooseTypes.h:115

◆ innerProductTranspose()

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

Inner product of the major transposed tensor with a rank two tensor.

Definition at line 813 of file RankFourTensor.C.

814 {
815  RankTwoTensorTempl<T> result;
816 
817  unsigned int index = 0;
818  for (unsigned int ij = 0; ij < N2; ++ij)
819  {
820  T bb = b._coords[ij];
821  for (unsigned int kl = 0; kl < N2; ++kl)
822  result._coords[kl] += _vals[index++] * bb;
823  }
824 
825  return result;
826 }
static constexpr unsigned int N2
T _vals[N4]
The values of the rank-four tensor stored by index=(((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) * LIBME...
RankTwoTensorTempl is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: MooseTypes.h:111

◆ invSymm() [1/2]

template<typename T >
RankFourTensorTempl< T > RankFourTensorTempl< 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 that C_ijkl = C_jikl = C_ijlk.

Definition at line 262 of file RankFourTensor.C.

263 {
264  unsigned int ntens = N * (N + 1) / 2;
265  int nskip = N - 1;
266 
267  RankFourTensorTempl<T> result;
268  std::vector<PetscScalar> mat;
269  mat.assign(ntens * ntens, 0);
270 
271  // We use the LAPACK matrix inversion routine here. Form the matrix
272  //
273  // mat[0] mat[1] mat[2] mat[3] mat[4] mat[5]
274  // mat[6] mat[7] mat[8] mat[9] mat[10] mat[11]
275  // mat[12] mat[13] mat[14] mat[15] mat[16] mat[17]
276  // mat[18] mat[19] mat[20] mat[21] mat[22] mat[23]
277  // mat[24] mat[25] mat[26] mat[27] mat[28] mat[29]
278  // mat[30] mat[31] mat[32] mat[33] mat[34] mat[35]
279  //
280  // This is filled from the indpendent components of C assuming
281  // the symmetry C_ijkl = C_ijlk = C_jikl.
282  //
283  // If there are two rank-four tensors X and Y then the reason for
284  // this filling becomes apparent if we want to calculate
285  // X_ijkl*Y_klmn = Z_ijmn
286  // For denote the "mat" versions of X, Y and Z by x, y and z.
287  // Then
288  // z_ab = x_ac*y_cb
289  // Eg
290  // z_00 = Z_0000 = X_0000*Y_0000 + X_0011*Y_1111 + X_0022*Y_2200 + 2*X_0001*Y_0100 +
291  // 2*X_0002*Y_0200 + 2*X_0012*Y_1200 (the factors of 2 come from the assumed symmetries)
292  // z_03 = 2*Z_0001 = X_0000*2*Y_0001 + X_0011*2*Y_1101 + X_0022*2*Y_2201 + 2*X_0001*2*Y_0101 +
293  // 2*X_0002*2*Y_0201 + 2*X_0012*2*Y_1201
294  // z_22 = 2*Z_0102 = X_0100*2*Y_0002 + X_0111*2*X_1102 + X_0122*2*Y_2202 + 2*X_0101*2*Y_0102 +
295  // 2*X_0102*2*Y_0202 + 2*X_0112*2*Y_1202
296  // Finally, we use LAPACK to find x^-1, and put it back into rank-4 tensor form
297  //
298  // mat[0] = C(0,0,0,0)
299  // mat[1] = C(0,0,1,1)
300  // mat[2] = C(0,0,2,2)
301  // mat[3] = C(0,0,0,1)*2
302  // mat[4] = C(0,0,0,2)*2
303  // mat[5] = C(0,0,1,2)*2
304 
305  // mat[6] = C(1,1,0,0)
306  // mat[7] = C(1,1,1,1)
307  // mat[8] = C(1,1,2,2)
308  // mat[9] = C(1,1,0,1)*2
309  // mat[10] = C(1,1,0,2)*2
310  // mat[11] = C(1,1,1,2)*2
311 
312  // mat[12] = C(2,2,0,0)
313  // mat[13] = C(2,2,1,1)
314  // mat[14] = C(2,2,2,2)
315  // mat[15] = C(2,2,0,1)*2
316  // mat[16] = C(2,2,0,2)*2
317  // mat[17] = C(2,2,1,2)*2
318 
319  // mat[18] = C(0,1,0,0)
320  // mat[19] = C(0,1,1,1)
321  // mat[20] = C(0,1,2,2)
322  // mat[21] = C(0,1,0,1)*2
323  // mat[22] = C(0,1,0,2)*2
324  // mat[23] = C(0,1,1,2)*2
325 
326  // mat[24] = C(0,2,0,0)
327  // mat[25] = C(0,2,1,1)
328  // mat[26] = C(0,2,2,2)
329  // mat[27] = C(0,2,0,1)*2
330  // mat[28] = C(0,2,0,2)*2
331  // mat[29] = C(0,2,1,2)*2
332 
333  // mat[30] = C(1,2,0,0)
334  // mat[31] = C(1,2,1,1)
335  // mat[32] = C(1,2,2,2)
336  // mat[33] = C(1,2,0,1)*2
337  // mat[34] = C(1,2,0,2)*2
338  // mat[35] = C(1,2,1,2)*2
339 
340  unsigned int index = 0;
341  for (unsigned int i = 0; i < N; ++i)
342  for (unsigned int j = 0; j < N; ++j)
343  for (unsigned int k = 0; k < N; ++k)
344  for (unsigned int l = 0; l < N; ++l)
345  {
346  if (i == j)
347  mat[k == l ? i * ntens + k : i * ntens + k + nskip + l] += _vals[index];
348  else // i!=j
349  mat[k == l ? (nskip + i + j) * ntens + k : (nskip + i + j) * ntens + k + nskip + l] +=
350  _vals[index]; // note the +=, which results in double-counting and is rectified
351  // below
352  index++;
353  }
354 
355  for (unsigned int i = 3; i < ntens; ++i)
356  for (unsigned int j = 0; j < ntens; ++j)
357  mat[i * ntens + j] /= 2.0; // because of double-counting above
358 
359  // use LAPACK to find the inverse
360  MatrixTools::inverse(mat, ntens);
361 
362  // build the resulting rank-four tensor
363  // using the inverse of the above algorithm
364  index = 0;
365  for (unsigned int i = 0; i < N; ++i)
366  for (unsigned int j = 0; j < N; ++j)
367  for (unsigned int k = 0; k < N; ++k)
368  for (unsigned int l = 0; l < N; ++l)
369  {
370  if (i == j)
371  result._vals[index] =
372  k == l ? mat[i * ntens + k] : mat[i * ntens + k + nskip + l] / 2.0;
373  else // i!=j
374  result._vals[index] = k == l ? mat[(nskip + i + j) * ntens + k]
375  : mat[(nskip + i + j) * ntens + k + nskip + l] / 2.0;
376  index++;
377  }
378 
379  return result;
380 }
RankFourTensorTempl is designed to handle any N-dimensional fourth order tensor, C.
Definition: MooseTypes.h:115
void inverse(const std::vector< std::vector< Real >> &m, std::vector< std::vector< Real >> &m_inv)
Inverse the dense square matrix m using LAPACK routines.
Definition: MatrixTools.C:27
T _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
Dimensionality of rank-four tensor.

◆ invSymm() [2/2]

template<>
RankFourTensorTempl< DualReal > RankFourTensorTempl< DualReal >::invSymm ( ) const

Definition at line 384 of file RankFourTensor.C.

385 {
386  mooseError("The invSymm operation calls to LAPACK, so AD is not supported.");
387  return {};
388 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:207

◆ isIsotropic()

template<typename T >
bool RankFourTensorTempl< T >::isIsotropic ( ) const

checks if the tensor is isotropic

Definition at line 873 of file RankFourTensor.C.

874 {
875  // prerequisite is symmetry
876  if (!isSymmetric())
877  return false;
878 
879  // inspect shear components
880  const T & mu = (*this)(0, 1, 0, 1);
881  // ...diagonal
882  if ((*this)(1, 2, 1, 2) != mu || (*this)(2, 0, 2, 0) != mu)
883  return false;
884  // ...off-diagonal
885  if ((*this)(2, 0, 1, 2) != 0.0 || (*this)(0, 1, 1, 2) != 0.0 || (*this)(0, 1, 2, 0) != 0.0)
886  return false;
887 
888  // off diagonal blocks in Voigt
889  unsigned int i1 = 0;
890  for (unsigned int i = 0; i < N; ++i)
891  {
892  for (unsigned int j = 0; j < N; ++j)
893  if (_vals[i1 + ((j + 1) % N) * N + (j + 2) % N] != 0.0)
894  return false;
895  i1 += N3 + N2;
896  }
897 
898  // top left block
899  const T & K1 = (*this)(0, 0, 0, 0);
900  const T & K2 = (*this)(0, 0, 1, 1);
901  if (!MooseUtils::relativeFuzzyEqual(K1 - 4.0 * mu / 3.0, K2 + 2.0 * mu / 3.0))
902  return false;
903  if ((*this)(1, 1, 1, 1) != K1 || (*this)(2, 2, 2, 2) != K1)
904  return false;
905  for (unsigned int i = 1; i < N; ++i)
906  for (unsigned int j = 0; j < i; ++j)
907  if ((*this)(i, i, j, j) != K2)
908  return false;
909 
910  return true;
911 }
static constexpr unsigned int N3
static constexpr unsigned int N2
bool isSymmetric() const
checks if the tensor is symmetric
T _vals[N4]
The values of the rank-four tensor stored by index=(((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) * LIBME...
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.
Definition: MooseUtils.h:344
static constexpr unsigned int N
Dimensionality of rank-four tensor.

◆ isSymmetric()

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

checks if the tensor is symmetric

Definition at line 852 of file RankFourTensor.C.

853 {
854  for (unsigned int i = 1; i < N; ++i)
855  for (unsigned int j = 0; j < i; ++j)
856  for (unsigned int k = 1; k < N; ++k)
857  for (unsigned int l = 0; l < k; ++l)
858  {
859  // minor symmetries
860  if ((*this)(i, j, k, l) != (*this)(j, i, k, l) ||
861  (*this)(i, j, k, l) != (*this)(i, j, l, k))
862  return false;
863 
864  // major symmetry
865  if ((*this)(i, j, k, l) != (*this)(k, l, i, j))
866  return false;
867  }
868  return true;
869 }
static constexpr unsigned int N
Dimensionality of rank-four tensor.

◆ L2norm()

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

sqrt(C_ijkl*C_ijkl)

Definition at line 250 of file RankFourTensor.C.

251 {
252  T l2 = 0;
253 
254  for (unsigned int i = 0; i < N4; ++i)
255  l2 += Utility::pow<2>(_vals[i]);
256 
257  return std::sqrt(l2);
258 }
static constexpr unsigned int N4
T _vals[N4]
The values of the rank-four tensor stored by index=(((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) * LIBME...

◆ operator()() [1/2]

template<typename T>
T& RankFourTensorTempl< T >::operator() ( unsigned int  i,
unsigned int  j,
unsigned int  k,
unsigned int  l 
)
inline

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

Definition at line 136 of file RankFourTensor.h.

137  {
138  return _vals[((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) * LIBMESH_DIM + l];
139  }
T _vals[N4]
The values of the rank-four tensor stored by index=(((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) * LIBME...

◆ operator()() [2/2]

template<typename T>
T RankFourTensorTempl< T >::operator() ( unsigned int  i,
unsigned int  j,
unsigned int  k,
unsigned int  l 
) const
inline

Gets the value for the index specified.

Takes index = 0,1,2 used for const

Definition at line 145 of file RankFourTensor.h.

146  {
147  return _vals[((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) * LIBMESH_DIM + l];
148  }
T _vals[N4]
The values of the rank-four tensor stored by index=(((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) * LIBME...

◆ operator*() [1/3]

template<typename T>
template<template< typename > class Tensor, typename T2 >
auto RankFourTensorTempl< T >::operator* ( const Tensor< T2 > &  a) const -> typename std::enable_if<TwoTensorMultTraits<Tensor, T2>::value, RankTwoTensorTempl<decltype(T() * T2())>>::type

C_ijkl*a_kl.

Definition at line 124 of file RankFourTensor.C.

127 {
128  typedef decltype(T() * T2()) ValueType;
129  RankTwoTensorTempl<ValueType> result;
130 
131  unsigned int index = 0;
132  for (unsigned int ij = 0; ij < N2; ++ij)
133  {
134  ValueType tmp = 0;
135  for (unsigned int kl = 0; kl < N2; ++kl)
136  tmp += _vals[index++] * b(kl / LIBMESH_DIM, kl % LIBMESH_DIM);
137  result._coords[ij] = tmp;
138  }
139 
140  return result;
141 }
static constexpr unsigned int N2
T _vals[N4]
The values of the rank-four tensor stored by index=(((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) * LIBME...
RankTwoTensorTempl is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
Definition: MooseTypes.h:111

◆ operator*() [2/3]

template<typename T>
template<typename T2>
auto RankFourTensorTempl< T >::operator* ( const T2 &  a) const -> typename std::enable_if<ScalarTraits<T2>::value, RankFourTensorTempl<decltype(T() * T2())>>::type

C_ijkl*a.

Definition at line 437 of file RankFourTensor.h.

440 {
441  typedef decltype(T() * T2()) ValueType;
442  RankFourTensorTempl<ValueType> result;
443 
444  for (unsigned int i = 0; i < N4; ++i)
445  result._vals[i] = _vals[i] * b;
446 
447  return result;
448 }
RankFourTensorTempl is designed to handle any N-dimensional fourth order tensor, C.
Definition: MooseTypes.h:115
static constexpr unsigned int N4
T _vals[N4]
The values of the rank-four tensor stored by index=(((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) * LIBME...

◆ operator*() [3/3]

template<typename T>
template<typename T2>
auto RankFourTensorTempl< T >::operator* ( const RankFourTensorTempl< T2 > &  a) const -> RankFourTensorTempl<decltype(T() * T2())>

C_ijpq*a_pqkl.

Definition at line 215 of file RankFourTensor.C.

217 {
218  typedef decltype(T() * T2()) ValueType;
219  RankFourTensorTempl<ValueType> result;
220 
221  unsigned int index = 0;
222  unsigned int ij1 = 0;
223  for (unsigned int i = 0; i < N; ++i)
224  {
225  for (unsigned int j = 0; j < N; ++j)
226  {
227  for (unsigned int k = 0; k < N; ++k)
228  {
229  for (unsigned int l = 0; l < N; ++l)
230  {
231  ValueType sum = 0;
232  for (unsigned int p = 0; p < N; ++p)
233  {
234  unsigned int p1 = N * p;
235  for (unsigned int q = 0; q < N; ++q)
236  sum += _vals[ij1 + p1 + q] * b(p, q, k, l);
237  }
238  result._vals[index++] = sum;
239  }
240  }
241  ij1 += N2;
242  }
243  }
244 
245  return result;
246 }
RankFourTensorTempl is designed to handle any N-dimensional fourth order tensor, C.
Definition: MooseTypes.h:115
static constexpr unsigned int N2
T _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
Dimensionality of rank-four tensor.

◆ operator*=()

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

C_ijkl *= a.

Definition at line 145 of file RankFourTensor.C.

146 {
147  for (unsigned int i = 0; i < N4; ++i)
148  _vals[i] *= a;
149  return *this;
150 }
static constexpr unsigned int N4
T _vals[N4]
The values of the rank-four tensor stored by index=(((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) * LIBME...

◆ operator+()

template<typename T>
template<typename T2 >
template RankFourTensorTempl< DualReal > RankFourTensorTempl< T >::operator+ ( const RankFourTensorTempl< T2 > &  a) const -> RankFourTensorTempl< decltype(T()+T2())>

C_ijkl + a_ijkl.

Definition at line 173 of file RankFourTensor.C.

175 {
177  for (unsigned int i = 0; i < N4; ++i)
178  result._vals[i] = _vals[i] + b._vals[i];
179  return result;
180 }
RankFourTensorTempl is designed to handle any N-dimensional fourth order tensor, C.
Definition: MooseTypes.h:115
static constexpr unsigned int N4
T _vals[N4]
The values of the rank-four tensor stored by index=(((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) * LIBME...

◆ operator+=()

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

C_ijkl += a_ijkl for all i, j, k, l.

Definition at line 163 of file RankFourTensor.C.

164 {
165  for (unsigned int i = 0; i < N4; ++i)
166  _vals[i] += a._vals[i];
167  return *this;
168 }
static constexpr unsigned int N4
T _vals[N4]
The values of the rank-four tensor stored by index=(((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) * LIBME...

◆ operator-() [1/2]

template<typename T>
template<typename T2 >
auto RankFourTensorTempl< T >::operator- ( const RankFourTensorTempl< T2 > &  a) const -> RankFourTensorTempl<decltype(T() - T2())>

C_ijkl - a_ijkl.

Definition at line 194 of file RankFourTensor.C.

196 {
197  RankFourTensorTempl<decltype(T() - T2())> result;
198  for (unsigned int i = 0; i < N4; ++i)
199  result._vals[i] = _vals[i] - b._vals[i];
200  return result;
201 }
RankFourTensorTempl is designed to handle any N-dimensional fourth order tensor, C.
Definition: MooseTypes.h:115
static constexpr unsigned int N4
T _vals[N4]
The values of the rank-four tensor stored by index=(((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) * LIBME...

◆ operator-() [2/2]

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

-C_ijkl

Definition at line 205 of file RankFourTensor.C.

206 {
207  RankFourTensorTempl<T> result;
208  for (unsigned int i = 0; i < N4; ++i)
209  result._vals[i] = -_vals[i];
210  return result;
211 }
RankFourTensorTempl is designed to handle any N-dimensional fourth order tensor, C.
Definition: MooseTypes.h:115
static constexpr unsigned int N4
T _vals[N4]
The values of the rank-four tensor stored by index=(((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) * LIBME...

◆ operator-=()

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

C_ijkl -= a_ijkl.

Definition at line 184 of file RankFourTensor.C.

185 {
186  for (unsigned int i = 0; i < N4; ++i)
187  _vals[i] -= a._vals[i];
188  return *this;
189 }
static constexpr unsigned int N4
T _vals[N4]
The values of the rank-four tensor stored by index=(((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) * LIBME...

◆ operator/()

template<typename T>
template<typename T2 >
auto RankFourTensorTempl< T >::operator/ ( const T2 &  a) const -> typename std::enable_if<ScalarTraits<T2>::value, RankFourTensorTempl<decltype(T() / T2())>>::type

C_ijkl/a.

Definition at line 453 of file RankFourTensor.h.

456 {
457  RankFourTensorTempl<decltype(T() / T2())> result;
458  for (unsigned int i = 0; i < N4; ++i)
459  result._vals[i] = _vals[i] / b;
460  return result;
461 }
RankFourTensorTempl is designed to handle any N-dimensional fourth order tensor, C.
Definition: MooseTypes.h:115
static constexpr unsigned int N4
T _vals[N4]
The values of the rank-four tensor stored by index=(((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) * LIBME...

◆ operator/=()

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

C_ijkl /= a for all i, j, k, l.

Definition at line 154 of file RankFourTensor.C.

155 {
156  for (unsigned int i = 0; i < N4; ++i)
157  _vals[i] /= a;
158  return *this;
159 }
static constexpr unsigned int N4
T _vals[N4]
The values of the rank-four tensor stored by index=(((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) * LIBME...

◆ operator=() [1/2]

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

copies values from a into this tensor

Definition at line 115 of file RankFourTensor.C.

116 {
117  for (unsigned int i = 0; i < N4; ++i)
118  _vals[i] = a._vals[i];
119  return *this;
120 }
static constexpr unsigned int N4
T _vals[N4]
The values of the rank-four tensor stored by index=(((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) * LIBME...

◆ operator=() [2/2]

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

Assignment-from-scalar operator.

Used only to zero out the tensor.

Returns
A reference to *this.

Definition at line 166 of file RankFourTensor.h.

167  {
168  libmesh_assert_equal_to(p, Scalar(0));
169  this->zero();
170  return *this;
171  }
void zero()
Zeros out the tensor.

◆ print()

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

Print the rank four tensor.

Definition at line 430 of file RankFourTensor.C.

431 {
432  for (unsigned int i = 0; i < N; ++i)
433  for (unsigned int j = 0; j < N; ++j)
434  {
435  stm << "i = " << i << " j = " << j << '\n';
436  for (unsigned int k = 0; k < N; ++k)
437  {
438  for (unsigned int l = 0; l < N; ++l)
439  stm << std::setw(15) << (*this)(i, j, k, l) << " ";
440 
441  stm << '\n';
442  }
443  }
444 }
static constexpr unsigned int N
Dimensionality of rank-four tensor.

◆ rotate()

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

Rotate the tensor using C_ijkl = R_im R_in R_ko R_lp C_mnop.

Definition at line 392 of file RankFourTensor.C.

393 {
394  RankFourTensorTempl<T> old = *this;
395 
396  unsigned int index = 0;
397  for (unsigned int i = 0; i < N; ++i)
398  {
399  for (unsigned int j = 0; j < N; ++j)
400  {
401  for (unsigned int k = 0; k < N; ++k)
402  {
403  for (unsigned int l = 0; l < N; ++l)
404  {
405  unsigned int index2 = 0;
406  T sum = 0.0;
407  for (unsigned int m = 0; m < N; ++m)
408  {
409  const T & a = R(i, m);
410  for (unsigned int n = 0; n < N; ++n)
411  {
412  const T & ab = a * R(j, n);
413  for (unsigned int o = 0; o < N; ++o)
414  {
415  const T & abc = ab * R(k, o);
416  for (unsigned int p = 0; p < N; ++p)
417  sum += abc * R(l, p) * old._vals[index2++];
418  }
419  }
420  }
421  _vals[index++] = sum;
422  }
423  }
424  }
425  }
426 }
RankFourTensorTempl is designed to handle any N-dimensional fourth order tensor, C.
Definition: MooseTypes.h:115
PetscInt m
T _vals[N4]
The values of the rank-four tensor stored by index=(((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) * LIBME...
PetscInt n
static constexpr unsigned int N
Dimensionality of rank-four tensor.

◆ sum3x1()

template<typename T >
VectorValue< T > RankFourTensorTempl< T >::sum3x1 ( ) const

Calculates the vector a[i] = sum over j Ciijj for i and j varying from 0 to 2.

Definition at line 840 of file RankFourTensor.C.

841 {
842  // used for volumetric locking correction
843  VectorValue<T> a(3);
844  a(0) = (*this)(0, 0, 0, 0) + (*this)(0, 0, 1, 1) + (*this)(0, 0, 2, 2); // C0000 + C0011 + C0022
845  a(1) = (*this)(1, 1, 0, 0) + (*this)(1, 1, 1, 1) + (*this)(1, 1, 2, 2); // C1100 + C1111 + C1122
846  a(2) = (*this)(2, 2, 0, 0) + (*this)(2, 2, 1, 1) + (*this)(2, 2, 2, 2); // C2200 + C2211 + C2222
847  return a;
848 }

◆ sum3x3()

template<typename T >
T RankFourTensorTempl< T >::sum3x3 ( ) const

Calculates the sum of Ciijj for i and j varying from 0 to 2.

Definition at line 830 of file RankFourTensor.C.

831 {
832  // summation of Ciijj for i and j ranging from 0 to 2 - used in the volumetric locking correction
833  return (*this)(0, 0, 0, 0) + (*this)(0, 0, 1, 1) + (*this)(0, 0, 2, 2) + (*this)(1, 1, 0, 0) +
834  (*this)(1, 1, 1, 1) + (*this)(1, 1, 2, 2) + (*this)(2, 2, 0, 0) + (*this)(2, 2, 1, 1) +
835  (*this)(2, 2, 2, 2);
836 }

◆ surfaceFillFromInputVector()

template<typename T>
void RankFourTensorTempl< T >::surfaceFillFromInputVector ( const std::vector< T > &  input)

Fills the tensor entries ignoring the last dimension (ie, C_ijkl=0 if any of i, j, k, or l = 3).

Fill method depends on size of input Input size = 2. Then C_1111 = C_2222 = input[0], and C_1122 = input[1], and C_1212 = (input[0]

  • input[1])/2, and C_ijkl = C_jikl = C_ijlk = C_klij, and C_1211 = C_1222 = 0. Input size = 9. Then C_1111 = input[0], C_1112 = input[1], C_1122 = input[3], C_1212 = input[4], C_1222 = input[5], C_1211 = input[6] C_2211 = input[7], C_2212 = input[8], C_2222 = input[9] and C_ijkl = C_jikl = C_ijlk

Definition at line 473 of file RankFourTensor.C.

474 {
475  zero();
476 
477  if (input.size() == 9)
478  {
479  // then fill from vector C_1111, C_1112, C_1122, C_1212, C_1222, C_1211, C_2211, C_2212, C_2222
480  (*this)(0, 0, 0, 0) = input[0];
481  (*this)(0, 0, 0, 1) = input[1];
482  (*this)(0, 0, 1, 1) = input[2];
483  (*this)(0, 1, 0, 1) = input[3];
484  (*this)(0, 1, 1, 1) = input[4];
485  (*this)(0, 1, 0, 0) = input[5];
486  (*this)(1, 1, 0, 0) = input[6];
487  (*this)(1, 1, 0, 1) = input[7];
488  (*this)(1, 1, 1, 1) = input[8];
489 
490  // fill in remainders from C_ijkl = C_ijlk = C_jikl
491  (*this)(0, 0, 1, 0) = (*this)(0, 0, 0, 1);
492  (*this)(0, 1, 1, 0) = (*this)(0, 1, 0, 1);
493  (*this)(1, 0, 0, 0) = (*this)(0, 1, 0, 0);
494  (*this)(1, 0, 0, 1) = (*this)(0, 1, 0, 1);
495  (*this)(1, 0, 1, 1) = (*this)(0, 1, 1, 1);
496  (*this)(1, 0, 0, 0) = (*this)(0, 1, 0, 0);
497  (*this)(1, 1, 1, 0) = (*this)(1, 1, 0, 1);
498  }
499  else if (input.size() == 2)
500  {
501  // only two independent constants, C_1111 and C_1122
502  (*this)(0, 0, 0, 0) = input[0];
503  (*this)(0, 0, 1, 1) = input[1];
504  // use symmetries
505  (*this)(1, 1, 1, 1) = (*this)(0, 0, 0, 0);
506  (*this)(1, 1, 0, 0) = (*this)(0, 0, 1, 1);
507  (*this)(0, 1, 0, 1) = 0.5 * ((*this)(0, 0, 0, 0) - (*this)(0, 0, 1, 1));
508  (*this)(1, 0, 0, 1) = (*this)(0, 1, 0, 1);
509  (*this)(0, 1, 1, 0) = (*this)(0, 1, 0, 1);
510  (*this)(1, 0, 1, 0) = (*this)(0, 1, 0, 1);
511  }
512  else
513  mooseError("Please provide correct number of inputs for surface RankFourTensorTempl<T> "
514  "initialization.");
515 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:207
void zero()
Zeros out the tensor.

◆ transposeMajor()

template<typename T >
RankFourTensorTempl< T > RankFourTensorTempl< T >::transposeMajor ( ) const

Transpose the tensor by swapping the first pair with the second pair of indices.

Returns
C_klji

Definition at line 448 of file RankFourTensor.C.

449 {
450  RankFourTensorTempl<T> result;
451 
452  unsigned int index = 0;
453  unsigned int i1 = 0;
454  for (unsigned int i = 0; i < N; ++i)
455  {
456  for (unsigned int j = 0; j < N; ++j)
457  {
458  for (unsigned int k = 0; k < N; ++k)
459  {
460  unsigned int ijk1 = k * N3 + i1 + j;
461  for (unsigned int l = 0; l < N; ++l)
462  result._vals[index++] = _vals[ijk1 + l * N2];
463  }
464  }
465  i1 += N;
466  }
467 
468  return result;
469 }
RankFourTensorTempl is designed to handle any N-dimensional fourth order tensor, C.
Definition: MooseTypes.h:115
static constexpr unsigned int N3
static constexpr unsigned int N2
T _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
Dimensionality of rank-four tensor.

◆ zero()

template<typename T >
void RankFourTensorTempl< T >::zero ( )

Zeros out the tensor.

Definition at line 107 of file RankFourTensor.C.

Referenced by RankFourTensorTempl< Real >::operator=().

108 {
109  for (unsigned int i = 0; i < N4; ++i)
110  _vals[i] = 0.0;
111 }
static constexpr unsigned int N4
T _vals[N4]
The values of the rank-four tensor stored by index=(((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) * LIBME...

Friends And Related Function Documentation

◆ dataLoad

template<typename T>
template<class T2 >
void dataLoad ( std::istream &  ,
RankFourTensorTempl< T2 > &  ,
void *   
)
friend

◆ dataStore

template<typename T>
template<class T2 >
void dataStore ( std::ostream &  ,
RankFourTensorTempl< T2 > &  ,
void *   
)
friend

◆ RankFourTensorTempl

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

Definition at line 411 of file RankFourTensor.h.

◆ RankThreeTensorTempl

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

Definition at line 413 of file RankFourTensor.h.

◆ RankTwoTensorTempl

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

Definition at line 409 of file RankFourTensor.h.

Member Data Documentation

◆ _vals

template<typename T>
T RankFourTensorTempl< T >::_vals[N4]
protected

◆ N

template<typename T>
constexpr unsigned int RankFourTensorTempl< T >::N = LIBMESH_DIM
staticprotected

Dimensionality of rank-four tensor.

Definition at line 300 of file RankFourTensor.h.

◆ N2

template<typename T>
constexpr unsigned int RankFourTensorTempl< T >::N2 = N * N
staticprotected

Definition at line 301 of file RankFourTensor.h.

◆ N3

template<typename T>
constexpr unsigned int RankFourTensorTempl< T >::N3 = N * N * N
staticprotected

◆ N4

template<typename T>
constexpr unsigned int RankFourTensorTempl< T >::N4 = N * N * N * N
staticprotected

Definition at line 303 of file RankFourTensor.h.


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