23 #include "libmesh/utility.h" 24 #include "libmesh/vector_value.h" 25 #include "libmesh/tensor_value.h" 49 mooseAssert(
N == 3,
"RankThreeTensor is currently only tested for 3 dimensions.");
64 mooseError(
"Unknown RankThreeTensor initialization pattern.");
71 fillFromInputVector(input, fill_method);
96 _vals[i] = a.
_vals[i];
101 template <
typename T>
110 unsigned int i1 = i * N2;
111 for (
unsigned int j1 = 0; j1 < N2; j1 +=
N)
113 sum += _vals[i1 + j1 + k] * a.
_coords[j1 + k];
120 template <
typename T>
130 unsigned int i1 = i * N2;
131 unsigned int j1 = j *
N;
133 sum += _vals[i1 + j1 + k] * a(k);
140 template <
typename T>
147 result.
_vals[i] = _vals[i] * b;
152 template <
typename T>
162 template <
typename T>
169 result.
_vals[i] = _vals[i] / b;
174 template <
typename T>
184 template <
typename T>
189 _vals[i] += a.
_vals[i];
194 template <
typename T>
206 template <
typename T>
211 _vals[i] -= a.
_vals[i];
216 template <
typename T>
228 template <
typename T>
235 result.
_vals[i] = -_vals[i];
240 template <
typename T>
252 template <
typename T>
258 if (fill_method == automatic)
260 if (input.size() == 27)
261 fill_method = general;
262 else if (input.size() == 3)
263 fill_method = plane_normal;
265 mooseError(
"Unsupported automatic fill method, use 27 values for 'general' and 3 for " 266 "'plane_normal', the supplied size was ",
271 if (fill_method == general)
272 fillGeneralFromInputVector(input);
274 else if (fill_method == plane_normal)
276 if (input.size() != 3)
277 mooseError(
"To use fillFromPlaneNormal, your input must have size 3, the supplied size was ",
285 mooseError(
"fillFromInputVector called with unknown fill_method of ", fill_method);
288 template <
typename T>
292 unsigned int index = 0;
295 const T a = input(i);
298 const T b = input(j);
301 const T c = input(k);
303 sum = -2.0 * a * b * c;
308 _vals[index++] = sum / 2.0;
314 template <
typename T>
320 unsigned int index = 0;
328 result.
_vals[index] += (*this)(m, i, j) * a(m, n) * (*this)(n, k, l);
335 template <
typename T>
341 unsigned int index = 0;
347 unsigned int index2 = 0;
355 sum += ab * R(k, o) * old.
_vals[index2++];
358 _vals[index++] = sum;
362 template <
typename T>
366 if (input.size() != 27)
368 "To use fillGeneralFromInputVector, your input must have size 27, the supplied size was ",
376 template <
typename T>
384 result(i) += _vals[i * N2 + j] * b.
_coords[j];
389 template <
typename T>
395 stm <<
"a(" << i <<
", j, k) = \n";
399 stm << std::setw(15) << (*this)(i, j, k) <<
' ';
RankFourTensorTempl is designed to handle any N-dimensional fourth order tensor, C.
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...
void mooseSetToZero< RankThreeTensor >(RankThreeTensor &v)
void fillFromPlaneNormal(const libMesh::VectorValue< T > &input)
Fills RankThreeTensor from plane normal vectors ref.
RankThreeTensorTempl< T > & operator/=(const T a)
r_ijk /= a for all i, j, k
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
libMesh::VectorValue< T > doubleContraction(const RankTwoTensorTempl< T > &b) const
Creates a vector from the double contraction of a rank three and rank two tensor. ...
RankThreeTensorTempl< T > & operator-=(const RankThreeTensorTempl< T > &a)
r_ijk -= a_ijk
void fillFromInputVector(const std::vector< T > &input, FillMethod fill_method=automatic)
fillFromInputVector takes some number of inputs to fill the Rank-3 tensor.
T _coords[LIBMESH_DIM *LIBMESH_DIM]
RankThreeTensorTempl< T > operator/(const T a) const
r_ijk/a
RankThreeTensor is designed to handle any N-dimensional third order tensor, r.
RankThreeTensorTempl< T > operator-() const
-r_ijk
FillMethod
To fill up the 27 entries in the 3rd-order tensor, fillFromInputVector is called with one of the foll...
RankThreeTensorTempl< T > & operator+=(const RankThreeTensorTempl< T > &a)
r_ijk += a_ijk for all i, j, k
static MooseEnum fillMethodEnum()
Static method for use in validParams for getting the "fill_method".
RankThreeTensorTempl< T > & operator*=(const T a)
r_ijk *= a
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
void rotate(const T2 &R)
Rotate the tensor using r_ijk = R_im R_in R_ko r_mno.
libMesh::VectorValue< T > operator*(const RankTwoTensorTempl< T > &a) const
b_i = r_ijk * a_jk
RankThreeTensorTempl< T > & operator=(const T &value)
Assignment-from-scalar operator.
void init(triangulateio &t)
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
T _vals[N3]
The values of the rank-three tensor stored by index=((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) ...
InitMethod
Initialization method.
T _vals[N4]
The values of the rank-four tensor stored by index=(((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) * LIBME...
RankThreeTensorTempl()
Default constructor; fills to zero.
RankThreeTensorTempl< T > operator+(const RankThreeTensorTempl< T > &a) const
r_ijkl + a_ijk
T L2norm() const
(r_ijk*r_ijk)
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template * sqrt(_arg)) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(tanh
RankTwoTensorTempl is designed to handle the Stress or Strain Tensor for a fully anisotropic material...
void mooseSetToZero< ADRankThreeTensor >(ADRankThreeTensor &v)
IntRange< T > make_range(T beg, T end)
void zero()
Zeros out the tensor.
void fillGeneralFromInputVector(const std::vector< T > &input)
void print(std::ostream &stm=Moose::out) const
Print the rank three tensor.
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