23 "variables using comma seperated values (CSV).");
24 params.
addParam<
bool>(
"sort_columns",
false,
"Toggle the sorting of columns alphabetically.");
30 "Align the outputted csv data by padding the numbers with trailing whitespace");
31 params.
addParam<std::string>(
"delimiter",
",",
"Assign the delimiter (default is ','");
32 params.
addParam<
unsigned int>(
"precision", 14,
"Set the output precision");
33 params.
addParam<
bool>(
"create_final_symlink",
35 "Enable/disable the creation of a _FINAL symlink for vector postprocessor " 36 "data with 'execute_on' includes 'FINAL'.");
38 "create_latest_symlink",
40 "Enable/disable the creation of a _LATEST symlink for vector postprocessor data.");
53 _align(getParam<bool>(
"align")),
54 _precision(getParam<unsigned
int>(
"precision")),
55 _delimiter(getParam<
std::string>(
"delimiter")),
56 _write_all_table(false),
57 _write_vector_table(false),
58 _sort_columns(getParam<bool>(
"sort_columns")),
59 _recovering(_app.isRecovering()),
60 _create_final_symlink(getParam<bool>(
"create_final_symlink")),
61 _create_latest_symlink(getParam<bool>(
"create_latest_symlink"))
84 for (
const auto & vpp_name :
out)
87 std::string out_latest =
_file_base +
"_" + short_name +
"_LATEST.csv";
88 std::string out_final =
_file_base +
"_" + short_name +
"_FINAL.csv";
96 "Missing expected postprocessors key");
97 mooseAssert(
advancedExecuteOn().contains(
"scalars"),
"Missing expected scalars key");
98 mooseAssert(
advancedExecuteOn().contains(
"reporters"),
"Missing expected reporters key");
105 const bool pp_active = n_pps > 0 && !pp_execute_on.contains(
EXEC_NONE);
106 const bool scalar_active = n_scalars > 0 && !scalar_execute_on.contains(
EXEC_NONE);
107 const bool reporter_active = n_reporters > 0 && !reporter_execute_on.contains(
EXEC_NONE);
108 if ((pp_execute_on != scalar_execute_on && pp_active && scalar_active) ||
109 (pp_execute_on != reporter_execute_on && pp_active && reporter_active))
110 mooseError(
"The parameters 'execute_postprocessors_on', 'execute_scalars_on', and " 111 "'execute_reporters_on' must be the same for CSV output.");
151 bool include_time_step,
154 std::ostringstream file_name;
158 if (short_name.size())
159 file_name <<
'_' << short_name;
161 if (include_time_step)
163 file_name <<
'_' << std::setw(
_padding) << std::setprecision(0) << std::setfill(
'0')
168 file_name <<
'_' << std::setw(
_padding) << std::setprecision(0) << std::setfill(
'0')
173 file_name <<
'_' << std::setw(
_padding) << std::setprecision(0) << std::setfill(
'0')
183 file_name <<
"." << std::setw(digits) << std::setfill(
'0') <<
processor_id();
185 return file_name.str();
213 const auto & vpp_name = it.first;
217 it.second.sortColumns();
219 bool include_time_suffix =
true;
236 it.second.printCSV(fname, 1,
_align);
240 std::ostringstream out_latest;
241 out_latest << fprefix <<
"_LATEST.csv";
245 out_latest <<
"." << std::setw(digits) << std::setfill(
'0') <<
processor_id();
260 std::ostringstream out_final;
261 out_final << std::get<1>(name_tuple) <<
"_FINAL.csv";
262 if (std::get<2>(name_tuple))
265 out_final <<
"." << std::setw(digits) << std::setfill(
'0') <<
processor_id();
const std::set< std::string > & getPostprocessorOutput()
The list of postprocessor names that are set for output.
unsigned int _precision
Decimal digits per number in the CSV file.
const ExecFlagType EXEC_NONE
bool _write_all_table
Flag for writing scalar and/or postprocessor data.
virtual std::string filename() override
The filename for the output file.
std::string _file_base
The base filename from the input paramaters.
virtual void output()
A single call to this function should output all the necessary data for a single timestep.
std::vector< std::tuple< std::string, std::string, bool > > _latest_vpp_filenames
Current list of VPP filenames for creating _LATEST/_FINAL symlinks.
virtual void outputReporters() override
Sets the write flag and calls TableOutput::outputVectorPostprocessors()
const std::set< std::string > & getVectorPostprocessorOutput()
The list of VectorPostprocessor names that are set for output.
std::string shortName(const std::string &name)
Function for stripping name after the file / in parser block.
virtual void outputVectorPostprocessors() override
Populates the tables with VectorPostprocessor values.
const OutputOnWarehouse & advancedExecuteOn() const
Get the current advanced 'execute_on' selections for display.
unsigned int _padding
Number of digits to pad the extensions.
const std::set< std::string > & getReporterOutput()
The list of Reporter names that are set for output.
bool _write_vector_table
Flag for writing vector postprocessor data.
processor_id_type n_processors() const
virtual void outputPostprocessors() override
Sets the write flag and calls TableOutput::outputPostprocessors()
PetscInt _linear_iter
Current linear iteration returned from PETSc.
bool containsCompleteHistory() const
Return whether or not this VectorPostprocessor contains complete history.
static InputParameters validParams()
const std::set< std::string > & getScalarOutput()
The list of scalar variables names that are set for output.
bool _align
Flag for aligning data in .csv file.
Based class for adding basic filename support to output base class.
ExecFlagType _current_execute_flag
Current execute on flag.
bool _recovering
Flag indicating MOOSE is recovering via –recover command-line option.
FEProblemBase * _problem_ptr
Pointer the the FEProblemBase object for output object (use this)
virtual void outputReporters() override
Populates the tables with Reporter values.
std::string _delimiter
The delimiter used when writing the CSV file.
const VectorPostprocessor & getVectorPostprocessorObjectByName(const std::string &object_name, const THREAD_ID tid=0) const
Return the VPP object given the name.
virtual void outputVectorPostprocessors() override
Sets the write flag and calls TableOutput::outputVectorPostprocessors()
const ReporterMode REPORTER_MODE_DISTRIBUTED
const ExecFlagType EXEC_LINEAR
const bool _time_data
Enable/disable VecptorPostprocessor time data file.
virtual void outputScalarVariables() override
Sets the write flag and calls TableOutput::outputScalarVariables()
virtual void outputPostprocessors() override
Populates the tables with postprocessor values.
const ReporterData & _reporter_data
Storage for Reporter values.
FormattedTable & _all_data_table
Table containing postprocessor values, scalar aux variables, and Real Reporters.
void clearSymlink(const std::string &link)
Remove a symbolic link, if the given filename is a link.
const ExecFlagType EXEC_NONLINEAR
void createSymlink(const std::string &target, const std::string &link)
Create a symbolic link, if the link already exists it is replaced.
bool hasVectorPostprocessorByName(const VectorPostprocessorName &name, const std::string &vector_name) const
Determine if the VectorPostprocessor data exists by name.
virtual void initialSetup()
Call init() method on setup.
int numDigits(const T &num)
Return the number of digits for a number.
std::string getVectorPostprocessorFilePrefix(const std::string &vpp_name)
Returns the filename without the time/timestep information.
const bool _sort_columns
Flag for sorting column names.
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
Base class for scalar variables and postprocessors output objects.
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 + "...
registerMooseObject("MooseApp", CSV)
virtual void output() override
Output the table to a *.csv file.
bool hasReporterWithMode(const std::string &obj_name, const ReporterMode &mode) const
Return true if the supplied mode exists in the produced Reporter values.
bool _create_latest_symlink
Flag for creating a _LATEST symlink.
bool _create_final_symlink
Flag for creating a _FINAL symlink.
virtual int timeStep()
Get the current time step.
CSV(const InputParameters ¶meters)
Class constructor.
processor_id_type processor_id() const
Base class for Postprocessors that produce a vector of values.
std::map< std::string, T >::iterator find(const std::string &name)
const ExecFlagType EXEC_FINAL
std::map< std::string, FormattedTable > _vector_postprocessor_tables
Formatted tables for outputting vector postprocessor data. One per VectorPostprocessor.
void ErrorVector unsigned int
virtual void outputScalarVariables() override
Populates the tables with scalar aux variables.
PetscInt _nonlinear_iter
Current non-linear iteration returned from PETSc.
void initialSetup() override
Setup the CSV output If restarting and the append_restart flag is false, then the output data is clea...
std::map< std::string, FormattedTable > & _vector_postprocessor_time_tables
Table for vector postprocessor time data.
static InputParameters validParams()