peclet-dem 1.1.0
Performance-portable XPBD Discrete Element Method (Kokkos + ArborX)
Loading...
Searching...
No Matches
peclet::dem::ShapeRegistry Class Reference

Host-side shape registry (Layer 1). More...

#include <shape_registry.hpp>

Inheritance diagram for peclet::dem::ShapeRegistry:
peclet::dem::Simulation

Public Member Functions

void setSphereShape (float radius)
 
void initializeShape (int shape_type, float radius, float height, float thickness)
 
int addShape (int shape_type, float radius, float height, float thickness)
 Append an analytic shape and return its index, for simulations with a MIXTURE of shapes.
 
void setShapeIds (const std::vector< int > &ids)
 Per-particle shape assignment.
 
int addSdfShape (const std::vector< float > &grid, int nx, int ny, int nz, F3 origin, F3 spacing, const std::vector< float > &shellFlat, F3 invInertia, float boundingRadius)
 Append a grid-SDF shape (the general non-spherical particle) to the mixture and return its index.
 
int numShapes () const
 
void setSdfShape (const std::vector< float > &grid, int nx, int ny, int nz, F3 origin, F3 spacing, const std::vector< float > &shellFlat, F3 invInertia, float boundingRadius)
 
int addSceneShape (const std::vector< int > &nodeInts, const std::vector< float > &nodeReals, int root, const std::vector< float > &shellFlat, F3 invInertia, float boundingRadius)
 
std::vector< float > autoShell (const std::vector< float > &grid, int nx, int ny, int nz, F3 origin, F3 spacing, float boundingRadius) const
 Generate a collision shell for a grid SDF by sampling its own zero level set, so a caller does not have to supply one.
 

Protected Member Functions

void ensureContactCapacity ()
 
void clearShapes ()
 
void appendShape (ShapeDesc sd, const std::vector< F3 > &shell, F3 invI, float baseRadius)
 Append one shape, taking ownership of its shell.
 
void uploadShapes ()
 Rebuild the device Views from the host registry.
 

Protected Attributes

Particles P_
 
float baseRadius_ = 1.0f
 
std::vector< ShapeDesc > shapesHost_
 
std::vector< F3 > shellHost_
 
std::vector< F3 > invIHost_
 
std::vector< float > baseRadiusHost_
 
std::vector< float > sdfSamplesHost_
 
int shellPoints_ = 0
 
std::vector< peclet::core::geom::ShapeNode< float > > shapeNodesHost_
 
F3 defaultInvI_ {2.5f, 2.5f, 2.5f}
 

Detailed Description

Host-side shape registry (Layer 1).

The device Views (P_.shapes / P_.shell / P_.sdfGrid) are rebuilt from the host vectors by uploadShapes(), which is what assigns each shape its shellOffset and grid offset into the shared pools. Keeping the authoritative copy on the host is what makes a MIXTURE of shapes possible at all: the old code wrote descriptor slot 0 directly and had nowhere to put a second shell.

Definition at line 32 of file shape_registry.hpp.

Member Function Documentation

◆ setSphereShape()

void peclet::dem::ShapeRegistry::setSphereShape ( float  radius)
inline

Definition at line 34 of file shape_registry.hpp.

References initializeShape(), and peclet::dem::SPHERE.

Referenced by peclet::dem::Simulation::Simulation().

◆ initializeShape()

void peclet::dem::ShapeRegistry::initializeShape ( int  shape_type,
float  radius,
float  height,
float  thickness 
)
inline

◆ addShape()

int peclet::dem::ShapeRegistry::addShape ( int  shape_type,
float  radius,
float  height,
float  thickness 
)
inline

Append an analytic shape and return its index, for simulations with a MIXTURE of shapes.

Same arguments as initializeShape, which stays the "single shape" entry point (it resets the registry). Assign the returned index to particles with setShapeIds().

Definition at line 115 of file shape_registry.hpp.

References appendShape(), baseRadiusHost_, ensureContactCapacity(), initializeShape(), invIHost_, sdfSamplesHost_, shapesHost_, shellHost_, and uploadShapes().

Referenced by NB_MODULE().

◆ setShapeIds()

void peclet::dem::ShapeRegistry::setShapeIds ( const std::vector< int > &  ids)
inline

Per-particle shape assignment.

Also refreshes each particle's inverse inertia from its new shape, so the order of setPositions/setShapeIds does not matter.

Definition at line 144 of file shape_registry.hpp.

References invIHost_, peclet::dem::Particles::invInertia, peclet::dem::Particles::numReal, P_, peclet::dem::Particles::shapeId, and shapesHost_.

Referenced by NB_MODULE().

◆ addSdfShape()

int peclet::dem::ShapeRegistry::addSdfShape ( const std::vector< float > &  grid,
int  nx,
int  ny,
int  nz,
F3  origin,
F3  spacing,
const std::vector< float > &  shellFlat,
F3  invInertia,
float  boundingRadius 
)
inline

Append a grid-SDF shape (the general non-spherical particle) to the mixture and return its index.

Same arguments as set_sdf_shape, which stays the single-shape entry point. The samples are appended to the shared pool and the descriptor's offset set accordingly.

Definition at line 168 of file shape_registry.hpp.

References appendShape(), autoShell(), ensureContactCapacity(), sdfSamplesHost_, peclet::dem::SHAPE_GRID_SDF, shapesHost_, peclet::dem::toCoreVec(), peclet::dem::ShapeDesc::type, uploadShapes(), peclet::dem::F3::x, peclet::dem::F3::y, and peclet::dem::F3::z.

Referenced by NB_MODULE().

◆ numShapes()

int peclet::dem::ShapeRegistry::numShapes ( ) const
inline

Definition at line 206 of file shape_registry.hpp.

References shapesHost_.

Referenced by NB_MODULE().

◆ setSdfShape()

void peclet::dem::ShapeRegistry::setSdfShape ( const std::vector< float > &  grid,
int  nx,
int  ny,
int  nz,
F3  origin,
F3  spacing,
const std::vector< float > &  shellFlat,
F3  invInertia,
float  boundingRadius 
)
inline

◆ addSceneShape()

int peclet::dem::ShapeRegistry::addSceneShape ( const std::vector< int > &  nodeInts,
const std::vector< float > &  nodeReals,
int  root,
const std::vector< float > &  shellFlat,
F3  invInertia,
float  boundingRadius 
)
inline

◆ autoShell()

std::vector< float > peclet::dem::ShapeRegistry::autoShell ( const std::vector< float > &  grid,
int  nx,
int  ny,
int  nz,
F3  origin,
F3  spacing,
float  boundingRadius 
) const
inline

Generate a collision shell for a grid SDF by sampling its own zero level set, so a caller does not have to supply one.

Layer 1: previously every shape needed a hand-written generator (there were only two, for the cylinder and the box) or a marching-cubes shell computed in Python; core's surfacePoints() is driven by the SDF itself and works for any geometry.

Definition at line 334 of file shape_registry.hpp.

References peclet::dem::F3::x, peclet::dem::F3::y, and peclet::dem::F3::z.

Referenced by addSdfShape(), and setSdfShape().

◆ ensureContactCapacity()

◆ clearShapes()

void peclet::dem::ShapeRegistry::clearShapes ( )
inlineprotected

Definition at line 383 of file shape_registry.hpp.

References baseRadiusHost_, invIHost_, sdfSamplesHost_, shapesHost_, and shellHost_.

Referenced by initializeShape(), and setSdfShape().

◆ appendShape()

void peclet::dem::ShapeRegistry::appendShape ( ShapeDesc  sd,
const std::vector< F3 > &  shell,
F3  invI,
float  baseRadius 
)
inlineprotected

Append one shape, taking ownership of its shell.

Fills in shellOffset from the running concatenation; the caller has already set the grid fields (if any).

Definition at line 393 of file shape_registry.hpp.

References baseRadiusHost_, invIHost_, peclet::dem::ShapeDesc::numPoints, shapesHost_, shellHost_, and peclet::dem::ShapeDesc::shellOffset.

Referenced by addSceneShape(), addSdfShape(), addShape(), initializeShape(), and setSdfShape().

◆ uploadShapes()

Member Data Documentation

◆ P_

Particles peclet::dem::ShapeRegistry::P_
protected

Definition at line 370 of file shape_registry.hpp.

Referenced by peclet::dem::Simulation::addAnalyticWall(), peclet::dem::Simulation::addPlane(), peclet::dem::Simulation::addSdfWall(), peclet::dem::Simulation::capacity(), peclet::dem::Simulation::clearExternalForces(), peclet::dem::Simulation::clearExternalTorques(), peclet::dem::Simulation::computeOverlaps(), peclet::dem::Simulation::cudaGraphs(), peclet::dem::Simulation::debugColoringConflicts(), peclet::dem::Simulation::debugColoringLeftovers(), peclet::dem::Simulation::debugMultilevelColoringConflicts(), peclet::dem::Simulation::debugSplitStats(), peclet::dem::Simulation::domainExtent(), peclet::dem::Simulation::domainOrigin(), peclet::dem::Simulation::domainPeriodic(), peclet::dem::Simulation::dt(), peclet::dem::Simulation::enablePeriodicity(), ensureContactCapacity(), peclet::dem::Simulation::exportLammps(), peclet::dem::Simulation::exportSdf(), peclet::dem::Simulation::externalForcesView(), peclet::dem::Simulation::externalTorquesView(), peclet::dem::Simulation::fusedSweeps(), peclet::dem::Simulation::getAngularVelocities(), peclet::dem::Simulation::getGrowthRate(), peclet::dem::Simulation::getInvInertia(), peclet::dem::Simulation::getMasses(), peclet::dem::Simulation::getPositions(), peclet::dem::Simulation::getQuaternions(), peclet::dem::Simulation::getScales(), peclet::dem::Simulation::getSdfGrid(), peclet::dem::Simulation::getVelocities(), peclet::dem::Simulation::globalScale(), peclet::dem::Simulation::gravity(), peclet::dem::Simulation::growthFactor(), peclet::dem::Simulation::incrementalColoring(), peclet::dem::Simulation::invMassView(), peclet::dem::Simulation::maxOverlap(), peclet::dem::Simulation::numAsleep(), peclet::dem::Simulation::numContacts(), peclet::dem::Simulation::numManifolds(), peclet::dem::Simulation::numParticles(), peclet::dem::Simulation::positionsView(), peclet::dem::Simulation::relax(), peclet::dem::Simulation::releaseViews(), peclet::dem::Simulation::restBankStats(), peclet::dem::Simulation::restitutionModel(), peclet::dem::Simulation::restOrphanStats(), peclet::dem::Simulation::setAngularVelocities(), peclet::dem::Simulation::setCudaGraphs(), peclet::dem::Simulation::setDomain(), peclet::dem::Simulation::setDomainCanonical(), peclet::dem::Simulation::setDomainMinMax(), peclet::dem::Simulation::setDt(), peclet::dem::Simulation::setExternalForces(), peclet::dem::Simulation::setExternalTorques(), peclet::dem::Simulation::setFusedSweeps(), peclet::dem::Simulation::setGlobalScale(), peclet::dem::Simulation::setGravity(), peclet::dem::Simulation::setGrowthParams(), peclet::dem::Simulation::setHertzMaterial(), peclet::dem::Simulation::setIncrementalColoring(), peclet::dem::Simulation::setInvInertia(), peclet::dem::Simulation::setInvMass(), peclet::dem::Simulation::setMaterialIds(), peclet::dem::Simulation::setMaterialParams(), peclet::dem::Simulation::setPairMaterial(), peclet::dem::Simulation::setPositions(), peclet::dem::Simulation::setQuaternions(), peclet::dem::Simulation::setRestitutionModel(), peclet::dem::Simulation::setScales(), peclet::dem::Simulation::setScalesUniform(), setSdfShape(), setShapeIds(), peclet::dem::Simulation::setShellDetection(), peclet::dem::Simulation::setSleeping(), peclet::dem::Simulation::setSolverIterations(), peclet::dem::Simulation::setStabilizationMode(), peclet::dem::Simulation::setThermostat(), peclet::dem::Simulation::setVelocities(), peclet::dem::Simulation::setVelocityUseGS(), peclet::dem::Simulation::setVerletSkin(), peclet::dem::Simulation::setWallMaterialId(), peclet::dem::Simulation::setWallTransform(), peclet::dem::Simulation::shellDetection(), peclet::dem::Simulation::Simulation(), peclet::dem::Simulation::sleeping(), peclet::dem::Simulation::stabilizationMode(), peclet::dem::Simulation::step(), peclet::dem::Simulation::stepHertz(), uploadShapes(), peclet::dem::Simulation::velocitiesView(), peclet::dem::Simulation::velocityUseGS(), peclet::dem::Simulation::verletSkin(), peclet::dem::Simulation::wallSdfAt(), and peclet::dem::Simulation::writeVtp().

◆ baseRadius_

float peclet::dem::ShapeRegistry::baseRadius_ = 1.0f
protected

◆ shapesHost_

std::vector<ShapeDesc> peclet::dem::ShapeRegistry::shapesHost_
protected

◆ shellHost_

std::vector<F3> peclet::dem::ShapeRegistry::shellHost_
protected

Definition at line 378 of file shape_registry.hpp.

Referenced by addShape(), appendShape(), clearShapes(), and uploadShapes().

◆ invIHost_

std::vector<F3> peclet::dem::ShapeRegistry::invIHost_
protected

Definition at line 379 of file shape_registry.hpp.

Referenced by addShape(), appendShape(), clearShapes(), setShapeIds(), and uploadShapes().

◆ baseRadiusHost_

std::vector<float> peclet::dem::ShapeRegistry::baseRadiusHost_
protected

Definition at line 380 of file shape_registry.hpp.

Referenced by addShape(), appendShape(), clearShapes(), and uploadShapes().

◆ sdfSamplesHost_

std::vector<float> peclet::dem::ShapeRegistry::sdfSamplesHost_
protected

Definition at line 381 of file shape_registry.hpp.

Referenced by addSdfShape(), addShape(), clearShapes(), setSdfShape(), and uploadShapes().

◆ shellPoints_

int peclet::dem::ShapeRegistry::shellPoints_ = 0
protected

Definition at line 464 of file shape_registry.hpp.

Referenced by ensureContactCapacity(), and uploadShapes().

◆ shapeNodesHost_

std::vector<peclet::core::geom::ShapeNode<float> > peclet::dem::ShapeRegistry::shapeNodesHost_
protected

Definition at line 465 of file shape_registry.hpp.

Referenced by addSceneShape(), and uploadShapes().

◆ defaultInvI_

F3 peclet::dem::ShapeRegistry::defaultInvI_ {2.5f, 2.5f, 2.5f}
protected

Definition at line 466 of file shape_registry.hpp.

Referenced by peclet::dem::Simulation::setPositions(), and uploadShapes().


The documentation for this class was generated from the following file: