peclet-dem 0.4.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)
 
F4 peclet::dem::detail::deltaQuat (F3 dTheta, F4 q)
 
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)
 Accumulate XPBD position corrections for numContacts contacts.
 
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={})
 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={})
 Incremental (warm-started) contact colouring for the single-GPU PGS position solve.
 
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, 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)
 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.