Celeritas 0.7.0-dev.224+develop.84a24a8b
Loading...
Searching...
No Matches
Public Member Functions | List of all members
celeritas::SimpleUnitTracker Class Reference

Track a particle in a universe of well-connected volumes. More...

#include <SimpleUnitTracker.hh>

Public Types

Type aliases
using ParamsRef = NativeCRef< OrangeParamsData >
 
using Initialization = detail::Initialization
 
using Intersection = detail::Intersection
 
using LocalState = detail::LocalState
 
using LogicEvaluator = std::conditional_t< orange_tracking_logic()==LogicNotation::infix, detail::InfixEvaluator, detail::PostfixEvaluator >
 

Public Member Functions

CELER_FUNCTION SimpleUnitTracker (ParamsRef const &params, SimpleUnitId id)
 Construct with reference to persistent parameter data.
 
CELER_FUNCTION LocalVolumeId::size_type num_volumes () const
 Number of local volumes.
 
CELER_FUNCTION LocalSurfaceId::size_type num_surfaces () const
 Number of local surfaces.
 
CELER_FUNCTION SimpleUnitRecord constunit_record () const
 SimpleUnitRecord for this tracker.
 
CELER_FUNCTION DaughterId daughter (LocalVolumeId vol) const
 DaughterId of universe embedded in a given volume.
 
CELER_FUNCTION vol_level_uint local_vol_level (LocalVolumeId vol) const
 Volume level relative to the "top" canonical volume in the universe.
 
CELER_FUNCTION LocalVolumeId local_parent (LocalVolumeId vol) const
 Local volume ID of the parent canonical volume, if any.
 
CELER_FUNCTION Initialization initialize (LocalState const &state) const
 Find the local volume from a position.
 
CELER_FUNCTION Initialization cross_boundary (LocalState const &state) const
 Find the local volume on the opposite side of a surface.
 
CELER_FUNCTION Intersection intersect (LocalState const &state) const
 Calculate distance-to-intercept for the next surface.
 
CELER_FUNCTION Intersection intersect (LocalState const &state, real_type max_dist) const
 Calculate distance-to-intercept for the next surface.
 
CELER_FUNCTION real_type safety (Real3 const &pos, LocalVolumeId vol) const
 Calculate nearest distance to a surface in any direction.
 
CELER_FUNCTION Real3 normal (Real3 const &pos, LocalSurfaceId surf) const
 Calculate the local surface normal.
 
template<class F >
CELER_FUNCTION auto intersect_impl (LocalState const &state, F &&is_valid) const -> Intersection
 Calculate distance-to-intercept for the next local surface.
 
template<class F >
CELER_FUNCTION auto background_intersect (LocalState const &state, F &&is_valid) const -> Intersection
 Calculate distance from the background volume to enter any other volume.
 

Detailed Description

Track a particle in a universe of well-connected volumes.

The simple unit tracker is based on a set of non-overlapping volumes comprised of surfaces. It is a faster but less "user-friendly" version of the masked unit tracker because it requires all volumes to be exactly defined by their connected surfaces. It does not check for overlaps.

All IDs inside the simple unit tracker are local and implementation-specific, with the exception that daughter IDs are global (but also implementation-specific).

Constructor & Destructor Documentation

◆ SimpleUnitTracker()

CELER_FUNCTION celeritas::SimpleUnitTracker::SimpleUnitTracker ( ParamsRef const params,
SimpleUnitId  suid 
)
inline

Construct with reference to persistent parameter data.

Todo:
When adding multiple universes, this will calculate range of LocalVolumeIds that belong to this unit. For now we assume all volumes and surfaces belong to us.

Member Function Documentation

◆ background_intersect()

template<class F >
CELER_FUNCTION auto celeritas::SimpleUnitTracker::background_intersect ( LocalState const state,
F &&  is_valid 
) const -> Intersection

Calculate distance from the background volume to enter any other volume.

This function is accelerated with the BIH.

◆ initialize()

CELER_FUNCTION auto celeritas::SimpleUnitTracker::initialize ( LocalState const state) const
inline

Find the local volume from a position.

To avoid edge cases and inconsistent logical/physical states, it is prohibited to initialize from an arbitrary point directly onto a surface.

Todo:
This prohibition currently also extends to internal surfaces, even if both sides of that surface are "in" the current cell. We may need to relax that.

◆ intersect_impl()

template<class F >
CELER_FUNCTION auto celeritas::SimpleUnitTracker::intersect_impl ( LocalState const state,
F &&  is_valid 
) const -> Intersection

Calculate distance-to-intercept for the next local surface.

The algorithm is:

  • If the volume is the "background" then search externally for the next volume with background_intersect (equivalent of DistanceToIn for Geant4)
  • Use the current volume to find potential intersecting surfaces and maximum number of intersections.
  • Loop over all surfaces and calculate the distance to intercept based on the given physical and logical state. Save to the thread-local buffer only intersections that are valid (either finite or less than the user-supplied maximum). The buffer contains the distances, the face indices, and an index used for sorting (if the volume has internal surfaces).
  • If no intersecting surfaces are found, return immediately. (Rely on the caller to set the "maximum distance" if we're not searching to infinity.)
  • If the volume has no special cases, find the closest surface by calling simple_intersect.
  • If the volume has internal surfaces call complex_intersect.

◆ local_parent()

CELER_FUNCTION LocalVolumeId celeritas::SimpleUnitTracker::local_parent ( LocalVolumeId  vol) const
inline

Local volume ID of the parent canonical volume, if any.

This gives the within-universe implementation volume ID of the canonical volume that "encloses" (i.e., has a level one less than) the given local volume. If the local parent volume is null, then the parent is the placement of the current ORANGE universe as a daughter.

◆ local_vol_level()

CELER_FUNCTION auto celeritas::SimpleUnitTracker::local_vol_level ( LocalVolumeId  vol) const
inline

Volume level relative to the "top" canonical volume in the universe.

When representing a Geant4 geometry, this will be zero for the top-level volume, one if it's a volume instance that's been "inlined" into this universe as a volume, two if it's a volume inlined inside that one, etc.

◆ safety()

CELER_FUNCTION real_type celeritas::SimpleUnitTracker::safety ( Real3 const pos,
LocalVolumeId  vol_id 
) const
inline

Calculate nearest distance to a surface in any direction.

The safety calculation uses a very limited method for calculating the safety distance: it's the nearest distance to any surface, for a certain subset of surfaces. Other surface types will return a safety distance of zero. Complex surfaces might return the distance to internal surfaces that do not represent the edge of a volume. Such distances are conservative but will necessarily slow down the simulation.


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