23 "variables using comma seperated values (CSV).");
29 params.
addParam<
bool>(
"sort_columns",
false,
"Toggle the sorting of columns alphabetically.");
35 "Align the outputted csv data by padding the numbers with trailing whitespace");
36 params.
addParam<std::string>(
"delimiter",
",",
"Assign the delimiter (default is ','");
37 params.
addParam<
unsigned int>(
"precision", 14,
"Set the output precision");
39 "scientific_notation",
false,
"Output floating point values in scientific notation.");
40 params.
addParam<
bool>(
"create_final_symlink",
42 "Enable/disable the creation of a _FINAL symlink for vector postprocessor "
43 "data with 'execute_on' includes 'FINAL'.");
45 "create_latest_symlink",
47 "Enable/disable the creation of a _LATEST symlink for vector postprocessor data.");
61 _align(getParam<bool>(
"align")),
62 _precision(getParam<unsigned
int>(
"precision")),
63 _scientific_notation(getParam<bool>(
"scientific_notation")),
64 _delimiter(getParam<
std::string>(
"delimiter")),
65 _write_all_table(false),
66 _write_vector_table(false),
67 _sort_columns(getParam<bool>(
"sort_columns")),
68 _recovering(_app.isRecovering()),
69 _create_final_symlink(getParam<bool>(
"create_final_symlink")),
70 _create_latest_symlink(getParam<bool>(
"create_latest_symlink"))
94 for (
const auto & vpp_name : out)
97 std::string out_latest =
_file_base +
"_" + short_name +
"_LATEST.csv";
98 std::string out_final =
_file_base +
"_" + short_name +
"_FINAL.csv";
106 "Missing expected postprocessors key");
107 mooseAssert(
advancedExecuteOn().contains(
"scalars"),
"Missing expected scalars key");
108 mooseAssert(
advancedExecuteOn().contains(
"reporters"),
"Missing expected reporters key");
115 const bool pp_active = n_pps > 0 && !pp_execute_on.isValueSet(
EXEC_NONE);
116 const bool scalar_active = n_scalars > 0 && !scalar_execute_on.isValueSet(
EXEC_NONE);
117 const bool reporter_active = n_reporters > 0 && !reporter_execute_on.isValueSet(
EXEC_NONE);
118 if ((pp_execute_on != scalar_execute_on && pp_active && scalar_active) ||
119 (pp_execute_on != reporter_execute_on && pp_active && reporter_active))
120 mooseError(
"The parameters 'execute_postprocessors_on', 'execute_scalars_on', and "
121 "'execute_reporters_on' must be the same for CSV output.");
161 bool include_time_step,
164 std::ostringstream file_name;
168 if (short_name.size())
169 file_name <<
'_' << short_name;
171 if (include_time_step)
173 file_name <<
'_' << std::setw(
_padding) << std::setprecision(0) << std::setfill(
'0')
178 file_name <<
'_' << std::setw(
_padding) << std::setprecision(0) << std::setfill(
'0')
183 file_name <<
'_' << std::setw(
_padding) << std::setprecision(0) << std::setfill(
'0')
193 file_name <<
"." << std::setw(digits) << std::setfill(
'0') <<
processor_id();
195 return file_name.str();
223 const auto & vpp_name = it.first;
228 it.second.sortColumns();
230 bool include_time_suffix =
true;
247 it.second.printCSV(fname, 1,
_align);
251 std::ostringstream out_latest;
252 out_latest << fprefix <<
"_LATEST.csv";
256 out_latest <<
"." << std::setw(digits) << std::setfill(
'0') <<
processor_id();
275 std::ostringstream out_final;
276 out_final << std::get<1>(name_tuple) <<
"_FINAL.csv";
277 if (std::get<2>(name_tuple))
280 out_final <<
"." << std::setw(digits) << std::setfill(
'0') <<
processor_id();
registerMooseObject("MooseApp", CSV)
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
const ExecFlagType EXEC_LINEAR
const ExecFlagType EXEC_NONLINEAR
const ExecFlagType EXEC_NONE
const ExecFlagType EXEC_FINAL
const ReporterMode REPORTER_MODE_DISTRIBUTED
void ErrorVector unsigned int
const std::set< std::string > & getReporterOutput()
The list of Reporter names that are set for output.
virtual void output()
A single call to this function should output all the necessary data for a single timestep.
const ReporterData & _reporter_data
Storage for Reporter values.
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.
const OutputOnWarehouse & advancedExecuteOn() const
Get the current advanced 'execute_on' selections for display.
Based class for adding basic filename support to output base class.
std::string getVectorPostprocessorFileName(const std::string &vpp_name, bool include_time_step, bool is_distributed)
Generates a filename pattern for Vectorpostprocessors filebase + VPP name + time step + "....
bool _scientific_notation
Flag for writing floating point values in scientific notation.
virtual void outputReporters() override
Sets the write flag and calls TableOutput::outputVectorPostprocessors()
virtual void output() override
Output the table to a *.csv file.
bool _create_final_symlink
Flag for creating a _FINAL symlink.
bool _write_all_table
Flag for writing scalar and/or postprocessor data.
virtual std::string filename() override
The filename for the output file.
void initialSetup() override
Setup the CSV output If restarting and the append_restart flag is false, then the output data is clea...
unsigned int _precision
Decimal digits per number in the CSV file.
virtual void outputPostprocessors() override
Sets the write flag and calls TableOutput::outputPostprocessors()
const bool _sort_columns
Flag for sorting column names.
std::string getVectorPostprocessorFilePrefix(const std::string &vpp_name)
Returns the filename without the time/timestep information.
std::string _delimiter
The delimiter used when writing the CSV file.
bool _align
Flag for aligning data in .csv file.
std::vector< std::tuple< std::string, std::string, bool > > _latest_vpp_filenames
Current list of VPP filenames for creating _LATEST/_FINAL symlinks.
static InputParameters validParams()
virtual void outputVectorPostprocessors() override
Sets the write flag and calls TableOutput::outputVectorPostprocessors()
virtual void outputScalarVariables() override
Sets the write flag and calls TableOutput::outputScalarVariables()
bool _create_latest_symlink
Flag for creating a _LATEST symlink.
CSV(const InputParameters ¶meters)
Class constructor.
bool _recovering
Flag indicating MOOSE is recovering via –recover command-line option.
bool _write_vector_table
Flag for writing vector postprocessor data.
const VectorPostprocessor & getVectorPostprocessorObjectByName(const std::string &object_name, const THREAD_ID tid=0) const
Return the VPP object given the name.
unsigned int _padding
Number of digits to pad the extensions.
std::string _file_base
The base filename from the input paramaters.
std::map< std::string, T >::iterator find(const std::string &name)
FEProblemBase * _problem_ptr
Pointer the the FEProblemBase object for output object (use this)
virtual int timeStep()
Get the current time step.
ExecFlagType _current_execute_flag
Current execute on flag.
PetscInt _nonlinear_iter
Current non-linear iteration returned from PETSc.
PetscInt _linear_iter
Current linear iteration returned from PETSc.
bool hasReporterWithMode(const std::string &obj_name, const ReporterMode &mode) const
Return true if the supplied mode exists in the produced Reporter values.
virtual void initialSetup()
Gets called at the beginning of the simulation before this object is asked to do its job.
Base class for scalar variables and postprocessors output objects.
virtual void outputScalarVariables() override
Populates the tables with scalar aux variables.
static void addMultiAppFixedPointIterationEndExecFlag(InputParameters ¶ms, const std::string ¶m)
Adds the exec flag MULTIAPP_FIXED_POINT_ITERATION_END to a parameter.
virtual void outputVectorPostprocessors() override
Populates the tables with VectorPostprocessor values.
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.
static InputParameters validParams()
virtual void outputPostprocessors() override
Populates the tables with postprocessor values.
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.
FormattedTable & _all_data_table
Table containing postprocessor values, scalar aux variables, and Real Reporters.
bool hasVectorPostprocessorByName(const VectorPostprocessorName &name, const std::string &vector_name) const
Determine if the VectorPostprocessor data exists by name.
Base class for Postprocessors that produce a vector of values.
bool containsCompleteHistory() const
Return whether or not this VectorPostprocessor contains complete history.
processor_id_type processor_id() const
processor_id_type n_processors() const
void createSymlink(const std::string &target, const std::string &link)
void clearSymlink(const std::string &link)
std::string shortName(const std::string &name)