24 #include <sys/types.h> 38 params.
addClassDescription(
"Adds short-cut syntax and common parameters to the Outputs block.");
42 "exodus",
false,
"Output the results using the default settings for Exodus output.");
44 "nemesis",
false,
"Output the results using the default settings for Nemesis output");
46 "console",
true,
"Output the results using the default settings for Console output");
49 "Output the scalar variable and postprocessors to a *.csv " 50 "file using the default CSV output.");
53 "Output the vector postprocessors to a *.xml " 54 "file using the default XML output.");
57 "Output Reporter values to a *.json " 58 "file using the default JSON output.");
60 "vtk",
false,
"Output the results using the default settings for VTKOutput output");
62 "xda",
false,
"Output the results using the default settings for XDA/XDR output (ascii)");
64 "xdr",
false,
"Output the results using the default settings for XDA/XDR output (binary)");
66 "gmv",
false,
"Output the results using the default settings for GMV output");
68 "tecplot",
false,
"Output the results using the default settings for Tecplot output");
72 "Output the scalar and postprocessor results using the default settings for GNUPlot output");
74 "solution_history",
false,
"Print a solution history file (.slh) using the default settings");
75 params.
addParam<
bool>(
"progress",
false,
"Print a progress bar");
76 params.
addParam<
bool>(
"dofmap",
false,
"Create the dof map .json output file");
77 params.
addParam<
bool>(
"controls",
false,
"Enable the screen output of Control systems.");
82 params.
addParam<
bool>(
"color",
true,
"Set to false to turn off all coloring in all outputs");
83 params.
addParam<std::string>(
"file_base",
84 "Common file base name to be utilized with all output objects");
85 params.
addParam<std::vector<std::string>>(
"output_if_base_contains",
86 "If this is supplied then output will only be done in " 87 "the case that the output base contains one of these " 88 "strings. This is helpful in outputting only a subset " 89 "of outputs when using MultiApps.");
91 "time_step_interval", 1,
"The interval (number of time steps) at which output occurs");
92 params.
addParam<
unsigned int>(
"interval",
93 "The interval (number of time steps) at which output occurs");
94 params.
deprecateParam(
"interval",
"time_step_interval",
"02/01/2025");
95 params.
addParam<std::vector<Real>>(
"sync_times",
97 "Times at which the output and solution is forced to occur");
99 "minimum_time_interval", 0.0,
"The minimum simulation time between output steps");
101 "append_date",
false,
"When true the date and time are appended to the output filename.");
102 params.
addParam<std::string>(
"append_date_format",
103 "The format of the date/time to append (see " 104 "http://www.cplusplus.com/reference/ctime/" 107 params.
addParam<std::vector<VariableName>>(
110 "A list of the variables and postprocessors that should NOT be output to the Exodus " 111 "file (may include Variables, ScalarVariables, and Postprocessor names).");
112 params.
addParam<std::vector<VariableName>>(
115 "A list of the variables and postprocessors that should be output to the Exodus file " 116 "(may include Variables, ScalarVariables, and Postprocessor names).");
125 "print_perf_log",
false,
"Use perf_graph instead!",
"Use perf_graph instead!");
128 "perf_graph",
false,
"Enable printing of the performance graph to the screen (Console)");
130 params.
addParam<
bool>(
"perf_graph_live",
true,
"Enables printing of live progress messages");
132 "perf_graph_live_time_limit", 5.0,
"Time (in seconds) to wait before printing a message.");
134 "perf_graph_live_mem_limit", 100,
"Memory (in MB) to cause a message to be printed.");
135 params.
addParam<
bool>(
"perf_graph_json",
false,
"Output the perf graph in JSON");
136 params.
addParam<FileName>(
"perf_graph_json_file",
"Path to a .json file to store the perf graph");
138 params.
addParam<
bool>(
"print_mesh_changed_info",
140 "When true, each time the mesh is changed the mesh information is printed");
141 params.
addParam<
bool>(
"print_linear_residuals",
143 "Enable printing of linear residuals to the screen (Console)");
144 params.
addParam<
bool>(
"print_nonlinear_residuals",
146 "Enable printing of nonlinear residuals to the screen (Console)");
147 params.
addParam<
bool>(
"print_nonlinear_converged_reason",
149 "Enable/disable printing of the nonlinear solver convergence reason to the " 150 "screen. This parameter only affects the output of the third-party solver " 151 "(e.g. PETSc), not MOOSE itself.");
152 params.
addParam<
bool>(
"print_linear_converged_reason",
154 "Enable/disable printing of the linear solver convergence reason to the " 155 "screen. This parameter only affects the output of the third-party solver " 156 "(e.g. PETSc), not MOOSE itself.");
159 "solution_invalidity_history",
161 "Enable printing of the time history of the solution invalidity occurrences " 162 "to the screen (console)");
169 :
Action(params), _action_params(_action_factory.getValidParams(
"AddOutputAction"))
182 #ifdef LIBMESH_HAVE_EXODUS_API 183 if (getParam<bool>(
"exodus"))
184 create(
"Exodus",
"exodus");
186 if (getParam<bool>(
"exodus"))
187 mooseWarning(
"Exodus output requested but not enabled through libMesh");
190 #ifdef LIBMESH_HAVE_NEMESIS_API 191 if (getParam<bool>(
"nemesis"))
192 create(
"Nemesis",
"nemesis");
194 if (getParam<bool>(
"nemesis"))
195 mooseWarning(
"Nemesis output requested but not enabled through libMesh");
199 if (getParam<bool>(
"console") && !
hasConsole())
200 create(
"Console",
"console");
202 if (getParam<bool>(
"csv"))
205 if (getParam<bool>(
"xml"))
206 create(
"XMLOutput",
"xml");
208 if (getParam<bool>(
"json"))
211 #ifdef LIBMESH_HAVE_VTK 212 if (getParam<bool>(
"vtk"))
215 if (getParam<bool>(
"vtk"))
216 mooseWarning(
"VTK output requested but not enabled through libMesh");
219 if (getParam<bool>(
"xda"))
222 if (getParam<bool>(
"xdr"))
225 if (getParam<bool>(
"gmv"))
228 if (getParam<bool>(
"tecplot"))
229 create(
"Tecplot",
"tecplot");
231 if (getParam<bool>(
"gnuplot"))
232 create(
"Gnuplot",
"gnuplot");
234 if (getParam<bool>(
"solution_history"))
235 create(
"SolutionHistory",
"solution_history");
237 if (getParam<bool>(
"progress"))
238 create(
"Progress",
"progress");
240 if (getParam<bool>(
"dofmap"))
241 create(
"DOFMap",
"dofmap");
245 const auto find_param =
246 [](
const std::vector<std::pair<const InputParameters *, std::string>> & options)
248 std::optional<std::string> from_param_name;
250 for (
const auto & [params, param_name] : options)
251 if (params->template get<bool>(param_name))
253 from_param_name = param_name;
254 from_params = params;
257 return std::make_pair(from_param_name, from_params);
261 const auto [from_param_name, from_params] =
264 create(
"ControlOutput", *from_param_name, from_params);
269 auto [from_param_name, from_params] = find_param({{&
parameters(),
"perf_graph"},
273 create(
"PerfGraphOutput", *from_param_name, from_params);
275 const auto add_perf_graph_json = [
this](
const std::string & from_param_name,
276 const std::string & set_param_name,
277 const std::string & set_param_value)
286 params.set<std::string>(set_param_name) = set_param_value;
287 params.set<
bool>(
"distributed") =
false;
288 if (set_param_name ==
"file_base")
289 params.set<
bool>(
"append_date") =
false;
293 if (getParam<bool>(
"perf_graph_json"))
294 add_perf_graph_json(
"perf_graph_json",
"file_base_suffix",
"perf_graph");
297 const auto & file = getParam<FileName>(
"perf_graph_json_file");
299 paramError(
"perf_graph_json_file",
"File must end with .json");
301 add_perf_graph_json(
"perf_graph_json_file",
"file_base", file_stripped);
304 if (!getParam<bool>(
"perf_graph_live"))
306 if (!from_param_name)
320 if (getParam<bool>(
"solution_invalidity_history"))
322 create(
"SolutionInvalidityOutput",
"solution_invalidity_history");
325 if (!getParam<bool>(
"color"))
333 if (!getParam<bool>(
"console") || (
isParamValid(
"print_nonlinear_converged_reason") &&
334 !getParam<bool>(
"print_nonlinear_converged_reason")))
337 if (!getParam<bool>(
"console") || (
isParamValid(
"print_linear_converged_reason") &&
338 !getParam<bool>(
"print_linear_converged_reason")))
344 (getParam<bool>(
"perf_graph_json") ||
isParamValid(
"perf_graph_json_file")))
357 const std::optional<std::string> & param_name,
360 const std::optional<std::string> & object_name )
366 params.
set<std::string>(
"type") = object_type;
375 std::transform(
name.begin(),
name.end(),
name.begin(), ::tolower);
379 std::shared_ptr<MooseObjectAction> action = std::static_pointer_cast<
MooseObjectAction>(
384 object_params.
set<
bool>(
"_built_by_moose") =
true;
388 object_params.applyParameters(*apply_params);
417 if (
type.compare(
"Console") == 0 && params.
get<
bool>(
"output_screen"))
InputParameters _action_params
Parameters from the action being created (AddOutputAction)
A MultiMooseEnum object to hold "execute_on" flags.
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.
bool hasConsole()
Check if a Console object that outputs to the screen has been defined.
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
const InputParameters & parameters()
Get the parameters of the object.
virtual const std::string & name() const
Get the name of the class.
void mooseWarning(Args &&... args) const
Emits a warning prefixed with object name and type.
std::shared_ptr< Action > create(const std::string &action, const std::string &action_name, InputParameters ¶meters)
static InputParameters validParams()
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
Factory & _factory
The Factory associated with the MooseApp.
std::string getExtension(const std::string &filename, const bool rfind=false)
Gets the extension of the passed file name.
std::string stripExtension(const std::string &s, const bool rfind=false)
Removes any file extension from the given string s (i.e.
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.
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.
static const ReporterName perf_graph_json_reporter
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.
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 std::string & getObjectName() const
Return the object name that produces the Reporter value.
ActionFactory & _action_factory
Builds Actions.
const std::string & getMooseObjectType() const
Return the object type to be created.
const T & getParam(const std::string &name)
Retrieve a parameter for the object.
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.
const InputParameters & _pars
Parameters of this object, references the InputParameters stored in the InputParametersWarehouse.
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.
const InputParameters & parameters() const
Get the parameters of the object.
ActionIterator actionBlocksWithActionEnd(const std::string &task)
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.
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