Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-18 09:09:16

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/user/detail/StepGatherAction.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include <memory>
0010 #include <string>
0011 #include <type_traits>
0012 #include <vector>
0013 
0014 #include "corecel/Assert.hh"
0015 #include "corecel/Macros.hh"
0016 #include "corecel/data/CollectionMirror.hh"
0017 #include "celeritas/global/ActionInterface.hh"
0018 #include "celeritas/global/CoreTrackDataFwd.hh"
0019 
0020 #include "StepParams.hh"
0021 #include "../StepData.hh"
0022 #include "../StepInterface.hh"
0023 
0024 namespace celeritas
0025 {
0026 namespace detail
0027 {
0028 //---------------------------------------------------------------------------//
0029 /*!
0030  * Gather track step properties at a point during the step.
0031  *
0032  * This implementation class is constructed by the StepCollector.
0033  */
0034 template<StepPoint P>
0035 class StepGatherAction final : public CoreStepActionInterface
0036 {
0037   public:
0038     //!@{
0039     //! \name Type aliases
0040     using SPConstStepParams = std::shared_ptr<StepParams const>;
0041     using SPStepInterface = std::shared_ptr<StepInterface>;
0042     using VecInterface = std::vector<SPStepInterface>;
0043     //!@}
0044 
0045   public:
0046     // Construct with action ID and storage
0047     StepGatherAction(ActionId id,
0048                      SPConstStepParams params,
0049                      VecInterface callbacks);
0050 
0051     // Launch kernel with host data
0052     void step(CoreParams const&, CoreStateHost&) const final;
0053 
0054     // Launch kernel with device data
0055     void step(CoreParams const&, CoreStateDevice&) const final;
0056 
0057     //! ID of the model
0058     ActionId action_id() const final { return id_; }
0059 
0060     //! Short name for the action
0061     std::string_view label() const final
0062     {
0063         return P == StepPoint::pre    ? "step-gather-pre"
0064                : P == StepPoint::post ? "step-gather-post"
0065                                       : std::string_view{};
0066     }
0067 
0068     // Name of the action (for user output)
0069     std::string_view description() const final { return description_; }
0070 
0071     //! Dependency ordering of the action
0072     StepActionOrder order() const final
0073     {
0074         return P == StepPoint::pre    ? StepActionOrder::user_pre
0075                : P == StepPoint::post ? StepActionOrder::user_post
0076                                       : StepActionOrder::size_;
0077     }
0078 
0079   private:
0080     //// DATA ////
0081 
0082     ActionId id_;
0083     SPConstStepParams params_;
0084     VecInterface callbacks_;
0085     std::string description_;
0086 };
0087 
0088 //---------------------------------------------------------------------------//
0089 template<StepPoint P>
0090 void step_gather_device(DeviceCRef<CoreParamsData> const&,
0091                         DeviceRef<CoreStateData>&,
0092                         DeviceCRef<StepParamsData> const&,
0093                         DeviceRef<StepStateData>&);
0094 
0095 //---------------------------------------------------------------------------//
0096 // EXPLICIT INSTANTIATION
0097 //---------------------------------------------------------------------------//
0098 
0099 extern template class StepGatherAction<StepPoint::pre>;
0100 extern template class StepGatherAction<StepPoint::post>;
0101 
0102 //---------------------------------------------------------------------------//
0103 }  // namespace detail
0104 }  // namespace celeritas