Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/celeritas/phys/detail/DiscreteSelectExecutor.hh was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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/phys/detail/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/Types.hh"
0013 #include "celeritas/global/CoreTrackView.hh"
0014 #include "celeritas/mat/MaterialTrackView.hh"
0015 #include "celeritas/track/SimTrackView.hh"
0016 
0017 #include "../PhysicsData.hh"
0018 #include "../PhysicsStepUtils.hh"
0019 #include "../PhysicsTrackView.hh"
0020 
0021 namespace celeritas
0022 {
0023 namespace detail
0024 {
0025 //---------------------------------------------------------------------------//
0026 struct DiscreteSelectExecutor
0027 {
0028     inline CELER_FUNCTION void
0029     operator()(celeritas::CoreTrackView const& track);
0030 };
0031 
0032 //---------------------------------------------------------------------------//
0033 /*!
0034  * Select a physics process before undergoing a collision.
0035  */
0036 CELER_FUNCTION void
0037 DiscreteSelectExecutor::operator()(celeritas::CoreTrackView const& track)
0038 {
0039     CELER_EXPECT(track.sim().status() == TrackStatus::alive);
0040     CELER_EXPECT(track.sim().post_step_action()
0041                  == track.physics().scalars().discrete_action());
0042     // Reset the MFP counter, to be resampled if the track survives the
0043     // interaction
0044     auto phys = track.physics();
0045     phys.reset_interaction_mfp();
0046 
0047     auto particle = track.particle();
0048     {
0049         // Select the action to take
0050         auto mat = track.material().material_record();
0051         auto rng = track.rng();
0052         auto step = track.physics_step();
0053         auto action
0054             = select_discrete_interaction(mat, particle, phys, step, rng);
0055         CELER_ASSERT(action);
0056         // Save it as the next kernel
0057         auto sim = track.sim();
0058         sim.post_step_action(action);
0059     }
0060 
0061     CELER_ENSURE(!phys.has_interaction_mfp());
0062 }
0063 
0064 //---------------------------------------------------------------------------//
0065 }  // namespace detail
0066 }  // namespace celeritas