Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-07 10:11:41

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/optical/Transporter.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include <memory>
0010 
0011 #include "corecel/Types.hh"
0012 #include "corecel/sys/ActionGroups.hh"
0013 #include "celeritas/Types.hh"
0014 #include "celeritas/user/ActionTimes.hh"
0015 #include "celeritas/user/StepTimes.hh"
0016 
0017 #include "CoreState.hh"
0018 
0019 namespace celeritas
0020 {
0021 template<class P, template<MemSpace M> class S>
0022 class ActionGroups;
0023 
0024 namespace optical
0025 {
0026 class CoreParams;
0027 template<MemSpace M>
0028 class CoreState;
0029 class CoreStateBase;
0030 
0031 //---------------------------------------------------------------------------//
0032 /*!
0033  * Transport all pending optical tracks to completion.
0034  *
0035  * \note This class must be constructed \em after all optical actions have been
0036  * added to the action registry.
0037  */
0038 class Transporter
0039 {
0040   public:
0041     //!@{
0042     //! \name Type aliases
0043     using CoreStateHost = CoreState<MemSpace::host>;
0044     using CoreStateDevice = CoreState<MemSpace::device>;
0045     using SPConstParams = std::shared_ptr<CoreParams const>;
0046     using SPActionTimes = std::shared_ptr<ActionTimes>;
0047     using SPStepTimes = std::shared_ptr<StepTimes>;
0048     using MapStrDbl = ActionTimes::MapStrDbl;
0049     using VecDbl = StepTimes::VecDbl;
0050     //!@}
0051 
0052     struct Input
0053     {
0054         SPConstParams params;
0055         SPActionTimes action_times;  //!< Optional
0056         SPStepTimes step_times;  //!< Optional
0057     };
0058 
0059   public:
0060     // Construct with problem parameters and setup options
0061     explicit Transporter(Input&&);
0062 
0063     // Transport all pending optical tracks
0064     void operator()(CoreStateBase&) const;
0065 
0066     //! Access the shared params
0067     SPConstParams const& params() const { return input_.params; }
0068 
0069     // Get the accumulated action times
0070     MapStrDbl get_action_times(AuxStateVec const&) const;
0071     // Get and reset the accumulated action times
0072     MapStrDbl exchange_action_times(AuxStateVec&) const;
0073 
0074     // Get the recorded step times
0075     VecDbl get_step_times(AuxStateVec const&) const;
0076     // Get and reset the recorded step times
0077     VecDbl exchange_step_times(AuxStateVec&) const;
0078 
0079   private:
0080     //// TYPES ////
0081 
0082     using ActionGroupsT = ActionGroups<CoreParams, CoreState>;
0083     using SPActionGroups = std::shared_ptr<ActionGroupsT>;
0084 
0085     //// DATA ////
0086 
0087     Input input_;
0088     SPActionGroups actions_;
0089 
0090     //// HELPERS ////
0091 
0092     template<MemSpace M>
0093     void transport_impl(CoreState<M>&) const;
0094 };
0095 
0096 //---------------------------------------------------------------------------//
0097 }  // namespace optical
0098 }  // namespace celeritas