7#include <Kokkos_Core.hpp>
31 KOKKOS_INLINE_FUNCTION
34 for (
int k = 0; k < 6; ++k)
41 KOKKOS_INLINE_FUNCTION
52 KOKKOS_INLINE_FUNCTION
64 KOKKOS_INLINE_FUNCTION
const scalar*
data()
const {
return data_; }
66 KOKKOS_INLINE_FUNCTION
constexpr size_t size()
const {
return 6; }
69 KOKKOS_INLINE_FUNCTION
74 static constexpr int lut[3][3] = {{0, 1, 2}, {1, 3, 4}, {2, 4, 5}};
75 return data_[lut[i][j]];
78 KOKKOS_INLINE_FUNCTION
81 static constexpr int lut[3][3] = {{0, 1, 2}, {1, 3, 4}, {2, 4, 5}};
82 return data_[lut[i][j]];
85 KOKKOS_INLINE_FUNCTION
88 for (
int k = 0; k < 6; ++k)
90 if (data_[k] != rhs.data_[k])
return false;
95 KOKKOS_INLINE_FUNCTION
99 for (
int k = 0; k < 6; ++k)
101 res.data_[k] = data_[k] + rhs.data_[k];
106 KOKKOS_INLINE_FUNCTION
109 for (
int k = 0; k < 6; ++k)
111 data_[k] += rhs.data_[k];
116 KOKKOS_INLINE_FUNCTION
120 for (
int k = 0; k < 6; ++k)
122 res.data_[k] = data_[k] - rhs.data_[k];
127 KOKKOS_INLINE_FUNCTION
130 for (
int k = 0; k < 6; ++k)
132 data_[k] -= rhs.data_[k];
137 KOKKOS_INLINE_FUNCTION
141 for (
int k = 0; k < 6; ++k)
143 res.data_[k] = data_[k] * s;
148 KOKKOS_INLINE_FUNCTION
151 for (
int k = 0; k < 6; ++k)
159 KOKKOS_INLINE_FUNCTION
163 KOKKOS_INLINE_FUNCTION
168 data_[0] - tr3, data_[1], data_[2], data_[3] - tr3, data_[4], data_[5] - tr3
173 KOKKOS_INLINE_FUNCTION
180 data_[0] - tr23, data_[1], data_[2], data_[3] - tr23, data_[4], data_[5] - tr23
190KOKKOS_INLINE_FUNCTION
194KOKKOS_INLINE_FUNCTION
198 s(0, 0) * v[0] + s(0, 1) * v[1] + s(0, 2) * v[2],
199 s(1, 0) * v[0] + s(1, 1) * v[1] + s(1, 2) * v[2],
200 s(2, 0) * v[0] + s(2, 1) * v[1] + s(2, 2) * v[2]
205KOKKOS_INLINE_FUNCTION
210 s(0, 0) * s(0, 0) + s(1, 1) * s(1, 1) + s(2, 2) * s(2, 2)
211 +
scalar(2) * (s(0, 1) * s(0, 1) + s(0, 2) * s(0, 2) + s(1, 2) * s(1, 2))
216KOKKOS_INLINE_FUNCTION
219 return s(0, 0) * s(0, 0) + s(1, 1) * s(1, 1) + s(2, 2) * s(2, 2)
220 +
scalar(2) * (s(0, 1) * s(0, 1) + s(0, 2) * s(0, 2) + s(1, 2) * s(1, 2));
224KOKKOS_INLINE_FUNCTION
229 0.5 * (t(0, 1) + t(1, 0)),
230 0.5 * (t(0, 2) + t(2, 0)),
232 0.5 * (t(1, 2) + t(2, 1)),
238KOKKOS_INLINE_FUNCTION
255KOKKOS_INLINE_FUNCTION
260 scalar(2) * t(0, 0) - sph,
263 scalar(2) * t(1, 1) - sph,
275 return SymmTensor(0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
A class for the representation of a symmetric 3x3 tensor.
KOKKOS_INLINE_FUNCTION bool operator==(const SymmTensor &rhs) const
KOKKOS_INLINE_FUNCTION SymmTensor(const scalar diag)
Construct scalar-times-identity symmetric tensor.
KOKKOS_INLINE_FUNCTION SymmTensor operator+(const SymmTensor &rhs) const
KOKKOS_INLINE_FUNCTION SymmTensor & operator+=(const SymmTensor &rhs)
KOKKOS_INLINE_FUNCTION SymmTensor operator*(const scalar s) const
KOKKOS_INLINE_FUNCTION scalar operator()(const size_t i, const size_t j) const
Component access — maps (i,j) to the stored upper-triangle.
KOKKOS_INLINE_FUNCTION scalar trace() const
Trace: xx + yy + zz.
KOKKOS_INLINE_FUNCTION SymmTensor & operator*=(const scalar s)
KOKKOS_INLINE_FUNCTION SymmTensor dev2() const
dev2: S - (2/3)*tr(S)*I (used in viscous stress)
KOKKOS_INLINE_FUNCTION SymmTensor dev() const
Deviatoric part: S - (1/3)*tr(S)*I.
KOKKOS_INLINE_FUNCTION SymmTensor & operator-=(const SymmTensor &rhs)
KOKKOS_INLINE_FUNCTION SymmTensor operator-(const SymmTensor &rhs) const
KOKKOS_INLINE_FUNCTION scalar * data()
KOKKOS_INLINE_FUNCTION SymmTensor(scalar xx, scalar xy, scalar xz, scalar yy, scalar yz, scalar zz)
KOKKOS_INLINE_FUNCTION scalar & operator()(const size_t i, const size_t j)
KOKKOS_INLINE_FUNCTION constexpr size_t size() const
KOKKOS_INLINE_FUNCTION const scalar * data() const
KOKKOS_INLINE_FUNCTION SymmTensor()
A class for the representation of a 3x3 tensor.
A class for the representation of a 3D Vec3.
Integer types used throughout NeoN.
std::ostream & operator<<(std::ostream &os, const Dictionary &in)
KOKKOS_INLINE_FUNCTION scalar mag(const scalar &s)
KOKKOS_INLINE_FUNCTION Tensor twoSymm(const Tensor &t)
T + T^T (= 2*symm(T)) as a full tensor.
KOKKOS_INLINE_FUNCTION Vec3 operator&(const SymmTensor &s, const Vec3 &v)
Symmetric matrix-vector product S·v.
KOKKOS_INLINE_FUNCTION SymmTensor operator*(const scalar s, const SymmTensor &st)
KOKKOS_INLINE_FUNCTION SymmTensor symm(const Tensor &t)
Symmetric part of a full tensor: ½(T + T^T)
KOKKOS_INLINE_FUNCTION SymmTensor devTwoSymm(const Tensor &t)
T + T^T - (2/3)*tr(T)*I — used for viscous stress.
KOKKOS_INLINE_FUNCTION SymmTensor one< SymmTensor >()
KOKKOS_INLINE_FUNCTION SymmTensor zero< SymmTensor >()
KOKKOS_INLINE_FUNCTION scalar magSqr(const SymmTensor &s)
Frobenius norm squared.
KOKKOS_INLINE_FUNCTION SymmTensor inv< SymmTensor >(SymmTensor)