16#include <Kokkos_Core.hpp>
17#include <Kokkos_Sort.hpp>
28 float muGlobal,
float& e,
float& mu) {
29 if (pairTable.extent(0) > 0) {
32 mu = pairTable(t + 1);
47 Kokkos::View<const float*, CpMem>
hertzE;
48 Kokkos::View<const float*, CpMem>
hertzNu;
53 Kokkos::View<const float* [3], CpMem>
pos;
54 Kokkos::View<const float* [3], CpMem>
vel;
55 Kokkos::View<const float* [3], CpMem>
angVel;
56 Kokkos::View<const float*, CpMem>
rad;
57 Kokkos::View<const float*, CpMem>
invMass;
64 Kokkos::View<const float* [4], CpMem>
quat;
65 Kokkos::View<const float*, CpMem>
scale;
67 Kokkos::View<const ShapeDesc*, CpMem>
shapes;
77 Kokkos::View<const WallSdf*, CpMem>
walls;
79 Kokkos::View<float* [3], CpMem>
xiWall;
91 const float le = Kokkos::log(e);
92 return le / Kokkos::sqrt(le * le + 9.8696044f);
98KOKKOS_INLINE_FUNCTION
F3 hertzForce(
float delta,
F3 nhat,
F3 vrel,
float rStar,
float mStar,
99 float eStar,
float gStar,
float e,
float mu,
float dt,
101 const float sq = Kokkos::sqrt(rStar * delta);
102 const float sn = 2.0f * eStar * sq;
103 const float st = 8.0f * gStar * sq;
104 const float kn = (4.0f / 3.0f) * eStar * sq;
106 const float etaN = -2.0f * 0.9128709f * bd * Kokkos::sqrt(sn * mStar);
107 const float etaT = -2.0f * 0.9128709f * bd * Kokkos::sqrt(st * mStar);
109 const float vn =
dot3(vrel, nhat);
110 const float fnSpring = kn * delta;
111 const float fn = fnSpring - etaN * vn;
118 const float ftLen = Kokkos::sqrt(
dot3(ft, ft));
119 const float ftMax = mu * Kokkos::fabs(fnSpring);
123 const float s = (ftLen > 1e-20f) ? ftMax / ftLen : 0.0f;
137 Kokkos::View<const float*, CpMem> scale,
139 Kokkos::View<const ShapeDesc*, CpMem> shapes,
141 if (shapes.extent(0) > 0 && scale.extent(0) > 0) {
144 return scale(i) * globalScale * d.
params.
x;
155 Kokkos::View<
float* [3],
CpMem> xi,
156 Kokkos::View<
float* [3],
CpMem> force,
158 const Kokkos::View<const float* [3], CpMem> pos = bodies.
pos, vel = bodies.
vel,
160 const Kokkos::View<const float*, CpMem> rad = bodies.
rad, invMass = bodies.
invMass;
161 const Kokkos::View<const float*, CpMem> scale = shp.scale;
162 const ScalarI shapeId = shp.shapeId;
163 const Kokkos::View<const ShapeDesc*, CpMem> shapes = shp.shapes;
164 const float globalScale = shp.globalScale;
168 const Kokkos::View<const float*, CpMem> hertzE = mat.
hertzE, hertzNu = mat.
hertzNu;
170 Kokkos::parallel_for(
171 "peclet::dem::hertz_pairs", Kokkos::RangePolicy<CpExec>(space, 0, numPairs),
172 KOKKOS_LAMBDA(
int idx) {
173 const int i = pairs(idx, 0), j = pairs(idx, 1);
175 const F3 dx =
sub3(pi, pj);
176 const float d = Kokkos::sqrt(
dot3(dx, dx));
179 const float delta = ri + rj - d;
180 if (delta <= 0.0f || d < 1e-12f) {
181 xi(idx, 0) = xi(idx, 1) = xi(idx, 2) = 0.0f;
184 const F3 nhat =
scale3(dx, 1.0f / d);
185 const F3 rA =
scale3(nhat, -(ri - 0.5f * delta));
186 const F3 rB =
scale3(nhat, (rj - 0.5f * delta));
189 const int ma = matId(i), mb = matId(j);
191 hertzPairEMu(ma, mb, pairTable, eGlobal, muGlobal, e, mu);
192 const float Ei = hertzE(ma), Ej = hertzE(mb);
193 const float ni = hertzNu(ma), nj = hertzNu(mb);
194 const float eStar = 1.0f / ((1.0f - ni * ni) / Ei + (1.0f - nj * nj) / Ej);
196 1.0f / (2.0f * (2.0f - ni) * (1.0f + ni) / Ei + 2.0f * (2.0f - nj) * (1.0f + nj) / Ej);
197 const float rStar = ri * rj / (ri + rj);
198 const float imSum = invMass(i) + invMass(j);
199 const float mStar = (imSum > 0.0f) ? 1.0f / imSum : 0.0f;
200 F3 x{xi(idx, 0), xi(idx, 1), xi(idx, 2)};
201 const F3 f =
hertzForce(delta, nhat, vrel, rStar, mStar, eStar, gStar, e, mu, dt, x);
206 for (
int c = 0; c < 3; ++c) {
207 Kokkos::atomic_add(&force(i, c), (&f.x)[c]);
208 Kokkos::atomic_add(&force(j, c), -(&f.x)[c]);
209 Kokkos::atomic_add(&torque(i, c), (&tA.x)[c]);
210 Kokkos::atomic_add(&torque(j, c), (&tB.x)[c]);
219 float eGlobal,
float muGlobal,
float& e,
float& mu) {
220 if (w.
materialId >= 0 && pairTable.extent(0) > 0) {
230 const float hx = 0.5f / w.
grid.invSpacing.x;
244 Kokkos::View<
float* [3],
CpMem> force,
246 const Kokkos::View<const WallSdf*, CpMem> walls = wall.
walls;
248 const Kokkos::View<float* [3], CpMem> xiWall = wall.
xiWall;
250 const Kokkos::View<float*, CpMem> snWall = wall.
snWall;
251 const Kokkos::View<const float* [3], CpMem> pos = bodies.
pos, vel = bodies.
vel,
253 const Kokkos::View<const float*, CpMem> rad = bodies.
rad, invMass = bodies.
invMass;
254 const Kokkos::View<const float* [4], CpMem> quat = shp.quat;
255 const Kokkos::View<const float*, CpMem> scale = shp.scale;
256 const ScalarI shapeId = shp.shapeId;
257 const Kokkos::View<const ShapeDesc*, CpMem> shapes = shp.shapes;
259 const float globalScale = shp.globalScale, contactRadiusFrac = shp.contactRadiusFrac;
260 const bool hasShapes = shp.hasShapes;
264 const Kokkos::View<const float*, CpMem> hertzE = mat.
hertzE, hertzNu = mat.
hertzNu;
266 Kokkos::parallel_for(
267 "peclet::dem::hertz_walls", Kokkos::RangePolicy<CpExec>(space, 0, numCand),
268 KOKKOS_LAMBDA(
int ci) {
269 const int enc = candSlots(ci);
270 const int i = enc / 8;
271 const int wi = enc % 8;
272 const F3 p =
loadF3(pos, i);
274 const WallSdf w = walls(wi);
275 const int slot = i * maxWalls + wi;
276 const int ma = matId(i);
277 if (hasShapes && shapes(shapeId(i)).numPoints > 0) {
280 const ShapeDesc dS = shapes(shapeId(i));
281 const F4 qP = F4{quat(i, 0), quat(i, 1), quat(i, 2), quat(i, 3)};
282 const float effScale = scale(i) * globalScale;
283 const float rc = contactRadiusFrac * dS.params.x * effScale;
285 hertzWallEMu(ma, w, pairTable, eGlobal, muGlobal, e, mu);
286 const int mw = (w.materialId >= 0) ? w.materialId : ma;
287 const float Ei = hertzE(ma), Ew = hertzE(mw);
288 const float ni = hertzNu(ma), nw = hertzNu(mw);
289 const float eStar = 1.0f / ((1.0f - ni * ni) / Ei + (1.0f - nw * nw) / Ew);
290 const float gStar = 1.0f / (2.0f * (2.0f - ni) * (1.0f + ni) / Ei +
291 2.0f * (2.0f - nw) * (1.0f + nw) / Ew);
292 const float mStar = (invMass(i) > 0.0f) ? 1.0f / invMass(i) : 0.0f;
295 const float snTotPrev = (snWall.extent(0) > 0) ? snWall(slot) : 0.0f;
296 const float dampC = (mStar > 0.0f) ? -2.0f * 0.9128709f * bd * Kokkos::sqrt(mStar) : 0.0f;
297 float fnSum = 0.0f, snSum = 0.0f, dMax = 0.0f;
298 F3 cSum{0, 0, 0}, nSum{0, 0, 0}, fAcc{0, 0, 0}, tAcc{0, 0, 0};
299 for (
int k = 0; k < dS.numPoints; ++k) {
300 const int sIdx = dS.shellOffset + k;
303 qP,
scale3(
F3{shell(sIdx, 0), shell(sIdx, 1), shell(sIdx, 2)}, effScale)));
307 const float delta = -sd;
309 const float gl =
len3(g);
312 const F3 nhat =
scale3(g, 1.0f / gl);
313 const F3 rA =
sub3(pW, p);
316 const float vnP =
dot3(vrelP, nhat);
317 const float sq = Kokkos::sqrt(rc * delta);
318 const float fnSpring = (4.0f / 3.0f) * eStar * sq * delta;
319 const float snI = 2.0f * eStar * sq;
320 const float snTot = (snTotPrev > snI) ? snTotPrev : snI;
321 const float etaI = dampC * snI / Kokkos::sqrt(snTot);
322 const F3 f =
scale3(nhat, fnSpring - etaI * vnP);
323 fAcc =
add3(fAcc, f);
326 snSum += 2.0f * eStar * sq;
333 xiWall(slot, 0) = xiWall(slot, 1) = xiWall(slot, 2) = 0.0f;
334 if (snWall.extent(0) > 0)
338 const F3 cpt =
scale3(cSum, 1.0f / fnSum);
340 const float nl =
len3(nhat);
342 nhat =
scale3(nhat, 1.0f / nl);
343 const F3 rA =
sub3(cpt, p);
346 if (snWall.extent(0) > 0)
347 snWall(slot) = snSum;
349 const float st = 8.0f * gStar * Kokkos::sqrt(rc * dMax);
350 const float etaT = -2.0f * 0.9128709f * bd * Kokkos::sqrt(st * mStar);
351 F3 x{xiWall(slot, 0), xiWall(slot, 1), xiWall(slot, 2)};
355 const float ftLen =
len3(ft);
356 const float ftMax = mu * fnSum;
358 const float sc2 = (ftLen > 1e-20f) ? ftMax / ftLen : 0.0f;
363 xiWall(slot, 0) = x.x;
364 xiWall(slot, 1) = x.y;
365 xiWall(slot, 2) = x.z;
366 fAcc =
add3(fAcc, ft);
368 for (
int c = 0; c < 3; ++c) {
369 Kokkos::atomic_add(&force(i, c), (&fAcc.x)[c]);
370 Kokkos::atomic_add(&torque(i, c), (&tAcc.x)[c]);
376 const float delta = r - s;
378 xiWall(slot, 0) = xiWall(slot, 1) = xiWall(slot, 2) = 0.0f;
382 const float gl = Kokkos::sqrt(
dot3(g, g));
385 const F3 nhat =
scale3(g, 1.0f / gl);
386 const F3 rA =
scale3(nhat, -(r - 0.5f * delta));
387 const F3 cpt =
add3(p, rA);
391 hertzWallEMu(ma, w, pairTable, eGlobal, muGlobal, e, mu);
392 const int mw = (w.materialId >= 0) ? w.materialId : ma;
393 const float Ei = hertzE(ma), Ew = hertzE(mw);
394 const float ni = hertzNu(ma), nw = hertzNu(mw);
395 const float eStar = 1.0f / ((1.0f - ni * ni) / Ei + (1.0f - nw * nw) / Ew);
396 const float gStar = 1.0f / (2.0f * (2.0f - ni) * (1.0f + ni) / Ei +
397 2.0f * (2.0f - nw) * (1.0f + nw) / Ew);
398 const float mStar = (invMass(i) > 0.0f) ? 1.0f / invMass(i) : 0.0f;
399 F3 x{xiWall(slot, 0), xiWall(slot, 1), xiWall(slot, 2)};
400 const F3 f =
hertzForce(delta, nhat, vrel, r, mStar, eStar, gStar, e, mu, dt, x);
401 xiWall(slot, 0) = x.x;
402 xiWall(slot, 1) = x.y;
403 xiWall(slot, 2) = x.z;
405 for (
int c = 0; c < 3; ++c) {
406 Kokkos::atomic_add(&force(i, c), (&f.x)[c]);
407 Kokkos::atomic_add(&torque(i, c), (&tA.x)[c]);
418 Kokkos::View<const WallSdf*, CpMem> walls,
GridView wallGrid,
419 Kokkos::View<
const float* [3],
CpMem> pos,
420 Kokkos::View<const float*, CpMem> rad,
float skin,
421 Kokkos::View<int*, CpMem> outSlots,
422 Kokkos::View<int, CpMem> outCount) {
424 Kokkos::deep_copy(space, outCount, 0);
425 const int cap =
static_cast<int>(outSlots.extent(0));
426 Kokkos::parallel_for(
427 "peclet::dem::hertz_wall_cand", Kokkos::RangePolicy<CpExec>(space, 0, numReal),
428 KOKKOS_LAMBDA(
int i) {
429 const F3 p{pos(i, 0), pos(i, 1), pos(i, 2)};
430 for (
int wi = 0; wi < numWalls; ++wi) {
432 if (s < rad(i) + skin) {
433 const int at = Kokkos::atomic_fetch_add(&outCount(), 1);
435 outSlots(at) = i * 8 + wi;
441 Kokkos::deep_copy(n, outCount);
442 return n < cap ? n : cap;
451 F3 gravity,
float dt,
bool integrateOrientation =
false) {
452 const Kokkos::View<const float*, CpMem> invMass = bodies.
invMass;
453 const Kokkos::View<const float* [3], CpMem> invInertia = bodies.
invInertia;
454 const Kokkos::View<float* [3], CpMem> vel = bodies.
vel, angVel = bodies.
angVel, pos = bodies.
pos;
455 const Kokkos::View<float* [4], CpMem> quat = bodies.
quat;
457 Kokkos::parallel_for(
458 "peclet::dem::hertz_integrate", Kokkos::RangePolicy<CpExec>(space, 0, numReal),
459 KOKKOS_LAMBDA(
int i) {
460 const float im = invMass(i);
462 const F3 iI{invInertia(i, 0), invInertia(i, 1), invInertia(i, 2)};
464 if (iI.
x == iI.
y && iI.
y == iI.
z) {
465 dw =
F3{torque(i, 0) * iI.
x, torque(i, 1) * iI.
x, torque(i, 2) * iI.
x};
471 for (
int c = 0; c < 3; ++c) {
472 vel(i, c) += (force(i, c) * im + (&gravity.
x)[c]) * dt;
473 angVel(i, c) += (&dw.
x)[c] * dt;
474 pos(i, c) += vel(i, c) * dt;
476 if (integrateOrientation) {
478 const F3 w{angVel(i, 0), angVel(i, 1), angVel(i, 2)};
480 F4 dq{0.5f * dt * (w.
x * q.
w + w.
y * q.
z - w.
z * q.
y),
481 0.5f * dt * (w.
y * q.
w + w.
z * q.
x - w.
x * q.
z),
482 0.5f * dt * (w.
z * q.
w + w.
x * q.
y - w.
y * q.
x),
483 0.5f * dt * (-w.
x * q.
x - w.
y * q.
y - w.
z * q.
z)};
484 q =
F4{q.
x + dq.
x, q.
y + dq.
y, q.
z + dq.
z, q.
w + dq.
w};
485 const float qn = Kokkos::sqrt(q.
x * q.
x + q.
y * q.
y + q.
z * q.
z + q.
w * q.
w);
487 quat(i, 0) = q.
x / qn;
488 quat(i, 1) = q.
y / qn;
489 quat(i, 2) = q.
z / qn;
490 quat(i, 3) = q.
w / qn;
494 force(i, 0) = force(i, 1) = force(i, 2) = 0.0f;
495 torque(i, 0) = torque(i, 1) = torque(i, 2) = 0.0f;
503 Kokkos::View<
const float* [3],
CpMem> refPos) {
506 Kokkos::parallel_reduce(
507 "peclet::dem::hertz_maxdisp", Kokkos::RangePolicy<CpExec>(space, 0, numReal),
508 KOKKOS_LAMBDA(
int i,
float& acc) {
510 const float dd =
dot3(d, d);
514 Kokkos::Max<float>(m));
530 Kokkos::View<
float* [3],
CpMem> xi,
531 Kokkos::View<float*, CpMem> snPrev,
532 Kokkos::View<
float* [3],
CpMem> force,
533 Kokkos::View<
float* [3],
CpMem> torque) {
534 const Kokkos::View<const float* [3], CpMem> pos = bodies.
pos, vel = bodies.
vel,
536 const Kokkos::View<const float*, CpMem> invMass = bodies.
invMass;
537 const Kokkos::View<const float* [4], CpMem> quat = shp.
quat;
538 const Kokkos::View<const float*, CpMem> scale = shp.
scale;
540 const Kokkos::View<const ShapeDesc*, CpMem> shapes = shp.
shapes;
546 const Kokkos::View<const float*, CpMem> hertzE = mat.
hertzE, hertzNu = mat.
hertzNu;
548 Kokkos::parallel_for(
549 "peclet::dem::hertz_shape_pairs", Kokkos::RangePolicy<CpExec>(space, 0, numPairs),
550 KOKKOS_LAMBDA(
int idx) {
551 const int idA = pairs(idx, 0), idB = pairs(idx, 1);
552 const ShapeDesc dA = shapes(shapeId(idA));
553 const ShapeDesc dB = shapes(shapeId(idB));
556 const float effScaleA = scale(idA) * globalScale, effScaleB = scale(idB) * globalScale;
559 const int iter = (countA > 0) ? countA : 1;
561 const int ma = matId(idA), mb = matId(idB);
563 hertzPairEMu(ma, mb, pairTable, eGlobal, muGlobal, e, mu);
564 const float Ei = hertzE(ma), Ej = hertzE(mb);
565 const float ni = hertzNu(ma), nj = hertzNu(mb);
566 const float eStar = 1.0f / ((1.0f - ni * ni) / Ei + (1.0f - nj * nj) / Ej);
568 1.0f / (2.0f * (2.0f - ni) * (1.0f + ni) / Ei + 2.0f * (2.0f - nj) * (1.0f + nj) / Ej);
571 const float rcA = (sphereA ? 1.0f : contactRadiusFrac) * dA.
params.
x * effScaleA;
574 const float rStar = rcA * rcB / (rcA + rcB);
575 const float imSum = invMass(idA) + invMass(idB);
576 const float mStar = (imSum > 0.0f) ? 1.0f / imSum : 0.0f;
582 float fnSum = 0.0f, snSum = 0.0f;
583 F3 cSum{0, 0, 0}, nSum{0, 0, 0};
585 F3 fAcc{0, 0, 0}, tAccA{0, 0, 0}, tAccB{0, 0, 0};
590 const float snTotPrev = snPrev(idx);
591 const float dampC = (mStar > 0.0f) ? -2.0f * 0.9128709f * bd * Kokkos::sqrt(mStar) : 0.0f;
593 for (
int k = 0; k < iter; ++k) {
595 float pointRadius = 0.0f;
598 pLocalA =
F3{shell(sIdx, 0), shell(sIdx, 1), shell(sIdx, 2)};
599 }
else if (sphereA) {
600 pointRadius = dA.
params.
x * effScaleA;
604 const float dist =
sdfEvalShape(pCanB, dB, sdfGrid) * effScaleB;
605 const float effDist = dist - pointRadius;
608 const float delta = -effDist;
610 const float len =
len3(nLoc);
611 nLoc = (len > 1e-9f) ?
scale3(nLoc, 1.0f / len) :
F3{0, 1, 0};
613 const F3 pSurfA =
sub3(pWorld,
scale3(nW, pointRadius));
614 const F3 rA =
sub3(pSurfA, posA);
618 const float vnP =
dot3(vrelP, nW);
619 const float sq = Kokkos::sqrt(rStar * delta);
620 const float fnSpring = (4.0f / 3.0f) * eStar * sq * delta;
621 const float snI = 2.0f * eStar * sq;
622 const float snTot = (snTotPrev > snI) ? snTotPrev : snI;
623 const float etaI = dampC * snI / Kokkos::sqrt(snTot);
624 const F3 f =
scale3(nW, fnSpring - etaI * vnP);
625 fAcc =
add3(fAcc, f);
629 snSum += 2.0f * eStar * sq;
637 xi(idx, 0) = xi(idx, 1) = xi(idx, 2) = 0.0f;
643 const F3 cpt =
scale3(cSum, 1.0f / fnSum);
645 const float nl =
len3(nhat);
647 nhat =
scale3(nhat, 1.0f / nl);
648 const F3 rA =
sub3(cpt, posA), rB =
sub3(cpt, posB);
652 const float st = 8.0f * gStar * Kokkos::sqrt(rStar * dMax);
653 const float etaT = -2.0f * 0.9128709f * bd * Kokkos::sqrt(st * mStar);
654 F3 x{xi(idx, 0), xi(idx, 1), xi(idx, 2)};
658 const float ftLen =
len3(ft);
659 const float ftMax = mu * fnSum;
661 const float sc = (ftLen > 1e-20f) ? ftMax / ftLen : 0.0f;
669 fAcc =
add3(fAcc, ft);
673 for (
int c = 0; c < 3; ++c) {
674 Kokkos::atomic_add(&force(idA, c), (&fAcc.
x)[c]);
675 Kokkos::atomic_add(&force(idB, c), -(&fAcc.
x)[c]);
676 Kokkos::atomic_add(&torque(idA, c), (&tAccA.x)[c]);
677 Kokkos::atomic_add(&torque(idB, c), (&tAccB.x)[c]);
float hertzBetaD(float e)
Restitution -> damping ratio beta_d = ln e / sqrt(ln^2 e + pi^2) (e in (0, 1]; e <= 0 -> -1,...
void hertzWallForces(Kokkos::View< const int *, CpMem > candSlots, int numCand, const HertzWallState &wall, const HertzBodies &bodies, const HertzMaterials &mat, float dt, Kokkos::View< float *[3], CpMem > force, Kokkos::View< float *[3], CpMem > torque, const HertzShapes &shp={})
SDF-wall forces (per particle x wall).
int hertzBuildWallCandidates(int numReal, int numWalls, Kokkos::View< const WallSdf *, CpMem > walls, GridView wallGrid, Kokkos::View< const float *[3], CpMem > pos, Kokkos::View< const float *, CpMem > rad, float skin, Kokkos::View< int *, CpMem > outSlots, Kokkos::View< int, CpMem > outCount)
Build the wall candidate list: particles within (radius + skin) of any wall's zero level.
F3 sdfGradShape(F3 p, const ShapeDesc &d, GridView grid)
Outward gradient of a shape's SDF at canonical point p, NOT normalised (callers normalise,...
void hertzIntegrate(int numReal, Kokkos::View< float *[3], CpMem > force, Kokkos::View< float *[3], CpMem > torque, const BodyState &bodies, F3 gravity, float dt, bool integrateOrientation=false)
Symplectic-Euler kick-drift (MUSEN-style) + displacement tracking for the Verlet rebuild.
CpExec::memory_space CpMem
float sampleWallSdf(F3 p, const WallSdf &w, GridView grid)
Trilinearly sample a static world-space wall SDF at world point p.
F3 invRotateVector(F4 q, F3 v)
F3 loadF3(PosView v, int i)
float sdfEvalShape(F3 p, const ShapeDesc &d, GridView grid)
Canonical-space SDF of a shape: analytic dispatch, or a trilinear grid sample for an imported grid SD...
void hertzWallEMu(int ma, const WallSdf &w, PairTableView pairTable, float eGlobal, float muGlobal, float &e, float &mu)
A particle-wall pair's (e, mu): the wall's material id through the pair table when both are set,...
F3 rotateVector(F4 q, F3 v)
void hertzPairEMu(int matA, int matB, PairTableView pairTable, float eGlobal, float muGlobal, float &e, float &mu)
Pairwise (e, mu) lookup shared with the narrowphase convention: pair table if present,...
F3 hertzForce(float delta, F3 nhat, F3 vrel, float rStar, float mStar, float eStar, float gStar, float e, float mu, float dt, F3 &xi)
One Hertz–Mindlin force evaluation for a sphere-sphere or sphere-wall contact.
Kokkos::View< const float *, CpMem > PairTableView
float hertzSphereRadius(int i, Kokkos::View< const float *, CpMem > rad, Kokkos::View< const float *, CpMem > scale, ScalarI shapeId, Kokkos::View< const ShapeDesc *, CpMem > shapes, float globalScale)
A body's Hertz sphere radius: a SPHERE shape's own radius, scale * globalScale * params....
Kokkos::DefaultExecutionSpace CpExec
void hertzPairForces(Kokkos::View< const int *[2], CpMem > pairs, int numPairs, const HertzBodies &bodies, const HertzMaterials &mat, float dt, Kokkos::View< float *[3], CpMem > xi, Kokkos::View< float *[3], CpMem > force, Kokkos::View< float *[3], CpMem > torque, const HertzShapes &shp={})
Cached-pair forces: overlap from current positions; history resets when a cached pair is currently se...
F4 loadF4(QuatView v, int i)
void hertzShapePairForces(Kokkos::View< const int *[2], CpMem > pairs, int numPairs, const HertzBodies &bodies, const HertzShapes &shp, GridView sdfGrid, const HertzMaterials &mat, float dt, Kokkos::View< float *[3], CpMem > xi, Kokkos::View< float *, CpMem > snPrev, Kokkos::View< float *[3], CpMem > force, Kokkos::View< float *[3], CpMem > torque)
Non-spherical pairs: per-point Hertz springs over A's point shell against B's SDF (the same one-sided...
Kokkos::View< const int *, CpMem > ScalarI
Kokkos::View< const float *[3], CpMem > ShellView
float hertzMaxDisp2(int numReal, Kokkos::View< const float *[3], CpMem > pos, Kokkos::View< const float *[3], CpMem > refPos)
Max squared displacement since the last pair build (called only at rebuild checks – keeping this out ...
Kokkos::View< const unsigned char *, CpMem > MatIdView
F3 wallSdfGradient(F3 q, const WallSdf &w, GridView wallGrid)
The wall SDF's gradient at q by central differences at half a grid cell (unnormalized).
Kokkos::View< const float *, CpMem > GridView
constexpr int kMaxMaterials
Pair-material lookup: flat [K*K*2] table, entry ((a*K + b)*2) = restitution, +1 = friction.
dem — portable (Kokkos) narrow-phase: SDF point-shell collision + boundary planes.
dem — portable (Kokkos) particle SoA container: the storage the dem flip pivots on.
A body's state, one row per particle slot (Particles::bodyState()).
Kokkos::View< float *[3], CpMem > pos
Kokkos::View< float *[3], CpMem > invInertia
Kokkos::View< float *, CpMem > invMass
Kokkos::View< float *[3], CpMem > angVel
Kokkos::View< float *[4], CpMem > quat
Kokkos::View< float *[3], CpMem > vel
The body state a Hertz force launcher reads.
Kokkos::View< const float *[3], CpMem > vel
Kokkos::View< const float *[3], CpMem > angVel
Kokkos::View< const float *[3], CpMem > pos
Kokkos::View< const float *, CpMem > invMass
Kokkos::View< const float *, CpMem > rad
The Hertz–Mindlin contact materials: each body's material id, the optional pair table of (e,...
Kokkos::View< const float *, CpMem > hertzNu
Kokkos::View< const float *, CpMem > hertzE
What a non-spherical Hertz contact reads: orientation, scale, shape id, the shape registry and its sh...
Kokkos::View< const float *[4], CpMem > quat
Kokkos::View< const float *, CpMem > scale
Kokkos::View< const ShapeDesc *, CpMem > shapes
The SDF walls and their per-(particle, wall) contact history at slot i * maxWalls + wall: the Mindlin...
Kokkos::View< float *, CpMem > snWall
Kokkos::View< const WallSdf *, CpMem > walls
Kokkos::View< float *[3], CpMem > xiWall
Portable mirror of ShapeDescriptor (analytic fields + a flat-array point shell).
Static, world-space SDF container/geometry the particles collide against (a drum barrel,...
peclet::core::geom::GridDesc< float > grid