Chi-Tech
PostProcessorPrinter.h
Go to the documentation of this file.
1#ifndef CHITECH_POSTPROCESSORPRINTER_H
2#define CHITECH_POSTPROCESSORPRINTER_H
3
5#include <memory>
6#include <vector>
7#include <string>
8#include <fstream>
9
10namespace chi
11{
12class PostProcessor;
13class PostProcessorPrinter; // fwd declare
14class ParameterBlock;
15
16/**A helper object to allow the printer to subscribe to events.*/
18{
19public:
21
22 void ReceiveEventUpdate(const Event& event) override;
23
24private:
26};
27
28enum class ScalarPPTableFormat : int
29{
30 VERTICAL = 0,
31 HORIZONTAL = 1,
32};
33
34/**A singleton responsible for printing post-processors.*/
36{
37public:
39
41 delete; // Deleted copy constructor
43 delete; // Deleted assignment operator
44
45 void ReceiveEventUpdate(const Event& event);
46
48
50 void SetEventsOnWhichPrintPPs(const std::vector<std::string>& events);
51
52 void SetPrintScalarTimeHistory(bool value);
53 void SetPrintVectorTimeHistory(bool value);
54
55 void SetScalarPerColumnSize(bool value);
56 void SetVectorPerColumnSize(bool value);
57
58 void SetTableColumnLimit(size_t limit);
59 void SetTimeHistoryLimit(size_t limit);
60
61 void SetCSVFilename(const std::string& csv_filename);
62
63 /**A manual means to print a post processor.*/
64 std::string
65 GetPrintedPostProcessors(const std::vector<const PostProcessor*>& pp_list) const;
66
67private:
69
70 void PrintPostProcessors(const Event& event) const;
71
72 // 00a_latest
73 void
74 PrintPPsLatestValuesOnly(const std::string& pps_typename,
75 const std::vector<const PostProcessor*>& pp_list,
76 const Event& event) const;
77
78 static std::string
79 PrintPPsHorizontal(const std::vector<std::pair<std::string, std::string>>&
80 scalar_ppnames_and_vals,
81 int);
82 static std::string
83 PrintPPsVertical(const std::vector<std::pair<std::string, std::string>>&
84 scalar_ppnames_and_vals,
85 int event_code);
86
87 // 00b_history
88 void PrintPPsTimeHistory(const std::string& pps_typename,
89 const std::vector<const PostProcessor*>& pp_list,
90 const Event& event,
91 bool per_column_sizes = false) const;
92
93 static std::string PrintPPsSubTimeHistory(
94 const std::vector<std::vector<std::string>>& sub_history);
95
96 // 01 csv
97 void PrintCSVFile(const Event& event) const;
98 static void
99 PrintScalarPPsToCSV(std::ofstream& csvfile,
100 const std::vector<const PostProcessor*>& pp_list);
101 static void
102 PrintVectorPPsToCSV(std::ofstream& csvfile,
103 const std::vector<const PostProcessor*>& pp_list);
104 static void
105 PrintArbitraryPPsToCSV(std::ofstream& csvfile,
106 const std::vector<const PostProcessor*>& pp_list);
107
108 // utils
109 static std::vector<const PostProcessor*>
111
112 static std::vector<const PostProcessor*>
114
115 static std::vector<const PostProcessor*>
117
118 static std::vector<std::vector<std::string>>
119 BuildPPHistoryMatrix(size_t timehistsize,
120 size_t time_history_limit,
121 const std::vector<const PostProcessor*>& pp_sub_list);
122
123 static std::shared_ptr<PPPrinterSubscribeHelper> helper_ptr_;
124 std::vector<std::string> events_on_which_to_print_postprocs_;
125
133
134 std::string csv_filename_;
135};
136
137} // namespace chi
138
139#endif // CHITECH_POSTPROCESSORPRINTER_H
PPPrinterSubscribeHelper(PostProcessorPrinter &printer_ref)
PostProcessorPrinter & printer_ref_
void ReceiveEventUpdate(const Event &event) override
PostProcessorPrinter(const PostProcessorPrinter &)=delete
void SetPrintScalarTimeHistory(bool value)
static std::shared_ptr< PPPrinterSubscribeHelper > helper_ptr_
bool per_column_size_vectors_
static void PrintScalarPPsToCSV(std::ofstream &csvfile, const std::vector< const PostProcessor * > &pp_list)
ScalarPPTableFormat scalar_pp_table_format_
static std::vector< const PostProcessor * > GetArbitraryPostProcessorsList(const Event &event)
static std::vector< const PostProcessor * > GetVectorPostProcessorsList(const Event &event)
static PostProcessorPrinter & GetInstance()
static std::string PrintPPsVertical(const std::vector< std::pair< std::string, std::string > > &scalar_ppnames_and_vals, int event_code)
static std::vector< const PostProcessor * > GetScalarPostProcessorsList(const Event &event)
void SetTimeHistoryLimit(size_t limit)
static char SubscribeToSystemWideEventPublisher()
void SetScalarPerColumnSize(bool value)
static void PrintArbitraryPPsToCSV(std::ofstream &csvfile, const std::vector< const PostProcessor * > &pp_list)
void ReceiveEventUpdate(const Event &event)
bool print_vector_time_history_
void PrintCSVFile(const Event &event) const
void SetPrintVectorTimeHistory(bool value)
void PrintPPsLatestValuesOnly(const std::string &pps_typename, const std::vector< const PostProcessor * > &pp_list, const Event &event) const
PostProcessorPrinter operator=(const PostProcessorPrinter &)=delete
void SetCSVFilename(const std::string &csv_filename)
bool print_scalar_time_history_
static std::string PrintPPsHorizontal(const std::vector< std::pair< std::string, std::string > > &scalar_ppnames_and_vals, int)
bool per_column_size_scalars_
void PrintPostProcessors(const Event &event) const
std::string csv_filename_
std::string GetPrintedPostProcessors(const std::vector< const PostProcessor * > &pp_list) const
void SetScalarPPTableFormat(ScalarPPTableFormat format)
void SetTableColumnLimit(size_t limit)
static std::vector< std::vector< std::string > > BuildPPHistoryMatrix(size_t timehistsize, size_t time_history_limit, const std::vector< const PostProcessor * > &pp_sub_list)
void PrintPPsTimeHistory(const std::string &pps_typename, const std::vector< const PostProcessor * > &pp_list, const Event &event, bool per_column_sizes=false) const
size_t time_history_limit_
std::vector< std::string > events_on_which_to_print_postprocs_
void SetEventsOnWhichPrintPPs(const std::vector< std::string > &events)
size_t table_column_limit_
static std::string PrintPPsSubTimeHistory(const std::vector< std::vector< std::string > > &sub_history)
PostProcessorPrinter()
static void PrintVectorPPsToCSV(std::ofstream &csvfile, const std::vector< const PostProcessor * > &pp_list)
void SetVectorPerColumnSize(bool value)