File indexing completed on 2025-02-22 10:31:32
0001
0002
0003
0004
0005
0006
0007
0008 #pragma once
0009
0010 #include <map>
0011 #include <memory>
0012 #include <vector>
0013
0014 #include "corecel/data/StreamStore.hh"
0015 #include "corecel/io/OutputInterface.hh"
0016 #include "celeritas/global/ActionInterface.hh"
0017 #include "celeritas/global/CoreTrackData.hh"
0018
0019 #include "ParticleTallyData.hh"
0020
0021 namespace celeritas
0022 {
0023
0024 class ParticleParams;
0025 class ActionRegistry;
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036 class ActionDiagnostic final : public CoreStepActionInterface,
0037 public CoreBeginRunActionInterface,
0038 public OutputInterface
0039 {
0040 public:
0041
0042
0043 using CoreStepActionInterface::CoreStateDevice;
0044 using CoreStepActionInterface::CoreStateHost;
0045
0046
0047 public:
0048
0049
0050 using WPConstActionRegistry = std::weak_ptr<ActionRegistry const>;
0051 using WPConstParticle = std::weak_ptr<ParticleParams const>;
0052 using MapStringCount = std::map<std::string, size_type>;
0053 using VecCount = std::vector<size_type>;
0054 using VecVecCount = std::vector<VecCount>;
0055
0056
0057 public:
0058
0059 static std::shared_ptr<ActionDiagnostic>
0060 make_and_insert(CoreParams const& core);
0061
0062
0063 explicit ActionDiagnostic(ActionId id);
0064
0065
0066 ~ActionDiagnostic();
0067
0068
0069
0070
0071 ActionId action_id() const final { return id_; }
0072
0073 std::string_view label() const final { return "action-diagnostic"; }
0074
0075 std::string_view description() const final;
0076
0077 StepActionOrder order() const final { return StepActionOrder::post; }
0078
0079
0080
0081
0082
0083 void begin_run(CoreParams const&, CoreStateHost&) final;
0084
0085 void begin_run(CoreParams const&, CoreStateDevice&) final;
0086
0087
0088
0089
0090
0091 void step(CoreParams const&, CoreStateHost&) const final;
0092
0093 void step(CoreParams const&, CoreStateDevice&) const final;
0094
0095
0096
0097
0098
0099 Category category() const final { return Category::result; }
0100
0101 void output(JsonPimpl*) const final;
0102
0103
0104
0105 MapStringCount calc_actions_map() const;
0106
0107
0108 VecVecCount calc_actions() const;
0109
0110
0111 size_type state_size() const;
0112
0113
0114 void clear();
0115
0116 private:
0117 using StoreT = StreamStore<ParticleTallyParamsData, ParticleTallyStateData>;
0118
0119 ActionId id_;
0120
0121 WPConstActionRegistry action_reg_;
0122 WPConstParticle particle_;
0123
0124 mutable StoreT store_;
0125
0126
0127
0128
0129 void begin_run_impl(CoreParams const&);
0130 };
0131
0132
0133 }