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; }
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);
96 KOKKOS_INLINE_FUNCTION Real
determinant(
const unsigned int dim = 3)
const;
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
115KOKKOS_INLINE_FUNCTION
180KOKKOS_INLINE_FUNCTION
void
189KOKKOS_INLINE_FUNCTION
void
199KOKKOS_INLINE_FUNCTION
void
208KOKKOS_INLINE_FUNCTION
void
217KOKKOS_INLINE_FUNCTION
void
229 return {left + right.
v[0], left + right.
v[1], left + right.
v[2]};
233KOKKOS_INLINE_FUNCTION Vector3<T>
236 return {left.
v[0] + right, left.
v[1] + right, left.
v[2] + right};
240KOKKOS_INLINE_FUNCTION Vector3<T>
243 return {left.
v[0] + right.
v[0], left.
v[1] + right.
v[1], left.
v[2] + right.
v[2]};
247KOKKOS_INLINE_FUNCTION Vector3<T>
250 return {left - right.
v[0], left - right.
v[1], left - right.
v[2]};
254KOKKOS_INLINE_FUNCTION Vector3<T>
257 return {left.
v[0] - right, left.
v[1] - right, left.
v[2] - right};
261KOKKOS_INLINE_FUNCTION Vector3<T>
264 return {left.
v[0] - right.
v[0], left.
v[1] - right.
v[1], left.
v[2] - right.
v[2]};
268KOKKOS_INLINE_FUNCTION Vector3<T>
271 return {left * right.
v[0], left * right.
v[1], left * right.
v[2]};
275KOKKOS_INLINE_FUNCTION Vector3<T>
278 return {left.
v[0] * right, left.
v[1] * right, left.
v[2] * right};
282KOKKOS_INLINE_FUNCTION T
285 return left.
v[0] * right.
v[0] + left.
v[1] * right.
v[1] + left.
v[2] * right.
v[2];
289KOKKOS_INLINE_FUNCTION Real
292 return ::Kokkos::sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
296KOKKOS_INLINE_FUNCTION Real
299 return v[0] * vector.
v[0] + v[1] * vector.
v[1] + v[2] * vector.
v[2];
303KOKKOS_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];
316KOKKOS_INLINE_FUNCTION
Real33
323 tensor(i, j) = v[i] * vector.
v[j];
333 a[i][j] = tensor(i, j);
338KOKKOS_INLINE_FUNCTION
Real33 &
343 a[i][j] = tensor.
a[i][j];
348KOKKOS_INLINE_FUNCTION
Real33 &
358KOKKOS_INLINE_FUNCTION
void
363 a[i][j] += tensor.
a[i][j];
366KOKKOS_INLINE_FUNCTION
void
374KOKKOS_INLINE_FUNCTION Real
381 value +=
a[i][j] * tensor.
a[i][j];
386KOKKOS_INLINE_FUNCTION
void
391 for (
unsigned int i = 0; i <
dim; ++i)
395KOKKOS_INLINE_FUNCTION Real
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]);
414KOKKOS_INLINE_FUNCTION
Real33
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;
447KOKKOS_INLINE_FUNCTION
Real33
454 tr_mat(i, j) =
a[j][i];
459KOKKOS_INLINE_FUNCTION
Real3
462 return Real3(
a[i][0],
a[i][1],
a[i][2]);
465KOKKOS_INLINE_FUNCTION
Real3
468 return Real3(
a[0][j],
a[1][j],
a[2][j]);
471KOKKOS_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)};
495KOKKOS_INLINE_FUNCTION Real33
503 mul(i, j) += left(i, k) * right(k, j);
508KOKKOS_INLINE_FUNCTION Real33
516KOKKOS_INLINE_FUNCTION Real33
524KOKKOS_INLINE_FUNCTION
Real3
527 return {left + right.
v[0], left + right.
v[1], left + right.
v[2]};
530KOKKOS_INLINE_FUNCTION
Real3
533 return {left.
v[0] + right, left.
v[1] + right, left.
v[2] + right};
536KOKKOS_INLINE_FUNCTION
Real3
539 return {left - right.
v[0], left - right.
v[1], left - right.
v[2]};
542KOKKOS_INLINE_FUNCTION
Real3
545 return {left.
v[0] - right, left.
v[1] - right, left.
v[2] - right};
548KOKKOS_INLINE_FUNCTION
Real3
551 return {left * right.
v[0], left * right.
v[1], left * right.
v[2]};
554KOKKOS_INLINE_FUNCTION
Real3
557 return {left.
v[0] * right, left.
v[1] * right, left.
v[2] * right};
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};
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)};
578KOKKOS_INLINE_FUNCTION
ADReal
581 return left(0) * right(0) + left(1) * right(1) + left(2) * right(2);
584KOKKOS_INLINE_FUNCTION
ADReal
587 return left(0) * right(0) + left(1) * right(1) + left(2) * right(2);
590KOKKOS_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));
603template <
typename T1,
typename T2>
609 template <
typename T3,
typename T4>
619template <
typename T1,
typename T2>
DualNumber< Real, DNDerivativeType, true > ADReal
Vector3< ADReal > ADReal3
KOKKOS_INLINE_FUNCTION Real3 curlFromVectorGradient(const Real33 grad, const unsigned int dim)
bool operator<(const Pair< T1, T2 > &left, const Pair< T1, T2 > &right)
KOKKOS_SCALAR_FUNCTION auto operator-(const T &left, const Scalar< U > &right) -> decltype(left - static_cast< const U & >(right))
KOKKOS_SCALAR_FUNCTION auto operator+(const T &left, const Scalar< U > &right) -> decltype(left+static_cast< const U & >(right))
KOKKOS_SCALAR_FUNCTION auto operator*(const T &left, const Scalar< U > &right) -> decltype(left *static_cast< const U & >(right))
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE.
auto & operator=(const std::pair< T3, T4 > pair)
KOKKOS_INLINE_FUNCTION Real determinant(const unsigned int dim=3) const
KOKKOS_INLINE_FUNCTION Real operator()(unsigned int i, unsigned int j) const
KOKKOS_INLINE_FUNCTION void operator+=(const Real33 tensor)
KOKKOS_INLINE_FUNCTION Real33(const Real scalar)
KOKKOS_INLINE_FUNCTION Real33()
KOKKOS_INLINE_FUNCTION Real & operator()(unsigned int i, unsigned int j)
KOKKOS_INLINE_FUNCTION Real33(const Real33 &tensor)=default
Real33(const libMesh::TypeTensor< Real > &tensor)
KOKKOS_INLINE_FUNCTION Real33 inverse(const unsigned int dim=3) const
Real33 & operator=(const libMesh::TypeTensor< Real > &tensor)
KOKKOS_INLINE_FUNCTION Real33 transpose() const
KOKKOS_INLINE_FUNCTION void operator*=(const Real scalar)
KOKKOS_INLINE_FUNCTION Real contract(const Real33 tensor) const
KOKKOS_INLINE_FUNCTION Real3 row(const unsigned int i) const
KOKKOS_INLINE_FUNCTION Real3 col(const unsigned int j) const
KOKKOS_INLINE_FUNCTION void identity(const unsigned int dim=3)
KOKKOS_INLINE_FUNCTION void operator-=(const T &scalar)
KOKKOS_INLINE_FUNCTION T & operator()(unsigned int i)
Vector3< T > & operator=(const libMesh::TypeVector< T > &vector)
KOKKOS_INLINE_FUNCTION Vector3(const T &x, const T &y, const T &z)
KOKKOS_INLINE_FUNCTION Vector3< T > & operator=(const T &scalar)
Vector3(const libMesh::TypeVector< T > &vector)
KOKKOS_INLINE_FUNCTION Vector3(const T &scalar)
KOKKOS_INLINE_FUNCTION void operator+=(const T &scalar)
KOKKOS_INLINE_FUNCTION Vector3(const Vector3< T > &vector)=default
KOKKOS_INLINE_FUNCTION Vector3< T > & operator=(const Vector3< T > &vector)
KOKKOS_INLINE_FUNCTION Vector3< T > operator-() const
KOKKOS_INLINE_FUNCTION void operator*=(const T &scalar)
KOKKOS_INLINE_FUNCTION Real33 cartesian_product(const Real3 vector) const
KOKKOS_INLINE_FUNCTION Vector3()
KOKKOS_INLINE_FUNCTION Real norm() const
KOKKOS_INLINE_FUNCTION void operator+=(const Vector3< U > &vector)
KOKKOS_INLINE_FUNCTION Real dot_product(const Real3 vector) const
KOKKOS_INLINE_FUNCTION Vector3< T > & operator=(const Vector3< U > &vector)
KOKKOS_INLINE_FUNCTION void operator-=(const Vector3< U > &vector)
KOKKOS_INLINE_FUNCTION Real3 cross_product(const Real3 vector) const
KOKKOS_INLINE_FUNCTION const T & operator()(unsigned int i) const