Chi-Tech
PostProcessor.h
Go to the documentation of this file.
1#ifndef CHITECH_POSTPROCESSOR_H
2#define CHITECH_POSTPROCESSOR_H
3
4#include "ChiObject.h"
6
7namespace chi
8{
9
10enum class PPType : int
11{
12 NO_VALUE = 0,
13 SCALAR = 1,
14 VECTOR = 2,
15 ARBITRARY = 3
16};
17
18enum class PPNumericFormat : int
19{
20 FIXED = 0,
22 SCIENTIFIC = 2,
23 GENERAL = 3,
24};
25
26/**Base class for all post-processors.*/
28{
29public:
31 {
32 size_t t_index_;
33 double time_;
35 };
36
37 /**Returns the name of the post-processors.*/
38 const std::string& Name() const;
39 /**Returns the type of the post-processors. This is the generic type
40 * SCALAR, VECTOR, etc. not the c++ type.*/
41 PPType Type() const;
42
43 /**Returns the numeric format of the post-processor for printing.*/
45 /**Returns the numeric precision of the post-processor for printing.*/
46 size_t NumericPrecision() const;
47
48 /**Calls the base ChiObject's method and adds a subscription to
49 * `chi_physics::PhysicsEventPublisher` singleton.*/
50 void PushOntoStack(std::shared_ptr<ChiObject>& new_object) override;
51
52 void ReceiveEventUpdate(const Event& event) override;
53
54 virtual void Execute(const Event& event_context) = 0;
55
56 /**Gets the scalar value currently stored for the post-processor.*/
57 virtual const ParameterBlock& GetValue() const;
58 virtual const std::vector<TimeHistoryEntry>& GetTimeHistory() const;
59
60 const std::vector<std::string>& PrintScope() const;
61
62 /**Converts a scalar value into a string format based on this post-processor's
63 * numeric specifications.*/
64 std::string ConvertScalarValueToString(const ParameterBlock& value) const;
65
66 /**Converts a scalar and vector values into a string format based on this
67 * post-processor's numeric specifications.*/
68 std::string ConvertValueToString(const ParameterBlock& value) const;
69
70
71 virtual ~PostProcessor() = default;
72
74protected:
75 explicit PostProcessor(const InputParameters& params, PPType type);
76
77 static PPType FigureTypeFromValue(const ParameterBlock& value);
78
79 /**Sets the post-processor's generic type.*/
80 void SetType(PPType type);
81
82
83
84 const std::string name_;
85 std::vector<std::string> subscribed_events_for_execution_;
86 std::vector<std::string> subscribed_events_for_printing_;
89
90 std::vector<TimeHistoryEntry> time_history_;
91
93 const size_t print_precision_ = 6;
94 std::string solvername_filter_;
95
96
97private:
98 static PPNumericFormat ConstructNumericFormat(const std::string& format_string);
99};
100
101} // namespace chi
102
103#endif // CHITECH_POSTPROCESSOR_H
Definition: PostProcessor.h:28
static PPNumericFormat ConstructNumericFormat(const std::string &format_string)
const size_t print_precision_
Definition: PostProcessor.h:93
PostProcessor(const InputParameters &params, PPType type)
virtual const std::vector< TimeHistoryEntry > & GetTimeHistory() const
virtual ~PostProcessor()=default
std::vector< std::string > subscribed_events_for_printing_
Definition: PostProcessor.h:86
static PPType FigureTypeFromValue(const ParameterBlock &value)
const PPNumericFormat print_numeric_format_
Definition: PostProcessor.h:92
ParameterBlock value_
Definition: PostProcessor.h:88
virtual const ParameterBlock & GetValue() const
std::vector< std::string > subscribed_events_for_execution_
Definition: PostProcessor.h:85
void ReceiveEventUpdate(const Event &event) override
const std::string & Name() const
virtual void Execute(const Event &event_context)=0
size_t NumericPrecision() const
void SetType(PPType type)
std::string solvername_filter_
Definition: PostProcessor.h:94
void PushOntoStack(std::shared_ptr< ChiObject > &new_object) override
std::vector< TimeHistoryEntry > time_history_
Definition: PostProcessor.h:90
PPType Type() const
PPType type_
Definition: PostProcessor.h:87
std::string ConvertValueToString(const ParameterBlock &value) const
std::string ConvertScalarValueToString(const ParameterBlock &value) const
static InputParameters GetInputParameters()
PPNumericFormat NumericFormat() const
const std::string name_
Definition: PostProcessor.h:84
const std::vector< std::string > & PrintScope() const
PPNumericFormat
Definition: PostProcessor.h:19
Definition: PostProcessor.h:31
size_t t_index_
Definition: PostProcessor.h:32
double time_
Definition: PostProcessor.h:33
ParameterBlock value_
Definition: PostProcessor.h:34