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 
19 registerMooseAction("MooseApp", SetupDebugAction, "add_output");
20 
21 template <>
24 {
26  params.addParam<unsigned int>(
27  "show_top_residuals", 0, "The number of top residuals to print out (0 = no output)");
28  params.addParam<bool>(
29  "show_var_residual_norms",
30  false,
31  "Print the residual norms of the individual solution variables at each nonlinear iteration");
32  params.addParam<bool>("show_actions", false, "Print out the actions being executed");
33  params.addParam<bool>(
34  "show_parser", false, "Shows parser block extraction and debugging information");
35  params.addParam<bool>(
36  "show_material_props",
37  false,
38  "Print out the material properties supplied for each block, face, neighbor, and/or sideset");
39 
40  params.addClassDescription(
41  "Adds various debugging type Outputters to the simulation system based on user parameters");
42 
43  return params;
44 }
45 
47 {
48  _awh.showActions(getParam<bool>("show_actions"));
49  _awh.showParser(getParam<bool>("show_parser"));
50 }
51 
52 void
54 {
55  // Material properties
56  if (_pars.get<bool>("show_material_props"))
57  {
58  const std::string type = "MaterialPropertyDebugOutput";
59  auto params = _factory.getValidParams(type);
60  _problem->addOutput(type, "_moose_material_property_debug_output", params);
61  }
62 
63  // Variable residusl norms
64  if (_pars.get<bool>("show_var_residual_norms"))
65  {
66  const std::string type = "VariableResidualNormsDebugOutput";
67  auto params = _factory.getValidParams(type);
68  _problem->addOutput(type, "_moose_variable_residual_norms_debug_output", params);
69  }
70 
71  // Top residuals
72  if (_pars.get<unsigned int>("show_top_residuals") > 0)
73  {
74  const std::string type = "TopResidualDebugOutput";
75  auto params = _factory.getValidParams(type);
76  params.set<unsigned int>("num_residuals") = _pars.get<unsigned int>("show_top_residuals");
77  _problem->addOutput(type, "_moose_top_residual_debug_output", params);
78  }
79 }
ActionWarehouse & _awh
Reference to ActionWarehouse where we store object build by actions.
Definition: Action.h:207
InputParameters getValidParams(const std::string &name)
Get valid parameters for the object.
Definition: Factory.C:67
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 debugging information during various warehouse opera...
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
Factory & _factory
The Factory associated with the MooseApp.
Definition: Action.h:186
registerMooseAction("MooseApp", SetupDebugAction, "add_output")
Base class for actions.
Definition: Action.h:35
InputParameters validParams< SetupDebugAction >()
void showParser(bool state=true)
InputParameters _pars
Input parameters for the action.
Definition: Action.h:171
SetupDebugAction(InputParameters parameters)
const std::string & type() const
Definition: Action.h:86
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:216
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 validParams< Action >()
Definition: Action.C:22