29#ifndef PECLET_VORO_PLANE_POLICY_HPP
30#define PECLET_VORO_PLANE_POLICY_HPP
32#include <Kokkos_Core.hpp>
46 KOKKOS_INLINE_FUNCTION
static Real
offsetFromRel(
const Real r[3], Real wSelf, Real wNbr) {
49 return Real(0.5) * (r[0] * r[0] + r[1] * r[1] + r[2] * r[2]);
58 KOKKOS_INLINE_FUNCTION
static Real
blockReachSq(Real rSqMax, Real wSelf, Real wMaxAll) {
61 return Real(4) * rSqMax;
68 Real wSelf, Real wNbr, Real L, Real pdir[3],
70 const Real Lh = Real(0.5) * L;
71 for (
int d = 0; d < 3; ++d) {
72 Real r = pNbr[d] - pSelf[d];
73 r = r > Lh ? r - L : (r < -Lh ? r + L : r);
82 KOKKOS_INLINE_FUNCTION
static void buildNormal(
const Real pSelf[3],
const Real pNbr[3],
83 Real wSelf, Real wNbr, Real L, Real nOut[3]) {
86 const Real l2 = pdir[0] * pdir[0] + pdir[1] * pdir[1] + pdir[2] * pdir[2];
87 const Real a = l2 > Real(0) ? off / l2 : Real(0);
88 for (
int d = 0; d < 3; ++d)
89 nOut[d] = a * pdir[d];
96 KOKKOS_INLINE_FUNCTION
static void chain(
const Real g[3],
const Real r[3], Real rho, Real c,
97 Real fSelf[3], Real fNbr[3], Real& fwSelf, Real& fwNbr) {
101 for (
int d = 0; d < 3; ++d) {
102 fSelf[d] = Real(-0.5) * g[d];
103 fNbr[d] = Real(0.5) * g[d];
120 template <
class Real>
121 KOKKOS_INLINE_FUNCTION
static Real
offsetFromRel(
const Real r[3], Real wSelf, Real wNbr) {
122 return Real(0.5) * (r[0] * r[0] + r[1] * r[1] + r[2] * r[2] + wSelf - wNbr);
130 template <
class Real>
131 KOKKOS_INLINE_FUNCTION
static Real
blockReachSq(Real rSqMax, Real wSelf, Real wMaxAll) {
132 const Real rm = Kokkos::sqrt(rSqMax);
133 const Real span = wMaxAll - wSelf > Real(0) ? wMaxAll - wSelf : Real(0);
134 const Real t = rm + Kokkos::sqrt(rSqMax + span);
140 template <
class Real>
142 Real wSelf, Real wNbr, Real L, Real pdir[3],
144 const Real Lh = Real(0.5) * L;
145 for (
int d = 0; d < 3; ++d) {
146 Real r = pNbr[d] - pSelf[d];
147 r = r > Lh ? r - L : (r < -Lh ? r + L : r);
154 template <
class Real>
155 KOKKOS_INLINE_FUNCTION
static void buildNormal(
const Real pSelf[3],
const Real pNbr[3],
156 Real wSelf, Real wNbr, Real L, Real nOut[3]) {
159 const Real l2 = pdir[0] * pdir[0] + pdir[1] * pdir[1] + pdir[2] * pdir[2];
160 const Real a = l2 > Real(0) ? off / l2 : Real(0);
161 for (
int d = 0; d < 3; ++d)
162 nOut[d] = a * pdir[d];
171 template <
class Real>
172 KOKKOS_INLINE_FUNCTION
static void chain(
const Real g[3],
const Real r[3], Real rho, Real c,
173 Real fSelf[3], Real fNbr[3], Real& fwSelf, Real& fwNbr) {
174 const Real invRho = rho > Real(0) ? Real(1) / rho : Real(0);
175 const Real alpha = Real(0.5) + Real(0.5) * c * invRho;
176 const Real rg = r[0] * g[0] + r[1] * g[1] + r[2] * g[2];
177 const Real kk = c * invRho * invRho * rg;
178 for (
int d = 0; d < 3; ++d) {
179 const Real jn = alpha * g[d] - kk * r[d];
183 const Real w = Real(0.5) * invRho * rg;
199template <
class Policy,
class Cell,
class Real>
200KOKKOS_INLINE_FUNCTION
void chainToDofs(
const Cell& c,
const Real seed[3],
const Real* pos,
201 Real wSelf,
const Real* weight, Real L,
const Real* gx,
202 const Real* gy,
const Real* gz, Real fSelf[3], Real& fwSelf,
203 Real* fnx, Real* fny, Real* fnz, Real* fwn) {
204 fSelf[0] = fSelf[1] = fSelf[2] = Real(0);
206 const Real Lh = Real(0.5) * L;
207 for (
int k = 0; k < c.np; ++k) {
208 const int j = c.pnbr[k];
210 fnx[k] = fny[k] = fnz[k] = Real(0);
214 const Real g[3] = {gx[k], gy[k], gz[k]};
215 Real r[3] = {Real(0), Real(0), Real(0)}, rho = Real(0), cc = Real(0);
216 if constexpr (Policy::kHasWeightDof) {
217 for (
int d = 0; d < 3; ++d) {
218 Real rr = pos[3 * j + d] - seed[d];
219 rr = rr > Lh ? rr - L : (rr < -Lh ? rr + L : rr);
222 rho = r[0] * r[0] + r[1] * r[1] + r[2] * r[2];
223 cc = wSelf - weight[j];
225 Real fs[3], fn[3], fws = Real(0), fwn1 = Real(0);
226 Policy::template chain<Real>(g, r, rho, cc, fs, fn, fws, fwn1);
Device-native Voronoi tessellation, geometry and finite-volume physics.
Definition convex_cell.hpp:41
KOKKOS_INLINE_FUNCTION void chainToDofs(const Cell &c, const Real seed[3], const Real *pos, Real wSelf, const Real *weight, Real L, const Real *gx, const Real *gy, const Real *gz, Real fSelf[3], Real &fwSelf, Real *fnx, Real *fny, Real *fnz, Real *fwn)
Definition plane_policy.hpp:200
Definition plane_policy.hpp:115
static KOKKOS_INLINE_FUNCTION Real blockReachSq(Real rSqMax, Real wSelf, Real wMaxAll)
Definition plane_policy.hpp:131
static KOKKOS_INLINE_FUNCTION Real offsetFromRel(const Real r[3], Real wSelf, Real wNbr)
Definition plane_policy.hpp:121
static constexpr bool kHasWeightDof
Definition plane_policy.hpp:116
static KOKKOS_INLINE_FUNCTION void buildNormal(const Real pSelf[3], const Real pNbr[3], Real wSelf, Real wNbr, Real L, Real nOut[3])
Foot-point normal n = (off/|pdir|²) pdir = α r.
Definition plane_policy.hpp:155
static KOKKOS_INLINE_FUNCTION void planeFromNeighbour(const Real pSelf[3], const Real pNbr[3], Real wSelf, Real wNbr, Real L, Real pdir[3], Real &off)
Definition plane_policy.hpp:141
static KOKKOS_INLINE_FUNCTION void chain(const Real g[3], const Real r[3], Real rho, Real c, Real fSelf[3], Real fNbr[3], Real &fwSelf, Real &fwNbr)
Definition plane_policy.hpp:172
Definition plane_policy.hpp:39
static KOKKOS_INLINE_FUNCTION void buildNormal(const Real pSelf[3], const Real pNbr[3], Real wSelf, Real wNbr, Real L, Real nOut[3])
Definition plane_policy.hpp:82
static KOKKOS_INLINE_FUNCTION void chain(const Real g[3], const Real r[3], Real rho, Real c, Real fSelf[3], Real fNbr[3], Real &fwSelf, Real &fwNbr)
Definition plane_policy.hpp:96
static KOKKOS_INLINE_FUNCTION Real offsetFromRel(const Real r[3], Real wSelf, Real wNbr)
Definition plane_policy.hpp:46
static KOKKOS_INLINE_FUNCTION Real blockReachSq(Real rSqMax, Real wSelf, Real wMaxAll)
Definition plane_policy.hpp:58
static KOKKOS_INLINE_FUNCTION void planeFromNeighbour(const Real pSelf[3], const Real pNbr[3], Real wSelf, Real wNbr, Real L, Real pdir[3], Real &off)
Definition plane_policy.hpp:67
static constexpr bool kHasWeightDof
Whether cells carry a per-seed weight DOF (Laguerre). Voronoi cells do not.
Definition plane_policy.hpp:41