25 #include <sys/types.h> 37 params.
addClassDescription(
"Adds short-cut syntax and common parameters to the Outputs block.");
41 "exodus",
false,
"Output the results using the default settings for Exodus output.");
43 "nemesis",
false,
"Output the results using the default settings for Nemesis output");
45 "console",
true,
"Output the results using the default settings for Console output");
48 "Output the scalar variable and postprocessors to a *.csv " 49 "file using the default CSV output.");
52 "Output the vector postprocessors to a *.xml " 53 "file using the default XML output.");
56 "Output Reporter values to a *.json " 57 "file using the default JSON output.");
59 "vtk",
false,
"Output the results using the default settings for VTKOutput output");
61 "xda",
false,
"Output the results using the default settings for XDA/XDR output (ascii)");
63 "xdr",
false,
"Output the results using the default settings for XDA/XDR output (binary)");
65 "gmv",
false,
"Output the results using the default settings for GMV output");
67 "tecplot",
false,
"Output the results using the default settings for Tecplot output");
71 "Output the scalar and postprocessor results using the default settings for GNUPlot output");
73 "solution_history",
false,
"Print a solution history file (.slh) using the default settings");
74 params.
addParam<
bool>(
"progress",
false,
"Print a progress bar");
75 params.
addParam<
bool>(
"dofmap",
false,
"Create the dof map .json output file");
76 params.
addParam<
bool>(
"controls",
false,
"Enable the screen output of Control systems.");
81 params.
addParam<
bool>(
"color",
true,
"Set to false to turn off all coloring in all outputs");
82 params.
addParam<std::string>(
"file_base",
83 "Common file base name to be utilized with all output objects");
84 params.
addParam<std::vector<std::string>>(
"output_if_base_contains",
85 "If this is supplied then output will only be done in " 86 "the case that the output base contains one of these " 87 "strings. This is helpful in outputting only a subset " 88 "of outputs when using MultiApps.");
90 "time_step_interval", 1,
"The interval (number of time steps) at which output occurs");
91 params.
addParam<std::vector<Real>>(
"sync_times",
93 "Times at which the output and solution is forced to occur");
95 "min_simulation_time_interval", 0.0,
"The minimum simulation time between output steps");
97 "append_date",
false,
"When true the date and time are appended to the output filename.");
98 params.
addParam<std::string>(
"append_date_format",
99 "The format of the date/time to append (see " 100 "http://www.cplusplus.com/reference/ctime/" 103 params.
addParam<std::vector<VariableName>>(
106 "A list of the variables and postprocessors that should NOT be output to the Exodus " 107 "file (may include Variables, ScalarVariables, and Postprocessor names).");
108 params.
addParam<std::vector<VariableName>>(
111 "A list of the variables and postprocessors that should be output to the Exodus file " 112 "(may include Variables, ScalarVariables, and Postprocessor names).");
121 "print_perf_log",
false,
"Use perf_graph instead!",
"Use perf_graph instead!");
124 "perf_graph",
false,
"Enable printing of the performance graph to the screen (Console)");
126 params.
addParam<
bool>(
"perf_graph_live",
true,
"Enables printing of live progress messages");
128 "perf_graph_live_time_limit", 5.0,
"Time (in seconds) to wait before printing a message.");
130 "perf_graph_live_mem_limit", 100,
"Memory (in MB) to cause a message to be printed.");
131 params.
addParam<
bool>(
"perf_graph_json",
false,
"Output the perf graph in JSON");
132 params.
addParam<FileName>(
"perf_graph_json_file",
"Path to a .json file to store the perf graph");
134 params.
addParam<
bool>(
"print_mesh_changed_info",
136 "When true, each time the mesh is changed the mesh information is printed");
137 params.
addParam<
bool>(
"print_linear_residuals",
139 "Enable printing of linear residuals to the screen (Console)");
140 params.
addParam<
bool>(
"print_nonlinear_residuals",
142 "Enable printing of nonlinear residuals to the screen (Console)");
143 params.
addParam<
bool>(
"print_nonlinear_converged_reason",
145 "Enable/disable printing of the nonlinear solver convergence reason to the " 146 "screen. This parameter only affects the output of the third-party solver " 147 "(e.g. PETSc), not MOOSE itself.");
148 params.
addParam<
bool>(
"print_linear_converged_reason",
150 "Enable/disable printing of the linear solver convergence reason to the " 151 "screen. This parameter only affects the output of the third-party solver " 152 "(e.g. PETSc), not MOOSE itself.");
155 "solution_invalidity_history",
157 "Enable printing of the time history of the solution invalidity occurrences " 158 "to the screen (console)");
165 :
Action(params), _action_params(_action_factory.getValidParams(
"AddOutputAction"))
173 static const std::string perf_graph_reporter_name =
"perf_graph_json";
175 static const OutputName perf_graph_json_output_name =
"auto_perf_graph_json";
183 #ifdef LIBMESH_HAVE_EXODUS_API 184 if (getParam<bool>(
"exodus"))
185 create(
"Exodus",
"exodus");
187 if (getParam<bool>(
"exodus"))
188 mooseWarning(
"Exodus output requested but not enabled through libMesh");
191 #ifdef LIBMESH_HAVE_NEMESIS_API 192 if (getParam<bool>(
"nemesis"))
193 create(
"Nemesis",
"nemesis");
195 if (getParam<bool>(
"nemesis"))
196 mooseWarning(
"Nemesis output requested but not enabled through libMesh");
200 if (getParam<bool>(
"console") && !
hasConsole())
201 create(
"Console",
"console");
203 if (getParam<bool>(
"csv"))
206 if (getParam<bool>(
"xml"))
207 create(
"XMLOutput",
"xml");
209 if (getParam<bool>(
"json"))
212 #ifdef LIBMESH_HAVE_VTK 213 if (getParam<bool>(
"vtk"))
216 if (getParam<bool>(
"vtk"))
217 mooseWarning(
"VTK output requested but not enabled through libMesh");
220 if (getParam<bool>(
"xda"))
223 if (getParam<bool>(
"xdr"))
226 if (getParam<bool>(
"gmv"))
229 if (getParam<bool>(
"tecplot"))
230 create(
"Tecplot",
"tecplot");
232 if (getParam<bool>(
"gnuplot"))
233 create(
"Gnuplot",
"gnuplot");
235 if (getParam<bool>(
"solution_history"))
236 create(
"SolutionHistory",
"solution_history");
238 if (getParam<bool>(
"progress"))
239 create(
"Progress",
"progress");
241 if (getParam<bool>(
"dofmap"))
242 create(
"DOFMap",
"dofmap");
246 const auto find_param =
247 [](
const std::vector<std::pair<const InputParameters *, std::string>> & options)
249 std::optional<std::string> from_param_name;
251 for (
const auto & [params, param_name] : options)
252 if (params->template get<bool>(param_name))
254 from_param_name = param_name;
255 from_params = params;
258 return std::make_pair(from_param_name, from_params);
262 const auto [from_param_name, from_params] =
265 create(
"ControlOutput", *from_param_name, from_params);
270 auto [from_param_name, from_params] = find_param({{&
parameters(),
"perf_graph"},
274 create(
"PerfGraphOutput", *from_param_name, from_params);
276 const auto add_perf_graph_json = [
this](
const std::string & from_param_name,
277 const std::string & set_param_name,
278 const std::string & set_param_value)
281 std::vector<ReporterName> reporters;
282 reporters.reserve(value_names.size());
283 for (
const auto & value_name : value_names)
290 reporters.push_back(
name);
294 params.
set<std::vector<ReporterName>>(
"reporters") = reporters;
297 params.set<std::string>(set_param_name) = set_param_value;
298 params.set<
bool>(
"distributed") =
false;
299 if (set_param_name ==
"file_base")
300 params.set<
bool>(
"append_date") =
false;
301 create(
"JSON", from_param_name, &
parameters(), ¶ms, perf_graph_json_output_name);
304 if (getParam<bool>(
"perf_graph_json"))
305 add_perf_graph_json(
"perf_graph_json",
"file_base_suffix",
"perf_graph");
308 const auto & file = getParam<FileName>(
"perf_graph_json_file");
310 paramError(
"perf_graph_json_file",
"File must end with .json");
312 add_perf_graph_json(
"perf_graph_json_file",
"file_base", file_stripped);
315 if (!getParam<bool>(
"perf_graph_live"))
317 if (!from_param_name)
331 if (getParam<bool>(
"solution_invalidity_history"))
333 create(
"SolutionInvalidityOutput",
"solution_invalidity_history");
336 if (!getParam<bool>(
"color"))
344 if (!getParam<bool>(
"console") || (
isParamValid(
"print_nonlinear_converged_reason") &&
345 !getParam<bool>(
"print_nonlinear_converged_reason")))
348 if (!getParam<bool>(
"console") || (
isParamValid(
"print_linear_converged_reason") &&
349 !getParam<bool>(
"print_linear_converged_reason")))
355 (getParam<bool>(
"perf_graph_json") ||
isParamValid(
"perf_graph_json_file")))
359 params.set<std::vector<OutputName>>(
"outputs") =
360 std::vector<OutputName>{perf_graph_json_output_name};
361 _problem->addReporter(
"PerfGraphReporter", perf_graph_reporter_name, params);
370 const std::optional<std::string> & param_name,
373 const std::optional<std::string> & object_name )
379 params.
set<std::string>(
"type") = object_type;
388 std::transform(
name.begin(),
name.end(),
name.begin(), ::tolower);
392 std::shared_ptr<MooseObjectAction> action = std::static_pointer_cast<
MooseObjectAction>(
397 object_params.
set<
bool>(
"_built_by_moose") =
true;
401 object_params.applyParameters(*apply_params);
430 if (
type.compare(
"Console") == 0 && params.
get<
bool>(
"output_screen"))
static const std::vector< ReporterValueName > value_names
The reporter values that this object declares; used within the CommonOutputAction to single out value...
InputParameters _action_params
Parameters from the action being created (AddOutputAction)
A MultiMooseEnum object to hold "execute_on" flags.
const InputParameters & _pars
The object's parameters.
void create(const std::string &object_type, const std::optional< std::string > ¶m_name, const InputParameters *const from_params=nullptr, const InputParameters *const apply_params=nullptr, const std::optional< std::string > &object_name={})
Helper method for creating the short-cut actions.
std::list< Action * >::iterator ActionIterator
alias to hide implementation details
ActionWarehouse & _awh
Reference to ActionWarehouse where we store object build by actions.
void paramError(const std::string ¶m, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
const T & getParam(const std::string &name) const
Retrieve a parameter for the object.
bool hasConsole()
Check if a Console object that outputs to the screen has been defined.
Factory & _factory
The Factory associated with the MooseApp.
const InputParameters & parameters() const
Get the parameters of the object.
ActionFactory & _action_factory
Builds Actions.
const ExecFlagType EXEC_NONE
InputParameters getValidParams(const std::string &name) const
Get valid parameters for the object.
static ExecFlagEnum getDefaultExecFlagEnum()
Return an ExecFlagEnum object with the available execution flags for Output objects.
CommonOutputAction(const InputParameters ¶ms)
void addActionBlock(std::shared_ptr< Action > blk)
This method add an Action instance to the warehouse.
const ExecFlagType EXEC_TIMESTEP_END
std::shared_ptr< Action > create(const std::string &action, const std::string &action_name, InputParameters ¶meters)
static InputParameters validParams()
void mooseWarning(Args &&... args) const
const std::string & name() const
Get the name of the class.
static InputParameters validParams()
InputParameters & getObjectParams()
Retrieve the parameters of the object to be created by this action.
std::vector< ReporterName > _common_reporter_names
The reporter names that we do not want to include in general JSON output.
std::string stripExtension(const std::string &s, const bool rfind)
void setActive(bool active)
Turn on or off timing.
void setLiveMemoryLimit(unsigned int mem_limit)
Sert the memory limit before a message prints.
virtual void act() override
Method to add objects to the simulation or perform other setup tasks.
void disableLivePrint()
Completely disables Live Print (cannot be restarted)
const std::string & type() const
Get the type of this class.
const std::string & _current_task
The current action (even though we have separate instances for each action)
std::string getDocString() const
Generate a documentation string for the "execute_on" parameter.
MooseApp & _app
The MOOSE application this is associated with.
const std::string & getMooseObjectType() const
Return the object type to be created.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void dontAddNonlinearConvergedReason(FEProblemBase &fe_problem)
Function to ensure that -snes_converged_reason is not added to the PetscOptions storage object to be ...
registerMooseAction("MooseApp", CommonOutputAction, "common_output")
bool setColorConsole(bool use_color, bool force=false)
Turns color escape sequences on/off for info written to stdout.
PerfGraph & perfGraph()
Get the PerfGraph.
void associateWithParameter(const std::string ¶m_name, InputParameters ¶ms) const
Associates the object's parameters params with the input location from this Action's parameter with t...
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type and optionally a file path to the top-level block p...
void setCommonParameters(const InputParameters *params_ptr)
Stores the common InputParameters object.
std::shared_ptr< FEProblemBase > & _problem
Convenience reference to a problem this action works on.
ActionIterator actionBlocksWithActionEnd(const std::string &task)
std::string getExtension(const std::string &filename, const bool rfind)
void dontAddLinearConvergedReason(FEProblemBase &fe_problem)
Function to ensure that -ksp_converged_reason is not added to the PetscOptions storage object to be l...
void setLiveTimeLimit(Real time_limit)
Set the time limit before a message prints.
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
ActionIterator actionBlocksWithActionBegin(const std::string &task)
Iterators to the Actions in the warehouse.
const ExecFlagType EXEC_FINAL
The Reporter system is comprised of objects that can contain any number of data values.
Meta-action for creating common output object parameters This action serves two purpose, first it adds common output object parameters.
OutputWarehouse & getOutputWarehouse()
Get the OutputWarehouse objects.
const ExecFlagType EXEC_INITIAL