Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-22 10:31:26

0001 //----------------------------------*-C++-*----------------------------------//
0002 // Copyright 2024 UT-Battelle, LLC, and other Celeritas developers.
0003 // See the top-level COPYRIGHT file for details.
0004 // SPDX-License-Identifier: (Apache-2.0 OR MIT)
0005 //---------------------------------------------------------------------------//
0006 //! \file celeritas/optical/action/detail/BoundaryExecutor.hh
0007 //---------------------------------------------------------------------------//
0008 #pragma once
0009 
0010 #include "corecel/Assert.hh"
0011 #include "corecel/Macros.hh"
0012 #include "celeritas/Types.hh"
0013 #include "celeritas/geo/GeoTrackView.hh"
0014 #include "celeritas/optical/CoreTrackView.hh"
0015 #include "celeritas/optical/MaterialView.hh"
0016 #include "celeritas/optical/SimTrackView.hh"
0017 
0018 namespace celeritas
0019 {
0020 namespace optical
0021 {
0022 namespace detail
0023 {
0024 //---------------------------------------------------------------------------//
0025 /*!
0026  * Cross a geometry boundary.
0027  *
0028  * \pre The track must have already been physically moved to the correct point
0029  * on the boundary.
0030  */
0031 struct BoundaryExecutor
0032 {
0033     inline CELER_FUNCTION void operator()(CoreTrackView& track);
0034 };
0035 
0036 //---------------------------------------------------------------------------//
0037 CELER_FUNCTION void BoundaryExecutor::operator()(CoreTrackView& track)
0038 {
0039     CELER_EXPECT([track] {
0040         auto sim = track.sim();
0041         return sim.post_step_action() == track.boundary_action()
0042                && sim.status() == TrackStatus::alive;
0043     }());
0044 
0045     auto geo = track.geometry();
0046     CELER_EXPECT(geo.is_on_boundary());
0047 
0048     // Particle entered a new volume before reaching the interaction point
0049     geo.cross_boundary();
0050     if (CELER_UNLIKELY(geo.failed()))
0051     {
0052         track.apply_errored();
0053         return;
0054     }
0055     else
0056     {
0057         auto sim = track.sim();
0058         sim.status(TrackStatus::killed);
0059     }
0060 }
0061 
0062 //---------------------------------------------------------------------------//
0063 }  // namespace detail
0064 }  // namespace optical
0065 }  // namespace celeritas