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

dem — portable (Kokkos) XPBD position solve (pure overlap removal). More...

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

Go to the source code of this file.

Classes

struct  peclet::dem::UnitEdges
 The position-unit edge source of colorEdges: a unit's edge is its leader contact's raw (bodyA, bodyB), or a hub copy slot through ov, keyed colorKey(leader). More...
struct  peclet::dem::PositionContactSweep
 The per-contact overlap-projection body lives in PositionContactSweep so the colored launch loop and the fused colour sweep (solver_fused.hpp) share it verbatim: solveOne(idx) must only run concurrently on contacts that are body-disjoint within one launch (a colour class). More...

Namespaces

namespace  peclet
namespace  peclet::dem
namespace  peclet::dem::detail

Functions

float peclet::dem::detail::computeW (F3 r, F3 dir, float invM, F3 invI)
void peclet::dem::countPositionJacobi (Kokkos::View< const ContactC *, CpMem > contacts, int numContacts, Kokkos::View< int *, CpMem > counts)
 Mass-split Jacobi count pass (docs/contact_solve_framework.md §3.1, D3): per body slot, the number of contacts the Jacobi position solve visits (every contact; a wall side counts nothing).
void peclet::dem::solvePosition (Kokkos::View< const ContactC *, CpMem > contacts, int numContacts, const BodyState &bodies, const BodyPred &pred, const BodyDelta &delta, Kokkos::View< float, CpMem > maxOverlap, Kokkos::View< const int *, CpMem > onlyColor={}, int colorFilter=0, bool massSplit=false)
 Accumulate XPBD position corrections for numContacts contacts.
bool peclet::dem::unitAsleep (const PosUnits &units, const Kokkos::View< const unsigned char *, CpMem > &sleepMask, int u)
 A position unit is sleep-inactive iff all its contacts are sleep-masked (§4.3).
int peclet::dem::colorContacts (Kokkos::View< const ContactC *, CpMem > contacts, int numContacts, int numBodies, Kokkos::View< int *, CpMem > cColor, const ColorScratch &scratch, int &leftover, Kokkos::View< const unsigned char *, CpMem > sleepMask={}, PosUnits units={}, SlotOverride ov={}, int vertexSpan=0)
 Greedy graph-colour the contacts (raw bodyA/bodyB): no two contacts sharing a body get the same colour.
int peclet::dem::colorContactsIncremental (Kokkos::View< const ContactC *, CpMem > contacts, int numContacts, int numBodies, const CarriedColors &carried, Kokkos::View< int *, CpMem > cColor, Kokkos::View< unsigned long long *, CpMem > keysOut, const ColorScratch &scratch, int &leftover, bool forceFull, Kokkos::View< const unsigned char *, CpMem > sleepMask={}, PosUnits units={})
 Incremental (warm-started) contact colouring for the single-GPU PGS position solve.
void peclet::dem::expandUnitColors (const PosUnits &units, int numUnits, Kokkos::View< const int *, CpMem > unitColor, Kokkos::View< int *, CpMem > contactColor)
 Copy each position unit's colour onto its contacts (contactColor(i) = unitColor(unit of i)).
void peclet::dem::commitContactColor (Kokkos::View< const unsigned long long *, CpMem > keys, Kokkos::View< const int *, CpMem > color, Kokkos::View< unsigned long long *, CpMem > prevKeys, Kokkos::View< int *, CpMem > prevColor, Kokkos::View< int *, CpMem > perm, int numContacts)
 Commit this substep's per-contact (key, colour) sorted by key, for next substep's warm gather.
bool peclet::dem::solvePositionColoredGS (Kokkos::View< const ContactC *, CpMem > contacts, const PosUnits &units, int numContacts, const ColorSchedule &sched, Kokkos::View< const float *, CpMem > invMass, Kokkos::View< float *[3], CpMem > posPred, Kokkos::View< const float *[4], CpMem > quatPred, Kokkos::View< const float *[4], CpMem > quatStatic, Kokkos::View< const float *[3], CpMem > invInertia, Kokkos::View< float, CpMem > maxOverlap, Kokkos::View< float *, CpMem > posLambdaAcc={}, const FusedLoopSpec *loop=nullptr, SlotOverride ov={}, Kokkos::View< float, CpMem > posResidual={}, float omega=1.0f)
 Colored Gauss–Seidel XPBD overlap solve: sweep the numColors colour classes in order, applying each contact's non-penetration correction directly to posPred (in place, translation only).

Detailed Description

dem — portable (Kokkos) XPBD position solve (pure overlap removal).

Kokkos port of solve_position_jacobi_kernel (solver_position.cu): one thread per contact evaluates the linearized non-penetration constraint C(x) (using the delta-rotated lever arms / normal), computes the XPBD position correction, and atomically scatters delta_pos / delta_quat and bumps the per-body constraint count (the caller averages by it). Faithful copy of the CUDA math over the SoA Views. Friction is a separate cluster (ported separately); the position solve does overlap only.

Definition in file solver_position.hpp.