https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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{
30public:
34 const std::string & param);
35
40
41 void clear();
42
43protected:
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
110 const Real _new_row_tol;
111
113 const bool _time_data;
114
116 const bool _time_column;
117};
118
119template <typename T>
120void
122{
123 static_assert(TableValueBase::isSupportedType<T>(), "Unsupported table value type.");
124
126 {
127 if (_reporter_table.empty() || !MooseUtils::absoluteFuzzyEqual(_reporter_table.getLastTime(),
131
132 if (_all_data_table.empty() || !MooseUtils::absoluteFuzzyEqual(_all_data_table.getLastTime(),
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}
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:103
Based class for output objects.
const ReporterData & _reporter_data
Storage for Reporter values.
This class is used for building, formatting, and outputting tables of numbers.
bool empty() const
Returns a boolean value based on whether the FormattedTable contains data or not.
void addData(const std::string &name, const T &value)
Method for adding data to the output table.
Real getLastTime() const
Retrieve the last time (or independent variable) value.
void addRow(Real time)
Force a new row in the table with the passed in time.
void outputTimeColumn(bool output_time)
Set whether or not to output time column.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
const InputParameters & parameters() const
Get the parameters of the object.
Definition MooseBase.h:131
const std::string & name() const
Get the name of the class.
Definition MooseBase.h:103
int & _t_step
The current time step.
Definition Output.h:220
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.
bool hasReporterValue(const ReporterName &reporter_name) const
Return True if a Reporter value with the given type and name have been created.
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.
The Reporter system is comprised of objects that can contain any number of data values.
Base class for scalar variables and postprocessors output objects.
Definition TableOutput.h:29
virtual void outputScalarVariables() override
Populates the tables with scalar aux variables.
FormattedTable & _reporter_table
Table containing Real Reporter values.
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
const bool _time_column
Enable/disable output of time column for Postprocessors.
bool _tables_restartable
Flag for allowing all table data to become restartable.
Definition TableOutput.h:86
virtual void outputVectorPostprocessors() override
Populates the tables with VectorPostprocessor values.
FormattedTable & _scalar_table
Table containing scalar aux variables.
Definition TableOutput.h:98
const bool _check_all_columns_for_new_row
If true, new postprocessor rows can be added if any column has a new value.
std::map< std::string, FormattedTable > _vector_postprocessor_tables
Formatted tables for outputting vector postprocessor data. One per VectorPostprocessor.
Definition TableOutput.h:92
void outputReporter(const ReporterName &name)
virtual void outputReporters() override
Populates the tables with Reporter values.
const Real _new_row_tol
Tolerance used when deciding whether or not to add a new row to the table.
static InputParameters validParams()
Definition TableOutput.C:26
virtual void outputPostprocessors() override
Populates the tables with postprocessor values.
FormattedTable & _postprocessor_table
Table containing postprocessor data.
Definition TableOutput.h:89
std::map< std::string, FormattedTable > & _vector_postprocessor_time_tables
Table for vector postprocessor time data.
Definition TableOutput.h:95
const bool _time_data
Enable/disable VecptorPostprocessor time data file.
bool shouldOutputPostprocessorsRow(const FormattedTable &table)
Checks to see if a new postprocessor row should be added.
FormattedTable & _all_data_table
Table containing postprocessor values, scalar aux variables, and Real Reporters.
void outputPostprocessorsRow(FormattedTable &table)
Outputs a new postprocessor row.