16 #ifdef MOOSE_KOKKOS_SCOPE 23 #include "libmesh/tensor_tools.h" 24 #include "libmesh/tensor_value.h" 42 #ifdef MOOSE_KOKKOS_SCOPE 44 KOKKOS_INLINE_FUNCTION
Vector3() { *
this = T{}; }
45 KOKKOS_INLINE_FUNCTION
Vector3(
const T & scalar) { *
this = scalar; }
47 KOKKOS_INLINE_FUNCTION
Vector3(
const T & x,
const T & y,
const T & z);
50 KOKKOS_INLINE_FUNCTION T &
operator()(
unsigned int i) {
return v[i]; }
51 KOKKOS_INLINE_FUNCTION
const T &
operator()(
unsigned int i)
const {
return v[i]; }
62 KOKKOS_INLINE_FUNCTION
void operator+=(
const T & scalar);
65 KOKKOS_INLINE_FUNCTION
void operator-=(
const T & scalar);
66 KOKKOS_INLINE_FUNCTION
void operator*=(
const T & scalar);
68 KOKKOS_INLINE_FUNCTION
Real norm()
const;
79 #ifdef MOOSE_KOKKOS_SCOPE 80 KOKKOS_INLINE_FUNCTION
Real33() { *
this = 0; }
81 KOKKOS_INLINE_FUNCTION
Real33(
const Real scalar) { *
this = scalar; }
82 KOKKOS_INLINE_FUNCTION
Real33(
const Real33 & tensor) =
default;
85 KOKKOS_INLINE_FUNCTION
Real &
operator()(
unsigned int i,
unsigned int j) {
return a[i][j]; }
86 KOKKOS_INLINE_FUNCTION
Real operator()(
unsigned int i,
unsigned int j)
const {
return a[i][j]; }
92 KOKKOS_INLINE_FUNCTION
void operator*=(
const Real scalar);
95 KOKKOS_INLINE_FUNCTION
void identity(
const unsigned int dim = 3);
99 KOKKOS_INLINE_FUNCTION
Real3 row(
const unsigned int i)
const;
100 KOKKOS_INLINE_FUNCTION
Real3 col(
const unsigned int j)
const;
104 #ifdef MOOSE_KOKKOS_SCOPE 106 template <
typename T>
114 template <
typename T>
115 KOKKOS_INLINE_FUNCTION
123 template <
typename T>
134 template <
typename T>
144 template <
typename T>
155 template <
typename T>
156 template <
typename U>
167 template <
typename T>
178 template <
typename T>
179 template <
typename U>
180 KOKKOS_INLINE_FUNCTION
void 188 template <
typename T>
189 KOKKOS_INLINE_FUNCTION
void 197 template <
typename T>
198 template <
typename U>
199 KOKKOS_INLINE_FUNCTION
void 207 template <
typename T>
208 KOKKOS_INLINE_FUNCTION
void 216 template <
typename T>
217 KOKKOS_INLINE_FUNCTION
void 225 template <
typename T>
229 return {left + right.
v[0], left + right.
v[1], left + right.
v[2]};
232 template <
typename T>
233 KOKKOS_INLINE_FUNCTION Vector3<T>
236 return {left.
v[0] + right, left.
v[1] + right, left.
v[2] + right};
239 template <
typename T>
240 KOKKOS_INLINE_FUNCTION Vector3<T>
243 return {left.
v[0] + right.
v[0], left.
v[1] + right.
v[1], left.
v[2] + right.
v[2]};
246 template <
typename T>
247 KOKKOS_INLINE_FUNCTION Vector3<T>
250 return {left - right.
v[0], left - right.
v[1], left - right.
v[2]};
253 template <
typename T>
254 KOKKOS_INLINE_FUNCTION Vector3<T>
257 return {left.
v[0] - right, left.
v[1] - right, left.
v[2] - right};
260 template <
typename T>
261 KOKKOS_INLINE_FUNCTION Vector3<T>
264 return {left.
v[0] - right.
v[0], left.
v[1] - right.
v[1], left.
v[2] - right.
v[2]};
267 template <
typename T>
268 KOKKOS_INLINE_FUNCTION Vector3<T>
271 return {left * right.
v[0], left * right.
v[1], left * right.
v[2]};
274 template <
typename T>
275 KOKKOS_INLINE_FUNCTION Vector3<T>
278 return {left.
v[0] * right, left.
v[1] * right, left.
v[2] * right};
281 template <
typename T>
282 KOKKOS_INLINE_FUNCTION T
285 return left.
v[0] * right.
v[0] + left.
v[1] * right.
v[1] + left.
v[2] * right.
v[2];
289 KOKKOS_INLINE_FUNCTION
Real 296 KOKKOS_INLINE_FUNCTION
Real 299 return v[0] * vector.
v[0] + v[1] * vector.
v[1] + v[2] * vector.
v[2];
303 KOKKOS_INLINE_FUNCTION
Real3 308 cross.
v[0] = v[1] * vector.
v[2] - v[2] * vector.
v[1];
309 cross.
v[1] = v[2] * vector.
v[0] - v[0] * vector.
v[2];
310 cross.
v[2] = v[0] * vector.
v[1] - v[1] * vector.
v[0];
316 KOKKOS_INLINE_FUNCTION
Real33 323 tensor(i, j) = v[i] * vector.
v[j];
333 a[i][j] = tensor(i, j);
338 KOKKOS_INLINE_FUNCTION
Real33 &
343 a[i][j] = tensor.
a[i][j];
348 KOKKOS_INLINE_FUNCTION
Real33 &
358 KOKKOS_INLINE_FUNCTION
void 363 a[i][j] += tensor.
a[i][j];
366 KOKKOS_INLINE_FUNCTION
void 367 Real33::operator*=(
const Real scalar)
374 KOKKOS_INLINE_FUNCTION
Real 375 Real33::contract(
const Real33 tensor)
const 381 value += a[i][j] * tensor.
a[i][j];
386 KOKKOS_INLINE_FUNCTION
void 387 Real33::identity(
const unsigned int dim)
391 for (
unsigned int i = 0; i <
dim; ++i)
395 KOKKOS_INLINE_FUNCTION
Real 396 Real33::determinant(
const unsigned int dim)
const 405 det = a[0][0] * a[1][1] - a[0][1] * a[1][0];
407 det = a[0][0] * (a[1][1] * a[2][2] - a[1][2] * a[2][1]) -
408 a[0][1] * (a[1][0] * a[2][2] - a[1][2] * a[2][0]) +
409 a[0][2] * (a[1][0] * a[2][1] - a[1][1] * a[2][0]);
414 KOKKOS_INLINE_FUNCTION
Real33 417 Real inv_det = 1.0 / determinant(
dim);
422 inv_mat(0, 0) = inv_det;
426 inv_mat(0, 0) = a[1][1] * inv_det;
427 inv_mat(0, 1) = -a[0][1] * inv_det;
428 inv_mat(1, 0) = -a[1][0] * inv_det;
429 inv_mat(1, 1) = a[0][0] * inv_det;
433 inv_mat(0, 0) = (a[1][1] * a[2][2] - a[1][2] * a[2][1]) * inv_det;
434 inv_mat(0, 1) = (a[0][2] * a[2][1] - a[0][1] * a[2][2]) * inv_det;
435 inv_mat(0, 2) = (a[0][1] * a[1][2] - a[0][2] * a[1][1]) * inv_det;
436 inv_mat(1, 0) = (a[1][2] * a[2][0] - a[1][0] * a[2][2]) * inv_det;
437 inv_mat(1, 1) = (a[0][0] * a[2][2] - a[0][2] * a[2][0]) * inv_det;
438 inv_mat(1, 2) = (a[0][2] * a[1][0] - a[0][0] * a[1][2]) * inv_det;
439 inv_mat(2, 0) = (a[1][0] * a[2][1] - a[1][1] * a[2][0]) * inv_det;
440 inv_mat(2, 1) = (a[0][1] * a[2][0] - a[0][0] * a[2][1]) * inv_det;
441 inv_mat(2, 2) = (a[0][0] * a[1][1] - a[0][1] * a[1][0]) * inv_det;
447 KOKKOS_INLINE_FUNCTION
Real33 448 Real33::transpose()
const 454 tr_mat(i, j) = a[j][i];
459 KOKKOS_INLINE_FUNCTION
Real3 460 Real33::row(
const unsigned int i)
const 462 return Real3(a[i][0], a[i][1], a[i][2]);
465 KOKKOS_INLINE_FUNCTION
Real3 466 Real33::col(
const unsigned int j)
const 468 return Real3(a[0][j], a[1][j], a[2][j]);
471 KOKKOS_INLINE_FUNCTION
Real3 474 return {left(0, 0) * right.
v[0] + left(0, 1) * right.
v[1] + left(0, 2) * right.
v[2],
475 left(1, 0) * right.
v[0] + left(1, 1) * right.
v[1] + left(1, 2) * right.
v[2],
476 left(2, 0) * right.
v[0] + left(2, 1) * right.
v[1] + left(2, 2) * right.
v[2]};
482 return {left(0, 0) * right(0) + left(0, 1) * right(1) + left(0, 2) * right(2),
483 left(1, 0) * right(0) + left(1, 1) * right(1) + left(1, 2) * right(2),
484 left(2, 0) * right(0) + left(2, 1) * right(1) + left(2, 2) * right(2)};
490 return {left(0) * right(0, 0) + left(1) * right(1, 0) + left(2) * right(2, 0),
491 left(0) * right(0, 1) + left(1) * right(1, 1) + left(2) * right(2, 1),
492 left(0) * right(0, 2) + left(1) * right(1, 2) + left(2) * right(2, 2)};
495 KOKKOS_INLINE_FUNCTION Real33
503 mul(i, j) += left(i, k) * right(k, j);
508 KOKKOS_INLINE_FUNCTION Real33
516 KOKKOS_INLINE_FUNCTION Real33
524 KOKKOS_INLINE_FUNCTION
Real3 527 return {left + right.
v[0], left + right.
v[1], left + right.
v[2]};
530 KOKKOS_INLINE_FUNCTION
Real3 533 return {left.
v[0] + right, left.
v[1] + right, left.
v[2] + right};
536 KOKKOS_INLINE_FUNCTION
Real3 539 return {left - right.
v[0], left - right.
v[1], left - right.
v[2]};
542 KOKKOS_INLINE_FUNCTION
Real3 545 return {left.
v[0] - right, left.
v[1] - right, left.
v[2] - right};
548 KOKKOS_INLINE_FUNCTION
Real3 551 return {left * right.
v[0], left * right.
v[1], left * right.
v[2]};
554 KOKKOS_INLINE_FUNCTION
Real3 557 return {left.
v[0] * right, left.
v[1] * right, left.
v[2] * right};
560 template <
typename T,
561 typename =
typename std::enable_if<
562 std::is_same<typename std::decay<T>::type,
ADReal>::value>::type>
566 return {left(0) * right, left(1) * right, left(2) * right};
569 template <
typename T,
570 typename =
typename std::enable_if<
571 std::is_same<typename std::decay<T>::type,
ADReal>::value>::type>
575 return {left * right(0), left * right(1), left * right(2)};
578 KOKKOS_INLINE_FUNCTION
ADReal 581 return left(0) * right(0) + left(1) * right(1) + left(2) * right(2);
584 KOKKOS_INLINE_FUNCTION
ADReal 587 return left(0) * right(0) + left(1) * right(1) + left(2) * right(2);
590 KOKKOS_INLINE_FUNCTION
Real3 596 return Real3(0, 0, grad(1, 0) - grad(0, 1));
598 return Real3(grad(2, 1) - grad(1, 2), grad(0, 2) - grad(2, 0), grad(1, 0) - grad(0, 1));
603 template <
typename T1,
typename T2>
609 template <
typename T3,
typename T4>
613 second = pair.second;
619 template <
typename T1,
typename T2>
623 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
Real33(const libMesh::TypeTensor< Real > &tensor)
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))
Real33 & operator=(const libMesh::TypeTensor< Real > &tensor)
KOKKOS_INLINE_FUNCTION Real33()
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE.
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)
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
KOKKOS_INLINE_FUNCTION Real33 cartesian_product(const Real3 vector) const
KOKKOS_INLINE_FUNCTION Real3 cross_product(const Real3 vector) const
KOKKOS_INLINE_FUNCTION Real3 curlFromVectorGradient(const Real33 grad, const unsigned int dim)
KOKKOS_INLINE_FUNCTION void operator+=(const Real33 tensor)
KOKKOS_INLINE_FUNCTION Real33 transpose() const
KOKKOS_INLINE_FUNCTION void operator*=(const Real scalar)
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
IntRange< T > make_range(T beg, T end)
KOKKOS_INLINE_FUNCTION Real & operator()(unsigned int i, unsigned int j)
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_INLINE_FUNCTION Real contract(const Real33 tensor) 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)