15 const std::string& pps_typename,
16 const std::vector<const PostProcessor*>& pp_list,
18 bool per_column_sizes )
const
20 if (pp_list.empty())
return;
22 std::set<size_t> unq_time_histsizes;
24 for (
const auto& pp : pp_list)
26 const size_t time_histsize = pp->GetTimeHistory().size();
27 unq_time_histsizes.insert(time_histsize);
32 std::map<size_t, std::vector<const PostProcessor*>> pp_timehist_size_subs;
33 for (
size_t time_histsize : unq_time_histsizes)
35 auto& subs = pp_timehist_size_subs[time_histsize];
36 for (
const auto& pp : pp_list)
37 if (pp->GetTimeHistory().size() == time_histsize) subs.push_back(pp);
41 for (
const auto& [timehistsize, pp_sub_list] : pp_timehist_size_subs)
43 if (pp_sub_list.empty())
continue;
46 const size_t num_rows =
48 const size_t num_cols = pp_sub_list.size() + 1;
54 size_t max_column_width = 0;
55 for (
const auto& row : value_matrix)
56 for (
const auto& entry : row)
57 max_column_width = std::max(max_column_width, entry.size());
59 std::max(max_column_width,
size_t(15));
61 std::vector<size_t> col_sizes;
62 if (not per_column_sizes) col_sizes.assign(num_cols, max_column_width);
65 col_sizes.assign(num_cols, 0);
66 for (
size_t j = 0; j < num_cols; ++j)
68 col_sizes[j] = value_matrix[0][j].size();
69 for (
size_t t = 1; t < num_rows; ++t)
70 col_sizes[j] = std::max(col_sizes[j], value_matrix[t][j].size());
75 auto LeftPad = [](std::string& entry,
size_t width)
77 const size_t pad_size = width - entry.size();
78 entry = std::string(pad_size,
' ').append(entry);
81 auto RightPad = [](std::string& entry,
size_t width)
83 const size_t pad_size = width - entry.size();
84 entry.append(std::string(pad_size,
' '));
87 for (
size_t j = 0; j < num_cols; ++j)
88 RightPad(value_matrix[0][j], col_sizes[j]);
89 for (
size_t i = 1; i < num_rows; ++i)
90 for (
size_t j = 0; j < num_cols; ++j)
91 LeftPad(value_matrix[i][j], col_sizes[j]);
94 std::vector<size_t> sub_mat_sizes;
95 size_t total_width = 0;
96 size_t col_counter = 0;
97 for (
size_t c = 0; c < num_cols; ++c)
101 const size_t projected_total_width =
102 total_width + col_sizes[c] + 5 + 2 + 1 + 2;
105 total_width = col_sizes[c] + 5 + 2 + 1;
106 sub_mat_sizes.push_back(col_counter);
109 total_width += col_sizes[c] + 2 + 1;
111 sub_mat_sizes.push_back(col_counter);
114 typedef std::vector<std::string> VecStr;
115 typedef std::vector<VecStr> MatStr;
116 std::vector<MatStr> sub_matrices;
118 for (
const size_t k : sub_mat_sizes)
120 MatStr sub_matrix(num_rows, VecStr(k - last_k + 1,
""));
122 for (
size_t i = 0; i < num_rows; ++i)
123 sub_matrix[i][0] = value_matrix[i][0];
126 for (
size_t i = 0; i < num_rows; ++i)
129 for (
size_t j = last_k; j < k; ++j, ++j_star)
130 sub_matrix[i][j_star] = value_matrix[i][j];
133 sub_matrices.push_back(std::move(sub_matrix));
136 std::stringstream outstr;
137 for (
const auto& sub_matrix : sub_matrices)
141 << pps_typename <<
" post-processors history at event \""
142 <<
event.Name() <<
"\"\n"
148 const std::vector<std::vector<std::string>>& sub_history)
150 const size_t num_rows = sub_history.size();
151 const size_t num_cols = sub_history.front().size();
153 std::stringstream output;
154 std::stringstream hline;
155 for (
size_t k = 0; k < num_cols; ++k)
157 const size_t col_str_size = sub_history.front()[k].size();
158 hline <<
"*" << std::string(col_str_size + 2,
'-');
162 output << hline.str();
163 for (
size_t i = 0; i < num_rows; ++i)
165 if (i == 1) output << hline.str();
166 std::stringstream line;
167 for (
size_t k = 0; k < num_cols; ++k)
168 line <<
"| " << sub_history[i][k] <<
" ";
170 output << line.str();
171 if (i == (num_rows - 1)) output << hline.str();
LogStream Log(LOG_LVL level=LOG_0)
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_
size_t table_column_limit_
static std::string PrintPPsSubTimeHistory(const std::vector< std::vector< std::string > > &sub_history)