https://mooseframework.inl.gov
TableOutput.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #pragma once
11 
12 // MOOSE includes
13 #include "AdvancedOutput.h"
14 #include "FileOutput.h"
15 #include "FormattedTable.h"
16 
29 {
30 public:
34  const std::string & param);
35 
40 
41  void clear();
42 
43 protected:
50  virtual void outputScalarVariables() override;
51 
55  virtual void outputPostprocessors() override;
56 
63 
72 
76  virtual void outputReporters() override;
77  template <typename T>
78  void outputReporter(const ReporterName & name);
79 
83  virtual void outputVectorPostprocessors() override;
84 
87 
90 
92  std::map<std::string, FormattedTable> _vector_postprocessor_tables;
93 
95  std::map<std::string, FormattedTable> & _vector_postprocessor_time_tables;
96 
99 
102 
105 
108 
111 
113  const bool _time_data;
114 
116  const bool _time_column;
117 };
118 
119 template <typename T>
120 void
122 {
123  static_assert(TableValueBase::isSupportedType<T>(), "Unsupported table value type.");
124 
126  {
128  getOutputTime(),
129  _new_row_tol))
131 
133  getOutputTime(),
134  _new_row_tol))
136 
137  const T & value = _reporter_data.getReporterValue<T>(name);
138  _reporter_table.addData<T>(name.getCombinedName(), value);
139  _all_data_table.addData<T>(name.getCombinedName(), value);
140  }
141  else if (_reporter_data.hasReporterValue<std::vector<T>>(name))
142  {
143  const std::string & obj_name = name.getObjectName();
144  const std::string & val_name = name.getValueName();
145  auto insert_pair = moose_try_emplace(_vector_postprocessor_tables, obj_name, FormattedTable());
146 
147  FormattedTable & table = insert_pair.first->second;
148  table.outputTimeColumn(false);
149 
150  const std::vector<T> & vector = _reporter_data.getReporterValue<std::vector<T>>(name);
151  table.addData<T>(val_name, vector);
152 
153  if (_time_data)
154  {
156  t_table.addData("timestep", _t_step, _time);
157  }
158  }
159 }
bool absoluteFuzzyEqual(const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
Function to check whether two variables are equal within an absolute tolerance.
Definition: MooseUtils.h:380
void addData(const std::string &name, const T &value)
Method for adding data to the output table.
FormattedTable & _postprocessor_table
Table containing postprocessor data.
Definition: TableOutput.h:89
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
int & _t_step
The current time step.
Definition: Output.h:220
bool empty() const
Returns a boolean value based on whether the FormattedTable contains data or not. ...
static void addMultiAppFixedPointIterationEndExecFlag(InputParameters &params, const std::string &param)
Adds the exec flag MULTIAPP_FIXED_POINT_ITERATION_END to a parameter.
Definition: TableOutput.C:71
std::pair< typename M::iterator, bool > moose_try_emplace(M &m, const typename M::key_type &k, Args &&... args)
Function to mirror the behavior of the C++17 std::map::try_emplace() method (no hint).
Definition: Moose.h:93
virtual const std::string & name() const
Get the name of the class.
Definition: MooseBase.h:57
void outputTimeColumn(bool output_time)
Set whether or not to output time column.
virtual void outputVectorPostprocessors() override
Populates the tables with VectorPostprocessor values.
Definition: TableOutput.C:191
void outputReporter(const ReporterName &name)
Definition: TableOutput.h:121
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
const T & getReporterValue(const ReporterName &reporter_name, const MooseObject &consumer, const ReporterMode &mode, const std::size_t time_index=0) const
Method for returning read only references to Reporter values.
Definition: ReporterData.h:388
TableOutput(const InputParameters &parameters)
Class constructor.
Definition: TableOutput.C:79
FormattedTable & _scalar_table
Table containing scalar aux variables.
Definition: TableOutput.h:98
const bool _time_column
Enable/disable output of time column for Postprocessors.
Definition: TableOutput.h:116
void clear()
Definition: TableOutput.C:296
bool _tables_restartable
Flag for allowing all table data to become restartable.
Definition: TableOutput.h:86
virtual void outputReporters() override
Populates the tables with Reporter values.
Definition: TableOutput.C:160
This class is used for building, formatting, and outputting tables of numbers.
const bool _time_data
Enable/disable VecptorPostprocessor time data file.
Definition: TableOutput.h:113
Real getLastTime() const
Retrieve the last time (or independent variable) value.
virtual void outputPostprocessors() override
Populates the tables with postprocessor values.
Definition: TableOutput.C:109
const ReporterData & _reporter_data
Storage for Reporter values.
FormattedTable & _all_data_table
Table containing postprocessor values, scalar aux variables, and Real Reporters.
Definition: TableOutput.h:104
Based class for output objects.
const bool _check_all_columns_for_new_row
If true, new postprocessor rows can be added if any column has a new value.
Definition: TableOutput.h:107
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Base class for scalar variables and postprocessors output objects.
Definition: TableOutput.h:28
void outputPostprocessorsRow(FormattedTable &table)
Outputs a new postprocessor row.
Definition: TableOutput.C:151
const InputParameters & parameters() const
Get the parameters of the object.
FormattedTable & _reporter_table
Table containing Real Reporter values.
Definition: TableOutput.h:101
bool hasReporterValue(const ReporterName &reporter_name) const
Return True if a Reporter value with the given type and name have been created.
Definition: ReporterData.h:445
const Real _new_row_tol
Tolerance used when deciding whether or not to add a new row to the table.
Definition: TableOutput.h:110
void addRow(Real time)
Force a new row in the table with the passed in time.
Real & _time
The current time for output purposes.
Definition: Output.h:214
virtual Real getOutputTime()
Get the time that will be used for stream/file outputting.
Definition: PetscOutput.C:273
std::map< std::string, FormattedTable > _vector_postprocessor_tables
Formatted tables for outputting vector postprocessor data. One per VectorPostprocessor.
Definition: TableOutput.h:92
bool shouldOutputPostprocessorsRow(const FormattedTable &table)
Checks to see if a new postprocessor row should be added.
Definition: TableOutput.C:119
The Reporter system is comprised of objects that can contain any number of data values.
Definition: ReporterName.h:30
virtual void outputScalarVariables() override
Populates the tables with scalar aux variables.
Definition: TableOutput.C:222
std::map< std::string, FormattedTable > & _vector_postprocessor_time_tables
Table for vector postprocessor time data.
Definition: TableOutput.h:95
static InputParameters validParams()
Definition: TableOutput.C:26