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

RankThreeTensor is designed to handle any N-dimensional third order tensor, r. More...

#include <RankThreeTensor.h>

Public Types

enum  InitMethod { initNone }
 Initialization method. More...
 
enum  FillMethod { automatic, general, plane_normal }
 To fill up the 27 entries in the 3rd-order tensor, fillFromInputVector is called with one of the following fill_methods. More...
 

Public Member Functions

 RankThreeTensorTempl ()
 Default constructor; fills to zero. More...
 
 RankThreeTensorTempl (const RankThreeTensorTempl< T > &a)=default
 Copy assignment operator must be defined if used. More...
 
template<typename T2 >
 RankThreeTensorTempl (const RankThreeTensorTempl< T2 > &copy)
 Construct from other class template instantiation. More...
 
 RankThreeTensorTempl (const InitMethod)
 Select specific initialization pattern. More...
 
 RankThreeTensorTempl (const std::vector< T > &, FillMethod method=automatic)
 Fill from vector. More...
 
T & operator() (unsigned int i, unsigned int j, unsigned int k)
 Gets the value for the index specified. Takes index = 0,1,2. More...
 
operator() (unsigned int i, unsigned int j, unsigned int k) const
 Gets the value for the index specified. Takes index = 0,1,2. Used for const. More...
 
RankThreeTensorTempl< T > & operator= (const T &value)
 Assignment-from-scalar operator. More...
 
void zero ()
 Zeros out the tensor. More...
 
void print (std::ostream &stm=Moose::out) const
 Print the rank three tensor. More...
 
RankThreeTensorTempl< T > & operator= (const RankThreeTensorTempl< T > &a)
 copies values from "a" into this tensor More...
 
template<typename T2 >
RankThreeTensorTempl< T > & operator= (const RankThreeTensorTempl< T2 > &a)
 
VectorValue< T > operator* (const RankTwoTensorTempl< T > &a) const
 b_i = r_ijk * a_jk More...
 
RankThreeTensorTempl< T > operator* (const T a) const
 r_ijk*a More...
 
RankThreeTensorTempl< T > & operator*= (const T a)
 r_ijk *= a More...
 
RankThreeTensorTempl< T > operator/ (const T a) const
 r_ijk/a More...
 
RankThreeTensorTempl< T > & operator/= (const T a)
 r_ijk /= a for all i, j, k More...
 
RankThreeTensorTempl< T > & operator+= (const RankThreeTensorTempl< T > &a)
 r_ijk += a_ijk for all i, j, k More...
 
RankThreeTensorTempl< T > operator+ (const RankThreeTensorTempl< T > &a) const
 r_ijkl + a_ijk More...
 
RankThreeTensorTempl< T > & operator-= (const RankThreeTensorTempl< T > &a)
 r_ijk -= a_ijk More...
 
RankThreeTensorTempl< T > operator- (const RankThreeTensorTempl< T > &a) const
 r_ijk - a_ijk More...
 
RankThreeTensorTempl< T > operator- () const
 -r_ijk More...
 
L2norm () const
 (r_ijk*r_ijk) More...
 
template<class T2 >
void rotate (const T2 &R)
 Rotate the tensor using r_ijk = R_im R_in R_ko r_mno. More...
 
void rotate (const TensorValue< T > &R)
 Rotate the tensor using r_ijk = R_im R_in R_ko r_mno. More...
 
void fillFromInputVector (const std::vector< T > &input, FillMethod fill_method=automatic)
 fillFromInputVector takes some number of inputs to fill the Rank-3 tensor. More...
 
void fillFromPlaneNormal (const VectorValue< T > &input)
 Fills RankThreeTensor from plane normal vectors ref. More...
 
RankFourTensorTempl< T > mixedProductRankFour (const RankTwoTensorTempl< T > &a) const
 Creates fourth order tensor D_{ijkl}=A_{mij}*b_{mn}*A_{nkl} where A is rank 3 and b is rank 2. More...
 
VectorValue< T > doubleContraction (const RankTwoTensorTempl< T > &b) const
 Creates a vector from the double contraction of a rank three and rank two tensor. More...
 

Static Public Member Functions

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

Static Public Attributes

static constexpr unsigned int N = Moose::dim
 tensor dimension and powers of the dimension More...
 
static constexpr unsigned int N2 = N * N
 
static constexpr unsigned int N3 = N * N * N
 

Protected Member Functions

void fillGeneralFromInputVector (const std::vector< T > &input)
 

Protected Attributes

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

Friends

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

Detailed Description

template<typename T>
class RankThreeTensorTempl< T >

RankThreeTensor is designed to handle any N-dimensional third order tensor, r.

Definition at line 56 of file RankThreeTensor.h.

Member Enumeration Documentation

◆ FillMethod

template<typename T>
enum RankThreeTensorTempl::FillMethod

To fill up the 27 entries in the 3rd-order tensor, fillFromInputVector is called with one of the following fill_methods.

See the fill*FromInputVector functions for more details

Enumerator
automatic 
general 
plane_normal 

Definition at line 76 of file RankThreeTensor.h.

◆ InitMethod

template<typename T>
enum RankThreeTensorTempl::InitMethod

Initialization method.

Enumerator
initNone 

Definition at line 66 of file RankThreeTensor.h.

Constructor & Destructor Documentation

◆ RankThreeTensorTempl() [1/5]

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

Default constructor; fills to zero.

Definition at line 45 of file RankThreeTensorImplementation.h.

46 {
47  mooseAssert(N == 3, "RankThreeTensor is currently only tested for 3 dimensions.");
48 
49  for (auto i : make_range(N3))
50  _vals[i] = 0;
51 }
T _vals[N3]
The values of the rank-three tensor stored by index=((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) ...
static constexpr unsigned int N3
IntRange< T > make_range(T beg, T end)
static constexpr unsigned int N
tensor dimension and powers of the dimension

◆ RankThreeTensorTempl() [2/5]

template<typename T>
RankThreeTensorTempl< T >::RankThreeTensorTempl ( const RankThreeTensorTempl< T > &  a)
default

Copy assignment operator must be defined if used.

◆ RankThreeTensorTempl() [3/5]

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

Construct from other class template instantiation.

Definition at line 251 of file RankThreeTensor.h.

252 {
253  for (const auto i : make_range(N3))
254  _vals[i] = copy._vals[i];
255 }
T _vals[N3]
The values of the rank-three tensor stored by index=((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) ...
static constexpr unsigned int N3
IntRange< T > make_range(T beg, T end)

◆ RankThreeTensorTempl() [4/5]

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

Select specific initialization pattern.

Definition at line 54 of file RankThreeTensorImplementation.h.

55 {
56  switch (init)
57  {
58  case initNone:
59  break;
60 
61  default:
62  mooseError("Unknown RankThreeTensor initialization pattern.");
63  }
64 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:284

◆ RankThreeTensorTempl() [5/5]

template<typename T >
RankThreeTensorTempl< T >::RankThreeTensorTempl ( const std::vector< T > &  input,
FillMethod  method = automatic 
)

Fill from vector.

Definition at line 67 of file RankThreeTensorImplementation.h.

68 {
69  fillFromInputVector(input, fill_method);
70 }
void fillFromInputVector(const std::vector< T > &input, FillMethod fill_method=automatic)
fillFromInputVector takes some number of inputs to fill the Rank-3 tensor.

Member Function Documentation

◆ doubleContraction()

template<typename T >
VectorValue< T > RankThreeTensorTempl< T >::doubleContraction ( const RankTwoTensorTempl< T > &  b) const

Creates a vector from the double contraction of a rank three and rank two tensor.

c_i = A_{ijk} * b_{jk}

Definition at line 356 of file RankThreeTensorImplementation.h.

357 {
358  VectorValue<T> result;
359 
360  for (auto i : make_range(N))
361  for (auto j : make_range(N2))
362  result(i) += _vals[i * N2 + j] * b._coords[j];
363 
364  return result;
365 }
static constexpr unsigned int N2
T _coords[LIBMESH_DIM *LIBMESH_DIM]
T _vals[N3]
The values of the rank-three tensor stored by index=((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) ...
IntRange< T > make_range(T beg, T end)
static constexpr unsigned int N
tensor dimension and powers of the dimension

◆ fillFromInputVector()

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

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

Parameters
inputthe numbers that will be placed in the tensor
fill_methodthis can be: general (use fillGeneralFromInputVector) more fill_methods to be implemented soon!

Definition at line 232 of file RankThreeTensorImplementation.h.

233 {
234  zero();
235 
236  if (fill_method == automatic)
237  {
238  if (input.size() == 27)
239  fill_method = general;
240  else if (input.size() == 3)
241  fill_method = plane_normal;
242  else
243  mooseError("Unsupported automatic fill method, use 27 values for 'general' and 3 for "
244  "'plane_normal', the supplied size was ",
245  input.size(),
246  ".");
247  }
248 
249  if (fill_method == general)
251 
252  else if (fill_method == plane_normal)
253  {
254  if (input.size() != 3)
255  mooseError("To use fillFromPlaneNormal, your input must have size 3, the supplied size was ",
256  input.size(),
257  ".");
258  fillFromPlaneNormal(VectorValue<T>(input[0], input[1], input[2]));
259  }
260 
261  else
262  // This is un-reachable unless a FillMethod is added and the if statement is not updated
263  mooseError("fillFromInputVector called with unknown fill_method of ", fill_method);
264 }
void fillFromPlaneNormal(const VectorValue< T > &input)
Fills RankThreeTensor from plane normal vectors ref.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:284
void zero()
Zeros out the tensor.
void fillGeneralFromInputVector(const std::vector< T > &input)

◆ fillFromPlaneNormal()

template<typename T >
void RankThreeTensorTempl< T >::fillFromPlaneNormal ( const VectorValue< T > &  input)

Fills RankThreeTensor from plane normal vectors ref.

Kuhl et. al. Int. J. Solids Struct. 38(2001) 2933-2952

Parameters
inputplane normal vector

Definition at line 268 of file RankThreeTensorImplementation.h.

269 {
270  unsigned int index = 0;
271  for (auto i : make_range(N))
272  {
273  const T a = input(i);
274  for (auto j : make_range(N))
275  {
276  const T b = input(j);
277  for (auto k : make_range(N))
278  {
279  const T c = input(k);
280  T sum = 0;
281  sum = -2.0 * a * b * c;
282  if (i == j)
283  sum += c;
284  if (i == k)
285  sum += b;
286  _vals[index++] = sum / 2.0;
287  }
288  }
289  }
290 }
T _vals[N3]
The values of the rank-three tensor stored by index=((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) ...
IntRange< T > make_range(T beg, T end)
static constexpr unsigned int N
tensor dimension and powers of the dimension

◆ fillGeneralFromInputVector()

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

Definition at line 342 of file RankThreeTensorImplementation.h.

343 {
344  if (input.size() != 27)
345  mooseError(
346  "To use fillGeneralFromInputVector, your input must have size 27, the supplied size was ",
347  input.size(),
348  ".");
349 
350  for (auto i : make_range(N3))
351  _vals[i] = input[i];
352 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:284
T _vals[N3]
The values of the rank-three tensor stored by index=((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) ...
static constexpr unsigned int N3
IntRange< T > make_range(T beg, T end)

◆ fillMethodEnum()

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

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

Definition at line 39 of file RankThreeTensorImplementation.h.

40 {
41  return MooseEnum("general plane_normal");
42 }
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:31

◆ L2norm()

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

(r_ijk*r_ijk)

Definition at line 220 of file RankThreeTensorImplementation.h.

221 {
222  T l2 = 0;
223 
224  for (auto i : make_range(N3))
225  l2 += Utility::pow<2>(_vals[i]);
226 
227  return std::sqrt(l2);
228 }
ADRealEigenVector< T, D, asd > sqrt(const ADRealEigenVector< T, D, asd > &)
T _vals[N3]
The values of the rank-three tensor stored by index=((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) ...
static constexpr unsigned int N3
IntRange< T > make_range(T beg, T end)
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template pow< 2 >(tan(_arg))+1.0) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(sqrt

◆ mixedProductRankFour()

template<typename T >
RankFourTensorTempl< T > RankThreeTensorTempl< T >::mixedProductRankFour ( const RankTwoTensorTempl< T > &  a) const

Creates fourth order tensor D_{ijkl}=A_{mij}*b_{mn}*A_{nkl} where A is rank 3 and b is rank 2.

Parameters
aRankThreeTensor A in the equation above

Definition at line 294 of file RankThreeTensorImplementation.h.

295 {
296  RankFourTensorTempl<T> result;
297 
298  unsigned int index = 0;
299  for (auto i : make_range(N))
300  for (auto j : make_range(N))
301  for (auto k : make_range(N))
302  for (auto l : make_range(N))
303  {
304  for (auto m : make_range(N))
305  for (auto n : make_range(N))
306  result._vals[index] += (*this)(m, i, j) * a(m, n) * (*this)(n, k, l);
307  index++;
308  }
309 
310  return result;
311 }
RankFourTensorTempl is designed to handle any N-dimensional fourth order tensor, C.
T _vals[N4]
The values of the rank-four tensor stored by index=(((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) * LIBME...
IntRange< T > make_range(T beg, T end)
static constexpr unsigned int N
tensor dimension and powers of the dimension

◆ operator()() [1/2]

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

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

Definition at line 102 of file RankThreeTensor.h.

103  {
104  return _vals[((i * N + j) * N + k)];
105  }
T _vals[N3]
The values of the rank-three tensor stored by index=((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) ...
static constexpr unsigned int N
tensor dimension and powers of the dimension

◆ operator()() [2/2]

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

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

Definition at line 108 of file RankThreeTensor.h.

109  {
110  return _vals[((i * N + j) * N + k)];
111  }
T _vals[N3]
The values of the rank-three tensor stored by index=((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) ...
static constexpr unsigned int N
tensor dimension and powers of the dimension

◆ operator*() [1/2]

template<typename T >
VectorValue< T > RankThreeTensorTempl< T >::operator* ( const RankTwoTensorTempl< T > &  a) const

b_i = r_ijk * a_jk

Definition at line 101 of file RankThreeTensorImplementation.h.

102 {
103  VectorValue<T> result;
104 
105  for (auto i : make_range(N))
106  {
107  T sum = 0;
108  unsigned int i1 = i * N2;
109  for (unsigned int j1 = 0; j1 < N2; j1 += N)
110  for (auto k : make_range(N))
111  sum += _vals[i1 + j1 + k] * a._coords[j1 + k];
112  result(i) = sum;
113  }
114 
115  return result;
116 }
static constexpr unsigned int N2
T _coords[LIBMESH_DIM *LIBMESH_DIM]
T _vals[N3]
The values of the rank-three tensor stored by index=((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) ...
IntRange< T > make_range(T beg, T end)
static constexpr unsigned int N
tensor dimension and powers of the dimension

◆ operator*() [2/2]

template<typename T >
RankThreeTensorTempl< T > RankThreeTensorTempl< T >::operator* ( const T  a) const

r_ijk*a

Definition at line 120 of file RankThreeTensorImplementation.h.

121 {
123 
124  for (auto i : make_range(N3))
125  result._vals[i] = _vals[i] * b;
126 
127  return result;
128 }
RankThreeTensor is designed to handle any N-dimensional third order tensor, r.
T _vals[N3]
The values of the rank-three tensor stored by index=((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) ...
static constexpr unsigned int N3
IntRange< T > make_range(T beg, T end)

◆ operator*=()

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

r_ijk *= a

Definition at line 132 of file RankThreeTensorImplementation.h.

133 {
134  for (auto i : make_range(N3))
135  _vals[i] *= a;
136 
137  return *this;
138 }
T _vals[N3]
The values of the rank-three tensor stored by index=((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) ...
static constexpr unsigned int N3
IntRange< T > make_range(T beg, T end)

◆ operator+()

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

r_ijkl + a_ijk

Definition at line 174 of file RankThreeTensorImplementation.h.

175 {
177 
178  for (auto i : make_range(N3))
179  result._vals[i] = _vals[i] + b._vals[i];
180 
181  return result;
182 }
RankThreeTensor is designed to handle any N-dimensional third order tensor, r.
T _vals[N3]
The values of the rank-three tensor stored by index=((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) ...
static constexpr unsigned int N3
IntRange< T > make_range(T beg, T end)

◆ operator+=()

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

r_ijk += a_ijk for all i, j, k

Definition at line 164 of file RankThreeTensorImplementation.h.

165 {
166  for (auto i : make_range(N3))
167  _vals[i] += a._vals[i];
168 
169  return *this;
170 }
T _vals[N3]
The values of the rank-three tensor stored by index=((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) ...
static constexpr unsigned int N3
IntRange< T > make_range(T beg, T end)

◆ operator-() [1/2]

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

r_ijk - a_ijk

Definition at line 196 of file RankThreeTensorImplementation.h.

197 {
199 
200  for (auto i : make_range(N3))
201  result._vals[i] = _vals[i] - b._vals[i];
202 
203  return result;
204 }
RankThreeTensor is designed to handle any N-dimensional third order tensor, r.
T _vals[N3]
The values of the rank-three tensor stored by index=((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) ...
static constexpr unsigned int N3
IntRange< T > make_range(T beg, T end)

◆ operator-() [2/2]

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

-r_ijk

Definition at line 208 of file RankThreeTensorImplementation.h.

209 {
211 
212  for (auto i : make_range(N3))
213  result._vals[i] = -_vals[i];
214 
215  return result;
216 }
RankThreeTensor is designed to handle any N-dimensional third order tensor, r.
T _vals[N3]
The values of the rank-three tensor stored by index=((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) ...
static constexpr unsigned int N3
IntRange< T > make_range(T beg, T end)

◆ operator-=()

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

r_ijk -= a_ijk

Definition at line 186 of file RankThreeTensorImplementation.h.

187 {
188  for (auto i : make_range(N3))
189  _vals[i] -= a._vals[i];
190 
191  return *this;
192 }
T _vals[N3]
The values of the rank-three tensor stored by index=((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) ...
static constexpr unsigned int N3
IntRange< T > make_range(T beg, T end)

◆ operator/()

template<typename T >
RankThreeTensorTempl< T > RankThreeTensorTempl< T >::operator/ ( const T  a) const

r_ijk/a

Definition at line 142 of file RankThreeTensorImplementation.h.

143 {
145 
146  for (auto i : make_range(N3))
147  result._vals[i] = _vals[i] / b;
148 
149  return result;
150 }
RankThreeTensor is designed to handle any N-dimensional third order tensor, r.
T _vals[N3]
The values of the rank-three tensor stored by index=((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) ...
static constexpr unsigned int N3
IntRange< T > make_range(T beg, T end)

◆ operator/=()

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

r_ijk /= a for all i, j, k

Definition at line 154 of file RankThreeTensorImplementation.h.

155 {
156  for (auto i : make_range(N3))
157  _vals[i] /= a;
158 
159  return *this;
160 }
T _vals[N3]
The values of the rank-three tensor stored by index=((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) ...
static constexpr unsigned int N3
IntRange< T > make_range(T beg, T end)

◆ operator=() [1/3]

template<typename T >
RankThreeTensorTempl< T > & RankThreeTensorTempl< T >::operator= ( const T &  value)

Assignment-from-scalar operator.

Definition at line 82 of file RankThreeTensorImplementation.h.

83 {
84  for (auto i : make_range(N3))
85  _vals[i] = value;
86  return *this;
87 }
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
T _vals[N3]
The values of the rank-three tensor stored by index=((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) ...
static constexpr unsigned int N3
IntRange< T > make_range(T beg, T end)

◆ operator=() [2/3]

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

copies values from "a" into this tensor

Definition at line 91 of file RankThreeTensorImplementation.h.

92 {
93  for (auto i : make_range(N3))
94  _vals[i] = a._vals[i];
95 
96  return *this;
97 }
T _vals[N3]
The values of the rank-three tensor stored by index=((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) ...
static constexpr unsigned int N3
IntRange< T > make_range(T beg, T end)

◆ operator=() [3/3]

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

Definition at line 310 of file RankThreeTensor.h.

311 {
312  for (const auto i : make_range(N))
313  for (const auto j : make_range(N))
314  for (const auto k : make_range(N))
315  (*this)(i, j, k) = a(i, j, k);
316 
317  return *this;
318 }
IntRange< T > make_range(T beg, T end)
static constexpr unsigned int N
tensor dimension and powers of the dimension

◆ print()

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

Print the rank three tensor.

Definition at line 369 of file RankThreeTensorImplementation.h.

370 {
371  for (auto i : make_range(N))
372  {
373  stm << "a(" << i << ", j, k) = \n";
374  for (auto j : make_range(N))
375  {
376  for (auto k : make_range(N))
377  stm << std::setw(15) << (*this)(i, j, k) << ' ';
378  stm << "\n";
379  }
380  stm << "\n";
381  }
382 
383  stm << std::flush;
384 }
IntRange< T > make_range(T beg, T end)
static constexpr unsigned int N
tensor dimension and powers of the dimension

◆ rotate() [1/2]

template<typename T >
template<class T2 >
void RankThreeTensorTempl< T >::rotate ( const T2 &  R)

Rotate the tensor using r_ijk = R_im R_in R_ko r_mno.

Definition at line 260 of file RankThreeTensor.h.

261 {
262  unsigned int index = 0;
263  for (const auto i : make_range(N))
264  for (const auto j : make_range(N))
265  for (const auto k : make_range(N))
266  {
267  unsigned int index2 = 0;
268  T sum = 0.0;
269  for (const auto m : make_range(N))
270  {
271  T a = R(i, m);
272  for (const auto n : make_range(N))
273  {
274  T ab = a * R(j, n);
275  for (const auto o : make_range(N))
276  sum += ab * R(k, o) * _vals[index2++];
277  }
278  }
279  _vals[index++] = sum;
280  }
281 }
T _vals[N3]
The values of the rank-three tensor stored by index=((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) ...
IntRange< T > make_range(T beg, T end)
static constexpr unsigned int N
tensor dimension and powers of the dimension

◆ rotate() [2/2]

template<typename T >
void RankThreeTensorTempl< T >::rotate ( const TensorValue< T > &  R)

Rotate the tensor using r_ijk = R_im R_in R_ko r_mno.

Definition at line 315 of file RankThreeTensorImplementation.h.

316 {
317  RankThreeTensorTempl<T> old = *this;
318 
319  unsigned int index = 0;
320  for (auto i : make_range(N))
321  for (auto j : make_range(N))
322  for (auto k : make_range(N))
323  {
324  T sum = 0.0;
325  unsigned int index2 = 0;
326  for (auto m : make_range(N))
327  {
328  T a = R(i, m);
329  for (auto n : make_range(N))
330  {
331  T ab = a * R(j, n);
332  for (auto o : make_range(N))
333  sum += ab * R(k, o) * old._vals[index2++];
334  }
335  }
336  _vals[index++] = sum;
337  }
338 }
RankThreeTensor is designed to handle any N-dimensional third order tensor, r.
T _vals[N3]
The values of the rank-three tensor stored by index=((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) ...
IntRange< T > make_range(T beg, T end)
static constexpr unsigned int N
tensor dimension and powers of the dimension

◆ zero()

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

Zeros out the tensor.

Definition at line 74 of file RankThreeTensorImplementation.h.

75 {
76  for (auto i : make_range(N3))
77  _vals[i] = 0;
78 }
T _vals[N3]
The values of the rank-three tensor stored by index=((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) ...
static constexpr unsigned int N3
IntRange< T > make_range(T beg, T end)

Friends And Related Function Documentation

◆ dataLoad

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

◆ dataStore

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

◆ RankFourTensorTempl

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

Definition at line 226 of file RankThreeTensor.h.

◆ RankThreeTensorTempl

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

Definition at line 223 of file RankThreeTensor.h.

◆ RankTwoTensorTempl

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

Definition at line 220 of file RankThreeTensor.h.

Member Data Documentation

◆ _vals

template<typename T>
T RankThreeTensorTempl< T >::_vals[N3]
protected

◆ N

template<typename T>
constexpr unsigned int RankThreeTensorTempl< T >::N = Moose::dim
static

tensor dimension and powers of the dimension

Definition at line 60 of file RankThreeTensor.h.

Referenced by RankThreeTensorTempl< T >::operator()().

◆ N2

template<typename T>
constexpr unsigned int RankThreeTensorTempl< T >::N2 = N * N
static

Definition at line 61 of file RankThreeTensor.h.

◆ N3

template<typename T>
constexpr unsigned int RankThreeTensorTempl< T >::N3 = N * N * N
static

Definition at line 62 of file RankThreeTensor.h.


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