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::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::countPositionJacobiKokkos (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::solvePositionKokkos (Kokkos::View< const ContactC *, CpMem > contacts, int numContacts, Kokkos::View< const float *, CpMem > invMass, Kokkos::View< const 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 *[3], CpMem > deltaPos, Kokkos::View< float *[4], CpMem > deltaQuat, Kokkos::View< int *, CpMem > constraintCounts, 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::colorContactsKokkos (Kokkos::View< const ContactC *, CpMem > contacts, int numContacts, int numBodies, Kokkos::View< int *, CpMem > cColor, Kokkos::View< long long *, CpMem > bodyWinner, Kokkos::View< std::uint64_t *, CpMem > bodyMask, 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::colorContactsIncrementalKokkos (Kokkos::View< const ContactC *, CpMem > contacts, int numContacts, int numBodies, Kokkos::View< const unsigned long long *, CpMem > prevKeys, Kokkos::View< const int *, CpMem > prevColor, int prevCount, Kokkos::View< int *, CpMem > cColor, Kokkos::View< unsigned long long *, CpMem > keysOut, Kokkos::View< long long *, CpMem > bodyWinner, Kokkos::View< std::uint64_t *, CpMem > bodyMask, 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::expandUnitColorsKokkos (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::commitContactColorKokkos (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::solvePositionColoredGSKokkos (Kokkos::View< const ContactC *, CpMem > contacts, const PosUnits &units, int numContacts, Kokkos::View< const int *, CpMem > cColor, int numColors, 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={}, Kokkos::View< const int *, CpMem > colorPerm={}, const std::vector< int > *colorOffs=nullptr, const FusedSweepCtx *fused=nullptr, 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.