peclet-dem 1.1.0
Performance-portable XPBD Discrete Element Method (Kokkos + ArborX)
Loading...
Searching...
No Matches
sleeping.hpp File Reference

dem — island sleeping / freezing for the single-GPU PGS statics path. More...

#include <Kokkos_Core.hpp>
#include "contact_preprocessing.hpp"
#include "dem_portable.hpp"

Go to the source code of this file.

Namespaces

namespace  peclet
namespace  peclet::dem

Functions

void peclet::dem::freezeAsleep (int numReal, Kokkos::View< const unsigned char *, CpMem > asleep, const BodyState &bodies, const BodyPred &pred)
 After predictVelocity: re-freeze the currently-asleep bodies so gravity/prediction do not move them — velPred = angVelPred = 0, posPred = pos, quatPred = quat.
void peclet::dem::buildInvMassEff (int numBodies, Kokkos::View< const unsigned char *, CpMem > asleep, Kokkos::View< const int *, CpMem > realIdx, Kokkos::View< const float *, CpMem > invMass, Kokkos::View< float *, CpMem > invMassEff, float sleeperFrac)
 Effective inverse mass for the solve: a sleeping body (real, or a periodic ghost whose real is asleep) is immovable — invMassEff = 0.
void peclet::dem::computeManifoldSleep (Kokkos::View< const ManifoldC *, CpMem > manifolds, int numManifolds, Kokkos::View< const int *, CpMem > realIdx, Kokkos::View< const unsigned char *, CpMem > asleep, Kokkos::View< unsigned char *, CpMem > manifoldSleep)
 Per-manifold "both endpoints asleep" flag (a static wall, bodyB < 0, counts as asleep).
void peclet::dem::computeContactSleep (Kokkos::View< const ContactC *, CpMem > contacts, int numContacts, Kokkos::View< const int *, CpMem > realIdx, Kokkos::View< const unsigned char *, CpMem > asleep, Kokkos::View< unsigned char *, CpMem > contactSleep)
 Per-contact twin of computeManifoldSleep for the position colouring.
void peclet::dem::wakeDisturbed (Kokkos::View< const ManifoldC *, CpMem > manifolds, int numManifolds, Kokkos::View< const int *, CpMem > realIdx, Kokkos::View< const float *[3], CpMem > velPred, float wakeSpeed, const SleepState &sleep, int numReal)
 Wake pass (before the solve): a sleeper is woken when actually disturbed.
void peclet::dem::wakeContactChange (int numReal, const SleepState &sleep, bool wakeOnChange)
 Contact-set-change wake rule (b): wake any still-asleep body whose live contact count differs from the stored one (a support gained or lost), then refresh the store.
void peclet::dem::updateSleep (int numReal, const BodyState &bodies, Kokkos::View< const float *, CpMem > rad, Kokkos::View< const unsigned char *, CpMem > grounded, const SleepState &sleep, float sleepSpeed, int K)
 Sleep detection (after the commit): an AWAKE, grounded body whose linear AND angular motion has stayed below sleepSpeed for K consecutive substeps is put to sleep (velocity + spin zeroed).

Detailed Description

dem — island sleeping / freezing for the single-GPU PGS statics path.

A settled granular bed is quasi-static: its contact network re-solves to the SAME frozen force balance every substep, and the multilevel stabilization pass rebuilds its whole hierarchy (~540 launches/substep at 25k) to re-arrest a pile that is not moving. Sleeping removes that waste: a REAL body whose motion has stayed below the solver's own resting floor for K substeps while grounded is put to sleep (velocity zeroed, integration skipped). A manifold whose BOTH endpoints are asleep (a static wall counts as asleep) is excluded from the colouring, the sweeps and the multilevel hierarchy — so a fully-settled bed collapses to the broad/narrow-phase floor. A sleeping body is given effective inverse mass 0 for the solve, so any awake–asleep contact treats the sleeper as immovable (kinematic) — exactly the role the grounded one-sided pass fakes — which keeps the solve correct WITHOUT waking the sleeper. Waking is therefore a physics decision, not a solver-correctness one: a sleeper is woken only when actually disturbed (a fast approaching neighbour, a change in its contact set, or a moving wall).

Single-GPU only (gravity on, no external force). Under MPI / CFD-DEM drag the caller leaves sleeping disabled, so this whole path is inert. Default ON (set_sleeping(False) disables).

Definition in file sleeping.hpp.