Back to home page

EIC code displayed by LXR

 
 

    


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

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/neutron/executor/NeutronInelasticExecutor.hh
0007 //---------------------------------------------------------------------------//
0008 #pragma once
0009 
0010 #include "corecel/Assert.hh"
0011 #include "celeritas/global/CoreTrackView.hh"
0012 #include "celeritas/mat/ElementSelector.hh"
0013 #include "celeritas/mat/ElementView.hh"
0014 #include "celeritas/neutron/data/NeutronInelasticData.hh"
0015 #include "celeritas/neutron/interactor/NeutronInelasticInteractor.hh"
0016 #include "celeritas/neutron/xs/NeutronInelasticMicroXsCalculator.hh"
0017 #include "celeritas/phys/Interaction.hh"
0018 
0019 namespace celeritas
0020 {
0021 //---------------------------------------------------------------------------//
0022 struct NeutronInelasticExecutor
0023 {
0024     inline CELER_FUNCTION Interaction
0025     operator()(celeritas::CoreTrackView const& track);
0026 
0027     NeutronInelasticRef params;
0028 };
0029 
0030 //---------------------------------------------------------------------------//
0031 /*!
0032  * Apply the NeutronInelasticInteractor to the current track.
0033  */
0034 CELER_FUNCTION Interaction
0035 NeutronInelasticExecutor::operator()(CoreTrackView const& track)
0036 {
0037     auto particle = track.make_particle_view();
0038     auto rng = track.make_rng_engine();
0039 
0040     // Select a target element
0041     auto material = track.make_material_view().make_material_view();
0042     auto elcomp_id = track.make_physics_step_view().element();
0043     if (!elcomp_id)
0044     {
0045         // Sample an element (based on element cross sections on the fly)
0046         ElementSelector select_el(
0047             material,
0048             NeutronInelasticMicroXsCalculator{params, particle.energy()},
0049             track.make_material_view().element_scratch());
0050         elcomp_id = select_el(rng);
0051         CELER_ASSERT(elcomp_id);
0052         track.make_physics_step_view().element(elcomp_id);
0053     }
0054 
0055     // Construct the interactor
0056     NeutronInelasticInteractor interact(params, particle);
0057 
0058     // Execute the interactor
0059     return interact(rng);
0060 }
0061 
0062 //---------------------------------------------------------------------------//
0063 }  // namespace celeritas