File indexing completed on 2026-01-10 10:05:47
0001
0002
0003
0004
0005
0006
0007 #pragma once
0008
0009 #include <memory>
0010
0011 #include "corecel/Macros.hh"
0012 #include "corecel/data/AuxInterface.hh"
0013 #include "corecel/data/AuxStateVec.hh"
0014 #include "celeritas/optical/action/ActionInterface.hh"
0015 #include "celeritas/phys/GeneratorInterface.hh"
0016
0017 #include "GeneratorTraits.hh"
0018 #include "OpticalGeneratorBase.hh"
0019 #include "../GeneratorData.hh"
0020 #include "../OffloadData.hh"
0021
0022 namespace celeritas
0023 {
0024 class CoreParams;
0025
0026 namespace optical
0027 {
0028 class MaterialParams;
0029 }
0030
0031 namespace detail
0032 {
0033
0034
0035
0036
0037
0038
0039
0040
0041 template<GeneratorType G>
0042 class GeneratorAction final : public OpticalGeneratorBase
0043 {
0044 public:
0045
0046
0047 using TraitsT = GeneratorTraits<G>;
0048 template<Ownership W, MemSpace M>
0049 using Data = typename TraitsT::template Data<W, M>;
0050 using SPConstParams = std::shared_ptr<typename TraitsT::Params const>;
0051 using SPConstMaterial = std::shared_ptr<optical::MaterialParams const>;
0052
0053
0054
0055 struct Input
0056 {
0057 SPConstMaterial material;
0058 SPConstParams shared;
0059 size_type capacity{};
0060
0061 explicit operator bool() const
0062 {
0063 return material && shared && capacity > 0;
0064 }
0065 };
0066
0067 public:
0068
0069 static std::shared_ptr<GeneratorAction>
0070 make_and_insert(::celeritas::CoreParams const&,
0071 optical::CoreParams const&,
0072 Input&&);
0073
0074
0075 GeneratorAction(ActionId, AuxId, GeneratorId, Input&&);
0076
0077
0078
0079
0080
0081 UPState create_state(MemSpace, StreamId, size_type) const final;
0082
0083
0084
0085
0086
0087
0088 void step(optical::CoreParams const&, CoreStateHost&) const final;
0089
0090 void step(optical::CoreParams const&, CoreStateDevice&) const final;
0091
0092
0093 private:
0094
0095
0096 Input data_;
0097
0098
0099
0100 template<MemSpace M>
0101 void step_impl(optical::CoreParams const&, optical::CoreState<M>&) const;
0102
0103 void generate(optical::CoreParams const&, CoreStateHost&) const;
0104 void generate(optical::CoreParams const&, CoreStateDevice&) const;
0105 };
0106
0107
0108
0109
0110
0111 extern template class GeneratorAction<GeneratorType::cherenkov>;
0112 extern template class GeneratorAction<GeneratorType::scintillation>;
0113
0114
0115 }
0116 }