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