Celeritas 0.7+cf8d83d
Loading...
Searching...
No Matches
Public Member Functions | List of all members
celeritas::VolumePathAccumulator Class Reference

Incrementally compute the unique ID of a path in the volume hierarchy. More...

#include <VolumePathAccumulator.hh>

Public Types

Type aliases
using ParamsRef = NativeCRef< VolumeParamsData >
 

Public Member Functions

 VolumePathAccumulator (ParamsRef const &params)
 Construct from volume hierarchy data.
 
VolumeUniqueInstanceId operator() (VolumeUniqueInstanceId uid, VolumeInstanceId vi) const
 Accumulate the contribution of one path step and return the updated ID.
 

Detailed Description

Incrementally compute the unique ID of a path in the volume hierarchy.

Each VolumeUniqueInstanceId uniquely identifies a root-to-node path (i.e., a Geant4 "touchable") in the volume DAG. This class computes the ID on the fly without allocating a path buffer: call operator() once for each VolumeInstanceId encountered while descending from the world volume, passing the current accumulated ID and receiving the updated one.

For a volume instance vi at position k in its parent volume's children list, the offset is the sum of num_desc(volume(vj)) for all preceding siblings vj (positions 0..k-1), where num_desc(V) counts the total number of unique paths ending at any node in V's subtree (including V itself). For a path \([vi_0, vi_1, \ldots, vi_k]\) the unique instance ID is

\[ \text{uid} = \sum_{i=0}^{k} \bigl(\text{offset}[vi_i] + 1\bigr). \]

The empty path (the world volume itself, with no enclosing instance) maps to ID 0 (see world_unique_instance ).

Example:
VolumePathAccumulator accum{params.host_ref()};
for (VolumeInstanceId vi : path_below_world)
{
uid = accum(uid, vi); // unique ID for the node reached via this step
}
constexpr VolumeUniqueInstanceId world_unique_instance
Unique instance ID of the "world" volume (root of the volume graph)
Definition VolumeData.hh:18
Type-safe "optional" index for accessing an array or collection of data.
Definition OpaqueId.hh:123
Incrementally compute the unique ID of a path in the volume hierarchy.
Definition VolumePathAccumulator.hh:53

The mapping relies on unique_instance_offsets precomputed in VolumeParamsData.

Member Function Documentation

◆ operator()()

VolumeUniqueInstanceId celeritas::VolumePathAccumulator::operator() ( VolumeUniqueInstanceId  uid,
VolumeInstanceId  vi 
) const
inline

Accumulate the contribution of one path step and return the updated ID.

The result after \(k\) calls equals the VolumeUniqueInstanceId of the node reached via the first \(k\) instances in the path.


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