Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-10-14 08:48:29

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/action/detail/BoundaryExecutor.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include "corecel/Assert.hh"
0010 #include "corecel/Macros.hh"
0011 #include "celeritas/Types.hh"
0012 #include "celeritas/geo/GeoTrackView.hh"
0013 #include "celeritas/optical/CoreTrackView.hh"
0014 #include "celeritas/optical/MaterialView.hh"
0015 #include "celeritas/optical/SimTrackView.hh"
0016 
0017 namespace celeritas
0018 {
0019 namespace optical
0020 {
0021 namespace detail
0022 {
0023 //---------------------------------------------------------------------------//
0024 /*!
0025  * Cross a geometry boundary.
0026  *
0027  * \pre The track must have already been physically moved to the correct point
0028  * on the boundary.
0029  */
0030 struct BoundaryExecutor
0031 {
0032     inline CELER_FUNCTION void operator()(CoreTrackView& track);
0033 };
0034 
0035 //---------------------------------------------------------------------------//
0036 CELER_FUNCTION void BoundaryExecutor::operator()(CoreTrackView& track)
0037 {
0038     CELER_EXPECT([track] {
0039         auto sim = track.sim();
0040         return sim.post_step_action() == track.boundary_action()
0041                && sim.status() == TrackStatus::alive;
0042     }());
0043 
0044     auto geo = track.geometry();
0045     CELER_EXPECT(geo.is_on_boundary());
0046 
0047     // Particle entered a new volume before reaching the interaction point
0048     geo.cross_boundary();
0049     if (CELER_UNLIKELY(geo.failed()))
0050     {
0051         track.apply_errored();
0052         return;
0053     }
0054     else
0055     {
0056         auto sim = track.sim();
0057         sim.status(TrackStatus::killed);
0058     }
0059 }
0060 
0061 //---------------------------------------------------------------------------//
0062 }  // namespace detail
0063 }  // namespace optical
0064 }  // namespace celeritas