File indexing completed on 2025-09-17 08:53:44
0001
0002
0003
0004
0005
0006
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
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
0049 explicit PhysicsParams(Input input);
0050
0051
0052 inline ModelId::size_type num_models() const { return models_.size(); }
0053
0054
0055 inline SPConstModel model(ModelId mid) const;
0056
0057
0058 inline ActionIdRange model_actions() const;
0059
0060
0061 HostRef const& host_ref() const final { return data_.host_ref(); }
0062
0063
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
0071 SPAction discrete_select_;
0072 VecModels models_;
0073
0074
0075 CollectionMirror<PhysicsParamsData> data_;
0076
0077
0078
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
0087
0088
0089
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
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 }
0109 }