Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-17 08:53:42

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/DiscreteSelectExecutor.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include "corecel/Assert.hh"
0010 #include "corecel/Macros.hh"
0011 #include "corecel/random/engine/RngEngine.hh"
0012 #include "celeritas/optical/CoreTrackView.hh"
0013 #include "celeritas/optical/PhysicsData.hh"
0014 #include "celeritas/optical/PhysicsStepUtils.hh"
0015 #include "celeritas/optical/PhysicsTrackView.hh"
0016 #include "celeritas/optical/SimTrackView.hh"
0017 
0018 namespace celeritas
0019 {
0020 namespace optical
0021 {
0022 //---------------------------------------------------------------------------//
0023 struct DiscreteSelectExecutor
0024 {
0025     inline CELER_FUNCTION void operator()(CoreTrackView const& track);
0026 };
0027 
0028 //---------------------------------------------------------------------------//
0029 /*!
0030  * Select a physics process before undergoing a collision.
0031  */
0032 CELER_FUNCTION void
0033 DiscreteSelectExecutor::operator()(CoreTrackView const& track)
0034 {
0035     CELER_EXPECT(track.sim().status() == TrackStatus::alive);
0036     CELER_EXPECT(track.sim().post_step_action()
0037                  == track.physics().discrete_action());
0038 
0039     // Reset the MFP counter, to be resampled if the track survives the
0040     // interaction
0041     auto phys = track.physics();
0042     phys.reset_interaction_mfp();
0043 
0044     // Select the action to take
0045     auto particle = track.particle();
0046     auto rng = track.rng();
0047     auto action = select_discrete_interaction(particle, phys, rng);
0048     CELER_ASSERT(action);
0049 
0050     // Save action as next kernel
0051     auto sim = track.sim();
0052     sim.post_step_action(action);
0053 
0054     CELER_ENSURE(!phys.has_interaction_mfp());
0055 }
0056 
0057 //---------------------------------------------------------------------------//
0058 }  // namespace optical
0059 }  // namespace celeritas