peclet-dem 0.4.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::freezeAsleepKokkos (int numReal, Kokkos::View< const unsigned char *, CpMem > asleep, Kokkos::View< const float *[3], CpMem > pos, Kokkos::View< const float *[4], CpMem > quat, Kokkos::View< float *[3], CpMem > posPred, Kokkos::View< float *[4], CpMem > quatPred, Kokkos::View< float *[3], CpMem > velPred, Kokkos::View< float *[3], CpMem > angVelPred)
 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::buildInvMassEffKokkos (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::computeManifoldSleepKokkos (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::computeContactSleepKokkos (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 computeManifoldSleepKokkos for the position colouring.
 
void peclet::dem::wakeDisturbedKokkos (Kokkos::View< const ManifoldC *, CpMem > manifolds, int numManifolds, Kokkos::View< const int *, CpMem > realIdx, Kokkos::View< const float *[3], CpMem > velPred, float wakeSpeed, Kokkos::View< unsigned char *, CpMem > asleep, Kokkos::View< unsigned char *, CpMem > sleepCounter, Kokkos::View< unsigned char *, CpMem > movingWall, Kokkos::View< int *, CpMem > curCount, int numReal)
 Wake pass (before the solve): a sleeper is woken when actually disturbed.
 
void peclet::dem::wakeContactChangeKokkos (int numReal, Kokkos::View< const int *, CpMem > curCount, Kokkos::View< int *, CpMem > prevCount, Kokkos::View< const unsigned char *, CpMem > movingWall, Kokkos::View< unsigned char *, CpMem > asleep, Kokkos::View< unsigned char *, CpMem > sleepCounter, 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::updateSleepKokkos (int numReal, Kokkos::View< const float *[3], CpMem > vel, Kokkos::View< const float *[3], CpMem > angVel, Kokkos::View< const float *, CpMem > rad, Kokkos::View< const unsigned char *, CpMem > grounded, Kokkos::View< const unsigned char *, CpMem > movingWall, Kokkos::View< unsigned char *, CpMem > asleep, Kokkos::View< unsigned char *, CpMem > sleepCounter, float sleepSpeed, int K, Kokkos::View< float *[3], CpMem > velOut, Kokkos::View< float *[3], CpMem > angVelOut)
 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 / PECLET_DEM_SLEEP=0).

Definition in file sleeping.hpp.