Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-07 10:11:39

0001 //------------------------------- -*- C++ -*- -------------------------------//
0002 // Copyright Celeritas contributors: see top-level COPYRIGHT file for details
0003 // SPDX-License-Identifier: (Apache-2.0 OR MIT)
0004 //---------------------------------------------------------------------------//
0005 //! \file celeritas/optical/surface/detail/PostBoundaryExecutor.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include "corecel/Assert.hh"
0010 #include "corecel/Macros.hh"
0011 #include "celeritas/optical/CoreTrackView.hh"
0012 
0013 namespace celeritas
0014 {
0015 namespace optical
0016 {
0017 namespace detail
0018 {
0019 //---------------------------------------------------------------------------//
0020 /*!
0021  * Finalize the track's boundary crossing.
0022  *
0023  * Updates the track's state base on whether it is re-entrant in the
0024  * pre-volume or entrant on the post-volume. The track's surface physics
0025  * state will be reset.
0026  *
0027  * \note This is only called if the traversal state is "exiting", as set by
0028  * SurfaceInteractionApplier .
0029  *
0030  * \sa BoundaryAction
0031  */
0032 struct PostBoundaryExecutor
0033 {
0034     // Finalize track's boundary crossing
0035     inline CELER_FUNCTION void operator()(CoreTrackView&) const;
0036 };
0037 
0038 //---------------------------------------------------------------------------//
0039 // INLINE DEFINITIONS
0040 //---------------------------------------------------------------------------//
0041 /*!
0042  * Finalize the track's boundary crossing.
0043  */
0044 CELER_FUNCTION void PostBoundaryExecutor::operator()(CoreTrackView& track) const
0045 {
0046     auto traverse = track.surface_physics().traversal();
0047     CELER_EXPECT(traverse.is_exiting());
0048 
0049     if (traverse.in_pre_volume())
0050     {
0051         // Re-entrant into the pre-volume
0052         auto geo = track.geometry();
0053         geo.cross_boundary();
0054         if (CELER_UNLIKELY(geo.failed()))
0055         {
0056             track.apply_errored();
0057             return;
0058         }
0059     }
0060 
0061     track.surface_physics().reset();
0062 
0063     if (!track.material_record().material_id())
0064     {
0065         // Kill track if it enters an invalid optical material after crossing
0066         // through a custom physics surface
0067         track.sim().status(TrackStatus::killed);
0068     }
0069 
0070     CELER_ENSURE(!track.surface_physics().is_crossing_boundary());
0071 }
0072 
0073 //---------------------------------------------------------------------------//
0074 }  // namespace detail
0075 }  // namespace optical
0076 }  // namespace celeritas