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], Real wSelf,
83 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) nOut[d] = a * pdir[d];
95 KOKKOS_INLINE_FUNCTION
static void chain(
const Real g[3],
const Real r[3], Real rho, Real c,
96 Real fSelf[3], Real fNbr[3], Real& fwSelf, Real& fwNbr) {
100 for (
int d = 0; d < 3; ++d) {
101 fSelf[d] = Real(-0.5) * g[d];
102 fNbr[d] = Real(0.5) * g[d];
118 template <
class Real>
119 KOKKOS_INLINE_FUNCTION
static Real
offsetFromRel(
const Real r[3], Real wSelf, Real wNbr) {
120 return Real(0.5) * (r[0] * r[0] + r[1] * r[1] + r[2] * r[2] + wSelf - wNbr);
128 template <
class Real>
129 KOKKOS_INLINE_FUNCTION
static Real
blockReachSq(Real rSqMax, Real wSelf, Real wMaxAll) {
130 const Real rm = Kokkos::sqrt(rSqMax);
131 const Real span = wMaxAll - wSelf > Real(0) ? wMaxAll - wSelf : Real(0);
132 const Real t = rm + Kokkos::sqrt(rSqMax + span);
138 template <
class Real>
140 Real wSelf, Real wNbr, Real L, Real pdir[3],
142 const Real Lh = Real(0.5) * L;
143 for (
int d = 0; d < 3; ++d) {
144 Real r = pNbr[d] - pSelf[d];
145 r = r > Lh ? r - L : (r < -Lh ? r + L : r);
152 template <
class Real>
153 KOKKOS_INLINE_FUNCTION
static void buildNormal(
const Real pSelf[3],
const Real pNbr[3], Real wSelf,
154 Real wNbr, Real L, Real nOut[3]) {
157 const Real l2 = pdir[0] * pdir[0] + pdir[1] * pdir[1] + pdir[2] * pdir[2];
158 const Real a = l2 > Real(0) ? off / l2 : Real(0);
159 for (
int d = 0; d < 3; ++d) nOut[d] = a * pdir[d];
168 template <
class Real>
169 KOKKOS_INLINE_FUNCTION
static void chain(
const Real g[3],
const Real r[3], Real rho, Real c,
170 Real fSelf[3], Real fNbr[3], Real& fwSelf, Real& fwNbr) {
171 const Real invRho = rho > Real(0) ? Real(1) / rho : Real(0);
172 const Real alpha = Real(0.5) + Real(0.5) * c * invRho;
173 const Real rg = r[0] * g[0] + r[1] * g[1] + r[2] * g[2];
174 const Real kk = c * invRho * invRho * rg;
175 for (
int d = 0; d < 3; ++d) {
176 const Real jn = alpha * g[d] - kk * r[d];
180 const Real w = Real(0.5) * invRho * rg;
196template <
class Policy,
class Cell,
class Real>
197KOKKOS_INLINE_FUNCTION
void chainToDofs(
const Cell& c,
const Real seed[3],
const Real* pos,
198 Real wSelf,
const Real* weight, Real L,
const Real* gx,
199 const Real* gy,
const Real* gz, Real fSelf[3], Real& fwSelf,
200 Real* fnx, Real* fny, Real* fnz, Real* fwn) {
201 fSelf[0] = fSelf[1] = fSelf[2] = Real(0);
203 const Real Lh = Real(0.5) * L;
204 for (
int k = 0; k < c.np; ++k) {
205 const int j = c.pnbr[k];
207 fnx[k] = fny[k] = fnz[k] = Real(0);
211 const Real g[3] = {gx[k], gy[k], gz[k]};
212 Real r[3] = {Real(0), Real(0), Real(0)}, rho = Real(0), cc = Real(0);
213 if constexpr (Policy::kHasWeightDof) {
214 for (
int d = 0; d < 3; ++d) {
215 Real rr = pos[3 * j + d] - seed[d];
216 rr = rr > Lh ? rr - L : (rr < -Lh ? rr + L : rr);
219 rho = r[0] * r[0] + r[1] * r[1] + r[2] * r[2];
220 cc = wSelf - weight[j];
222 Real fs[3], fn[3], fws = Real(0), fwn1 = Real(0);
223 Policy::template chain<Real>(g, r, rho, cc, fs, fn, fws, fwn1);
Definition convex_cell.hpp:40
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:197
Definition plane_policy.hpp:113
static KOKKOS_INLINE_FUNCTION Real blockReachSq(Real rSqMax, Real wSelf, Real wMaxAll)
Definition plane_policy.hpp:129
static KOKKOS_INLINE_FUNCTION Real offsetFromRel(const Real r[3], Real wSelf, Real wNbr)
Definition plane_policy.hpp:119
static constexpr bool kHasWeightDof
Definition plane_policy.hpp:114
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:153
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:139
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:169
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:95
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