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

dem — portable (Kokkos) contact->manifold reduction, replacing the thrust-based reduce_contacts_to_manifolds() in contact_preprocessing.cu. More...

#include <cstdint>
#include <Kokkos_Core.hpp>
#include <Kokkos_Sort.hpp>
#include "dem_portable.hpp"

Go to the source code of this file.

Classes

struct  peclet::dem::ContactC
 Portable mirror of ParticleSystem.cuh ContactConstraint (the fields this reduction touches). More...
 
struct  peclet::dem::ManifoldC
 Portable mirror of ManifoldConstraint. More...
 

Namespaces

namespace  peclet
 
namespace  peclet::dem
 

Typedefs

using peclet::dem::CpExec = Kokkos::DefaultExecutionSpace
 
using peclet::dem::CpMem = CpExec::memory_space
 

Functions

std::uint64_t peclet::dem::pairKey (const ContactC &c)
 Canonical pair key: (min<<32)|max, or (idA<<32)|0xFFFFFFFF for a boundary (idB<0) contact.
 
void peclet::dem::decodeKey (std::uint64_t key, int &bodyA, int &bodyB)
 Decode the canonical (bodyA, bodyB) from a pair key (bodyB = -1 for boundary).
 
ManifoldC peclet::dem::transformContact (const ContactC &c)
 Per-contact transform to a single-point manifold, aligned to the canonical pair.
 
int peclet::dem::reduceContactsToManifoldsKokkos (Kokkos::View< const ContactC *, CpMem > contacts, int n, Kokkos::View< ManifoldC *, CpMem > outManifolds, Kokkos::View< int, CpMem > outCount)
 Reduce n contacts to manifolds (one per unique canonical pair).
 

Detailed Description

dem — portable (Kokkos) contact->manifold reduction, replacing the thrust-based reduce_contacts_to_manifolds() in contact_preprocessing.cu.

Same pipeline: key each contact by its canonical pair, group by key, and within a group sum the aligned normals / torque arms / lever arms and count the points. thrust::sort_by_key + reduce_by_key become Kokkos::Experimental::sort_by_key + a scan-based segmented reduction (atomic accumulation), so no thrust/cub. The per-contact math (ContactToManifold / TransformAndFilter) is reused verbatim as KOKKOS_INLINE_FUNCTION and is shared with the host reference in the test.

One intentional change vs the thrust version: a manifold's (bodyA,bodyB) is decoded determinist -ically from the pair key (canonical min/max, or (idA,-1) for boundary), rather than taken from the first contact of an unstably-sorted run. The summed quantities are commutative, so they are unaffected. Decoupled from ParticleSystemData (portable POD mirrors) for standalone validation.

Definition in file contact_preprocessing.hpp.