www.mooseframework.org
SetupDebugAction.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14 
15 #include "SetupDebugAction.h"
16 #include "FEProblem.h"
17 #include "ActionWarehouse.h"
18 #include "Factory.h"
19 #include "Output.h"
20 #include "MooseApp.h"
21 #include "MooseObjectAction.h"
22 #include "ActionFactory.h"
23 
24 template <>
27 {
29  params.addParam<unsigned int>(
30  "show_top_residuals", 0, "The number of top residuals to print out (0 = no output)");
31  params.addParam<bool>(
32  "show_var_residual_norms",
33  false,
34  "Print the residual norms of the individual solution variables at each nonlinear iteration");
35  params.addParam<bool>("show_actions", false, "Print out the actions being executed");
36  params.addParam<bool>(
37  "show_parser", false, "Shows parser block extraction and debugging information");
38  params.addParam<bool>(
39  "show_material_props",
40  false,
41  "Print out the material properties supplied for each block, face, neighbor, and/or sideset");
42  return params;
43 }
44 
46  : Action(parameters), _action_params(_action_factory.getValidParams("AddOutputAction"))
47 {
48  _awh.showActions(getParam<bool>("show_actions"));
49  _awh.showParser(getParam<bool>("show_parser"));
50 
51  // Set the ActionWarehouse pointer in the parameters that will be passed to the actions created
52  // with this action
54 }
55 
56 void
58 {
59  // Material properties
60  if (_pars.get<bool>("show_material_props"))
61  createOutputAction("MaterialPropertyDebugOutput", "_moose_material_property_debug_output");
62 
63  // Variable residusl norms
64  if (_pars.get<bool>("show_var_residual_norms"))
65  createOutputAction("VariableResidualNormsDebugOutput",
66  "_moose_variable_residual_norms_debug_output");
67 
68  // Top residuals
69  if (_pars.get<unsigned int>("show_top_residuals") > 0)
70  {
71  MooseObjectAction * action =
72  createOutputAction("TopResidualDebugOutput", "_moose_top_residual_debug_output");
73  action->getObjectParams().set<unsigned int>("num_residuals") =
74  _pars.get<unsigned int>("show_top_residuals");
75  }
76 }
77 
79 SetupDebugAction::createOutputAction(const std::string & type, const std::string & name)
80 {
81  // Set the 'type =' parameters for the desired object
82  _action_params.set<std::string>("type") = type;
83 
84  // Create the action
85  std::shared_ptr<MooseObjectAction> action = std::static_pointer_cast<MooseObjectAction>(
86  _action_factory.create("AddOutputAction", name, _action_params));
87 
88  // Set the object parameters
89  InputParameters & object_params = action->getObjectParams();
90  object_params.set<bool>("_built_by_moose") = true;
91 
92  // Add the action to the warehouse
93  _awh.addActionBlock(action);
94 
95  // Return the pointer to the action
96  return action.get();
97 }
ActionWarehouse & _awh
Reference to ActionWarehouse where we store object build by actions.
Definition: Action.h:122
ActionFactory & _action_factory
Builds Actions.
Definition: Action.h:104
virtual void act() override
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 debugging information during various warehouse opera...
Storage for action instances.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
void addActionBlock(std::shared_ptr< Action > blk)
This method add an Action instance to the warehouse.
Base class for actions.
Definition: Action.h:39
InputParameters validParams< SetupDebugAction >()
const std::string & type() const
Definition: Action.h:61
void showParser(bool state=true)
MooseObjectAction * createOutputAction(const std::string &type, const std::string &name)
Helper method for creating Output actions.
InputParameters & getObjectParams()
Retreive the parameters of the object to be created by this action.
InputParameters _pars
Input parameters for the action.
Definition: Action.h:86
SetupDebugAction(InputParameters parameters)
const std::string & name() const
The name of the action.
Definition: Action.h:51
std::shared_ptr< Action > create(const std::string &action, const std::string &action_name, InputParameters parameters)
Definition: ActionFactory.C:26
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...
InputParameters _action_params
Parameters from the action being created (AddOutputAction)
InputParameters validParams< Action >()
Definition: Action.C:23