46 return std::is_fundamental<T>::value || std::is_same<T, std::string>::value;
49 virtual void print(std::ostream & os)
const = 0;
51 virtual void store(std::ostream & stream,
void * context) = 0;
62 if (!this->isSupportedType<T>())
63 mooseError(
"Unsupported type ", MooseUtils::prettyCppType<T>(),
" for FormattedTable.");
69 virtual void print(std::ostream & os)
const override { os << this->
_value; };
71 virtual void store(std::ostream & stream,
void * context)
override;
73 load(std::istream & stream, std::shared_ptr<TableValueBase> & value_base,
void * context);
83 os << (this->_value ?
"True" :
"False");
90 std::string type =
typeid(T).name();
98 std::shared_ptr<TableValueBase> & value_base,
103 value_base = std::dynamic_pointer_cast<TableValueBase>(std::make_shared<
TableValue<T>>(value));
140 void append(
bool append_existing_file);
151 template <
typename T = Real>
152 void addData(
const std::string & name,
const T & value);
157 template <
typename T = Real>
158 void addData(
const std::string & name,
const T & value, Real time);
164 template <
typename T = Real>
165 void addData(
const std::string & name,
const std::vector<T> & vector);
175 template <
typename T = Real>
195 void printTable(std::ostream & out,
unsigned int last_n_entries = 0);
197 unsigned int last_n_entries,
199 void printTable(
const std::string & file_name);
206 void printCSV(
const std::string & file_name,
int interval = 1,
bool align =
false);
210 void makeGnuplot(
const std::string & base_file,
const std::string & format);
239 unsigned int last_n_entries,
240 std::map<std::string, unsigned short> & col_widths,
241 std::vector<std::string>::iterator & col_begin,
242 std::vector<std::string>::iterator & col_end);
245 std::map<std::string, unsigned short> & col_widths,
246 std::vector<std::string>::iterator & col_begin,
247 std::vector<std::string>::iterator & col_end)
const;
249 std::map<std::string, unsigned short> & col_widths,
250 std::vector<std::string>::iterator & col_begin,
251 std::vector<std::string>::iterator & col_end)
const;
256 std::map<std::string, unsigned short> & col_widths,
257 std::vector<std::string>::iterator & col_begin,
258 std::vector<std::string>::iterator & col_end)
const;
266 std::vector<std::pair<Real, std::map<std::string, std::shared_ptr<TableValueBase>>>>
_data;
285 void open(
const std::string & file_name);
287 void printRow(std::pair<Real, std::map<std::string, std::shared_ptr<TableValueBase>>> & row_data,
337 dataStore<FormattedTable>(std::ostream & stream,
FormattedTable & table,
void * context);
338 friend void dataLoad<FormattedTable>(std::istream & stream,
FormattedTable & v,
void * context);
346 mooseError(
"No Data stored in the the FormattedTable");
348 auto back_it =
_data.rbegin();
349 back_it->second[name] =
350 std::dynamic_pointer_cast<TableValueBase>(std::make_shared<
TableValue<T>>(value));
363 auto back_it =
_data.rbegin();
365 mooseAssert(back_it ==
_data.rend() || !MooseUtils::absoluteFuzzyLessThan(time, back_it->first),
366 "Attempting to add data to FormattedTable with the dependent variable in a "
367 "non-increasing order.\nDid you mean to use addData(std::string &, const "
368 "std::vector<Real> &)?");
371 if (back_it ==
_data.rend() || !MooseUtils::absoluteFuzzyEqual(time, back_it->first))
373 _data.emplace_back(time, std::map<std::string, std::shared_ptr<TableValueBase>>());
374 back_it =
_data.rbegin();
377 back_it->second[name] =
378 std::dynamic_pointer_cast<TableValueBase>(std::make_shared<
TableValue<T>>(value));
391 for (MooseIndex(vector) i = 0; i < vector.size(); ++i)
393 if (i ==
_data.size())
394 _data.emplace_back(i, std::map<std::string, std::shared_ptr<TableValueBase>>());
396 mooseAssert(MooseUtils::absoluteFuzzyEqual(
_data[i].first, i),
397 "Inconsistent indexing in VPP vector");
399 auto & curr_entry =
_data[i];
400 curr_entry.second[name] =
401 std::dynamic_pointer_cast<TableValueBase>(std::make_shared<
TableValue<T>>(vector[i]));
415 mooseAssert(!
empty(),
"No Data stored in the FormattedTable");
417 auto & last_data_map =
_data.rbegin()->second;
418 auto it = last_data_map.find(name);
419 if (it == last_data_map.end())
420 mooseError(
"No Data found for name: " + name);
422 auto value = std::dynamic_pointer_cast<TableValue<T>>(it->second);
424 mooseError(
"Data for ", name,
" is not of the requested type.");
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
static constexpr bool isSupportedType()
virtual void store(std::ostream &stream, void *context)=0
virtual ~TableValueBase()=default
virtual void print(std::ostream &os) const =0
virtual void store(std::ostream &stream, void *context) override
virtual void print(std::ostream &os) const override
static void load(std::istream &stream, std::shared_ptr< TableValueBase > &value_base, void *context)
TableValue(const T &value)
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...