File indexing completed on 2025-02-22 10:31:27
0001
0002
0003
0004
0005
0006
0007
0008 #pragma once
0009
0010 #include "corecel/Assert.hh"
0011 #include "corecel/data/DeviceVector.hh"
0012 #include "corecel/data/ObserverPtr.hh"
0013 #include "corecel/data/ParamsDataInterface.hh"
0014 #include "celeritas/geo/GeoFwd.hh"
0015 #include "celeritas/random/RngParamsFwd.hh"
0016
0017 #include "CoreTrackData.hh"
0018
0019 namespace celeritas
0020 {
0021
0022 class ActionRegistry;
0023
0024 namespace optical
0025 {
0026
0027 class MaterialParams;
0028 class TrackInitParams;
0029
0030
0031
0032
0033
0034
0035 class CoreParams final : public ParamsDataInterface<CoreParamsData>
0036 {
0037 public:
0038
0039
0040 using SPConstGeo = std::shared_ptr<GeoParams const>;
0041 using SPConstMaterial = std::shared_ptr<MaterialParams const>;
0042 using SPConstRng = std::shared_ptr<RngParams const>;
0043 using SPConstTrackInit = std::shared_ptr<TrackInitParams const>;
0044 using SPActionRegistry = std::shared_ptr<ActionRegistry>;
0045
0046 template<MemSpace M>
0047 using ConstRef = CoreParamsData<Ownership::const_reference, M>;
0048 template<MemSpace M>
0049 using ConstPtr = ObserverPtr<ConstRef<M> const, M>;
0050
0051
0052 struct Input
0053 {
0054 SPConstGeo geometry;
0055 SPConstMaterial material;
0056
0057 SPConstRng rng;
0058 SPConstTrackInit init;
0059
0060 SPActionRegistry action_reg;
0061
0062
0063 StreamId::size_type max_streams{1};
0064
0065
0066 explicit operator bool() const
0067 {
0068 return geometry && material && rng && init && action_reg
0069 && max_streams;
0070 }
0071 };
0072
0073 public:
0074
0075 CoreParams(Input&& inp);
0076
0077
0078
0079
0080 HostRef const& host_ref() const final { return host_ref_; }
0081
0082 DeviceRef const& device_ref() const final { return device_ref_; }
0083
0084
0085
0086
0087 SPConstGeo const& geometry() const { return input_.geometry; }
0088 SPConstMaterial const& material() const { return input_.material; }
0089 SPConstRng const& rng() const { return input_.rng; }
0090 SPConstTrackInit const& init() const { return input_.init; }
0091 SPActionRegistry const& action_reg() const { return input_.action_reg; }
0092
0093
0094
0095 using ParamsDataInterface<CoreParamsData>::ref;
0096
0097
0098 template<MemSpace M>
0099 inline ConstPtr<M> ptr() const;
0100
0101
0102 size_type max_streams() const { return input_.max_streams; }
0103
0104 private:
0105 Input input_;
0106 HostRef host_ref_;
0107 DeviceRef device_ref_;
0108
0109
0110 DeviceVector<DeviceRef> device_ref_vec_;
0111 };
0112
0113
0114
0115
0116
0117
0118
0119
0120 template<MemSpace M>
0121 auto CoreParams::ptr() const -> ConstPtr<M>
0122 {
0123 if constexpr (M == MemSpace::host)
0124 {
0125 return make_observer(&host_ref_);
0126 }
0127 #ifndef __NVCC__
0128
0129
0130
0131 else
0132 #endif
0133 {
0134 CELER_ENSURE(!device_ref_vec_.empty());
0135 return make_observer(device_ref_vec_);
0136 }
0137 }
0138
0139
0140 }
0141 }