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.");
66 const T &
get()
const {
return _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,
140 void append(
bool append_existing_file);
151 template <
typename T = Real>
157 template <
typename T = Real>
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);
341 template <
typename T>
346 mooseError(
"No Data stored in the the FormattedTable");
348 auto back_it =
_data.rbegin();
349 back_it->second[
name] =
359 template <
typename T>
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] =
387 template <
typename T>
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] =
411 template <
typename T>
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())
std::string name(const ElemQuality q)
virtual void print(std::ostream &os) const =0
static constexpr bool isSupportedType()
KOKKOS_INLINE_FUNCTION const T * find(const T &target, const T *const begin, const T *const end)
Find a value in an array.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
std::unique_ptr< T_DEST, T_DELETER > dynamic_pointer_cast(std::unique_ptr< T_SRC, T_DELETER > &src)
These are reworked from https://stackoverflow.com/a/11003103.
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
std::basic_ostream< charT, traits > * os
static void load(std::istream &stream, std::shared_ptr< TableValueBase > &value_base, void *context)
TableValue(const T &value)
virtual void print(std::ostream &os) const override
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
virtual void store(std::ostream &stream, void *context) override
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
virtual void store(std::ostream &stream, void *context)=0
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual ~TableValueBase()=default