Back to home page

EIC code displayed by LXR

 
 

    


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

0001 //----------------------------------*-C++-*----------------------------------//
0002 // Copyright 2022-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/user/detail/StepGatherAction.hh
0007 //---------------------------------------------------------------------------//
0008 #pragma once
0009 
0010 #include <memory>
0011 #include <string>
0012 #include <type_traits>
0013 #include <vector>
0014 
0015 #include "corecel/Assert.hh"
0016 #include "corecel/Macros.hh"
0017 #include "corecel/data/CollectionMirror.hh"
0018 #include "corecel/data/CollectionStateStore.hh"
0019 #include "celeritas/global/ActionInterface.hh"
0020 #include "celeritas/global/CoreTrackDataFwd.hh"
0021 
0022 #include "StepStorage.hh"
0023 #include "../StepData.hh"
0024 #include "../StepInterface.hh"
0025 
0026 namespace celeritas
0027 {
0028 namespace detail
0029 {
0030 //---------------------------------------------------------------------------//
0031 /*!
0032  * Gather track step properties at a point during the step.
0033  *
0034  * This implementation class is constructed by the StepCollector.
0035  */
0036 template<StepPoint P>
0037 class StepGatherAction final : public CoreStepActionInterface
0038 {
0039   public:
0040     //!@{
0041     //! \name Type aliases
0042     using SPStepStorage = std::shared_ptr<StepStorage>;
0043     using SPStepInterface = std::shared_ptr<StepInterface>;
0044     using VecInterface = std::vector<SPStepInterface>;
0045     //!@}
0046 
0047   public:
0048     // Construct with action ID and storage
0049     StepGatherAction(ActionId id, SPStepStorage storage, 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     SPStepStorage storage_;
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