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

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

Static Protected Attributes

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

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 31 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 70 of file RankThreeTensor.h.

◆ InitMethod

template<typename T>
enum RankThreeTensorTempl::InitMethod

Initialization method.

Enumerator
initNone 

Definition at line 60 of file RankThreeTensor.h.

Constructor & Destructor Documentation

◆ RankThreeTensorTempl() [1/4]

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

Default constructor; fills to zero.

Definition at line 54 of file RankThreeTensor.C.

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

◆ RankThreeTensorTempl() [2/4]

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

Construct from other class template instantiation.

Definition at line 227 of file RankThreeTensor.h.

228 {
229  for (unsigned int i = 0; i < N3; ++i)
230  _vals[i] = copy._vals[i];
231 }
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

◆ RankThreeTensorTempl() [3/4]

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

Select specific initialization pattern.

Definition at line 63 of file RankThreeTensor.C.

64 {
65  switch (init)
66  {
67  case initNone:
68  break;
69 
70  default:
71  mooseError("Unknown RankThreeTensor initialization pattern.");
72  }
73 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:207

◆ RankThreeTensorTempl() [4/4]

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

Fill from vector.

Definition at line 76 of file RankThreeTensor.C.

77 {
78  fillFromInputVector(input, fill_method);
79 }
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 363 of file RankThreeTensor.C.

364 {
365  VectorValue<T> result;
366 
367  for (unsigned int i = 0; i < N; ++i)
368  for (unsigned int j = 0; j < N2; ++j)
369  result(i) += _vals[i * N2 + j] * b._coords[j];
370 
371  return result;
372 }
static constexpr unsigned int N2
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
Dimensionality of rank-three tensor.

◆ 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 239 of file RankThreeTensor.C.

240 {
241  zero();
242 
243  if (fill_method == automatic)
244  {
245  if (input.size() == 27)
246  fill_method = general;
247  else if (input.size() == 3)
248  fill_method = plane_normal;
249  else
250  mooseError("Unsupported automatic fill method, use 27 values for 'general' and 3 for "
251  "'plane_normal', the supplied size was ",
252  input.size(),
253  ".");
254  }
255 
256  if (fill_method == general)
258 
259  else if (fill_method == plane_normal)
260  {
261  if (input.size() != 3)
262  mooseError("To use fillFromPlaneNormal, your input must have size 3, the supplied size was ",
263  input.size(),
264  ".");
265  fillFromPlaneNormal(VectorValue<T>(input[0], input[1], input[2]));
266  }
267 
268  else
269  // This is un-reachable unless a FillMethod is added and the if statement is not updated
270  mooseError("fillFromInputVector called with unknown fill_method of ", fill_method);
271 }
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:207
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 275 of file RankThreeTensor.C.

276 {
277  unsigned int index = 0;
278  for (unsigned int i = 0; i < N; ++i)
279  {
280  const T a = input(i);
281  for (unsigned int j = 0; j < N; ++j)
282  {
283  const T b = input(j);
284  for (unsigned int k = 0; k < N; ++k)
285  {
286  const T c = input(k);
287  T sum = 0;
288  sum = -2 * a * b * c;
289  if (i == j)
290  sum += c;
291  if (i == k)
292  sum += b;
293  _vals[index++] = sum / 2.0;
294  }
295  }
296  }
297 }
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
Dimensionality of rank-three tensor.

◆ fillGeneralFromInputVector()

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

Definition at line 349 of file RankThreeTensor.C.

350 {
351  if (input.size() != 27)
352  mooseError(
353  "To use fillGeneralFromInputVector, your input must have size 27, the supplied size was ",
354  input.size(),
355  ".");
356 
357  for (unsigned int i = 0; i < N3; ++i)
358  _vals[i] = input[i];
359 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:207
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

◆ fillMethodEnum()

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

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

Definition at line 48 of file RankThreeTensor.C.

49 {
50  return MooseEnum("general plane_normal");
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

◆ L2norm()

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

(r_ijk*r_ijk)

Definition at line 227 of file RankThreeTensor.C.

228 {
229  T l2 = 0;
230 
231  for (unsigned int i = 0; i < N3; ++i)
232  l2 += Utility::pow<2>(_vals[i]);
233 
234  return std::sqrt(l2);
235 }
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

◆ 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 301 of file RankThreeTensor.C.

302 {
303  RankFourTensorTempl<T> result;
304 
305  unsigned int index = 0;
306  for (unsigned int i = 0; i < N; ++i)
307  for (unsigned int j = 0; j < N; ++j)
308  for (unsigned int k = 0; k < N; ++k)
309  for (unsigned int l = 0; l < N; ++l)
310  {
311  for (unsigned int m = 0; m < N; ++m)
312  for (unsigned int n = 0; n < N; ++n)
313  result._vals[index] += (*this)(m, i, j) * a(m, n) * (*this)(n, k, l);
314  index++;
315  }
316 
317  return result;
318 }
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-three tensor.

◆ 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 93 of file RankThreeTensor.h.

94  {
95  return _vals[((i * N + j) * N + k)];
96  }
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
Dimensionality of rank-three tensor.

◆ 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 99 of file RankThreeTensor.h.

100  {
101  return _vals[((i * N + j) * N + k)];
102  }
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
Dimensionality of rank-three tensor.

◆ 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 109 of file RankThreeTensor.C.

110 {
111  VectorValue<T> result;
112 
113  for (unsigned int i = 0; i < N; ++i)
114  {
115  T sum = 0;
116  unsigned int i1 = i * N2;
117  for (unsigned int j1 = 0; j1 < N2; j1 += N)
118  for (unsigned int k = 0; k < N; ++k)
119  sum += _vals[i1 + j1 + k] * a._coords[j1 + k];
120  result(i) = sum;
121  }
122 
123  return result;
124 }
static constexpr unsigned int N2
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
Dimensionality of rank-three tensor.

◆ operator*() [2/2]

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

r_ijk*a

Definition at line 127 of file RankThreeTensor.C.

128 {
130 
131  for (unsigned int i = 0; i < N3; ++i)
132  result._vals[i] = _vals[i] * b;
133 
134  return result;
135 }
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

◆ operator*=()

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

r_ijk *= a

Definition at line 139 of file RankThreeTensor.C.

140 {
141  for (unsigned int i = 0; i < N3; ++i)
142  _vals[i] *= a;
143 
144  return *this;
145 }
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

◆ operator+()

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

r_ijkl + a_ijk

Definition at line 181 of file RankThreeTensor.C.

182 {
184 
185  for (unsigned int i = 0; i < N3; ++i)
186  result._vals[i] = _vals[i] + b._vals[i];
187 
188  return result;
189 }
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

◆ 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 171 of file RankThreeTensor.C.

172 {
173  for (unsigned int i = 0; i < N3; ++i)
174  _vals[i] += a._vals[i];
175 
176  return *this;
177 }
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

◆ operator-() [1/2]

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

r_ijk - a_ijk

Definition at line 203 of file RankThreeTensor.C.

204 {
206 
207  for (unsigned int i = 0; i < N3; ++i)
208  result._vals[i] = _vals[i] - b._vals[i];
209 
210  return result;
211 }
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

◆ operator-() [2/2]

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

-r_ijk

Definition at line 215 of file RankThreeTensor.C.

216 {
218 
219  for (unsigned int i = 0; i < N3; ++i)
220  result._vals[i] = -_vals[i];
221 
222  return result;
223 }
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

◆ operator-=()

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

r_ijk -= a_ijk

Definition at line 193 of file RankThreeTensor.C.

194 {
195  for (unsigned int i = 0; i < N3; ++i)
196  _vals[i] -= a._vals[i];
197 
198  return *this;
199 }
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

◆ operator/()

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

r_ijk/a

Definition at line 149 of file RankThreeTensor.C.

150 {
152 
153  for (unsigned int i = 0; i < N3; ++i)
154  result._vals[i] = _vals[i] / b;
155 
156  return result;
157 }
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

◆ operator/=()

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

r_ijk /= a for all i, j, k

Definition at line 161 of file RankThreeTensor.C.

162 {
163  for (unsigned int i = 0; i < N3; ++i)
164  _vals[i] /= a;
165 
166  return *this;
167 }
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

◆ operator=() [1/2]

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

Assignment-from-scalar operator.

Definition at line 91 of file RankThreeTensor.C.

92 {
93  for (unsigned int i = 0; i < N3; ++i)
94  _vals[i] = value;
95  return *this;
96 }
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

◆ operator=() [2/2]

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

copies values from "a" into this tensor

Definition at line 100 of file RankThreeTensor.C.

101 {
102  for (unsigned int i = 0; i < N3; ++i)
103  _vals[i] = a._vals[i];
104 
105  return *this;
106 }
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

◆ print()

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

Print the rank three tensor.

Definition at line 376 of file RankThreeTensor.C.

377 {
378  for (unsigned int i = 0; i < N; ++i)
379  {
380  stm << "a(" << i << ", j, k) = \n";
381  for (unsigned int j = 0; j < N; ++j)
382  {
383  for (unsigned int k = 0; k < N; ++k)
384  stm << std::setw(15) << (*this)(i, j, k) << ' ';
385  stm << "\n";
386  }
387  stm << "\n";
388  }
389 }
static constexpr unsigned int N
Dimensionality of rank-three tensor.

◆ 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 236 of file RankThreeTensor.h.

237 {
238  unsigned int index = 0;
239  for (unsigned int i = 0; i < N; ++i)
240  for (unsigned int j = 0; j < N; ++j)
241  for (unsigned int k = 0; k < N; ++k)
242  {
243  unsigned int index2 = 0;
244  T sum = 0.0;
245  for (unsigned int m = 0; m < N; ++m)
246  {
247  T a = R(i, m);
248  for (unsigned int n = 0; n < N; ++n)
249  {
250  T ab = a * R(j, n);
251  for (unsigned int o = 0; o < N; ++o)
252  sum += ab * R(k, o) * _vals[index2++];
253  }
254  }
255  _vals[index++] = sum;
256  }
257 }
PetscInt m
T _vals[N3]
The values of the rank-three tensor stored by index=((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) ...
PetscInt n
static constexpr unsigned int N
Dimensionality of rank-three tensor.

◆ 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 322 of file RankThreeTensor.C.

323 {
324  RankThreeTensorTempl<T> old = *this;
325 
326  unsigned int index = 0;
327  for (unsigned int i = 0; i < N; ++i)
328  for (unsigned int j = 0; j < N; ++j)
329  for (unsigned int k = 0; k < N; ++k)
330  {
331  T sum = 0.0;
332  unsigned int index2 = 0;
333  for (unsigned int m = 0; m < N; ++m)
334  {
335  T a = R(i, m);
336  for (unsigned int n = 0; n < N; ++n)
337  {
338  T ab = a * R(j, n);
339  for (unsigned int o = 0; o < N; ++o)
340  sum += ab * R(k, o) * old._vals[index2++];
341  }
342  }
343  _vals[index++] = sum;
344  }
345 }
RankThreeTensor is designed to handle any N-dimensional third order tensor, r.
PetscInt m
T _vals[N3]
The values of the rank-three tensor stored by index=((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) ...
PetscInt n
static constexpr unsigned int N
Dimensionality of rank-three tensor.

◆ zero()

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

Zeros out the tensor.

Definition at line 83 of file RankThreeTensor.C.

84 {
85  for (unsigned int i = 0; i < N3; ++i)
86  _vals[i] = 0;
87 }
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

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 219 of file RankThreeTensor.h.

◆ RankThreeTensorTempl

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

Definition at line 216 of file RankThreeTensor.h.

◆ RankTwoTensorTempl

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

Definition at line 213 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 = LIBMESH_DIM
staticprotected

Dimensionality of rank-three tensor.

Definition at line 197 of file RankThreeTensor.h.

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

◆ N2

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

Definition at line 198 of file RankThreeTensor.h.

◆ N3

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

Definition at line 199 of file RankThreeTensor.h.


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