Back to home page

EIC code displayed by LXR

 
 

    


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

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/global/alongstep/AlongStepGeneralLinearAction.hh
0007 //---------------------------------------------------------------------------//
0008 #pragma once
0009 
0010 #include <memory>
0011 #include <string>
0012 
0013 #include "corecel/Assert.hh"
0014 #include "corecel/Macros.hh"
0015 #include "celeritas/Types.hh"
0016 #include "celeritas/em/data/FluctuationData.hh"
0017 #include "celeritas/em/data/UrbanMscData.hh"
0018 #include "celeritas/global/ActionInterface.hh"
0019 
0020 namespace celeritas
0021 {
0022 class UrbanMscParams;
0023 class FluctuationParams;
0024 class PhysicsParams;
0025 class MaterialParams;
0026 class ParticleParams;
0027 
0028 //---------------------------------------------------------------------------//
0029 /*!
0030  * Along-step kernel for particles without fields.
0031  *
0032  * This kernel is for problems without EM fields, for particle types that may
0033  * have (but do not *need* to have) along-step energy loss, optional energy
0034  * fluctuation, and optional multiple scattering.
0035  */
0036 class AlongStepGeneralLinearAction final : public CoreStepActionInterface
0037 {
0038   public:
0039     //!@{
0040     //! \name Type aliases
0041     using SPConstFluctuations = std::shared_ptr<FluctuationParams const>;
0042     using SPConstMsc = std::shared_ptr<UrbanMscParams const>;
0043     //!@}
0044 
0045   public:
0046     static std::shared_ptr<AlongStepGeneralLinearAction>
0047     from_params(ActionId id,
0048                 MaterialParams const& materials,
0049                 ParticleParams const& particles,
0050                 SPConstMsc const& msc,
0051                 bool eloss_fluctuation);
0052 
0053     // Construct with next action ID, and optional EM energy fluctuation
0054     AlongStepGeneralLinearAction(ActionId id,
0055                                  SPConstFluctuations fluct,
0056                                  SPConstMsc msc);
0057 
0058     // Default destructor
0059     ~AlongStepGeneralLinearAction();
0060 
0061     // Launch kernel with host data
0062     void step(CoreParams const&, CoreStateHost&) const final;
0063 
0064     // Launch kernel with device data
0065     void step(CoreParams const&, CoreStateDevice&) const final;
0066 
0067     //! ID of the model
0068     ActionId action_id() const final { return id_; }
0069 
0070     //! Short name for the along-step kernel
0071     std::string_view label() const final
0072     {
0073         return "along-step-general-linear";
0074     }
0075 
0076     //! Short description of the action
0077     std::string_view description() const final
0078     {
0079         return "apply along-step for particles with no field";
0080     }
0081 
0082     //! Dependency ordering of the action
0083     StepActionOrder order() const final { return StepActionOrder::along; }
0084 
0085     //// ACCESSORS ////
0086 
0087     //! Whether energy flucutation is in use
0088     bool has_fluct() const { return static_cast<bool>(fluct_); }
0089 
0090     //! Whether MSC is in use
0091     bool has_msc() const { return static_cast<bool>(msc_); }
0092 
0093   private:
0094     ActionId id_;
0095     SPConstFluctuations fluct_;
0096     SPConstMsc msc_;
0097 };
0098 
0099 //---------------------------------------------------------------------------//
0100 // INLINE DEFINITIONS
0101 //---------------------------------------------------------------------------//
0102 
0103 #if !CELER_USE_DEVICE
0104 inline void
0105 AlongStepGeneralLinearAction::step(CoreParams const&, CoreStateDevice&) const
0106 {
0107     CELER_NOT_CONFIGURED("CUDA OR HIP");
0108 }
0109 #endif
0110 
0111 //---------------------------------------------------------------------------//
0112 }  // namespace celeritas