16 #ifdef MOOSE_KOKKOS_SCOPE 23 #include "libmesh/tensor_tools.h" 41 #ifdef MOOSE_KOKKOS_SCOPE 43 KOKKOS_INLINE_FUNCTION
Vector3() { *
this = T{}; }
44 KOKKOS_INLINE_FUNCTION
Vector3(
const T & scalar) { *
this = scalar; }
46 KOKKOS_INLINE_FUNCTION
Vector3(
const T & x,
const T & y,
const T & z);
49 KOKKOS_INLINE_FUNCTION T &
operator()(
unsigned int i) {
return v[i]; }
50 KOKKOS_INLINE_FUNCTION
const T &
operator()(
unsigned int i)
const {
return v[i]; }
61 KOKKOS_INLINE_FUNCTION
void operator+=(
const T & scalar);
64 KOKKOS_INLINE_FUNCTION
void operator-=(
const T & scalar);
65 KOKKOS_INLINE_FUNCTION
void operator*=(
const T & scalar);
67 KOKKOS_INLINE_FUNCTION
Real norm()
const;
78 #ifdef MOOSE_KOKKOS_SCOPE 79 KOKKOS_INLINE_FUNCTION
Real33() { *
this = 0; }
80 KOKKOS_INLINE_FUNCTION
Real33(
const Real scalar) { *
this = scalar; }
81 KOKKOS_INLINE_FUNCTION
Real33(
const Real33 & tensor) { *
this = tensor; }
83 KOKKOS_INLINE_FUNCTION
Real &
operator()(
unsigned int i,
unsigned int j) {
return a[i][j]; }
84 KOKKOS_INLINE_FUNCTION
Real operator()(
unsigned int i,
unsigned int j)
const {
return a[i][j]; }
90 KOKKOS_INLINE_FUNCTION
void identity(
const unsigned int dim = 3);
94 KOKKOS_INLINE_FUNCTION
Real3 row(
const unsigned int i)
const;
95 KOKKOS_INLINE_FUNCTION
Real3 col(
const unsigned int j)
const;
99 #ifdef MOOSE_KOKKOS_SCOPE 101 template <
typename T>
109 template <
typename T>
110 KOKKOS_INLINE_FUNCTION
118 template <
typename T>
129 template <
typename T>
139 template <
typename T>
150 template <
typename T>
151 template <
typename U>
162 template <
typename T>
173 template <
typename T>
174 template <
typename U>
175 KOKKOS_INLINE_FUNCTION
void 183 template <
typename T>
184 KOKKOS_INLINE_FUNCTION
void 192 template <
typename T>
193 template <
typename U>
194 KOKKOS_INLINE_FUNCTION
void 202 template <
typename T>
203 KOKKOS_INLINE_FUNCTION
void 211 template <
typename T>
212 KOKKOS_INLINE_FUNCTION
void 220 template <
typename T>
224 return {left + right.
v[0], left + right.
v[1], left + right.
v[2]};
227 template <
typename T>
228 KOKKOS_INLINE_FUNCTION Vector3<T>
231 return {left.
v[0] + right, left.
v[1] + right, left.
v[2] + right};
234 template <
typename T>
235 KOKKOS_INLINE_FUNCTION Vector3<T>
238 return {left.
v[0] + right.
v[0], left.
v[1] + right.
v[1], left.
v[2] + right.
v[2]};
241 template <
typename T>
242 KOKKOS_INLINE_FUNCTION Vector3<T>
245 return {left - right.
v[0], left - right.
v[1], left - right.
v[2]};
248 template <
typename T>
249 KOKKOS_INLINE_FUNCTION Vector3<T>
252 return {left.
v[0] - right, left.
v[1] - right, left.
v[2] - right};
255 template <
typename T>
256 KOKKOS_INLINE_FUNCTION Vector3<T>
259 return {left.
v[0] - right.
v[0], left.
v[1] - right.
v[1], left.
v[2] - right.
v[2]};
262 template <
typename T>
263 KOKKOS_INLINE_FUNCTION Vector3<T>
266 return {left * right.
v[0], left * right.
v[1], left * right.
v[2]};
269 template <
typename T>
270 KOKKOS_INLINE_FUNCTION Vector3<T>
273 return {left.
v[0] * right, left.
v[1] * right, left.
v[2] * right};
276 template <
typename T>
277 KOKKOS_INLINE_FUNCTION T
280 return left.
v[0] * right.
v[0] + left.
v[1] * right.
v[1] + left.
v[2] * right.
v[2];
284 KOKKOS_INLINE_FUNCTION
Real 291 KOKKOS_INLINE_FUNCTION
Real 294 return v[0] * vector.
v[0] + v[1] * vector.
v[1] + v[2] * vector.
v[2];
298 KOKKOS_INLINE_FUNCTION
Real3 303 cross.
v[0] = v[1] * vector.
v[2] - v[2] * vector.
v[1];
304 cross.
v[1] = v[2] * vector.
v[0] - v[0] * vector.
v[2];
305 cross.
v[2] = v[0] * vector.
v[1] - v[1] * vector.
v[0];
311 KOKKOS_INLINE_FUNCTION
Real33 316 for (
unsigned int i = 0; i < 3; ++i)
317 for (
unsigned int j = 0; j < 3; ++j)
318 tensor(i, j) = v[i] * vector.
v[j];
323 KOKKOS_INLINE_FUNCTION
Real33 &
326 for (
unsigned int i = 0; i < 3; ++i)
327 for (
unsigned int j = 0; j < 3; ++j)
328 a[i][j] = tensor.
a[i][j];
333 KOKKOS_INLINE_FUNCTION
Real33 &
336 for (
unsigned int i = 0; i < 3; ++i)
337 for (
unsigned int j = 0; j < 3; ++j)
343 KOKKOS_INLINE_FUNCTION
void 346 for (
unsigned int i = 0; i < 3; ++i)
347 for (
unsigned int j = 0; j < 3; ++j)
348 a[i][j] += tensor.
a[i][j];
351 KOKKOS_INLINE_FUNCTION
void 352 Real33::identity(
const unsigned int dim)
356 for (
unsigned int i = 0; i <
dim; ++i)
360 KOKKOS_INLINE_FUNCTION
Real 361 Real33::determinant(
const unsigned int dim)
const 370 det = a[0][0] * a[1][1] - a[0][1] * a[1][0];
372 det = a[0][0] * (a[1][1] * a[2][2] - a[1][2] * a[2][1]) -
373 a[0][1] * (a[1][0] * a[2][2] - a[1][2] * a[2][0]) +
374 a[0][2] * (a[1][0] * a[2][1] - a[1][1] * a[2][0]);
379 KOKKOS_INLINE_FUNCTION
Real33 382 Real inv_det = 1.0 / determinant(
dim);
387 inv_mat(0, 0) = inv_det;
391 inv_mat(0, 0) = a[1][1] * inv_det;
392 inv_mat(0, 1) = -a[0][1] * inv_det;
393 inv_mat(1, 0) = -a[1][0] * inv_det;
394 inv_mat(1, 1) = a[0][0] * inv_det;
398 inv_mat(0, 0) = (a[1][1] * a[2][2] - a[1][2] * a[2][1]) * inv_det;
399 inv_mat(0, 1) = (a[0][2] * a[2][1] - a[0][1] * a[2][2]) * inv_det;
400 inv_mat(0, 2) = (a[0][1] * a[1][2] - a[0][2] * a[1][1]) * inv_det;
401 inv_mat(1, 0) = (a[1][2] * a[2][0] - a[1][0] * a[2][2]) * inv_det;
402 inv_mat(1, 1) = (a[0][0] * a[2][2] - a[0][2] * a[2][0]) * inv_det;
403 inv_mat(1, 2) = (a[0][2] * a[1][0] - a[0][0] * a[1][2]) * inv_det;
404 inv_mat(2, 0) = (a[1][0] * a[2][1] - a[1][1] * a[2][0]) * inv_det;
405 inv_mat(2, 1) = (a[0][1] * a[2][0] - a[0][0] * a[2][1]) * inv_det;
406 inv_mat(2, 2) = (a[0][0] * a[1][1] - a[0][1] * a[1][0]) * inv_det;
412 KOKKOS_INLINE_FUNCTION
Real33 413 Real33::transpose()
const 417 for (
unsigned int i = 0; i < 3; ++i)
418 for (
unsigned int j = 0; j < 3; ++j)
419 tr_mat(i, j) = a[j][i];
424 KOKKOS_INLINE_FUNCTION
Real3 425 Real33::row(
const unsigned int i)
const 427 return Real3(a[i][0], a[i][1], a[i][2]);
430 KOKKOS_INLINE_FUNCTION
Real3 431 Real33::col(
const unsigned int j)
const 433 return Real3(a[0][j], a[1][j], a[2][j]);
436 KOKKOS_INLINE_FUNCTION
Real3 439 return {left(0, 0) * right.
v[0] + left(0, 1) * right.
v[1] + left(0, 2) * right.
v[2],
440 left(1, 0) * right.
v[0] + left(1, 1) * right.
v[1] + left(1, 2) * right.
v[2],
441 left(2, 0) * right.
v[0] + left(2, 1) * right.
v[1] + left(2, 2) * right.
v[2]};
444 KOKKOS_INLINE_FUNCTION Real33
449 for (
unsigned int i = 0; i < 3; ++i)
450 for (
unsigned int j = 0; j < 3; ++j)
451 for (
unsigned int k = 0; k < 3; ++k)
452 mul(i, j) += left(i, k) * right(k, j);
457 KOKKOS_INLINE_FUNCTION
Real3 460 return {left + right.
v[0], left + right.
v[1], left + right.
v[2]};
463 KOKKOS_INLINE_FUNCTION
Real3 466 return {left.
v[0] + right, left.
v[1] + right, left.
v[2] + right};
469 KOKKOS_INLINE_FUNCTION
Real3 472 return {left - right.
v[0], left - right.
v[1], left - right.
v[2]};
475 KOKKOS_INLINE_FUNCTION
Real3 478 return {left.
v[0] - right, left.
v[1] - right, left.
v[2] - right};
481 KOKKOS_INLINE_FUNCTION
Real3 484 return {left * right.
v[0], left * right.
v[1], left * right.
v[2]};
487 KOKKOS_INLINE_FUNCTION
Real3 490 return {left.
v[0] * right, left.
v[1] * right, left.
v[2] * right};
493 template <
typename T,
494 typename =
typename std::enable_if<
495 std::is_same<typename std::decay<T>::type,
ADReal>::value>::type>
499 return {left(0) * right, left(1) * right, left(2) * right};
502 template <
typename T,
503 typename =
typename std::enable_if<
504 std::is_same<typename std::decay<T>::type,
ADReal>::value>::type>
508 return {left * right(0), left * right(1), left * right(2)};
511 KOKKOS_INLINE_FUNCTION
ADReal 514 return left(0) * right(0) + left(1) * right(1) + left(2) * right(2);
517 KOKKOS_INLINE_FUNCTION
ADReal 520 return left(0) * right(0) + left(1) * right(1) + left(2) * right(2);
525 template <
typename T1,
typename T2>
531 template <
typename T3,
typename T4>
535 second = pair.second;
541 template <
typename T1,
typename T2>
545 return std::make_pair(left.first, left.second) < std::make_pair(right.first, right.second);
KOKKOS_SCALAR_FUNCTION auto operator+(const T &left, const Scalar< U > &right) -> decltype(left+static_cast< const U &>(right))
KOKKOS_INLINE_FUNCTION void operator-=(const Vector3< U > &vector)
KOKKOS_INLINE_FUNCTION const T & operator()(unsigned int i) const
KOKKOS_INLINE_FUNCTION Real operator()(unsigned int i, unsigned int j) const
Vector3< T > & operator=(const libMesh::TypeVector< T > &vector)
KOKKOS_INLINE_FUNCTION void identity(const unsigned int dim=3)
KOKKOS_INLINE_FUNCTION Real dot_product(const Real3 vector) const
KOKKOS_INLINE_FUNCTION Real33 inverse(const unsigned int dim=3) const
KOKKOS_SCALAR_FUNCTION auto operator*(const T &left, const Scalar< U > &right) -> decltype(left *static_cast< const U &>(right))
KOKKOS_INLINE_FUNCTION Real33()
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE.
KOKKOS_INLINE_FUNCTION Vector3(const Vector3< T > &vector)
DualNumber< Real, DNDerivativeType, true > ADReal
KOKKOS_INLINE_FUNCTION void operator*=(const T &scalar)
KOKKOS_INLINE_FUNCTION Real3 col(const unsigned int j) const
KOKKOS_INLINE_FUNCTION Real norm() const
auto & operator=(const std::pair< T3, T4 > pair)
KOKKOS_INLINE_FUNCTION Real33 cartesian_product(const Real3 vector) const
KOKKOS_INLINE_FUNCTION Real3 cross_product(const Real3 vector) const
KOKKOS_INLINE_FUNCTION void operator+=(const Real33 tensor)
KOKKOS_INLINE_FUNCTION Real33 transpose() const
KOKKOS_INLINE_FUNCTION T & operator()(unsigned int i)
KOKKOS_INLINE_FUNCTION Real33(const Real scalar)
KOKKOS_INLINE_FUNCTION Real determinant(const unsigned int dim=3) const
infix_ostream_iterator< T, charT, traits > & operator=(T const &item)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
KOKKOS_INLINE_FUNCTION Vector3()
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template * sqrt(_arg)) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(tanh
KOKKOS_INLINE_FUNCTION Vector3< T > operator-() const
KOKKOS_INLINE_FUNCTION Real33(const Real33 &tensor)
KOKKOS_INLINE_FUNCTION Real & operator()(unsigned int i, unsigned int j)
KOKKOS_INLINE_FUNCTION Real33 & operator=(const Real33 &tensor)
Vector3< ADReal > ADReal3
KOKKOS_INLINE_FUNCTION ADReal operator*(const ADReal3 &left, const Real3 right)
KOKKOS_INLINE_FUNCTION Vector3(const T &scalar)
KOKKOS_INLINE_FUNCTION Real3 operator+(const Real3 left, const Real right)
KOKKOS_INLINE_FUNCTION Real3 row(const unsigned int i) const
KOKKOS_SCALAR_FUNCTION auto operator-(const T &left, const Scalar< U > &right) -> decltype(left - static_cast< const U &>(right))
Order operator-(Order o, T p)
KOKKOS_INLINE_FUNCTION void operator+=(const Vector3< U > &vector)