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

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

#include <RankFourTensor.h>

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

Public Member Functions

 RankFourTensor ()
 Default constructor; fills to zero. More...
 
 RankFourTensor (const InitMethod)
 Select specific initialization pattern. More...
 
 RankFourTensor (const std::vector< Real > &, FillMethod)
 Fill from vector. More...
 
Real & 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...
 
Real 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...
 
RankFourTensoroperator= (const RankFourTensor &a)
 copies values from a into this tensor More...
 
RankTwoTensor operator* (const RankTwoTensor &a) const
 C_ijkl*a_kl. More...
 
RealTensorValue operator* (const RealTensorValue &a) const
 C_ijkl*a_kl. More...
 
RankFourTensor operator* (const Real a) const
 C_ijkl*a. More...
 
RankFourTensoroperator*= (const Real a)
 C_ijkl *= a. More...
 
RankFourTensor operator/ (const Real a) const
 C_ijkl/a. More...
 
RankFourTensoroperator/= (const Real a)
 C_ijkl /= a for all i, j, k, l. More...
 
RankFourTensoroperator+= (const RankFourTensor &a)
 C_ijkl += a_ijkl for all i, j, k, l. More...
 
RankFourTensor operator+ (const RankFourTensor &a) const
 C_ijkl + a_ijkl. More...
 
RankFourTensoroperator-= (const RankFourTensor &a)
 C_ijkl -= a_ijkl. More...
 
RankFourTensor operator- (const RankFourTensor &a) const
 C_ijkl - a_ijkl. More...
 
RankFourTensor operator- () const
 -C_ijkl More...
 
RankFourTensor operator* (const RankFourTensor &a) const
 C_ijpq*a_pqkl. More...
 
Real L2norm () const
 sqrt(C_ijkl*C_ijkl) More...
 
RankFourTensor 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...
 
template<class T >
void rotate (const T &R)
 Rotate the tensor using C_ijkl = R_im R_in R_ko R_lp C_mnop. More...
 
void rotate (const RealTensorValue &R)
 Rotate the tensor using C_ijkl = R_im R_in R_ko R_lp C_mnop. More...
 
void rotate (const RankTwoTensor &R)
 Rotate the tensor using C_ijkl = R_im R_in R_ko R_lp C_mnop. More...
 
RankFourTensor transposeMajor () const
 Transpose the tensor by swapping the first pair with the second pair of indices. More...
 
void surfaceFillFromInputVector (const std::vector< Real > &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< Real > &input, FillMethod fill_method)
 fillFromInputVector takes some number of inputs to fill the Rank-4 tensor. More...
 
RankTwoTensor innerProductTranspose (const RankTwoTensor &) const
 Inner product of the major transposed tensor with a rank two tensor. More...
 
Real sum3x3 () const
 Calculates the sum of Ciijj for i and j varying from 0 to 2. More...
 
RealGradient 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...
 
void fillGeneralIsotropic (Real i0, Real i1, Real i2)
 Vector-less fill API functions. See docs of the corresponding ...FromInputVector methods. More...
 
void fillAntisymmetricIsotropic (Real i0)
 
void fillSymmetricIsotropic (Real i0, Real i1)
 
void fillSymmetricIsotropicEandNu (Real E, Real nu)
 

Static Public Member Functions

static RankFourTensor Identity ()
 
static RankFourTensor IdentityFour ()
 
static MooseEnum fillMethodEnum ()
 Static method for use in validParams for getting the "fill_method". More...
 

Protected Member Functions

void fillSymmetricFromInputVector (const std::vector< Real > &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< Real > &input)
 fillAntisymmetricFromInputVector takes 6 inputs to fill the the antisymmetric Rank-4 tensor with the appropriate symmetries maintained. More...
 
void fillGeneralIsotropicFromInputVector (const std::vector< Real > &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< Real > &input)
 fillAntisymmetricIsotropicFromInputVector takes 1 input to fill the the antisymmetric Rank-4 tensor with the appropriate symmetries maintained. More...
 
void fillSymmetricIsotropicFromInputVector (const std::vector< Real > &input)
 fillSymmetricIsotropicFromInputVector takes 2 inputs to fill the the symmetric Rank-4 tensor with the appropriate symmetries maintained. More...
 
void fillSymmetricIsotropicEandNuFromInputVector (const std::vector< Real > &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< Real > &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< Real > &input)
 fillGeneralFromInputVector takes 81 inputs to fill the Rank-4 tensor No symmetries are explicitly maintained More...
 
void fillPrincipalFromInputVector (const std::vector< Real > &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

Real _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

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

Detailed Description

RankFourTensor 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, RankFourTensor 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 42 of file RankFourTensor.h.

Member Enumeration Documentation

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 59 of file RankFourTensor.h.

Initialization method.

Enumerator
initNone 
initIdentity 
initIdentityFour 
initIdentitySymmetricFour 

Definition at line 46 of file RankFourTensor.h.

Constructor & Destructor Documentation

RankFourTensor::RankFourTensor ( )

Default constructor; fills to zero.

Definition at line 53 of file RankFourTensor.C.

Referenced by Identity(), and IdentityFour().

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

Select specific initialization pattern.

Definition at line 62 of file RankFourTensor.C.

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

Fill from vector.

Definition at line 97 of file RankFourTensor.C.

98 {
99  fillFromInputVector(input, fill_method);
100 }
void fillFromInputVector(const std::vector< Real > &input, FillMethod fill_method)
fillFromInputVector takes some number of inputs to fill the Rank-4 tensor.

Member Function Documentation

void RankFourTensor::fillAntisymmetricFromInputVector ( const std::vector< Real > &  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 658 of file RankFourTensor.C.

Referenced by fillFromInputVector().

659 {
660  if (input.size() != 6)
661  mooseError(
662  "To use fillAntisymmetricFromInputVector, your input must have size 6. Yours has size ",
663  input.size());
664 
665  zero();
666 
667  (*this)(0, 1, 0, 1) = input[0]; // B1212
668  (*this)(0, 1, 0, 2) = input[1]; // B1213
669  (*this)(0, 1, 1, 2) = input[2]; // B1223
670 
671  (*this)(0, 2, 0, 2) = input[3]; // B1313
672  (*this)(0, 2, 1, 2) = input[4]; // B1323
673 
674  (*this)(1, 2, 1, 2) = input[5]; // B2323
675 
676  // symmetry on the two pairs
677  (*this)(0, 2, 0, 1) = (*this)(0, 1, 0, 2);
678  (*this)(1, 2, 0, 1) = (*this)(0, 1, 1, 2);
679  (*this)(1, 2, 0, 2) = (*this)(0, 2, 1, 2);
680  // have now got the upper parts of vals[0][1], vals[0][2] and vals[1][2]
681 
682  // fill in from antisymmetry relations
683  for (unsigned int i = 0; i < N; ++i)
684  for (unsigned int j = 0; j < N; ++j)
685  {
686  (*this)(0, 1, j, i) = -(*this)(0, 1, i, j);
687  (*this)(0, 2, j, i) = -(*this)(0, 2, i, j);
688  (*this)(1, 2, j, i) = -(*this)(1, 2, i, j);
689  }
690  // have now got all of vals[0][1], vals[0][2] and vals[1][2]
691 
692  // fill in from antisymmetry relations
693  for (unsigned int i = 0; i < N; ++i)
694  for (unsigned int j = 0; j < N; ++j)
695  {
696  (*this)(1, 0, i, j) = -(*this)(0, 1, i, j);
697  (*this)(2, 0, i, j) = -(*this)(0, 2, i, j);
698  (*this)(2, 1, i, j) = -(*this)(1, 2, i, j);
699  }
700 }
void zero()
Zeros out the tensor.
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
Dimensionality of rank-four tensor.
void RankFourTensor::fillAntisymmetricIsotropic ( Real  i0)

Definition at line 740 of file RankFourTensor.C.

Referenced by operator()().

741 {
742  fillGeneralIsotropic(0.0, 0.0, i0);
743 }
void fillGeneralIsotropic(Real i0, Real i1, Real i2)
Vector-less fill API functions. See docs of the corresponding ...FromInputVector methods.
void RankFourTensor::fillAntisymmetricIsotropicFromInputVector ( const std::vector< Real > &  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 730 of file RankFourTensor.C.

Referenced by fillFromInputVector().

731 {
732  if (input.size() != 1)
733  mooseError("To use fillAntisymmetricIsotropicFromInputVector, your input must have size 1. "
734  "Yours has size ",
735  input.size());
736  fillGeneralIsotropic(0.0, 0.0, input[0]);
737 }
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
void fillGeneralIsotropic(Real i0, Real i1, Real i2)
Vector-less fill API functions. See docs of the corresponding ...FromInputVector methods.
void RankFourTensor::fillAxisymmetricRZFromInputVector ( const std::vector< Real > &  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 784 of file RankFourTensor.C.

Referenced by fillFromInputVector().

785 {
786  if (input.size() != 5)
787  mooseError("To use fillAxisymmetricRZFromInputVector, your input must have size 5. Your "
788  "vector has size ",
789  input.size());
790 
791  // C1111 C1122 C1133 C2222 C2233=C1133
793  input[1],
794  input[2],
795  input[0],
796  input[2],
797  // C3333 C2323 C3131=C2323 C1212
798  input[3],
799  input[4],
800  input[4],
801  (input[0] - input[1]) * 0.5},
802  false);
803 }
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
void fillSymmetricFromInputVector(const std::vector< Real > &input, bool all)
fillSymmetricFromInputVector takes either 21 (all=true) or 9 (all=false) inputs to fill in the Rank-4...
void RankFourTensor::fillFromInputVector ( const std::vector< Real > &  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 557 of file RankFourTensor.C.

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

558 {
559  zero();
560 
561  switch (fill_method)
562  {
563  case antisymmetric:
565  break;
566  case symmetric9:
567  fillSymmetricFromInputVector(input, false);
568  break;
569  case symmetric21:
570  fillSymmetricFromInputVector(input, true);
571  break;
572  case general_isotropic:
574  break;
575  case symmetric_isotropic:
577  break;
580  break;
583  break;
584  case axisymmetric_rz:
586  break;
587  case general:
589  break;
590  case principal:
592  break;
593  default:
594  mooseError("fillFromInputVector called with unknown fill_method of ", fill_method);
595  }
596 }
void fillAntisymmetricIsotropicFromInputVector(const std::vector< Real > &input)
fillAntisymmetricIsotropicFromInputVector takes 1 input to fill the the antisymmetric Rank-4 tensor w...
void fillGeneralFromInputVector(const std::vector< Real > &input)
fillGeneralFromInputVector takes 81 inputs to fill the Rank-4 tensor No symmetries are explicitly mai...
void zero()
Zeros out the tensor.
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
void fillSymmetricIsotropicEandNuFromInputVector(const std::vector< Real > &input)
fillSymmetricIsotropicEandNuFromInputVector is a variation of the fillSymmetricIsotropicFromInputVect...
void fillAntisymmetricFromInputVector(const std::vector< Real > &input)
fillAntisymmetricFromInputVector takes 6 inputs to fill the the antisymmetric Rank-4 tensor with the ...
void fillSymmetricIsotropicFromInputVector(const std::vector< Real > &input)
fillSymmetricIsotropicFromInputVector takes 2 inputs to fill the the symmetric Rank-4 tensor with the...
void fillSymmetricFromInputVector(const std::vector< Real > &input, bool all)
fillSymmetricFromInputVector takes either 21 (all=true) or 9 (all=false) inputs to fill in the Rank-4...
void fillGeneralIsotropicFromInputVector(const std::vector< Real > &input)
fillGeneralIsotropicFromInputVector takes 3 inputs to fill the Rank-4 tensor with symmetries C_ijkl =...
void fillPrincipalFromInputVector(const std::vector< Real > &input)
fillPrincipalFromInputVector takes 9 inputs to fill a Rank-4 tensor C1111 = input0 C1122 = input1 C11...
void fillAxisymmetricRZFromInputVector(const std::vector< Real > &input)
fillAxisymmetricRZFromInputVector takes 5 inputs to fill the axisymmetric Rank-4 tensor with the appr...
void RankFourTensor::fillGeneralFromInputVector ( const std::vector< Real > &  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 806 of file RankFourTensor.C.

Referenced by fillFromInputVector().

807 {
808  if (input.size() != 81)
809  mooseError("To use fillGeneralFromInputVector, your input must have size 81. Yours has size ",
810  input.size());
811 
812  for (unsigned int i = 0; i < N4; ++i)
813  _vals[i] = input[i];
814 }
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 N4
Real _vals[N4]
The values of the rank-four tensor stored by index=(((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) * LIBME...
void RankFourTensor::fillGeneralIsotropic ( Real  i0,
Real  i1,
Real  i2 
)

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

Definition at line 714 of file RankFourTensor.C.

Referenced by fillAntisymmetricIsotropic(), fillAntisymmetricIsotropicFromInputVector(), fillGeneralIsotropicFromInputVector(), fillSymmetricIsotropic(), fillSymmetricIsotropicEandNu(), fillSymmetricIsotropicFromInputVector(), and operator()().

715 {
716  for (unsigned int i = 0; i < N; ++i)
717  for (unsigned int j = 0; j < N; ++j)
718  for (unsigned int k = 0; k < N; ++k)
719  for (unsigned int l = 0; l < N; ++l)
720  {
721  (*this)(i, j, k, l) =
722  i0 * (i == j) * (k == l) + i1 * (i == k) * (j == l) + i1 * (i == l) * (j == k);
723  for (unsigned int m = 0; m < N; ++m)
724  (*this)(i, j, k, l) +=
725  i2 * PermutationTensor::eps(i, j, m) * PermutationTensor::eps(k, l, m);
726  }
727 }
int eps(unsigned int i, unsigned int j)
2D version
PetscInt m
static constexpr unsigned int N
Dimensionality of rank-four tensor.
void RankFourTensor::fillGeneralIsotropicFromInputVector ( const std::vector< Real > &  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 703 of file RankFourTensor.C.

Referenced by fillFromInputVector().

704 {
705  if (input.size() != 3)
706  mooseError(
707  "To use fillGeneralIsotropicFromInputVector, your input must have size 3. Yours has size ",
708  input.size());
709 
710  fillGeneralIsotropic(input[0], input[1], input[2]);
711 }
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
void fillGeneralIsotropic(Real i0, Real i1, Real i2)
Vector-less fill API functions. See docs of the corresponding ...FromInputVector methods.
MooseEnum RankFourTensor::fillMethodEnum ( )
static

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

Definition at line 46 of file RankFourTensor.C.

Referenced by operator()().

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:37
void RankFourTensor::fillPrincipalFromInputVector ( const std::vector< Real > &  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 817 of file RankFourTensor.C.

Referenced by fillFromInputVector().

818 {
819  if (input.size() != 9)
820  mooseError("To use fillPrincipalFromInputVector, your input must have size 9. Yours has size ",
821  input.size());
822 
823  zero();
824 
825  (*this)(0, 0, 0, 0) = input[0];
826  (*this)(0, 0, 1, 1) = input[1];
827  (*this)(0, 0, 2, 2) = input[2];
828  (*this)(1, 1, 0, 0) = input[3];
829  (*this)(1, 1, 1, 1) = input[4];
830  (*this)(1, 1, 2, 2) = input[5];
831  (*this)(2, 2, 0, 0) = input[6];
832  (*this)(2, 2, 1, 1) = input[7];
833  (*this)(2, 2, 2, 2) = input[8];
834 }
void zero()
Zeros out the tensor.
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
void RankFourTensor::fillSymmetricFromInputVector ( const std::vector< Real > &  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 599 of file RankFourTensor.C.

Referenced by fillAxisymmetricRZFromInputVector(), and fillFromInputVector().

600 {
601  if ((all == true && input.size() != 21) || (all == false && input.size() != 9))
602  mooseError("Please check the number of entries in the stiffness input vector.");
603 
604  zero();
605 
606  if (all == true)
607  {
608  (*this)(0, 0, 0, 0) = input[0]; // C1111
609  (*this)(0, 0, 1, 1) = input[1]; // C1122
610  (*this)(0, 0, 2, 2) = input[2]; // C1133
611  (*this)(0, 0, 1, 2) = input[3]; // C1123
612  (*this)(0, 0, 0, 2) = input[4]; // C1113
613  (*this)(0, 0, 0, 1) = input[5]; // C1112
614 
615  (*this)(1, 1, 1, 1) = input[6]; // C2222
616  (*this)(1, 1, 2, 2) = input[7]; // C2233
617  (*this)(1, 1, 1, 2) = input[8]; // C2223
618  (*this)(0, 2, 1, 1) = input[9]; // C2213 //flipped for filling purposes
619  (*this)(0, 1, 1, 1) = input[10]; // C2212 //flipped for filling purposes
620 
621  (*this)(2, 2, 2, 2) = input[11]; // C3333
622  (*this)(1, 2, 2, 2) = input[12]; // C3323 //flipped for filling purposes
623  (*this)(0, 2, 2, 2) = input[13]; // C3313 //flipped for filling purposes
624  (*this)(0, 1, 2, 2) = input[14]; // C3312 //flipped for filling purposes
625 
626  (*this)(1, 2, 1, 2) = input[15]; // C2323
627  (*this)(0, 2, 1, 2) = input[16]; // C2313 //flipped for filling purposes
628  (*this)(0, 1, 1, 2) = input[17]; // C2312 //flipped for filling purposes
629 
630  (*this)(0, 2, 0, 2) = input[18]; // C1313
631  (*this)(0, 1, 0, 2) = input[19]; // C1312 //flipped for filling purposes
632 
633  (*this)(0, 1, 0, 1) = input[20]; // C1212
634  }
635  else
636  {
637  (*this)(0, 0, 0, 0) = input[0]; // C1111
638  (*this)(0, 0, 1, 1) = input[1]; // C1122
639  (*this)(0, 0, 2, 2) = input[2]; // C1133
640  (*this)(1, 1, 1, 1) = input[3]; // C2222
641  (*this)(1, 1, 2, 2) = input[4]; // C2233
642  (*this)(2, 2, 2, 2) = input[5]; // C3333
643  (*this)(1, 2, 1, 2) = input[6]; // C2323
644  (*this)(0, 2, 0, 2) = input[7]; // C1313
645  (*this)(0, 1, 0, 1) = input[8]; // C1212
646  }
647 
648  // fill in from symmetry relations
649  for (unsigned int i = 0; i < N; ++i)
650  for (unsigned int j = 0; j < N; ++j)
651  for (unsigned int k = 0; k < N; ++k)
652  for (unsigned int l = 0; l < N; ++l)
653  (*this)(i, j, l, k) = (*this)(j, i, k, l) = (*this)(j, i, l, k) = (*this)(k, l, i, j) =
654  (*this)(l, k, j, i) = (*this)(k, l, j, i) = (*this)(l, k, i, j) = (*this)(i, j, k, l);
655 }
void zero()
Zeros out the tensor.
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
Dimensionality of rank-four tensor.
void RankFourTensor::fillSymmetricIsotropic ( Real  i0,
Real  i1 
)

Definition at line 756 of file RankFourTensor.C.

Referenced by operator()().

757 {
758  fillGeneralIsotropic(i0, i1, 0.0);
759 }
void fillGeneralIsotropic(Real i0, Real i1, Real i2)
Vector-less fill API functions. See docs of the corresponding ...FromInputVector methods.
void RankFourTensor::fillSymmetricIsotropicEandNu ( Real  E,
Real  nu 
)

Definition at line 774 of file RankFourTensor.C.

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

775 {
776  // Calculate lambda and the shear modulus from the given young's modulus and poisson's ratio
777  const Real lambda = E * nu / ((1.0 + nu) * (1.0 - 2.0 * nu));
778  const Real G = E / (2.0 * (1.0 + nu));
779 
780  fillGeneralIsotropic(lambda, G, 0.0);
781 }
void fillGeneralIsotropic(Real i0, Real i1, Real i2)
Vector-less fill API functions. See docs of the corresponding ...FromInputVector methods.
void RankFourTensor::fillSymmetricIsotropicEandNuFromInputVector ( const std::vector< Real > &  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 762 of file RankFourTensor.C.

Referenced by fillFromInputVector().

763 {
764  if (input.size() != 2)
765  mooseError(
766  "To use fillSymmetricIsotropicEandNuFromInputVector, your input must have size 2. Yours "
767  "has size ",
768  input.size());
769 
770  fillSymmetricIsotropicEandNu(input[0], input[1]);
771 }
void fillSymmetricIsotropicEandNu(Real E, Real nu)
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
void RankFourTensor::fillSymmetricIsotropicFromInputVector ( const std::vector< Real > &  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 746 of file RankFourTensor.C.

Referenced by fillFromInputVector().

747 {
748  if (input.size() != 2)
749  mooseError("To use fillSymmetricIsotropicFromInputVector, your input must have size 2. Yours "
750  "has size ",
751  input.size());
752  fillGeneralIsotropic(input[0], input[1], 0.0);
753 }
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
void fillGeneralIsotropic(Real i0, Real i1, Real i2)
Vector-less fill API functions. See docs of the corresponding ...FromInputVector methods.
static RankFourTensor RankFourTensor::Identity ( )
inlinestatic

Definition at line 83 of file RankFourTensor.h.

83 { return RankFourTensor(initIdentity); }
RankFourTensor()
Default constructor; fills to zero.
static RankFourTensor RankFourTensor::IdentityFour ( )
inlinestatic

Definition at line 84 of file RankFourTensor.h.

84 { return RankFourTensor(initIdentityFour); };
RankFourTensor()
Default constructor; fills to zero.
RankTwoTensor RankFourTensor::innerProductTranspose ( const RankTwoTensor b) const

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

Definition at line 837 of file RankFourTensor.C.

Referenced by operator()().

838 {
839  RankTwoTensor result;
840 
841  unsigned int index = 0;
842  for (unsigned int ij = 0; ij < N2; ++ij)
843  {
844  Real bb = b._vals[ij];
845  for (unsigned int kl = 0; kl < N2; ++kl)
846  result._vals[kl] += _vals[index++] * bb;
847  }
848 
849  return result;
850 }
Real _vals[N2]
The values of the rank-two tensor stored by index=(i * LIBMESH_DIM + j)
static constexpr unsigned int N2
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...
RankFourTensor RankFourTensor::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 268 of file RankFourTensor.C.

Referenced by operator()().

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

checks if the tensor is isotropic

Definition at line 893 of file RankFourTensor.C.

Referenced by operator()().

894 {
895  // prerequisite is symmetry
896  if (!isSymmetric())
897  return false;
898 
899  // inspect shear components
900  const Real mu = (*this)(0, 1, 0, 1);
901  // ...diagonal
902  if ((*this)(1, 2, 1, 2) != mu || (*this)(2, 0, 2, 0) != mu)
903  return false;
904  // ...off-diagonal
905  if ((*this)(2, 0, 1, 2) != 0.0 || (*this)(0, 1, 1, 2) != 0.0 || (*this)(0, 1, 2, 0) != 0.0)
906  return false;
907 
908  // off diagonal blocks in Voigt
909  unsigned int i1 = 0;
910  for (unsigned int i = 0; i < N; ++i)
911  {
912  for (unsigned int j = 0; j < N; ++j)
913  if (_vals[i1 + ((j + 1) % N) * N + (j + 2) % N] != 0.0)
914  return false;
915  i1 += N3 + N2;
916  }
917 
918  // top left block
919  const Real K1 = (*this)(0, 0, 0, 0);
920  const Real K2 = (*this)(0, 0, 1, 1);
921  if (!MooseUtils::relativeFuzzyEqual(K1 - 4.0 * mu / 3.0, K2 + 2.0 * mu / 3.0))
922  return false;
923  if ((*this)(1, 1, 1, 1) != K1 || (*this)(2, 2, 2, 2) != K1)
924  return false;
925  for (unsigned int i = 1; i < N; ++i)
926  for (unsigned int j = 0; j < i; ++j)
927  if ((*this)(i, i, j, j) != K2)
928  return false;
929 
930  return true;
931 }
bool relativeFuzzyEqual(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 a relative tolerance.
bool isSymmetric() const
checks if the tensor is symmetric
static constexpr unsigned int N2
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 N3
static constexpr unsigned int N
Dimensionality of rank-four tensor.
bool RankFourTensor::isSymmetric ( ) const

checks if the tensor is symmetric

Definition at line 873 of file RankFourTensor.C.

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

874 {
875  for (unsigned int i = 1; i < N; ++i)
876  for (unsigned int j = 0; j < i; ++j)
877  for (unsigned int k = 1; k < N; ++k)
878  for (unsigned int l = 0; l < k; ++l)
879  {
880  // minor symmetries
881  if ((*this)(i, j, k, l) != (*this)(j, i, k, l) ||
882  (*this)(i, j, k, l) != (*this)(i, j, l, k))
883  return false;
884 
885  // major symmetry
886  if ((*this)(i, j, k, l) != (*this)(k, l, i, j))
887  return false;
888  }
889  return true;
890 }
static constexpr unsigned int N
Dimensionality of rank-four tensor.
Real RankFourTensor::L2norm ( ) const

sqrt(C_ijkl*C_ijkl)

Definition at line 257 of file RankFourTensor.C.

Referenced by operator()().

258 {
259  Real l2 = 0;
260 
261  for (unsigned int i = 0; i < N4; ++i)
262  l2 += Utility::pow<2>(_vals[i]);
263 
264  return std::sqrt(l2);
265 }
static constexpr unsigned int N4
Real _vals[N4]
The values of the rank-four tensor stored by index=(((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) * LIBME...
Real& RankFourTensor::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 87 of file RankFourTensor.h.

88  {
89  return _vals[((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) * LIBMESH_DIM + l];
90  }
Real _vals[N4]
The values of the rank-four tensor stored by index=(((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) * LIBME...
Real RankFourTensor::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 96 of file RankFourTensor.h.

97  {
98  return _vals[((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) * LIBMESH_DIM + l];
99  }
Real _vals[N4]
The values of the rank-four tensor stored by index=(((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) * LIBME...
RankTwoTensor RankFourTensor::operator* ( const RankTwoTensor a) const

C_ijkl*a_kl.

Definition at line 117 of file RankFourTensor.C.

Referenced by operator()().

118 {
119  RankTwoTensor result;
120 
121  unsigned int index = 0;
122  for (unsigned int ij = 0; ij < N2; ++ij)
123  {
124  Real tmp = 0;
125  for (unsigned int kl = 0; kl < N2; ++kl)
126  tmp += _vals[index++] * b._vals[kl];
127  result._vals[ij] = tmp;
128  }
129 
130  return result;
131 }
Real _vals[N2]
The values of the rank-two tensor stored by index=(i * LIBMESH_DIM + j)
static constexpr unsigned int N2
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...
RealTensorValue RankFourTensor::operator* ( const RealTensorValue &  a) const

C_ijkl*a_kl.

Definition at line 133 of file RankFourTensor.C.

134 {
135  RealTensorValue result;
136 
137  unsigned int index = 0;
138  for (unsigned int i = 0; i < N; ++i)
139  for (unsigned int j = 0; j < N; ++j)
140  for (unsigned int k = 0; k < N; ++k)
141  for (unsigned int l = 0; l < N; ++l)
142  result(i, j) += _vals[index++] * b(k, l);
143 
144  return result;
145 }
Real _vals[N4]
The values of the rank-four tensor stored by index=(((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) * LIBME...
TensorValue< Real > RealTensorValue
Definition: Assembly.h:45
static constexpr unsigned int N
Dimensionality of rank-four tensor.
RankFourTensor RankFourTensor::operator* ( const Real  a) const

C_ijkl*a.

Definition at line 147 of file RankFourTensor.C.

148 {
149  RankFourTensor result;
150 
151  for (unsigned int i = 0; i < N4; ++i)
152  result._vals[i] = _vals[i] * b;
153 
154  return result;
155 }
static constexpr unsigned int N4
Real _vals[N4]
The values of the rank-four tensor stored by index=(((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) * LIBME...
RankFourTensor is designed to handle any N-dimensional fourth order tensor, C.
RankFourTensor RankFourTensor::operator* ( const RankFourTensor a) const

C_ijpq*a_pqkl.

Definition at line 225 of file RankFourTensor.C.

226 {
227  RankFourTensor result;
228 
229  unsigned int index = 0;
230  unsigned int ij1 = 0;
231  for (unsigned int i = 0; i < N; ++i)
232  {
233  for (unsigned int j = 0; j < N; ++j)
234  {
235  for (unsigned int k = 0; k < N; ++k)
236  {
237  for (unsigned int l = 0; l < N; ++l)
238  {
239  Real sum = 0;
240  for (unsigned int p = 0; p < N; ++p)
241  {
242  unsigned int p1 = N * p;
243  for (unsigned int q = 0; q < N; ++q)
244  sum += _vals[ij1 + p1 + q] * b(p, q, k, l);
245  }
246  result._vals[index++] = sum;
247  }
248  }
249  ij1 += N2;
250  }
251  }
252 
253  return result;
254 }
static constexpr unsigned int N2
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
Dimensionality of rank-four tensor.
RankFourTensor is designed to handle any N-dimensional fourth order tensor, C.
RankFourTensor & RankFourTensor::operator*= ( const Real  a)

C_ijkl *= a.

Definition at line 158 of file RankFourTensor.C.

Referenced by operator()().

159 {
160  for (unsigned int i = 0; i < N4; ++i)
161  _vals[i] *= a;
162  return *this;
163 }
static constexpr unsigned int N4
Real _vals[N4]
The values of the rank-four tensor stored by index=(((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) * LIBME...
RankFourTensor RankFourTensor::operator+ ( const RankFourTensor a) const

C_ijkl + a_ijkl.

Definition at line 191 of file RankFourTensor.C.

Referenced by operator()().

192 {
193  RankFourTensor result;
194  for (unsigned int i = 0; i < N4; ++i)
195  result._vals[i] = _vals[i] + b._vals[i];
196  return result;
197 }
static constexpr unsigned int N4
Real _vals[N4]
The values of the rank-four tensor stored by index=(((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) * LIBME...
RankFourTensor is designed to handle any N-dimensional fourth order tensor, C.
RankFourTensor & RankFourTensor::operator+= ( const RankFourTensor a)

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

Definition at line 183 of file RankFourTensor.C.

Referenced by operator()().

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

C_ijkl - a_ijkl.

Definition at line 208 of file RankFourTensor.C.

209 {
210  RankFourTensor result;
211  for (unsigned int i = 0; i < N4; ++i)
212  result._vals[i] = _vals[i] - b._vals[i];
213  return result;
214 }
static constexpr unsigned int N4
Real _vals[N4]
The values of the rank-four tensor stored by index=(((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) * LIBME...
RankFourTensor is designed to handle any N-dimensional fourth order tensor, C.
RankFourTensor RankFourTensor::operator- ( ) const

-C_ijkl

Definition at line 217 of file RankFourTensor.C.

Referenced by operator()().

218 {
219  RankFourTensor result;
220  for (unsigned int i = 0; i < N4; ++i)
221  result._vals[i] = -_vals[i];
222  return result;
223 }
static constexpr unsigned int N4
Real _vals[N4]
The values of the rank-four tensor stored by index=(((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) * LIBME...
RankFourTensor is designed to handle any N-dimensional fourth order tensor, C.
RankFourTensor & RankFourTensor::operator-= ( const RankFourTensor a)

C_ijkl -= a_ijkl.

Definition at line 200 of file RankFourTensor.C.

Referenced by operator()().

201 {
202  for (unsigned int i = 0; i < N4; ++i)
203  _vals[i] -= a._vals[i];
204  return *this;
205 }
static constexpr unsigned int N4
Real _vals[N4]
The values of the rank-four tensor stored by index=(((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) * LIBME...
RankFourTensor RankFourTensor::operator/ ( const Real  a) const

C_ijkl/a.

Definition at line 166 of file RankFourTensor.C.

Referenced by operator()().

167 {
168  RankFourTensor result;
169  for (unsigned int i = 0; i < N4; ++i)
170  result._vals[i] = _vals[i] / b;
171  return result;
172 }
static constexpr unsigned int N4
Real _vals[N4]
The values of the rank-four tensor stored by index=(((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) * LIBME...
RankFourTensor is designed to handle any N-dimensional fourth order tensor, C.
RankFourTensor & RankFourTensor::operator/= ( const Real  a)

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

Definition at line 175 of file RankFourTensor.C.

Referenced by operator()().

176 {
177  for (unsigned int i = 0; i < N4; ++i)
178  _vals[i] /= a;
179  return *this;
180 }
static constexpr unsigned int N4
Real _vals[N4]
The values of the rank-four tensor stored by index=(((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) * LIBME...
RankFourTensor & RankFourTensor::operator= ( const RankFourTensor a)

copies values from a into this tensor

Definition at line 110 of file RankFourTensor.C.

Referenced by operator()().

111 {
112  for (unsigned int i = 0; i < N4; ++i)
113  _vals[i] = a._vals[i];
114  return *this;
115 }
static constexpr unsigned int N4
Real _vals[N4]
The values of the rank-four tensor stored by index=(((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) * LIBME...
void RankFourTensor::print ( std::ostream &  stm = Moose::out) const

Print the rank four tensor.

Definition at line 471 of file RankFourTensor.C.

Referenced by operator()().

472 {
473  for (unsigned int i = 0; i < N; ++i)
474  for (unsigned int j = 0; j < N; ++j)
475  {
476  stm << "i = " << i << " j = " << j << '\n';
477  for (unsigned int k = 0; k < N; ++k)
478  {
479  for (unsigned int l = 0; l < N; ++l)
480  stm << std::setw(15) << (*this)(i, j, k, l) << " ";
481 
482  stm << '\n';
483  }
484  }
485 }
static constexpr unsigned int N
Dimensionality of rank-four tensor.
template<class T >
void RankFourTensor::rotate ( const T &  R)

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

Definition at line 360 of file RankFourTensor.h.

Referenced by operator()().

361 {
362  RankFourTensor old = *this;
363 
364  int 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  Real sum = 0.0;
371  int index2 = 0;
372  for (unsigned int m = 0; m < N; ++m)
373  {
374  Real a = R(i, m);
375  for (unsigned int n = 0; n < N; ++n)
376  {
377  Real ab = a * R(j, n);
378  for (unsigned int o = 0; o < N; ++o)
379  {
380  Real abc = ab * R(k, o);
381  for (unsigned int p = 0; p < N; ++p)
382  sum += abc * R(l, p) * old._vals[index2++];
383  }
384  }
385  }
386  _vals[index++] = sum;
387  }
388 }
PetscInt m
Real _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.
RankFourTensor is designed to handle any N-dimensional fourth order tensor, C.
void RankFourTensor::rotate ( const RealTensorValue &  R)

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

Definition at line 389 of file RankFourTensor.C.

390 {
391  RankFourTensor old = *this;
392 
393  unsigned int index = 0;
394  for (unsigned int i = 0; i < N; ++i)
395  {
396  for (unsigned int j = 0; j < N; ++j)
397  {
398  for (unsigned int k = 0; k < N; ++k)
399  {
400  for (unsigned int l = 0; l < N; ++l)
401  {
402  unsigned int index2 = 0;
403  Real sum = 0.0;
404  for (unsigned int m = 0; m < N; ++m)
405  {
406  const Real a = R(i, m);
407  for (unsigned int n = 0; n < N; ++n)
408  {
409  const Real ab = a * R(j, n);
410  for (unsigned int o = 0; o < N; ++o)
411  {
412  const Real abc = ab * R(k, o);
413  for (unsigned int p = 0; p < N; ++p)
414  sum += abc * R(l, p) * old._vals[index2++];
415  }
416  }
417  }
418  _vals[index++] = sum;
419  }
420  }
421  }
422  }
423 }
PetscInt m
Real _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.
RankFourTensor is designed to handle any N-dimensional fourth order tensor, C.
void RankFourTensor::rotate ( const RankTwoTensor R)

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

Definition at line 426 of file RankFourTensor.C.

427 {
428  RankFourTensor old = *this;
429 
430  unsigned int index = 0;
431  unsigned int i1 = 0;
432  for (unsigned int i = 0; i < N; ++i)
433  {
434  unsigned int j1 = 0;
435  for (unsigned int j = 0; j < N; ++j)
436  {
437  unsigned int k1 = 0;
438  for (unsigned int k = 0; k < N; ++k)
439  {
440  unsigned int l1 = 0;
441  for (unsigned int l = 0; l < N; ++l)
442  {
443  unsigned int index2 = 0;
444  Real sum = 0.0;
445  for (unsigned int m = 0; m < N; ++m)
446  {
447  const Real a = R._vals[i1 + m];
448  for (unsigned int n = 0; n < N; ++n)
449  {
450  const Real ab = a * R._vals[j1 + n];
451  for (unsigned int o = 0; o < N; ++o)
452  {
453  const Real abc = ab * R._vals[k1 + o];
454  for (unsigned int p = 0; p < N; ++p)
455  sum += abc * R._vals[l1 + p] * old._vals[index2++];
456  }
457  }
458  }
459  _vals[index++] = sum;
460  l1 += N;
461  }
462  k1 += N;
463  }
464  j1 += N;
465  }
466  i1 += N;
467  }
468 }
Real _vals[N2]
The values of the rank-two tensor stored by index=(i * LIBMESH_DIM + j)
PetscInt m
Real _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.
RankFourTensor is designed to handle any N-dimensional fourth order tensor, C.
RealGradient RankFourTensor::sum3x1 ( ) const

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

Definition at line 862 of file RankFourTensor.C.

Referenced by operator()().

863 {
864  // used for volumetric locking correction
865  RealGradient a(3);
866  a(0) = (*this)(0, 0, 0, 0) + (*this)(0, 0, 1, 1) + (*this)(0, 0, 2, 2); // C0000 + C0011 + C0022
867  a(1) = (*this)(1, 1, 0, 0) + (*this)(1, 1, 1, 1) + (*this)(1, 1, 2, 2); // C1100 + C1111 + C1122
868  a(2) = (*this)(2, 2, 0, 0) + (*this)(2, 2, 1, 1) + (*this)(2, 2, 2, 2); // C2200 + C2211 + C2222
869  return a;
870 }
RealVectorValue RealGradient
Definition: Assembly.h:43
Real RankFourTensor::sum3x3 ( ) const

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

Definition at line 853 of file RankFourTensor.C.

Referenced by operator()().

854 {
855  // summation of Ciijj for i and j ranging from 0 to 2 - used in the volumetric locking correction
856  return (*this)(0, 0, 0, 0) + (*this)(0, 0, 1, 1) + (*this)(0, 0, 2, 2) + (*this)(1, 1, 0, 0) +
857  (*this)(1, 1, 1, 1) + (*this)(1, 1, 2, 2) + (*this)(2, 2, 0, 0) + (*this)(2, 2, 1, 1) +
858  (*this)(2, 2, 2, 2);
859 }
void RankFourTensor::surfaceFillFromInputVector ( const std::vector< Real > &  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 512 of file RankFourTensor.C.

Referenced by operator()().

513 {
514  zero();
515 
516  if (input.size() == 9)
517  {
518  // then fill from vector C_1111, C_1112, C_1122, C_1212, C_1222, C_1211, C_2211, C_2212, C_2222
519  (*this)(0, 0, 0, 0) = input[0];
520  (*this)(0, 0, 0, 1) = input[1];
521  (*this)(0, 0, 1, 1) = input[2];
522  (*this)(0, 1, 0, 1) = input[3];
523  (*this)(0, 1, 1, 1) = input[4];
524  (*this)(0, 1, 0, 0) = input[5];
525  (*this)(1, 1, 0, 0) = input[6];
526  (*this)(1, 1, 0, 1) = input[7];
527  (*this)(1, 1, 1, 1) = input[8];
528 
529  // fill in remainders from C_ijkl = C_ijlk = C_jikl
530  (*this)(0, 0, 1, 0) = (*this)(0, 0, 0, 1);
531  (*this)(0, 1, 1, 0) = (*this)(0, 1, 0, 1);
532  (*this)(1, 0, 0, 0) = (*this)(0, 1, 0, 0);
533  (*this)(1, 0, 0, 1) = (*this)(0, 1, 0, 1);
534  (*this)(1, 0, 1, 1) = (*this)(0, 1, 1, 1);
535  (*this)(1, 0, 0, 0) = (*this)(0, 1, 0, 0);
536  (*this)(1, 1, 1, 0) = (*this)(1, 1, 0, 1);
537  }
538  else if (input.size() == 2)
539  {
540  // only two independent constants, C_1111 and C_1122
541  (*this)(0, 0, 0, 0) = input[0];
542  (*this)(0, 0, 1, 1) = input[1];
543  // use symmetries
544  (*this)(1, 1, 1, 1) = (*this)(0, 0, 0, 0);
545  (*this)(1, 1, 0, 0) = (*this)(0, 0, 1, 1);
546  (*this)(0, 1, 0, 1) = 0.5 * ((*this)(0, 0, 0, 0) - (*this)(0, 0, 1, 1));
547  (*this)(1, 0, 0, 1) = (*this)(0, 1, 0, 1);
548  (*this)(0, 1, 1, 0) = (*this)(0, 1, 0, 1);
549  (*this)(1, 0, 1, 0) = (*this)(0, 1, 0, 1);
550  }
551  else
552  mooseError(
553  "Please provide correct number of inputs for surface RankFourTensor initialization.");
554 }
void zero()
Zeros out the tensor.
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
RankFourTensor RankFourTensor::transposeMajor ( ) const

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

Returns
C_klji

Definition at line 488 of file RankFourTensor.C.

Referenced by operator()().

489 {
490  RankFourTensor result;
491 
492  unsigned int index = 0;
493  unsigned int i1 = 0;
494  for (unsigned int i = 0; i < N; ++i)
495  {
496  for (unsigned int j = 0; j < N; ++j)
497  {
498  for (unsigned int k = 0; k < N; ++k)
499  {
500  unsigned int ijk1 = k * N3 + i1 + j;
501  for (unsigned int l = 0; l < N; ++l)
502  result._vals[index++] = _vals[ijk1 + l * N2];
503  }
504  }
505  i1 += N;
506  }
507 
508  return result;
509 }
static constexpr unsigned int N2
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 N3
static constexpr unsigned int N
Dimensionality of rank-four tensor.
RankFourTensor is designed to handle any N-dimensional fourth order tensor, C.
void RankFourTensor::zero ( )

Zeros out the tensor.

Definition at line 103 of file RankFourTensor.C.

Referenced by fillAntisymmetricFromInputVector(), fillFromInputVector(), fillPrincipalFromInputVector(), fillSymmetricFromInputVector(), operator()(), RankFourTensor(), and surfaceFillFromInputVector().

104 {
105  for (unsigned int i = 0; i < N4; ++i)
106  _vals[i] = 0.0;
107 }
static constexpr unsigned int N4
Real _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

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

Definition at line 351 of file DataIO.h.

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.

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 RankThreeTensor
friend

Definition at line 347 of file RankFourTensor.h.

friend class RankTwoTensor
friend

Definition at line 346 of file RankFourTensor.h.

Member Data Documentation

Real RankFourTensor::_vals[N4]
protected
constexpr unsigned int RankFourTensor::N = LIBMESH_DIM
staticprotected
constexpr unsigned int RankFourTensor::N2 = N * N
staticprotected

Definition at line 239 of file RankFourTensor.h.

Referenced by innerProductTranspose(), isIsotropic(), operator*(), and transposeMajor().

constexpr unsigned int RankFourTensor::N3 = N * N * N
staticprotected

Definition at line 240 of file RankFourTensor.h.

Referenced by isIsotropic(), and transposeMajor().

constexpr unsigned int RankFourTensor::N4 = N * N * N * N
staticprotected

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