File indexing completed on 2026-11-07 09:43:35
0001
0002
0003
0004
0005
0006
0007 #pragma once
0008
0009 #include <vector>
0010
0011 #include "corecel/Types.hh"
0012 #include "celeritas/Types.hh"
0013 #include "celeritas/optical/gen/GeneratorData.hh"
0014
0015 #include "LocalOffloadInterface.hh"
0016
0017 class G4EventManager;
0018
0019 namespace celeritas
0020 {
0021 namespace optical
0022 {
0023 class CoreStateBase;
0024 class GeneratorAction;
0025 class Transporter;
0026 }
0027
0028 struct SetupOptions;
0029 class SharedParams;
0030
0031
0032
0033
0034
0035 class LocalOpticalGenOffload final : public LocalOffloadInterface
0036 {
0037 public:
0038
0039
0040 using DistributionData = optical::GeneratorDistributionData;
0041
0042
0043 public:
0044
0045 LocalOpticalGenOffload() = default;
0046
0047
0048 LocalOpticalGenOffload(SetupOptions const& options, SharedParams& params);
0049
0050
0051
0052
0053
0054 void Initialize(SetupOptions const&, SharedParams&) final;
0055
0056
0057 void InitializeEvent(int) final;
0058
0059
0060 void Flush() final;
0061
0062
0063 void Finalize() final;
0064
0065
0066 bool Initialized() const final { return static_cast<bool>(state_); }
0067
0068
0069 size_type GetBufferSize() const final { return num_photons_; }
0070
0071
0072 MapStrDbl GetActionTime() const final;
0073
0074
0075
0076 void Push(DistributionData const&);
0077
0078
0079 explicit operator bool() const { return this->Initialized(); }
0080
0081 private:
0082
0083 std::shared_ptr<optical::Transporter> transport_;
0084
0085
0086 std::shared_ptr<optical::GeneratorAction const> generate_;
0087
0088
0089 std::shared_ptr<optical::CoreStateBase> state_;
0090
0091
0092 std::vector<DistributionData> buffer_;
0093
0094
0095 size_type num_photons_{};
0096
0097
0098 size_type auto_flush_{};
0099
0100
0101 UniqueEventId event_id_;
0102 G4EventManager* event_manager_{nullptr};
0103 };
0104
0105
0106 }