9#ifndef DEM_PERIODICITY_HPP
10#define DEM_PERIODICITY_HPP
12#include <Kokkos_Core.hpp>
29 const double innerX = (dom.
size.
x - 2.0f * sx > 0.0f) ? (dom.
size.
x - 2.0f * sx) : 0.0;
30 const double innerY = (dom.
size.
y - 2.0f * sy > 0.0f) ? (dom.
size.
y - 2.0f * sy) : 0.0;
31 const double innerZ = (dom.
size.
z - 2.0f * sz > 0.0f) ? (dom.
size.
z - 2.0f * sz) : 0.0;
32 const double volTotal =
static_cast<double>(dom.
size.
x) * dom.
size.
y * dom.
size.
z;
35 const double ghostFraction = (volTotal - innerX * innerY * innerZ) / volTotal;
36 const double estGhosts = (ghostFraction > 0.5) ? nReal * 32.0 : nReal * ghostFraction * 4.0;
37 return nReal +
static_cast<int>(estGhosts) + 4096;
44 Vf invMass,
V3 posPred,
V3 vel,
V3 velPred,
V4 quat,
V4 quatPred,
45 V3 angVel,
V3 angVelPred,
Vf scale,
Vi shapeId,
Vi realIndices,
46 Kokkos::View<int, CpMem> topGhost) {
51 "peclet::dem::generate_ghosts", Kokkos::RangePolicy<CpExec>(space, 0, numReal),
52 KOKKOS_LAMBDA(
int i) {
55 ? ((p.
x < dom.
min.
x + skin) ? 1 : ((p.
x > dom.
max.
x - skin) ? -1 : 0))
58 ? ((p.
y < dom.
min.
y + skin) ? 1 : ((p.
y > dom.
max.
y - skin) ? -1 : 0))
61 ? ((p.
z < dom.
min.
z + skin) ? 1 : ((p.
z > dom.
max.
z - skin) ? -1 : 0))
63 const int ax[2] = {0, sx}, ay[2] = {0, sy}, az[2] = {0, sz};
64 const int nx = (sx == 0) ? 1 : 2, ny = (sy == 0) ? 1 : 2, nz = (sz == 0) ? 1 : 2;
66 const F3 pPred =
ldF3(posPred, i);
67 for (
int a = 0; a < nx; ++a)
68 for (
int b = 0; b < ny; ++b)
69 for (
int c = 0; c < nz; ++c) {
70 const int ix = ax[a], iy = ay[b], iz = az[c];
71 if (ix == 0 && iy == 0 && iz == 0)
73 const int slot = Kokkos::atomic_fetch_add(&topGhost(), 1);
74 if (slot >= capacity) {
75 Kokkos::atomic_add(&topGhost(), -1);
79 st3(pos, slot,
add3(p, shift));
80 st3(posPred, slot,
add3(pPred, shift));
81 invMass(slot) = invMass(i);
82 st3(vel, slot,
ldF3(vel, i));
83 st3(velPred, slot,
ldF3(velPred, i));
84 st4(quat, slot,
ldF4(quat, i));
85 st4(quatPred, slot,
ldF4(quatPred, i));
86 st3(angVel, slot,
ldF3(angVel, i));
87 st3(angVelPred, slot,
ldF3(angVelPred, i));
88 scale(slot) = scale(i);
89 shapeId(slot) = shapeId(i);
90 realIndices(slot) = i;
dem — portable POD types + math + analytic SDFs shared by the Kokkos kernel ports.
dem — portable (Kokkos) time integration kernels (integration.cu).
void st3(const V3 &v, int i, F3 a)
void st4(const V4 &v, int i, F4 a)
Kokkos::View< float *, CpMem > Vf
Kokkos::View< int *, CpMem > Vi
Kokkos::View< float *[3], CpMem > V3
F3 ldF3(const V &v, int i)
F4 ldF4(const V &v, int i)
Kokkos::View< float *[4], CpMem > V4
void generateGhostsKokkos(int numReal, int capacity, Domain dom, float skin, V3 pos, Vf invMass, V3 posPred, V3 vel, V3 velPred, V4 quat, V4 quatPred, V3 angVel, V3 angVelPred, Vf scale, Vi shapeId, Vi realIndices, Kokkos::View< int, CpMem > topGhost)
Generate periodic ghosts for particles [0,numReal).
Kokkos::DefaultExecutionSpace CpExec
int calculateGhostCapacity(int nReal, Domain dom, float skin)
Padded particle-array capacity that leaves room for the periodic ghosts generateGhostsKokkos will emi...