core 1.5.0
Shared MPI block decomposition, asynchronous ghost-layer exchange, SDF geometry, load balancing (header-only C++20)
Loading...
Searching...
No Matches
peclet::core::geom Namespace Reference

Namespaces

namespace  body_detail
 
namespace  detail
 
namespace  owner_detail
 
namespace  prim
 
namespace  quad_detail
 Gauss-Legendre nodes/weights on [0,1] for n = 1..8.
 
namespace  query_detail
 

Classes

struct  BodyProperties
 
struct  Box
 Axis-aligned solid box of half-extents half: standard exact box SDF, negative inside. More...
 
struct  CandidateGrid
 Owning host-side candidate grid. More...
 
struct  CandidateGridView
 Non-owning candidate grid: uniform bins over [origin, origin+extent), CSR lists of primitive (or instance) indices, plus an ALWAYS list of never-pruned entries. More...
 
struct  Complement
 Negation: the solid and the void swap (sdf -> -sdf). More...
 
class  DeviceScene
 Owning device-resident scene. Copyable (Views are shared_ptr-like); view() is cheap. More...
 
struct  GridDesc
 Descriptor for one sampled field inside a shared sample pool. More...
 
struct  GridSdf
 A signed-distance field sampled on a regular axis-aligned grid (negative inside solid). More...
 
struct  HollowCylinder
 Solid hollow cylinder (a tube wall) of given outer/inner radius and height about axis. More...
 
struct  Instance
 One placed copy of a shape tree (contract 7). More...
 
struct  InstanceBound
 World bounding sphere of an instance + the PRUNING CERTIFICATE. More...
 
struct  InstanceMotionView
 Non-owning, POD, device-copyable rigid-body motion state for a scene's instances. More...
 
struct  PeriodicBox
 Min-image box. on = false disables wrapping (all extents ignored). More...
 
struct  PoolPtr
 Adaptors so a raw pointer can stand in for a Kokkos View (Views already provide operator()), letting host tests and device kernels share one evaluator. More...
 
class  SceneBuilder
 Owns a scene under construction and hands out a non-owning SceneView over it. More...
 
class  SceneQueryDevice
 Owns everything a SceneQueryView needs on ONE memory space: the DeviceScene, the extracted sphere-union arrays when the scene is a plain sphere union (mode selected ONCE, here), the candidate-grid CSR, and the periodicity. More...
 
struct  SceneQueryView
 The one POD every consumer captures: sphere-union fast path when the scene is a plain sphere union, general scene otherwise, candidate-accelerated in both modes, min-image periodic. More...
 
struct  SceneView
 Non-owning bundle of everything a scene evaluation needs (resolved decision 4). More...
 
struct  ShapeNode
 One node of a flat shape tree. POD, trivially copyable, safe in a Kokkos View. More...
 
struct  Sphere
 Solid ball: negative inside. More...
 
class  SphereBedQuery
 Owning, host-side accelerated union-of-spheres query. More...
 
struct  SphereUnionView
 Non-owning union-of-spheres view. More...
 
struct  TablePtr
 
struct  Transform
 Conformal placement: canonical -> parent frame. Identity by default. More...
 
struct  VtiVector
 A sampled vector field on a regular grid (3 interleaved components per point, x-fastest). More...
 

Enumerations

enum  ShapeKind : int {
  kGrid = 0 , kSphere = 1 , kHollowCylinder = 2 , kBox = 3 ,
  kHollowCylinderShell = 4 , kCapsule = 5 , kTorus = 6 , kCone = 7 ,
  kEllipsoid = 8 , kSuperquadric = 9 , kCsgBase = 32 , kUnion = 32 ,
  kIntersection = 33 , kDifference = 34
}
 Node kind tag. More...
 
enum class  GridExtension : int { kObject = 0 , kContainer = 1 , kClamp = 2 }
 NOT YET A NODE KIND: prim::Rounded (offset/rounding) stays a compile-time wrapper for now. More...
 

Functions

template<class Real , class Phi >
BodyProperties< Real > bodyProperties (const Phi &phi, Vec3< Real > lo, Vec3< Real > hi, int n=32, int order=5, int nseg=8, Real density=Real(1))
 Mass properties of {phi < 0} over the box [lo, hi], composite implicit quadrature: an n^3 cell grid; per cell a tensor Gauss rule (order nodes per transverse axis, height axis chosen from the central gradient like cellVolumeFraction) with analytic 1-D moments along each line.
 
template<class ExecSpace , class Real , class PtsView , class OutView >
void evalSphereUnionPoints (const ExecSpace &space, const SphereUnionView< Real > &u, const PeriodicBox< Real > &box, const CandidateGridView< Real > &grid, const PtsView &pts, const OutView &out)
 Batched sphere-union evaluation, device: pts is (N,3), out is (N), any layouts/memory spaces reachable from ExecSpace.
 
template<class Real >
void evalSphereUnionPointsHost (const SphereUnionView< Real > &u, const PeriodicBox< Real > &box, const CandidateGridView< Real > &grid, const Real *pts, std::size_t n, Real *out)
 Host-pointer form (the oracle / today's single-threaded builders): plain loop, no Kokkos types in the signature, same per-point expressions.
 
template<class ExecSpace , class Real , class PtsView , class OutView >
void evalScenePoints (const ExecSpace &space, const SceneView< Real > &sc, const PtsView &pts, const OutView &out)
 Batched general-scene evaluation (union over instances), device.
 
template<class Real >
void evalScenePointsHost (const SceneView< Real > &sc, const Real *pts, std::size_t n, Real *out)
 
template<class ExecSpace , class Real , class PtsView , class OutView >
void evalQueryPoints (const ExecSpace &space, const SceneQueryView< Real > &q, const PtsView &pts, const OutView &out)
 Batched driver over a SceneQueryView (the form the restructured AMR builders and flow's sampling kernels consume).
 
template<typename S >
GridSdf sample (const S &shape, IVec< 3 > dims, Vec< 3 > origin, Vec< 3 > spacing)
 Sample any analytic SDF onto a grid, producing a GridSdf (e.g. to bake geometry for a solver).
 
template<class Real , class Phi >
PECLET_HD Real faceAperture (const Phi &phi, Vec3< Real > origin, int axis, Real hu, Real hv, int order=4, int nseg=8, bool breakpoints=true)
 Fluid fraction ({phi > 0}) of the axis-aligned FACE with corner origin, normal axis, and side lengths hu, hv along the two axes following axis cyclically.
 
template<class Real , class Phi >
PECLET_HD Real cellVolumeFraction (const Phi &phi, Vec3< Real > origin, Vec3< Real > h, int order=4, int nseg=8)
 Fluid fraction ({phi > 0}) of the axis-aligned BOX [origin, origin+h].
 
template<class Real >
PECLET_HD Vec3< Real > toCanonical (const Transform< Real > &tr, Vec3< Real > p)
 Map a point from the parent frame into this transform's canonical frame.
 
template<class Real , class Pool >
PECLET_HD Real sampleGrid (Vec3< Real > p, const GridDesc< Real > &d, const Pool &pool)
 Trilinear sample of a grid field, with the clamp-plus-residual off-grid extension selected by d.extension.
 
template<class Real , class Grids , class Pool >
PECLET_HD Real evalLeaf (const ShapeNode< Real > &n, Vec3< Real > p, const Grids &grids, const Pool &pool)
 Evaluate a single LEAF node at a point already in that node's canonical frame.
 
template<class Real >
PECLET_HD Vec3< Real > instanceCentre (const Instance< Real > &inst)
 Rigid-body surface velocity of instance inst at world point p: linVel + angVel x (p - c), with c the pinned centre when there is one and the body's translation otherwise (an unpinned center is the NaN sentinel and must never enter the arithmetic).
 
template<class Real >
PECLET_HD Vec3< Real > instanceVelocity (const Instance< Real > &inst, Vec3< Real > p)
 
template<class Real , class Nodes , class Grids , class Pool >
PECLET_HD Real evalTree (const Nodes &nodes, int nodeCount, int root, Vec3< Real > p, const Grids &grids, const Pool &pool)
 Evaluate the shape tree rooted at root at point p (in the root's parent frame).
 
template<class Real , class Grids , class Pool >
PECLET_HD Vec3< Real > leafGrad (const ShapeNode< Real > &n, Vec3< Real > p, const Grids &grids, const Pool &pool)
 Closed-form gradient of one leaf in its canonical frame (unnormalised, mirroring the prim::* contracts).
 
template<class Real , class Nodes , class Grids , class Pool >
PECLET_HD Real evalTreeGrad (const Nodes &nodes, int nodeCount, int root, Vec3< Real > p, const Grids &grids, const Pool &pool, Vec3< Real > &grad)
 evalTree WITH its analytic gradient, one traversal (Layer 0's runtime layer catching up with the compile-time leaves' exact grads).
 
template<class Real >
PECLET_HD Real evalInstance (const SceneView< Real > &sc, int i, Vec3< Real > p)
 Signed distance of ONE instance at world point p.
 
template<class Real >
PECLET_HD Real evalCandidates (const SceneView< Real > &sc, Vec3< Real > p, const int *candidates, int nCandidates)
 Signed distance of a scene over a CANDIDATE LIST (contract 9): the union of the listed instances, i.e.
 
template<class Real >
PECLET_HD Real evalScene (const SceneView< Real > &sc, Vec3< Real > p)
 Convenience: the union of EVERY instance.
 
template<class Real >
void encodeNode (const ShapeNode< Real > &n, int *ints, Real *reals)
 
template<class Real >
ShapeNode< Real > decodeNode (const int *ints, const Real *reals)
 
template<class Real >
void encodeInstance (const Instance< Real > &v, int *ints, Real *reals)
 
template<class Real >
Instance< Real > decodeInstance (const int *ints, const Real *reals, int stride=kInstanceRealStride)
 
template<class Real >
std::vector< Vec3< Real > > surfacePoints (const SceneView< Real > &sc, int root, Real spacing, Vec3< Real > lo, Vec3< Real > hi, int projectIters=4)
 Sample points on the zero level set of a shape tree — the GENERAL surface-point generator.
 
template<class Real >
PECLET_HD Vec3< Real > minImage (Vec3< Real > d, const PeriodicBox< Real > &b)
 Min-image a displacement.
 
template<class Real >
PECLET_HD Real sphereDist2 (const SphereUnionView< Real > &u, int i, Vec3< Real > p, const PeriodicBox< Real > &box)
 Squared min-image distance from p to sphere i — THE per-sphere expression, shared by every path (brute, subset, batched, host, device) so drift between them is impossible.
 
template<class Real >
PECLET_HD Real evalSphereUnionSubset (const SphereUnionView< Real > &u, Vec3< Real > p, const PeriodicBox< Real > &box, const int *items, int count)
 Union SDF over an index subset (a candidate list).
 
template<class Real >
PECLET_HD Real evalSphereUnion (const SphereUnionView< Real > &u, Vec3< Real > p, const PeriodicBox< Real > &box)
 Brute-force union SDF (all spheres) — the reference the candidate path must match bit-for-bit, and the fallback for out-of-coverage queries.
 
template<class Real >
PECLET_HD Real evalSphereUnionGrid (const SphereUnionView< Real > &u, Vec3< Real > p, const PeriodicBox< Real > &box, const CandidateGridView< Real > &g)
 Union SDF through the candidate grid: bin lookup + short list, full-scan fallback when the bin is out of coverage or its list is empty.
 
template<class Real >
CandidateGrid< Real > buildSphereCandidateGrid (const SphereUnionView< Real > &u, Vec3< Real > origin, Vec3< Real > extent, const PeriodicBox< Real > &box, int nbHint=0)
 Geometry-driven candidate build for a sphere union over [origin, origin+extent).
 
template<class Real >
PECLET_HD Real evalInstancePeriodic (const SceneView< Real > &sc, int i, Vec3< Real > p, const PeriodicBox< Real > &box, Real boundR=Real(-1))
 Instance evaluation with MIN-IMAGE periodicity.
 
template<class Real >
PECLET_HD Real evalScenePeriodic (const SceneView< Real > &sc, Vec3< Real > p, const PeriodicBox< Real > &box, const Real *boundR=nullptr)
 Union over every instance, min-image periodic.
 
template<class Real >
InstanceBound< Real > instanceBound (const SceneView< Real > &sc, int i)
 World bounding sphere + certificate of one instance (host-side; used by candidate builds).
 
template<class Real >
PECLET_HD Real evalSceneGrid (const SceneView< Real > &sc, Vec3< Real > p, const PeriodicBox< Real > &box, const CandidateGridView< Real > &g, const Real *boundR=nullptr)
 Union over a candidate list + the always-list, min-image periodic.
 
template<class Real >
CandidateGrid< Real > buildSceneCandidateGrid (const SceneView< Real > &sc, Vec3< Real > origin, Vec3< Real > extent, const PeriodicBox< Real > &box, Real binSizeHint=0)
 Candidate grid for a GENERAL scene: certified instances splat Lipschitz bounds evaluated at bin centers within their inflated bounding-sphere band (the generateSdfKokkos pattern); non-certified instances go on the always-list.
 
template<class Real >
PECLET_HD void sphereUnionOwnerSubset (const SphereUnionView< Real > &u, Vec3< Real > p, const PeriodicBox< Real > &box, const int *items, int count, Real &best, int &bestI)
 Accumulate the argmin over an explicit index subset (a candidate list) into (best, bestI).
 
template<class Real >
PECLET_HD Real sphereUnionEvalOwner (const SphereUnionView< Real > &u, Vec3< Real > p, const PeriodicBox< Real > &box, int &own)
 Brute-force value + owner (all spheres) — the reference the candidate path must match, and the out-of-coverage fallback.
 
template<class Real >
PECLET_HD Real sphereUnionEvalOwnerGrid (const SphereUnionView< Real > &u, Vec3< Real > p, const PeriodicBox< Real > &box, const CandidateGridView< Real > &g, int &own)
 Value + owner through the candidate grid.
 
template<class Real >
PECLET_HD Real sceneEvalOwnerPeriodic (const SceneView< Real > &sc, Vec3< Real > p, const PeriodicBox< Real > &box, int &own, const Real *boundR=nullptr)
 Value + owner over every instance of a general scene, min-image periodic.
 
template<class Real >
PECLET_HD Real sceneEvalOwnerGrid (const SceneView< Real > &sc, Vec3< Real > p, const PeriodicBox< Real > &box, const CandidateGridView< Real > &g, int &own, const Real *boundR=nullptr)
 Value + owner through a general-scene candidate grid: always-list ∪ candidate list, with the same empty-list / out-of-coverage full-scan fallback evalSceneGrid uses (an owner that disagreed with the value would attribute a wall velocity to a body that is not the nearest).
 
template<class Real >
PECLET_HD int sphereUnionOwner (const SphereUnionView< Real > &u, Vec3< Real > p, const PeriodicBox< Real > &box)
 Owner-only wrappers (the value is discarded by the compiler on every backend).
 
template<class Real >
PECLET_HD int sphereUnionOwnerGrid (const SphereUnionView< Real > &u, Vec3< Real > p, const PeriodicBox< Real > &box, const CandidateGridView< Real > &g)
 
template<class Real >
PECLET_HD int sceneOwnerPeriodic (const SceneView< Real > &sc, Vec3< Real > p, const PeriodicBox< Real > &box, const Real *boundR=nullptr)
 
template<class Real >
PECLET_HD int sceneOwnerGrid (const SceneView< Real > &sc, Vec3< Real > p, const PeriodicBox< Real > &box, const CandidateGridView< Real > &g, const Real *boundR=nullptr)
 
template<class Real >
PECLET_HD Vec3< Real > instanceVelocity (const InstanceMotionView< Real > &m, int i, Vec3< Real > p, const PeriodicBox< Real > &box)
 Velocity of the material point of instance i currently at world point p: v = lin_i + ang_i x (p - c_i)
 
template<class Real >
PECLET_HD Vec3< Real > wallPoint (Vec3< Real > p, Real sdf, Vec3< Real > grad)
 Project a probe onto the zero level set along the local gradient: w = p - sdf(p) * n_hat.
 
template<class Real >
bool motionIsStatic (const InstanceMotionView< Real > &m)
 True when no instance carries motion – the predicate a consumer uses to keep the static path bit-identical rather than "moving with zero velocity".
 
template<class Real >
bool extractSphereUnion (const SceneView< Real > &sc, std::vector< Real > &cx, std::vector< Real > &cy, std::vector< Real > &cz, std::vector< Real > &r)
 Try to view a scene as a PLAIN sphere union: every instance a single kSphere leaf with a bitwise-identity node transform and a translation-only, scale-1, identity-rotation instance transform.
 
template<typename S >
Vec< 3 > gradient (const S &shape, const Vec< 3 > &p, double h=1e-4)
 Generic outward normal via central differences; works for any shape with eval().
 
void writeVti (const std::string &path, const GridSdf &g, const std::string &name="sdf")
 Write a GridSdf as a VTK ImageData (.vti), PointData Float32 scalar, ASCII.
 
GridSdf readVti (const std::string &path)
 Read a VTK ImageData (.vti) written by writeVti (ASCII PointData scalar) into a GridSdf.
 
void writeVtiVector (const std::string &path, const VtiVector &g, const std::string &name="vector")
 Write a 3-component vector field as a VTK ImageData PointData vector (ASCII), ParaView-openable.
 
VtiVector readVtiVector (const std::string &path)
 Read a vector-field VTI written by writeVtiVector.
 

Variables

constexpr int kMaxTreeDepth = 16
 Maximum shape-tree depth the iterative evaluator supports.
 
constexpr int kNodeIntStride = 3
 
constexpr int kNodeRealStride = 16
 
constexpr int kInstanceIntStride = 2
 
constexpr int kInstanceRealStride = 18
 
constexpr int kInstanceRealStrideLegacy
 

Enumeration Type Documentation

◆ ShapeKind

Node kind tag.

The first four values are dem's ShapeKind numbering VERBATIM (dem_portable.hpp:77: SHAPE_GRID_SDF=0, SPHERE=1, HOLLOW_CYLINDER=2, BOX=3) so dem's existing Python shape_type integers keep working through the rung-3 port with no remapping table. Everything past 3 is new. CSG operators start at kCsgBase so kind >= kCsgBase is the leaf/operator test.

Enumerator
kGrid 

sampled field; aux0 = index into the GridDesc table

kSphere 

params[0] = radius

kHollowCylinder 

params[0..2] = rOuter, height, thickness (distance-exact, y axis)

kBox 

params[0..2] = hx, hy, hz

kHollowCylinderShell 

params[0..2] = rOuter, rInner, height (sign-exact, z axis)

kCapsule 

params[0..1] = radius, halfLength (exact, y axis)

kTorus 

params[0..1] = majorRadius, minorRadius (exact, y axis)

kCone 

params[0..2] = rBottom, rTop, halfHeight (exact, y axis)

kEllipsoid 

params[0..2] = rx, ry, rz (BOUND, under-estimates)

kSuperquadric 

params[0..3] = rx, ry, rz, exponent (BOUND, under-estimates)

kCsgBase 
kUnion 

min(L, R) — aux0/aux1 = child node indices

kIntersection 

max(L, R)

kDifference 

max(L, -R) — L minus R

Definition at line 35 of file scene.hpp.

◆ GridExtension

NOT YET A NODE KIND: prim::Rounded (offset/rounding) stays a compile-time wrapper for now.

Folding a rounding radius into every node would add an unconditional subtract to every leaf eval, and no scene consumer needs it yet; add it with the rung-5 encoding if one does. Off-grid extension policy for a sampled field (contract 6). The query is clamped into the lattice and trilinearly sampled; the policy decides what happens to the distance between the query and that clamped point: kObject (+residual) — a BODY. Outside the stored box means further from the body, so the far field must grow POSITIVE. dem sampleGridSdf. kContainer (-residual) — a CONTAINER whose void is bounded. Outside the stored box is wall-side, so it must read ever more NEGATIVE. dem sampleWallSdf. kClamp (no residual) — nearest-valid-sample extrapolation: the field simply flattens at the box face. The right choice when the stored box already encloses everything of interest and off-grid queries are incidental, which is what core's host GridSdf and voro's grid provider both want. Getting the sign backwards is not cosmetic: dem's history records a 180k-bead pile losing 71k grains through a distributor because a container read "clear" beyond its own grid face. kClamp has that failure mode by construction, so use it only where the box genuinely bounds the domain.

Enumerator
kObject 
kContainer 
kClamp 

Definition at line 71 of file scene.hpp.

Function Documentation

◆ bodyProperties()

template<class Real , class Phi >
BodyProperties< Real > peclet::core::geom::bodyProperties ( const Phi &  phi,
Vec3< Real >  lo,
Vec3< Real >  hi,
int  n = 32,
int  order = 5,
int  nseg = 8,
Real  density = Real(1) 
)

Mass properties of {phi < 0} over the box [lo, hi], composite implicit quadrature: an n^3 cell grid; per cell a tensor Gauss rule (order nodes per transverse axis, height axis chosen from the central gradient like cellVolumeFraction) with analytic 1-D moments along each line.

All ten raw moments (volume, 3 first, 6 second) come from the same line walks in one pass.

The box MUST contain the whole solid; anything outside is not seen (that is what the bounding sphere of instanceBound / SceneBuilder is for). Cost = n^3 * order^2 lines, each ~nseg + 40 bisection evaluations near the surface; preprocessing-grade, seconds at the defaults.

Definition at line 282 of file body_properties.hpp.

References peclet::core::geom::quad_detail::gaussCount().

◆ evalSphereUnionPoints()

void peclet::core::geom::evalSphereUnionPoints ( const ExecSpace &  space,
const SphereUnionView< Real > &  u,
const PeriodicBox< Real > &  box,
const CandidateGridView< Real > &  grid,
const PtsView &  pts,
const OutView &  out 
)

Batched sphere-union evaluation, device: pts is (N,3), out is (N), any layouts/memory spaces reachable from ExecSpace.

The union/grid views must point into ExecSpace-accessible memory.

Definition at line 115 of file device_scene.hpp.

References evalSphereUnionGrid().

◆ evalSphereUnionPointsHost()

template<class Real >
void peclet::core::geom::evalSphereUnionPointsHost ( const SphereUnionView< Real > &  u,
const PeriodicBox< Real > &  box,
const CandidateGridView< Real > &  grid,
const Real *  pts,
std::size_t  n,
Real *  out 
)

Host-pointer form (the oracle / today's single-threaded builders): plain loop, no Kokkos types in the signature, same per-point expressions.

Definition at line 130 of file device_scene.hpp.

References evalSphereUnionGrid().

◆ evalScenePoints()

void peclet::core::geom::evalScenePoints ( const ExecSpace &  space,
const SceneView< Real > &  sc,
const PtsView &  pts,
const OutView &  out 
)

Batched general-scene evaluation (union over instances), device.

Definition at line 140 of file device_scene.hpp.

References evalScene().

◆ evalScenePointsHost()

template<class Real >
void peclet::core::geom::evalScenePointsHost ( const SceneView< Real > &  sc,
const Real *  pts,
std::size_t  n,
Real *  out 
)

Definition at line 151 of file device_scene.hpp.

References evalScene().

◆ evalQueryPoints()

void peclet::core::geom::evalQueryPoints ( const ExecSpace &  space,
const SceneQueryView< Real > &  q,
const PtsView &  pts,
const OutView &  out 
)

Batched driver over a SceneQueryView (the form the restructured AMR builders and flow's sampling kernels consume).

Definition at line 278 of file device_scene.hpp.

◆ sample()

template<typename S >
GridSdf peclet::core::geom::sample ( const S &  shape,
IVec< 3 >  dims,
Vec< 3 >  origin,
Vec< 3 >  spacing 
)

Sample any analytic SDF onto a grid, producing a GridSdf (e.g. to bake geometry for a solver).

Definition at line 67 of file grid_sdf.hpp.

References peclet::core::geom::GridSdf::dims, peclet::core::geom::GridSdf::origin, peclet::core::geom::GridSdf::spacing, and peclet::core::geom::GridSdf::values.

◆ faceAperture()

template<class Real , class Phi >
PECLET_HD Real peclet::core::geom::faceAperture ( const Phi &  phi,
Vec3< Real >  origin,
int  axis,
Real  hu,
Real  hv,
int  order = 4,
int  nseg = 8,
bool  breakpoints = true 
)

Fluid fraction ({phi > 0}) of the axis-aligned FACE with corner origin, normal axis, and side lengths hu, hv along the two axes following axis cyclically.

order is the number of Gauss nodes across the face (4 by default); nseg the initial bracketing subdivision along the height direction.

The height direction is the in-face axis along which the field varies faster at the face centre, so the interface is a graph over the other one. That choice is made ONCE per face – failure mode 4.

Definition at line 187 of file quadrature.hpp.

References peclet::core::geom::quad_detail::gaussCount(), peclet::core::geom::quad_detail::positiveLength(), peclet::core::Vec3< Real >::x, peclet::core::Vec3< Real >::y, and peclet::core::Vec3< Real >::z.

◆ cellVolumeFraction()

template<class Real , class Phi >
PECLET_HD Real peclet::core::geom::cellVolumeFraction ( const Phi &  phi,
Vec3< Real >  origin,
Vec3< Real >  h,
int  order = 4,
int  nseg = 8 
)

Fluid fraction ({phi > 0}) of the axis-aligned BOX [origin, origin+h].

Same construction one dimension up: a tensor Gauss rule over the two transverse axes, exact 1-D measure along the height axis. Same non-certification.

Definition at line 282 of file quadrature.hpp.

References peclet::core::geom::quad_detail::gaussCount(), peclet::core::geom::quad_detail::positiveLength(), peclet::core::Vec3< Real >::x, peclet::core::Vec3< Real >::y, and peclet::core::Vec3< Real >::z.

◆ toCanonical()

template<class Real >
PECLET_HD Vec3< Real > peclet::core::geom::toCanonical ( const Transform< Real > &  tr,
Vec3< Real >  p 
)

Map a point from the parent frame into this transform's canonical frame.

Operation order is dem's narrow-phase verbatim (narrowphase.hpp: invRotateVector(q, p - pos), then multiply by 1/effScale) so a transformed leaf reproduces a dem contact probe bit-for-bit.

Definition at line 95 of file scene.hpp.

References peclet::core::invRotate(), peclet::core::scale(), and peclet::core::sub().

Referenced by evalInstance(), evalTree(), and evalTreeGrad().

◆ sampleGrid()

template<class Real , class Pool >
PECLET_HD Real peclet::core::geom::sampleGrid ( Vec3< Real >  p,
const GridDesc< Real > &  d,
const Pool &  pool 
)

Trilinear sample of a grid field, with the clamp-plus-residual off-grid extension selected by d.extension.

Verbatim transcription of dem sampleGridSdf (narrowphase.hpp:104) and sampleWallSdf, which are the same body differing only in the residual's sign.

Definition at line 127 of file scene.hpp.

References peclet::core::detail::hdMax(), peclet::core::detail::hdMin(), peclet::core::detail::hdSqrt(), kClamp, kObject, peclet::core::Vec3< Real >::x, peclet::core::Vec3< Real >::y, and peclet::core::Vec3< Real >::z.

Referenced by peclet::core::geom::GridSdf::eval(), evalLeaf(), and leafGrad().

◆ evalLeaf()

template<class Real , class Grids , class Pool >
PECLET_HD Real peclet::core::geom::evalLeaf ( const ShapeNode< Real > &  n,
Vec3< Real >  p,
const Grids &  grids,
const Pool &  pool 
)

Evaluate a single LEAF node at a point already in that node's canonical frame.

No transform, no recursion — the formulas all live in geom::prim.

Definition at line 163 of file scene.hpp.

References peclet::core::geom::ShapeNode< Real >::aux0, kBox, kCapsule, kCone, kEllipsoid, kGrid, kHollowCylinder, kHollowCylinderShell, peclet::core::geom::ShapeNode< Real >::kind, kSphere, kSuperquadric, kTorus, peclet::core::geom::ShapeNode< Real >::params, and sampleGrid().

Referenced by evalTree(), and evalTreeGrad().

◆ instanceCentre()

template<class Real >
PECLET_HD Vec3< Real > peclet::core::geom::instanceCentre ( const Instance< Real > &  inst)

Rigid-body surface velocity of instance inst at world point p: linVel + angVel x (p - c), with c the pinned centre when there is one and the body's translation otherwise (an unpinned center is the NaN sentinel and must never enter the arithmetic).

Definition at line 215 of file scene.hpp.

References peclet::core::geom::Instance< Real >::centerPinned.

Referenced by instanceVelocity().

◆ instanceVelocity() [1/2]

template<class Real >
PECLET_HD Vec3< Real > peclet::core::geom::instanceVelocity ( const Instance< Real > &  inst,
Vec3< Real >  p 
)

◆ evalTree()

template<class Real , class Nodes , class Grids , class Pool >
PECLET_HD Real peclet::core::geom::evalTree ( const Nodes &  nodes,
int  nodeCount,
int  root,
Vec3< Real >  p,
const Grids &  grids,
const Pool &  pool 
)

Evaluate the shape tree rooted at root at point p (in the root's parent frame).

Iterative post-order walk over the flat node array with an explicit frame stack. A node's children are evaluated at the node's CANONICAL point and their results scaled by the node's scale on the way out, so d_parent = s * d_canonical composes correctly down the tree.

Returns 1e9 if the tree exceeds kMaxTreeDepth or references a child out of range — a malformed scene reads as "infinitely far away" rather than corrupting memory.

< 0 = entered, 1 = left child done, 2 = both done

Definition at line 254 of file scene.hpp.

References evalLeaf(), peclet::core::detail::hdMax(), peclet::core::detail::hdMin(), kCsgBase, kIntersection, kMaxTreeDepth, kUnion, peclet::core::scale(), and toCanonical().

◆ leafGrad()

template<class Real , class Grids , class Pool >
PECLET_HD Vec3< Real > peclet::core::geom::leafGrad ( const ShapeNode< Real > &  n,
Vec3< Real >  p,
const Grids &  grids,
const Pool &  pool 
)

Closed-form gradient of one leaf in its canonical frame (unnormalised, mirroring the prim::* contracts).

kGrid has no closed form: a leaf-LOCAL central difference over sampleGrid at half a lattice spacing per axis – confined to the one leaf, unlike the old whole-tree difference.

Definition at line 320 of file scene.hpp.

References peclet::core::geom::ShapeNode< Real >::aux0, kBox, kCapsule, kCone, kEllipsoid, kGrid, kHollowCylinder, kHollowCylinderShell, peclet::core::geom::ShapeNode< Real >::kind, kSphere, kSuperquadric, kTorus, peclet::core::geom::ShapeNode< Real >::params, sampleGrid(), peclet::core::Vec3< Real >::x, peclet::core::Vec3< Real >::y, and peclet::core::Vec3< Real >::z.

Referenced by evalTreeGrad().

◆ evalTreeGrad()

template<class Real , class Nodes , class Grids , class Pool >
PECLET_HD Real peclet::core::geom::evalTreeGrad ( const Nodes &  nodes,
int  nodeCount,
int  root,
Vec3< Real >  p,
const Grids &  grids,
const Pool &  pool,
Vec3< Real > &  grad 
)

evalTree WITH its analytic gradient, one traversal (Layer 0's runtime layer catching up with the compile-time leaves' exact grads).

Returns the value – computed with evalTree's own expressions in evalTree's own order, so the two never disagree – and fills grad (unnormalised, in p's frame).

THE CHAIN RULE COSTS ONE ROTATION PER NODE. For v = s * f(invRotate(q, p - t) / s) the scale cancels: grad_p v = rotate(q, grad f). So the gradient rides the same stack as the value, each pop rotating it into the parent frame.

RIDGES (CSG edges). min/max is a SELECTION: the gradient of the active branch, chosen by the SAME comparison the value makes (ties keep the left branch, deterministically). At the edge of a difference this returns one face's EXACT normal – where a central difference across the tree smears the two faces into an average that belongs to neither, which is precisely the failure mode for contact normals on composed particles with sharp features. The gradient is discontinuous across the ridge because the geometry is; a smeared normal is not a smoother answer, it is a wrong one.

Definition at line 377 of file scene.hpp.

References evalLeaf(), peclet::core::detail::hdMax(), peclet::core::detail::hdMin(), kCsgBase, kIntersection, kMaxTreeDepth, kUnion, leafGrad(), peclet::core::rotate(), peclet::core::scale(), and toCanonical().

◆ evalInstance()

template<class Real >
PECLET_HD Real peclet::core::geom::evalInstance ( const SceneView< Real > &  sc,
int  i,
Vec3< Real >  p 
)

Signed distance of ONE instance at world point p.

The instance transform maps world -> the tree's frame and its scale carries the result back, composing with each node's own transform exactly as nested nodes do.

Definition at line 470 of file scene.hpp.

References toCanonical().

Referenced by evalCandidates(), and evalScene().

◆ evalCandidates()

template<class Real >
PECLET_HD Real peclet::core::geom::evalCandidates ( const SceneView< Real > &  sc,
Vec3< Real >  p,
const int *  candidates,
int  nCandidates 
)

Signed distance of a scene over a CANDIDATE LIST (contract 9): the union of the listed instances, i.e.

the nearest solid among them. Consumers bin instances by AABB and pass only the ones whose bound reaches the query cell, so acceleration is pluggable rather than baked in.

Definition at line 484 of file scene.hpp.

References evalInstance().

◆ evalScene()

template<class Real >
PECLET_HD Real peclet::core::geom::evalScene ( const SceneView< Real > &  sc,
Vec3< Real >  p 
)

Convenience: the union of EVERY instance.

O(instanceCount) per query – correct, and the right thing for the handful-of-objects case (a stirrer in a tank), but for particle-instanced scenes bin first and call evalCandidates.

Definition at line 499 of file scene.hpp.

References evalInstance().

Referenced by evalScenePoints(), and evalScenePointsHost().

◆ encodeNode()

◆ decodeNode()

◆ encodeInstance()

◆ decodeInstance()

◆ surfacePoints()

template<class Real >
std::vector< Vec3< Real > > peclet::core::geom::surfacePoints ( const SceneView< Real > &  sc,
int  root,
Real  spacing,
Vec3< Real >  lo,
Vec3< Real >  hi,
int  projectIters = 4 
)

Sample points on the zero level set of a shape tree — the GENERAL surface-point generator.

Layer 1 of docs/ANALYTIC_SDF_GEOMETRY.md: dem's collision shells were produced by per-shape hand-written generators (a cylinder one, a box one), so every new primitive needed bespoke code and shapes without one could not be a collision body at all. This is driven by the SDF itself, so it works for ANY node — the whole leaf vocabulary, CSG trees, and sampled grids alike.

Method: walk a lattice of pitch spacing over [lo, hi], keep the cells whose |f| shows the surface passes nearby, project each survivor onto the surface by Newton steps along the gradient (p <- p - f(p) * n(p), which converges immediately for an exact distance field and still converges for a bound), then deduplicate by snapping to a half-pitch grid.

Deliberately NOT ray casting from a centre: that is simpler but only correct for star-shaped bodies, and a torus, a hollow cylinder and most CSG results are not star-shaped.

Host-side setup code — call it once when registering a shape, never per step.

Definition at line 415 of file scene_builder.hpp.

References peclet::core::Vec3< Real >::x, peclet::core::Vec3< Real >::y, and peclet::core::Vec3< Real >::z.

◆ minImage()

template<class Real >
PECLET_HD Vec3< Real > peclet::core::geom::minImage ( Vec3< Real >  d,
const PeriodicBox< Real > &  b 
)

Min-image a displacement.

FMA-CANONICAL: d = fma(-nearbyint(d/L), L, d) per axis. Explicit fma is correctly rounded by IEEE on every backend and cannot be re-contracted by nvcc, which is what makes host and device evaluation BIT-IDENTICAL — the property the AMR parity ctests assume. The retired stopgap computed the two-rounding form (mul then sub); the difference is bounded at 1 ulp of the displacement and its effect on the final distance is measured in the geom_scene_query gate (and empirically zero on the acceptance meshes' classifications). Do not "optimise" the divide into a multiply by 1/L: that rounds differently.

Definition at line 84 of file scene_query.hpp.

References peclet::core::geom::PeriodicBox< Real >::Lx, peclet::core::geom::PeriodicBox< Real >::Ly, peclet::core::geom::PeriodicBox< Real >::Lz, and peclet::core::geom::PeriodicBox< Real >::on.

Referenced by buildSphereCandidateGrid(), evalInstancePeriodic(), instanceVelocity(), and sphereDist2().

◆ sphereDist2()

template<class Real >
PECLET_HD Real peclet::core::geom::sphereDist2 ( const SphereUnionView< Real > &  u,
int  i,
Vec3< Real >  p,
const PeriodicBox< Real > &  box 
)

Squared min-image distance from p to sphere i — THE per-sphere expression, shared by every path (brute, subset, batched, host, device) so drift between them is impossible.

FMA-canonical for the same host==device reason as minImage.

Definition at line 115 of file scene_query.hpp.

References peclet::core::geom::SphereUnionView< Real >::cx, peclet::core::geom::SphereUnionView< Real >::cy, peclet::core::geom::SphereUnionView< Real >::cz, minImage(), peclet::core::Vec3< Real >::x, peclet::core::Vec3< Real >::y, and peclet::core::Vec3< Real >::z.

Referenced by evalSphereUnion(), evalSphereUnionSubset(), sphereUnionEvalOwner(), and sphereUnionOwnerSubset().

◆ evalSphereUnionSubset()

template<class Real >
PECLET_HD Real peclet::core::geom::evalSphereUnionSubset ( const SphereUnionView< Real > &  u,
Vec3< Real >  p,
const PeriodicBox< Real > &  box,
const int *  items,
int  count 
)

Union SDF over an index subset (a candidate list).

Per-sphere expression is the stopgap's: displacement, min-image, dx*dx + dy*dy + dz*dz (this association), sqrt, minus r. The equal-radius path takes min over the squared distances first and pays ONE sqrt: the winning sphere's d2 is the same number the general path would sqrt, so the result is bit-identical.

Definition at line 127 of file scene_query.hpp.

References peclet::core::geom::SphereUnionView< Real >::equalR, peclet::core::detail::hdSqrt(), peclet::core::geom::SphereUnionView< Real >::r, peclet::core::geom::SphereUnionView< Real >::r0, and sphereDist2().

Referenced by evalSphereUnionGrid().

◆ evalSphereUnion()

template<class Real >
PECLET_HD Real peclet::core::geom::evalSphereUnion ( const SphereUnionView< Real > &  u,
Vec3< Real >  p,
const PeriodicBox< Real > &  box 
)

Brute-force union SDF (all spheres) — the reference the candidate path must match bit-for-bit, and the fallback for out-of-coverage queries.

Definition at line 151 of file scene_query.hpp.

References peclet::core::geom::SphereUnionView< Real >::equalR, peclet::core::detail::hdSqrt(), peclet::core::geom::SphereUnionView< Real >::n, peclet::core::geom::SphereUnionView< Real >::r, peclet::core::geom::SphereUnionView< Real >::r0, and sphereDist2().

Referenced by peclet::core::geom::SceneQueryView< Real >::eval(), and evalSphereUnionGrid().

◆ evalSphereUnionGrid()

template<class Real >
PECLET_HD Real peclet::core::geom::evalSphereUnionGrid ( const SphereUnionView< Real > &  u,
Vec3< Real >  p,
const PeriodicBox< Real > &  box,
const CandidateGridView< Real > &  g 
)

Union SDF through the candidate grid: bin lookup + short list, full-scan fallback when the bin is out of coverage or its list is empty.

Bit-identical to evalSphereUnion by the superset argument in the header comment.

Definition at line 209 of file scene_query.hpp.

References peclet::core::geom::CandidateGridView< Real >::binOf(), evalSphereUnion(), evalSphereUnionSubset(), peclet::core::geom::CandidateGridView< Real >::items, and peclet::core::geom::CandidateGridView< Real >::offsets.

Referenced by peclet::core::geom::SceneQueryView< Real >::eval(), evalSphereUnionPoints(), evalSphereUnionPointsHost(), and peclet::core::geom::SphereBedQuery::operator()().

◆ buildSphereCandidateGrid()

template<class Real >
CandidateGrid< Real > peclet::core::geom::buildSphereCandidateGrid ( const SphereUnionView< Real > &  u,
Vec3< Real >  origin,
Vec3< Real >  extent,
const PeriodicBox< Real > &  box,
int  nbHint = 0 
)

Geometry-driven candidate build for a sphere union over [origin, origin+extent).

Two splat passes over each sphere's bounded bin neighbourhood: pass 1: each sphere lowers U(B) (atomic-min-shaped, serial here) with its upper bound upper_i(B) = d(binCenter, c_i) + halfDiag - r_i; pass 2: each sphere appends itself to bins where lower_i(B) = d - halfDiag - r_i <= U(B). The neighbourhood of pass 2 is bounded by the pass-1 U field, so far bins are never visited by far spheres; bins no sphere reaches keep empty lists and the query path falls back (exact). nbHint overrides the bin count per axis (default targets bin ~ r_mean/2, the measured sweet spot for 1-5 entry lists on the RCP bed).

Definition at line 247 of file scene_query.hpp.

References peclet::core::geom::SphereUnionView< Real >::cx, peclet::core::geom::SphereUnionView< Real >::cy, peclet::core::geom::SphereUnionView< Real >::cz, peclet::core::detail::hdFloor(), peclet::core::geom::CandidateGrid< Real >::items, peclet::core::geom::PeriodicBox< Real >::Lx, peclet::core::geom::PeriodicBox< Real >::Ly, peclet::core::geom::PeriodicBox< Real >::Lz, peclet::core::geom::CandidateGrid< Real >::meta, minImage(), peclet::core::geom::SphereUnionView< Real >::n, peclet::core::geom::CandidateGrid< Real >::offsets, peclet::core::geom::PeriodicBox< Real >::on, peclet::core::geom::SphereUnionView< Real >::r, peclet::core::Vec3< Real >::x, peclet::core::Vec3< Real >::y, and peclet::core::Vec3< Real >::z.

Referenced by peclet::core::geom::SceneQueryDevice< Real, MemSpace >::build(), and peclet::core::geom::SphereBedQuery::SphereBedQuery().

◆ evalInstancePeriodic()

template<class Real >
PECLET_HD Real peclet::core::geom::evalInstancePeriodic ( const SceneView< Real > &  sc,
int  i,
Vec3< Real >  p,
const PeriodicBox< Real > &  box,
Real  boundR = Real(-1) 
)

Instance evaluation with MIN-IMAGE periodicity.

SUBTLETY (a bug this replaced): min-imaging the displacement to the instance ORIGIN is only correct for bodies whose every point sits AT the origin (spheres). A body part offset from the origin — a stirrer blade — can have its nearest periodic image across the seam the origin-wrap did not take: body point at local +0.3 in a unit box, probe at 0.55 → origin-wrap gives displacement −0.45 and distance 0.75, but the true periodic distance is 0.25. So the evaluation takes the min over the axis images that can matter: the wrapped displacement, plus the neighbouring image on each axis where the probe is within boundR (the instance's world bounding radius) of the seam. boundR < 0 means "unknown": every axis neighbour is tried (up to 8 tree walks — correct, slower; supply bounds via instanceBound for the fast form).

Definition at line 372 of file scene_query.hpp.

References peclet::core::invRotate(), peclet::core::geom::PeriodicBox< Real >::Lx, peclet::core::geom::PeriodicBox< Real >::Ly, peclet::core::geom::PeriodicBox< Real >::Lz, minImage(), peclet::core::geom::PeriodicBox< Real >::on, peclet::core::scale(), and peclet::core::sub().

Referenced by buildSceneCandidateGrid(), evalSceneGrid(), evalScenePeriodic(), sceneEvalOwnerGrid(), and sceneEvalOwnerPeriodic().

◆ evalScenePeriodic()

template<class Real >
PECLET_HD Real peclet::core::geom::evalScenePeriodic ( const SceneView< Real > &  sc,
Vec3< Real >  p,
const PeriodicBox< Real > &  box,
const Real *  boundR = nullptr 
)

Union over every instance, min-image periodic.

boundR is an optional per-instance world bounding-radius array (from instanceBound) that keeps the seam handling to one tree walk away from seams. The non-periodic case reduces bitwise to evalScene.

Definition at line 420 of file scene_query.hpp.

References evalInstancePeriodic().

Referenced by peclet::core::geom::SceneQueryView< Real >::eval(), and evalSceneGrid().

◆ instanceBound()

template<class Real >
InstanceBound< Real > peclet::core::geom::instanceBound ( const SceneView< Real > &  sc,
int  i 
)
inline

World bounding sphere + certificate of one instance (host-side; used by candidate builds).

Definition at line 553 of file scene_query.hpp.

References peclet::core::add(), peclet::core::geom::query_detail::nodeBound(), peclet::core::rotate(), and peclet::core::scale().

Referenced by buildSceneCandidateGrid().

◆ evalSceneGrid()

template<class Real >
PECLET_HD Real peclet::core::geom::evalSceneGrid ( const SceneView< Real > &  sc,
Vec3< Real >  p,
const PeriodicBox< Real > &  box,
const CandidateGridView< Real > &  g,
const Real *  boundR = nullptr 
)

Union over a candidate list + the always-list, min-image periodic.

Exact when the list is a certified-argmin superset and every non-certified instance rides the always-list (see the header comment): min(min_certified-kept, min_always) == the full min.

Definition at line 570 of file scene_query.hpp.

References peclet::core::geom::CandidateGridView< Real >::always, peclet::core::geom::CandidateGridView< Real >::alwaysCount, peclet::core::geom::CandidateGridView< Real >::binOf(), evalInstancePeriodic(), evalScenePeriodic(), peclet::core::geom::CandidateGridView< Real >::items, and peclet::core::geom::CandidateGridView< Real >::offsets.

Referenced by peclet::core::geom::SceneQueryView< Real >::eval().

◆ buildSceneCandidateGrid()

template<class Real >
CandidateGrid< Real > peclet::core::geom::buildSceneCandidateGrid ( const SceneView< Real > &  sc,
Vec3< Real >  origin,
Vec3< Real >  extent,
const PeriodicBox< Real > &  box,
Real  binSizeHint = 0 
)

Candidate grid for a GENERAL scene: certified instances splat Lipschitz bounds evaluated at bin centers within their inflated bounding-sphere band (the generateSdfKokkos pattern); non-certified instances go on the always-list.

Bins outside every band keep empty lists and queries there fall back (exact). For sphere-only scenes prefer the SphereUnion path – this build costs one instance eval per (instance, nearby bin).

Definition at line 609 of file scene_query.hpp.

References peclet::core::geom::CandidateGrid< Real >::always, evalInstancePeriodic(), instanceBound(), peclet::core::geom::CandidateGrid< Real >::instBoundR, peclet::core::geom::CandidateGrid< Real >::items, peclet::core::geom::CandidateGrid< Real >::meta, peclet::core::geom::CandidateGrid< Real >::offsets, peclet::core::geom::PeriodicBox< Real >::on, peclet::core::Vec3< Real >::x, peclet::core::Vec3< Real >::y, and peclet::core::Vec3< Real >::z.

Referenced by peclet::core::geom::SceneQueryDevice< Real, MemSpace >::build().

◆ sphereUnionOwnerSubset()

template<class Real >
PECLET_HD void peclet::core::geom::sphereUnionOwnerSubset ( const SphereUnionView< Real > &  u,
Vec3< Real >  p,
const PeriodicBox< Real > &  box,
const int *  items,
int  count,
Real &  best,
int &  bestI 
)

Accumulate the argmin over an explicit index subset (a candidate list) into (best, bestI).

best carries d2 on the equal-radius path and the signed distance otherwise — the caller converts, exactly once, like evalSphereUnion.

Definition at line 757 of file scene_query.hpp.

References peclet::core::geom::SphereUnionView< Real >::equalR, peclet::core::detail::hdSqrt(), peclet::core::geom::SphereUnionView< Real >::r, sphereDist2(), and peclet::core::geom::owner_detail::take().

Referenced by sphereUnionEvalOwnerGrid().

◆ sphereUnionEvalOwner()

template<class Real >
PECLET_HD Real peclet::core::geom::sphereUnionEvalOwner ( const SphereUnionView< Real > &  u,
Vec3< Real >  p,
const PeriodicBox< Real > &  box,
int &  own 
)

◆ sphereUnionEvalOwnerGrid()

template<class Real >
PECLET_HD Real peclet::core::geom::sphereUnionEvalOwnerGrid ( const SphereUnionView< Real > &  u,
Vec3< Real >  p,
const PeriodicBox< Real > &  box,
const CandidateGridView< Real > &  g,
int &  own 
)

◆ sceneEvalOwnerPeriodic()

template<class Real >
PECLET_HD Real peclet::core::geom::sceneEvalOwnerPeriodic ( const SceneView< Real > &  sc,
Vec3< Real >  p,
const PeriodicBox< Real > &  box,
int &  own,
const Real *  boundR = nullptr 
)

Value + owner over every instance of a general scene, min-image periodic.

Definition at line 815 of file scene_query.hpp.

References evalInstancePeriodic(), and peclet::core::geom::owner_detail::take().

Referenced by peclet::core::geom::SceneQueryView< Real >::evalOwner(), and sceneOwnerPeriodic().

◆ sceneEvalOwnerGrid()

template<class Real >
PECLET_HD Real peclet::core::geom::sceneEvalOwnerGrid ( const SceneView< Real > &  sc,
Vec3< Real >  p,
const PeriodicBox< Real > &  box,
const CandidateGridView< Real > &  g,
int &  own,
const Real *  boundR = nullptr 
)

Value + owner through a general-scene candidate grid: always-list ∪ candidate list, with the same empty-list / out-of-coverage full-scan fallback evalSceneGrid uses (an owner that disagreed with the value would attribute a wall velocity to a body that is not the nearest).

Definition at line 831 of file scene_query.hpp.

References peclet::core::geom::CandidateGridView< Real >::always, peclet::core::geom::CandidateGridView< Real >::alwaysCount, peclet::core::geom::CandidateGridView< Real >::binOf(), evalInstancePeriodic(), peclet::core::geom::CandidateGridView< Real >::items, peclet::core::geom::CandidateGridView< Real >::offsets, and peclet::core::geom::owner_detail::take().

Referenced by peclet::core::geom::SceneQueryView< Real >::evalOwner(), and sceneOwnerGrid().

◆ sphereUnionOwner()

template<class Real >
PECLET_HD int peclet::core::geom::sphereUnionOwner ( const SphereUnionView< Real > &  u,
Vec3< Real >  p,
const PeriodicBox< Real > &  box 
)

Owner-only wrappers (the value is discarded by the compiler on every backend).

Definition at line 861 of file scene_query.hpp.

References sphereUnionEvalOwner().

◆ sphereUnionOwnerGrid()

template<class Real >
PECLET_HD int peclet::core::geom::sphereUnionOwnerGrid ( const SphereUnionView< Real > &  u,
Vec3< Real >  p,
const PeriodicBox< Real > &  box,
const CandidateGridView< Real > &  g 
)

Definition at line 868 of file scene_query.hpp.

References sphereUnionEvalOwnerGrid().

◆ sceneOwnerPeriodic()

template<class Real >
PECLET_HD int peclet::core::geom::sceneOwnerPeriodic ( const SceneView< Real > &  sc,
Vec3< Real >  p,
const PeriodicBox< Real > &  box,
const Real *  boundR = nullptr 
)

Definition at line 875 of file scene_query.hpp.

References sceneEvalOwnerPeriodic().

◆ sceneOwnerGrid()

template<class Real >
PECLET_HD int peclet::core::geom::sceneOwnerGrid ( const SceneView< Real > &  sc,
Vec3< Real >  p,
const PeriodicBox< Real > &  box,
const CandidateGridView< Real > &  g,
const Real *  boundR = nullptr 
)

Definition at line 882 of file scene_query.hpp.

References sceneEvalOwnerGrid().

◆ instanceVelocity() [2/2]

template<class Real >
PECLET_HD Vec3< Real > peclet::core::geom::instanceVelocity ( const InstanceMotionView< Real > &  m,
int  i,
Vec3< Real >  p,
const PeriodicBox< Real > &  box 
)

Velocity of the material point of instance i currently at world point p: v = lin_i + ang_i x (p - c_i)

PERIODICITY. The lever arm is MIN-IMAGED. A body can own a wall point across a periodic seam (that is exactly what the seam-image enumeration in evalInstancePeriodic exists for), and the raw p - c_i is then a full box length wrong – which for a rotating body is not a small error but an O(L*|ang|) wall velocity pointing the wrong way, concentrated on the cells the seam cuts. Translation is unaffected, so this only ever bites the rotational case, silently.

Definition at line 919 of file scene_query.hpp.

References peclet::core::geom::InstanceMotionView< Real >::lin, minImage(), peclet::core::Vec3< Real >::x, peclet::core::Vec3< Real >::y, and peclet::core::Vec3< Real >::z.

◆ wallPoint()

template<class Real >
PECLET_HD Vec3< Real > peclet::core::geom::wallPoint ( Vec3< Real >  p,
Real  sdf,
Vec3< Real >  grad 
)

Project a probe onto the zero level set along the local gradient: w = p - sdf(p) * n_hat.

grad need not be normalised (it usually arrives as a raw central difference of a sampled field). Exact for an exact-distance field; O(h) for a sampled one, which is the accuracy of the wall point the v1 moving-geometry path places. Degenerate gradients (inside a solid pocket, or at a medial axis where the central difference cancels) return p unchanged rather than a NaN – the consumer then reads a wall velocity at the probe itself, which is the right fallback for a rigid body (v varies only over the lever arm) and a bounded one for any body.

Definition at line 950 of file scene_query.hpp.

References peclet::core::Vec3< Real >::x, peclet::core::Vec3< Real >::y, and peclet::core::Vec3< Real >::z.

◆ motionIsStatic()

template<class Real >
bool peclet::core::geom::motionIsStatic ( const InstanceMotionView< Real > &  m)
inline

True when no instance carries motion – the predicate a consumer uses to keep the static path bit-identical rather than "moving with zero velocity".

Definition at line 962 of file scene_query.hpp.

◆ extractSphereUnion()

template<class Real >
bool peclet::core::geom::extractSphereUnion ( const SceneView< Real > &  sc,
std::vector< Real > &  cx,
std::vector< Real > &  cy,
std::vector< Real > &  cz,
std::vector< Real > &  r 
)
inline

Try to view a scene as a PLAIN sphere union: every instance a single kSphere leaf with a bitwise-identity node transform and a translation-only, scale-1, identity-rotation instance transform.

Returns the centers/radii (world) or empty when any instance fails the test.

Definition at line 1018 of file scene_query.hpp.

References peclet::core::geom::ShapeNode< Real >::kind, kSphere, peclet::core::geom::ShapeNode< Real >::params, and peclet::core::geom::ShapeNode< Real >::transform.

Referenced by peclet::core::geom::SceneQueryDevice< Real, MemSpace >::build().

◆ gradient()

template<typename S >
Vec< 3 > peclet::core::geom::gradient ( const S &  shape,
const Vec< 3 > &  p,
double  h = 1e-4 
)

Generic outward normal via central differences; works for any shape with eval().

Definition at line 86 of file sdf.hpp.

◆ writeVti()

void peclet::core::geom::writeVti ( const std::string &  path,
const GridSdf &  g,
const std::string &  name = "sdf" 
)
inline

Write a GridSdf as a VTK ImageData (.vti), PointData Float32 scalar, ASCII.

Definition at line 24 of file vti_io.hpp.

References peclet::core::geom::GridSdf::dims, peclet::core::geom::GridSdf::origin, peclet::core::geom::GridSdf::spacing, and peclet::core::geom::GridSdf::values.

◆ readVti()

GridSdf peclet::core::geom::readVti ( const std::string &  path)
inline

Read a VTK ImageData (.vti) written by writeVti (ASCII PointData scalar) into a GridSdf.

Definition at line 58 of file vti_io.hpp.

References peclet::core::geom::GridSdf::dims, peclet::core::geom::GridSdf::origin, peclet::core::geom::GridSdf::spacing, peclet::core::geom::GridSdf::values, and peclet::core::geom::detail::vtiAttr().

◆ writeVtiVector()

void peclet::core::geom::writeVtiVector ( const std::string &  path,
const VtiVector &  g,
const std::string &  name = "vector" 
)
inline

Write a 3-component vector field as a VTK ImageData PointData vector (ASCII), ParaView-openable.

Definition at line 99 of file vti_io.hpp.

References peclet::core::geom::VtiVector::dims, peclet::core::geom::VtiVector::origin, peclet::core::geom::VtiVector::spacing, and peclet::core::geom::VtiVector::values.

◆ readVtiVector()

VtiVector peclet::core::geom::readVtiVector ( const std::string &  path)
inline

Variable Documentation

◆ kMaxTreeDepth

constexpr int peclet::core::geom::kMaxTreeDepth = 16
constexpr

Maximum shape-tree depth the iterative evaluator supports.

A stirrer (shaft union blades) is depth 2-3; 16 is far above anything a scene should need, and it bounds the on-stack frame array so the evaluator allocates nothing and stays device-safe (no recursion — contract 5).

Definition at line 243 of file scene.hpp.

Referenced by evalTree(), and evalTreeGrad().

◆ kNodeIntStride

constexpr int peclet::core::geom::kNodeIntStride = 3
inlineconstexpr

◆ kNodeRealStride

constexpr int peclet::core::geom::kNodeRealStride = 16
inlineconstexpr

◆ kInstanceIntStride

constexpr int peclet::core::geom::kInstanceIntStride = 2
inlineconstexpr

◆ kInstanceRealStride

constexpr int peclet::core::geom::kInstanceRealStride = 18
inlineconstexpr

◆ kInstanceRealStrideLegacy

constexpr int peclet::core::geom::kInstanceRealStrideLegacy
inlineconstexpr
Initial value:
=
17

Definition at line 52 of file scene_builder.hpp.

Referenced by peclet::core::geom::SceneBuilder< Real >::decode().