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