Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-17 08:53:44

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/PhysicsParams.hh
0007 //---------------------------------------------------------------------------//
0008 #pragma once
0009 
0010 #include "corecel/data/CollectionMirror.hh"
0011 #include "corecel/data/ParamsDataInterface.hh"
0012 
0013 #include "Model.hh"
0014 #include "PhysicsData.hh"
0015 #include "action/ActionInterface.hh"
0016 
0017 namespace celeritas
0018 {
0019 class ActionRegistry;
0020 
0021 namespace optical
0022 {
0023 class MaterialParams;
0024 
0025 //---------------------------------------------------------------------------//
0026 class PhysicsParams final : public ParamsDataInterface<PhysicsParamsData>
0027 {
0028   public:
0029     //!@{
0030     //! \name Type aliases
0031     using SPConstModel = std::shared_ptr<Model const>;
0032     using SPConstMaterials = std::shared_ptr<MaterialParams const>;
0033 
0034     using VecModels = std::vector<SPConstModel>;
0035     using VecModelBuilders = std::vector<Model::ModelBuilder>;
0036 
0037     using ActionIdRange = Range<ActionId>;
0038     //!@}
0039 
0040     struct Input
0041     {
0042         VecModelBuilders model_builders;
0043         SPConstMaterials materials;
0044         ActionRegistry* action_registry = nullptr;
0045     };
0046 
0047   public:
0048     // Construct from models
0049     explicit PhysicsParams(Input input);
0050 
0051     //! Number of optical models
0052     inline ModelId::size_type num_models() const { return models_.size(); }
0053 
0054     // Get an optical model
0055     inline SPConstModel model(ModelId mid) const;
0056 
0057     // Get the action IDs for all models
0058     inline ActionIdRange model_actions() const;
0059 
0060     //! Access optical physics data on the host
0061     HostRef const& host_ref() const final { return data_.host_ref(); }
0062 
0063     //! Access optical physics data on the device
0064     DeviceRef const& device_ref() const final { return data_.device_ref(); }
0065 
0066   private:
0067     using SPAction = std::shared_ptr<StaticConcreteAction const>;
0068     using HostValue = HostVal<PhysicsParamsData>;
0069 
0070     // Actions
0071     SPAction discrete_select_;
0072     VecModels models_;
0073 
0074     // Host/device storage
0075     CollectionMirror<PhysicsParamsData> data_;
0076 
0077     //!@{
0078     //! \name Data construction helper functions
0079     VecModels build_models(VecModelBuilders const& model_builders,
0080                            ActionRegistry& action_reg) const;
0081     void build_mfps(MaterialParams const& mats, HostValue& data) const;
0082     //!@}
0083 };
0084 
0085 //---------------------------------------------------------------------------//
0086 // INLINE DEFINITIONS
0087 //---------------------------------------------------------------------------//
0088 /*!
0089  * Get an optical model associated with the given model identifier.
0090  */
0091 auto PhysicsParams::model(ModelId mid) const -> SPConstModel
0092 {
0093     CELER_EXPECT(mid < this->num_models());
0094     return models_[mid.get()];
0095 }
0096 
0097 //---------------------------------------------------------------------------//
0098 /*!
0099  * Get the action identifierss for all optical models.
0100  */
0101 auto PhysicsParams::model_actions() const -> ActionIdRange
0102 {
0103     auto offset = host_ref().scalars.model_to_action;
0104     return {ActionId{offset}, ActionId{offset + this->num_models()}};
0105 }
0106 
0107 //---------------------------------------------------------------------------//
0108 }  // namespace optical
0109 }  // namespace celeritas