www.mooseframework.org
SetupDebugAction.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #include "SetupDebugAction.h"
11 #include "FEProblem.h"
12 #include "ActionWarehouse.h"
13 #include "Factory.h"
14 #include "Output.h"
15 #include "MooseApp.h"
16 #include "MooseObjectAction.h"
17 #include "ActionFactory.h"
18 #include "AddAuxVariableAction.h"
19 #include "MooseUtils.h"
20 
21 registerMooseAction("MooseApp", SetupDebugAction, "add_output");
22 
25 {
27  params.addParam<unsigned int>(
28  "show_top_residuals", 0, "The number of top residuals to print out (0 = no output)");
29  params.addParam<bool>(
30  "show_var_residual_norms",
31  false,
32  "Print the residual norms of the individual solution variables at each nonlinear iteration");
33  params.addParam<bool>("show_action_dependencies", false, "Print out the action dependencies");
34  params.addParam<bool>("show_actions", false, "Print out the actions being executed");
35  params.addParam<bool>(
36  "show_parser", false, "Shows parser block extraction and debugging information");
37  params.addParam<bool>(
38  "show_material_props",
39  false,
40  "Print out the material properties supplied for each block, face, neighbor, and/or sideset");
41  params.addParam<bool>("show_mesh_meta_data", false, "Print out the available mesh meta data");
42  params.addParam<bool>(
43  "show_reporters", false, "Print out information about the declared and requested Reporters");
44 
46  print_on.addAvailableFlags(EXEC_TRANSFER);
47  print_on.addAvailableFlags(EXEC_FAILED);
48  print_on.addAvailableFlags(EXEC_ALWAYS);
49  params.addParam<ExecFlagEnum>(
50  "show_execution_order",
51  print_on,
52  "Print more information about the order of execution during calculations");
53  params.addDeprecatedParam<bool>(
54  "pid_aux",
55  "Add a AuxVariable named \"pid\" that shows the processors and partitioning",
56  "pid_aux is deprecated, use output_process_domains");
57  params.addParam<bool>(
58  "output_process_domains",
59  false,
60  "Add a AuxVariable named \"pid\" that shows the partitioning for each process");
61  params.addParam<bool>(
62  "show_functors", false, "Whether to print information about the functors in the problem");
63 
64  params.addClassDescription("Adds various debugging type output to the simulation system.");
65 
66  return params;
67 }
68 
70 {
71  _awh.showActionDependencies(getParam<bool>("show_action_dependencies"));
72  _awh.showActions(getParam<bool>("show_actions"));
73  _awh.showParser(getParam<bool>("show_parser"));
74 }
75 
76 void
78 {
79  // Material properties
80  if (_pars.get<bool>("show_material_props"))
81  {
82  const std::string type = "MaterialPropertyDebugOutput";
83  auto params = _factory.getValidParams(type);
84  _problem->addOutput(type, "_moose_material_property_debug_output", params);
85  }
86 
87  // Variable residual norms
88  if (_pars.get<bool>("show_var_residual_norms"))
89  {
90  const std::string type = "VariableResidualNormsDebugOutput";
91  auto params = _factory.getValidParams(type);
92  _problem->addOutput(type, "_moose_variable_residual_norms_debug_output", params);
93  }
94 
95  // Top residuals
96  if (_pars.get<unsigned int>("show_top_residuals") > 0)
97  {
98  const std::string type = "TopResidualDebugOutput";
99  auto params = _factory.getValidParams(type);
100  params.set<unsigned int>("num_residuals") = _pars.get<unsigned int>("show_top_residuals");
101  _problem->addOutput(type, "_moose_top_residual_debug_output", params);
102  }
103 
104  // Print full names of mesh meta data
105  if (getParam<bool>("show_mesh_meta_data"))
106  {
107  _console << "Mesh meta data:\n";
108  for (auto it = _app.getRestartableDataMapBegin(); it != _app.getRestartableDataMapEnd(); ++it)
109  if (it->first == MooseApp::MESH_META_DATA)
110  for (auto & data : it->second.first)
111  _console << " " << data.name() << std::endl;
112  }
113 
114  // Print Reporter information
115  if (getParam<bool>("show_reporters"))
116  {
117  const std::string type = "ReporterDebugOutput";
118  auto params = _factory.getValidParams(type);
119  _problem->addOutput(type, "_moose_reporter_debug_output", params);
120  }
121 
122  // Print execution information in all loops
123  if (parameters().isParamSetByUser("show_execution_order"))
124  _problem->setExecutionPrinting(getParam<ExecFlagEnum>("show_execution_order"));
125 
126  // Add pid aux
127  if (getParam<bool>("output_process_domains") ||
128  (isParamValid("pid_aux") && getParam<bool>("pid_aux")))
129  {
130  if (_problem->hasVariable("pid"))
131  paramError("output_process_domains", "Variable with the name \"pid\" already exists");
132 
133  auto fe_type = FEType(CONSTANT, MONOMIAL);
135  auto var_params = _factory.getValidParams(type);
136  _problem->addAuxVariable(type, "pid", var_params);
137 
138  InputParameters params = _factory.getValidParams("ProcessorIDAux");
139  params.set<AuxVariableName>("variable") = "pid";
140  _problem->addAuxKernel("ProcessorIDAux", "pid_aux", params);
141  }
142 
143  // Add functor output
144  if (getParam<bool>("show_functors"))
145  _problem->setFunctorOutput(getParam<bool>("show_functors"));
146 }
const ExecFlagType EXEC_TRANSFER
Definition: Moose.C:47
const ExecFlagType EXEC_FAILED
Definition: Moose.C:40
A MultiMooseEnum object to hold "execute_on" flags.
Definition: ExecFlagEnum.h:21
auto getRestartableDataMapBegin()
Iterator based access to the extra RestartableDataMap objects; see Checkpoint.C for use case...
Definition: MooseApp.h:1022
void addDeprecatedParam(const std::string &name, const T &value, const std::string &doc_string, const std::string &deprecation_message)
static std::string variableType(const FEType &fe_type, const bool is_fv=false, const bool is_array=false)
Determines a variable type.
ActionWarehouse & _awh
Reference to ActionWarehouse where we store object build by actions.
Definition: Action.h:170
std::vector< std::pair< R1, R2 > > get(const std::string &param1, const std::string &param2) const
Combine two vector parameters into a single vector of pairs.
static const RestartableDataMapName MESH_META_DATA
Definition: MooseApp.h:95
virtual void act() override
Method to add objects to the simulation or perform other setup tasks.
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
void showActions(bool state=true)
This method sets a Boolean which is used to show information about action execution of various wareho...
InputParameters getValidParams(const std::string &name) const
Get valid parameters for the object.
Definition: Factory.C:67
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
void showActionDependencies(bool state=true)
This method sets a Boolean which is used to print information about action dependencies before variou...
const ExecFlagType EXEC_ALWAYS
Definition: Moose.C:43
registerMooseAction("MooseApp", SetupDebugAction, "add_output")
Base class for actions.
Definition: Action.h:38
SetupDebugAction(const InputParameters &parameters)
ExecFlagEnum getDefaultExecFlagEnum()
Return the default ExecFlagEnum for MOOSE.
Definition: MooseUtils.C:1056
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
Factory & _factory
The Factory associated with the MooseApp.
CONSTANT
void showParser(bool state=true)
This method sets a Boolean which is used to show debugging information when actions are inserted in t...
static InputParameters validParams()
Definition: Action.C:24
const std::string & type() const
Get the type of this class.
Definition: MooseBase.h:51
MooseApp & _app
The MOOSE application this is associated with.
Definition: MooseBase.h:84
void paramError(const std::string &param, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
MONOMIAL
bool isParamSetByUser(const std::string &nm) const
Test if the supplied parameter is set by a user, as opposed to not set or set to default.
auto getRestartableDataMapEnd()
Definition: MooseApp.h:1024
const InputParameters & _pars
Parameters of this object, references the InputParameters stored in the InputParametersWarehouse.
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump...
std::shared_ptr< FEProblemBase > & _problem
Convenience reference to a problem this action works on.
Definition: Action.h:179
const InputParameters & parameters() const
Get the parameters of the object.
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an option parameter and a documentation string to the InputParameters object...
const ConsoleStream _console
An instance of helper class to write streams to the Console objects.
static InputParameters validParams()