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

dem — the shared contact-solve driver: the full modern velocity + position solve sequence (warm-started colored PGS with persistent contacts, gravity statics / stabilization passes, friction, colored-GS overlap projection, adaptive stops), extracted from demStep so the single-GPU and the distributed (MPI) steps run ONE driver instead of drifting copies. More...

#include <algorithm>
#include <cstdlib>
#include <Kokkos_Core.hpp>
#include <utility>
#include <vector>
#include "broadphase_arborx.hpp"
#include "contact_preprocessing.hpp"
#include "particles.hpp"
#include "solver_friction.hpp"
#include "solver_multilevel.hpp"
#include "solver_position.hpp"
#include "solver_velocity.hpp"

Go to the source code of this file.

Classes

struct  peclet::dem::CudaIterGraph
 
struct  peclet::dem::SoloSolveHooks
 Single-GPU hooks: no ghost refresh, residuals are already global. Everything inlines away. More...
 

Namespaces

namespace  peclet
 
namespace  peclet::dem
 

Macros

#define PECLET_DEM_GRAPH_LOOP(useVar, graphVar, emitVar, slotVar)   (void)graphVar;
 

Functions

int peclet::dem::readInt (Kokkos::View< int, CpMem > v)
 
float peclet::dem::readFloat (Kokkos::View< float, CpMem > v)
 
void peclet::dem::fillGidBaseKokkos (Vi gid, int n, int base)
 gid(i) = base + i over [0, n) — the per-rank global-id re-base of the distributed step (namespace scope: nvcc forbids KOKKOS_LAMBDA in member functions).
 
float peclet::dem::maxOwnedRadius (const Particles &P)
 Largest effective particle radius over the owned set (= max scale × globalScale, growth included).
 
int peclet::dem::findCollisionsGrow (Particles &P, float margin)
 Broad phase with an automatically-grown pair buffer.
 
int peclet::dem::findCollisionsVerlet (Particles &P, float margin, float maxRad)
 Verlet-cached impulse broadphase (single-GPU, non-periodic).
 
template<class Hooks >
void peclet::dem::demSolveContacts (Particles &P, int nc, int nm, int nBodies, Kokkos::View< const int *, CpMem > keyIdx, const Hooks &hooks)
 One full velocity + position contact solve over the already-built contacts/manifolds (see file comment).
 

Detailed Description

dem — the shared contact-solve driver: the full modern velocity + position solve sequence (warm-started colored PGS with persistent contacts, gravity statics / stabilization passes, friction, colored-GS overlap projection, adaptive stops), extracted from demStep so the single-GPU and the distributed (MPI) steps run ONE driver instead of drifting copies.

The two callers differ only through the Hooks policy:

  • SoloSolveHooks (single-GPU): every hook is a no-op / identity — the driver compiles to exactly the pre-extraction demStep sequence (validated bit-for-bit on the Serial backend).
  • MpiSolveHooks (sim.hpp, PECLET_DEM_MPI): processor-block Gauss–Seidel — the colouring and the sweeps stay rank-local over owned + ghost bodies (ghost pairs are solved redundantly on both owners; ghost deltas are discarded at the next refresh), syncVelocities / syncPositions refresh the ghost copies owner->ghost every syncEvery iterations plus once after every solve phase, and allMax turns each adaptive-stop residual into a global MPI_Allreduce(MAX) so all ranks take the same break (a rank-local break would desynchronise the collective ghost refreshes and deadlock).

nBodies is the body-slot span of the solve graph: numReal on the single-GPU path (ghost slots are realIndices-mapped onto their owners), numReal + numGhost under MPI (ghosts are self-mapped slots solved in place). keyIdx maps a body slot to the identity used in the persistent-pair keys: realIndices on the single-GPU path, the global particle id under MPI (local slots are not stable across halo rebuilds / migration).

Definition in file solve_driver.hpp.

Macro Definition Documentation

◆ PECLET_DEM_GRAPH_LOOP

#define PECLET_DEM_GRAPH_LOOP (   useVar,
  graphVar,
  emitVar,
  slotVar 
)    (void)graphVar;

Definition at line 208 of file solve_driver.hpp.