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/detail/ScintGeneratorAction.hh
0007 //---------------------------------------------------------------------------//
0008 #pragma once
0009 
0010 #include <memory>
0011 
0012 #include "corecel/Macros.hh"
0013 #include "corecel/data/AuxInterface.hh"
0014 #include "corecel/data/Collection.hh"
0015 #include "celeritas/global/ActionInterface.hh"
0016 #include "celeritas/optical/GeneratorDistributionData.hh"
0017 
0018 namespace celeritas
0019 {
0020 namespace optical
0021 {
0022 class ScintillationParams;
0023 }  // namespace optical
0024 
0025 namespace detail
0026 {
0027 class OffloadParams;
0028 //---------------------------------------------------------------------------//
0029 /*!
0030  * Generate scintillation photons from optical distribution data.
0031  *
0032  * This samples and buffers new optical track initializers in a reproducible
0033  * way. Rather than let each thread generate all initializers from one
0034  * distribution, the work is split as evenly as possible among threads:
0035  * multiple threads may generate initializers from a single distribution.
0036  */
0037 class ScintGeneratorAction final : public CoreStepActionInterface
0038 {
0039   public:
0040     //!@{
0041     //! \name Type aliases
0042     using SPConstScintillation
0043         = std::shared_ptr<celeritas::optical::ScintillationParams const>;
0044     using SPOffloadParams = std::shared_ptr<OffloadParams>;
0045     //!@}
0046 
0047   public:
0048     // Construct with action ID, data IDs, and optical properties
0049     ScintGeneratorAction(ActionId id,
0050                          AuxId offload_id,
0051                          AuxId optical_id,
0052                          SPConstScintillation scintillation,
0053                          size_type auto_flush);
0054 
0055     // Launch kernel with host data
0056     void step(CoreParams const&, CoreStateHost&) const final;
0057 
0058     // Launch kernel with device data
0059     void step(CoreParams const&, CoreStateDevice&) const final;
0060 
0061     //! ID of the model
0062     ActionId action_id() const final { return id_; }
0063 
0064     //! Short name for the action
0065     std::string_view label() const final
0066     {
0067         return "generate-scintillation-photons";
0068     }
0069 
0070     // Name of the action (for user output)
0071     std::string_view description() const final;
0072 
0073     //! Dependency ordering of the action
0074     StepActionOrder order() const final { return StepActionOrder::user_post; }
0075 
0076   private:
0077     //// DATA ////
0078 
0079     ActionId id_;
0080     AuxId offload_id_;
0081     AuxId optical_id_;
0082     SPConstScintillation scintillation_;
0083     size_type auto_flush_;
0084 
0085     //// HELPER FUNCTIONS ////
0086 
0087     template<MemSpace M>
0088     void step_impl(CoreParams const&, CoreState<M>&) const;
0089 
0090     void generate(CoreParams const&, CoreStateHost&) const;
0091     void generate(CoreParams const&, CoreStateDevice&) const;
0092 };
0093 
0094 //---------------------------------------------------------------------------//
0095 }  // namespace detail
0096 }  // namespace celeritas