22#include "libmesh/dof_map.h"
23#include "libmesh/string_to_enum.h"
35 "When true and VectorPostprocessor data exists, write "
36 "a csv file containing the timestep and time "
40 params.
addParam<
bool>(
"append_restart",
false,
"Append existing file on restart");
45 "Whether or not the 'time' column should be written for Postprocessor CSV files");
47 MooseEnum new_row_detection_columns(
"time all",
"time");
48 new_row_detection_columns.addDocumentation(
50 "If the time for a new row would match the previous row's time within 'new_row_tolerance', "
51 "do not add the row.");
52 new_row_detection_columns.addDocumentation(
54 "If all columns for a new row would match the previous row's columns within "
55 "'new_row_tolerance', do not add the row.");
57 new_row_detection_columns,
58 "Columns to check for duplicate rows; duplicate rows are not output.");
59 params.
addParam<Real>(
"new_row_tolerance",
61 "The independent variable tolerance for determining when a new row should "
62 "be added to the table (Note: This value must be set independently for "
63 "Postprocessor output to type=Console and type=CSV file separately.");
72 const std::string & param)
81 _tables_restartable(getParam<bool>(
"append_restart")),
82 _postprocessor_table(_tables_restartable
85 _vector_postprocessor_time_tables(
87 "vector_postprocessor_time_table")
89 "vector_postprocessor_time_table")),
90 _scalar_table(_tables_restartable ? declareRestartableData<
FormattedTable>(
"scalar_table")
92 _reporter_table(_tables_restartable ? declareRestartableData<
FormattedTable>(
"reporter_table")
94 _all_data_table(_tables_restartable ? declareRestartableData<
FormattedTable>(
"all_data_table")
96 _check_all_columns_for_new_row(getParam<
MooseEnum>(
"new_row_detection_columns") ==
"all"),
97 _new_row_tol(getParam<Real>(
"new_row_tolerance")),
98 _time_data(getParam<bool>(
"time_data")),
99 _time_column(getParam<bool>(
"time_column"))
127 if (!MooseUtils::absoluteFuzzyEqual(old_time, new_time,
_new_row_tol))
133 bool all_columns_are_identical =
true;
136 const Real old_pp_value = table.
getLastData(pp_name);
138 if (!MooseUtils::absoluteFuzzyEqual(old_pp_value, new_pp_value,
_new_row_tol))
140 all_columns_are_identical =
false;
144 return !all_columns_are_identical;
169 outputReporter<bool>(r_name);
170 outputReporter<unsigned short int>(r_name);
171 outputReporter<unsigned int>(r_name);
172 outputReporter<unsigned long int>(r_name);
173 outputReporter<unsigned long long int>(r_name);
174 outputReporter<short int>(r_name);
175 outputReporter<int>(r_name);
176 outputReporter<long int>(r_name);
177 outputReporter<long long int>(r_name);
178 outputReporter<float>(r_name);
179 outputReporter<long double>(r_name);
180 outputReporter<char>(r_name);
181 outputReporter<std::string>(r_name);
186 outputReporter<Real>(r_name);
198 const std::string & vpp_name = r_name.getObjectName();
199 const std::string & vec_name = r_name.getValueName();
200 const bool vpp_out = out.find(vpp_name) != out.end();
210 table.
addData(vec_name, vector);
228 for (
const auto & out_name : out)
244 auto value_size = value.size();
248 const std::vector<dof_id_type> & dof_indices = scalar_var.
dofIndices();
249 auto dof_size = dof_indices.size();
250 bool need_release =
false;
254 if (dof_size > value_size)
256 value.resize(dof_size);
265 const DofMap & dof_map = scalar_var.
sys().
dofMap();
266 for (
decltype(dof_size) i = 0; i < dof_size; ++i)
268 const processor_id_type pid = dof_map.dof_owner(dof_indices[i]);
281 for (
decltype(dof_size) i = 0; i < dof_size; ++i)
283 std::ostringstream os;
284 os << out_name <<
"_" << i;
OutputTools< Real >::VariableValue VariableValue
std::vector< Real > VectorPostprocessorValue
const ExecFlagType EXEC_MULTIAPP_FIXED_POINT_ITERATION_END
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).
Based class for output objects.
const std::set< std::string > & getReporterOutput()
The list of Reporter names that are set for output.
static InputParameters enableOutputTypes(const std::string &names=std::string())
A method for enabling individual output type control.
const ReporterData & _reporter_data
Storage for Reporter values.
void clearLastExecuteTime()
Clears bookkeeping used to suppress duplicate EXEC_FINAL output at the same time.
static InputParameters validParams()
const std::set< std::string > & getScalarOutput()
The list of scalar variables names that are set for output.
const std::set< std::string > & getVectorPostprocessorOutput()
The list of VectorPostprocessor names that are set for output.
const std::set< std::string > & getPostprocessorOutput()
The list of postprocessor names that are set for output.
A MultiMooseEnum object to hold "execute_on" flags.
std::string getDocString() const
Generate a documentation string for the "execute_on" parameter.
void addAvailableFlags(const ExecFlagType &flag, Args... flags)
Add additional execute_on flags to the list of possible flags.
virtual MooseVariableScalar & getScalarVariable(const THREAD_ID tid, const std::string &var_name) override
Returns the scalar variable reference from whichever system contains it.
const PostprocessorValue & getPostprocessorValueByName(const PostprocessorName &name, std::size_t t_index=0) const
Get a read-only reference to the value associated with a Postprocessor that exists.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
virtual const std::vector< dof_id_type > & dofIndices() const
Get local DoF indices.
SystemBase & sys()
Get the system this variable is part of.
Class for scalar variables (they are different).
const VariableValue & sln() const
void reinit(bool reinit_for_derivative_reordering=false)
Fill out the VariableValue arrays from the system solution vector.
FEProblemBase * _problem_ptr
Pointer the the FEProblemBase object for output object (use this)
int & _t_step
The current time step.
Real & _time
The current time for output purposes.
virtual Real getOutputTime()
Get the time that will be used for stream/file outputting.
bool hasPostprocessorByName(const PostprocessorName &name) const
Determine if the Postprocessor data exists.
std::set< ReporterName > getReporterNames() const
Return a list of all reporter names.
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.
const std::string & getObjectName() const
Return the object name that produces the Reporter value.
virtual libMesh::DofMap & dofMap()
Gets writeable reference to the dof map.
void broadcast(T &data, const unsigned int root_id=0, const bool identical_sizes=false) const
virtual void outputScalarVariables() override
Populates the tables with scalar aux variables.
FormattedTable & _reporter_table
Table containing Real Reporter values.
static void addMultiAppFixedPointIterationEndExecFlag(InputParameters ¶ms, const std::string ¶m)
Adds the exec flag MULTIAPP_FIXED_POINT_ITERATION_END to a parameter.
const bool _time_column
Enable/disable output of time column for Postprocessors.
virtual void outputVectorPostprocessors() override
Populates the tables with VectorPostprocessor values.
FormattedTable & _scalar_table
Table containing scalar aux variables.
const bool _check_all_columns_for_new_row
If true, new postprocessor rows can be added if any column has a new value.
TableOutput(const InputParameters ¶meters)
Class constructor.
std::map< std::string, FormattedTable > _vector_postprocessor_tables
Formatted tables for outputting vector postprocessor data. One per VectorPostprocessor.
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()
virtual void outputPostprocessors() override
Populates the tables with postprocessor values.
FormattedTable & _postprocessor_table
Table containing postprocessor data.
std::map< std::string, FormattedTable > & _vector_postprocessor_time_tables
Table for vector postprocessor time data.
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.
const Parallel::Communicator & comm() const
static constexpr Real TOLERANCE