www.mooseframework.org
TableOutput.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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:
32 
37 
38  void clear();
39 
40 protected:
47  virtual void outputScalarVariables() override;
48 
52  virtual void outputPostprocessors() override;
53 
57  virtual void outputReporters() override;
58  template <typename T>
59  void outputReporter(const ReporterName & name);
60 
64  virtual void outputVectorPostprocessors() override;
65 
68 
71 
73  std::map<std::string, FormattedTable> _vector_postprocessor_tables;
74 
76  std::map<std::string, FormattedTable> & _vector_postprocessor_time_tables;
77 
80 
83 
86 
89 
91  const bool _time_data;
92 
94  const bool _time_column;
95 };
96 
97 template <typename T>
98 void
100 {
101  static_assert(TableValueBase::isSupportedType<T>(), "Unsupported table value type.");
102 
104  {
106  getOutputTime(),
107  _new_row_tol))
109 
111  getOutputTime(),
112  _new_row_tol))
114 
115  const T & value = _reporter_data.getReporterValue<T>(name);
116  _reporter_table.addData<T>(name.getCombinedName(), value);
117  _all_data_table.addData<T>(name.getCombinedName(), value);
118  }
119  else if (_reporter_data.hasReporterValue<std::vector<T>>(name))
120  {
121  const std::string & obj_name = name.getObjectName();
122  const std::string & val_name = name.getValueName();
123  auto insert_pair = moose_try_emplace(_vector_postprocessor_tables, obj_name, FormattedTable());
124 
125  FormattedTable & table = insert_pair.first->second;
126  table.outputTimeColumn(false);
127 
128  const std::vector<T> & vector = _reporter_data.getReporterValue<std::vector<T>>(name);
129  table.addData<T>(val_name, vector);
130 
131  if (_time_data)
132  {
134  t_table.addData("timestep", _t_step, _time);
135  }
136  }
137 }
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:346
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:70
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:214
bool empty() const
Returns a boolean value based on whether the FormattedTable contains data or not. ...
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:94
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:142
void outputReporter(const ReporterName &name)
Definition: TableOutput.h:99
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:379
TableOutput(const InputParameters &parameters)
Class constructor.
Definition: TableOutput.C:57
FormattedTable & _scalar_table
Table containing scalar aux variables.
Definition: TableOutput.h:79
const bool _time_column
Enable/disable output of time column for Postprocessors.
Definition: TableOutput.h:94
void clear()
Definition: TableOutput.C:247
bool _tables_restartable
Flag for allowing all table data to become restartable.
Definition: TableOutput.h:67
virtual void outputReporters() override
Populates the tables with Reporter values.
Definition: TableOutput.C:111
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:91
virtual void outputPostprocessors() override
Populates the tables with postprocessor values.
Definition: TableOutput.C:86
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:85
Based class for output objects.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Base class for scalar variables and postprocessors output objects.
Definition: TableOutput.h:28
const InputParameters & parameters() const
Get the parameters of the object.
FormattedTable & _reporter_table
Table containing Real Reporter values.
Definition: TableOutput.h:82
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:436
const Real _new_row_tol
Tolerance used when deciding whether or not to add a new row to the table.
Definition: TableOutput.h:88
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:208
virtual Real getOutputTime()
Get the time that will be used for stream/file outputting.
Definition: PetscOutput.C:265
std::map< std::string, FormattedTable > _vector_postprocessor_tables
Formatted tables for outputting vector postprocessor data. One per VectorPostprocessor.
Definition: TableOutput.h:73
Real getLastTime()
Retrieve the last time (or independent variable) value.
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:173
std::map< std::string, FormattedTable > & _vector_postprocessor_time_tables
Table for vector postprocessor time data.
Definition: TableOutput.h:76
static InputParameters validParams()
Definition: TableOutput.C:26