Line data Source code
1 : //* This file is part of the MOOSE framework
2 : //* https://mooseframework.inl.gov
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 : #include "BlockRestrictionDebugOutput.h"
21 :
22 : using namespace libMesh;
23 :
24 : registerMooseAction("MooseApp", SetupDebugAction, "add_output");
25 :
26 : InputParameters
27 2029 : SetupDebugAction::validParams()
28 : {
29 2029 : InputParameters params = Action::validParams();
30 6087 : params.addParam<unsigned int>(
31 4058 : "show_top_residuals", 0, "The number of top residuals to print out (0 = no output)");
32 6087 : params.addParam<bool>(
33 : "show_var_residual_norms",
34 4058 : false,
35 : "Print the residual norms of the individual solution variables at each nonlinear iteration");
36 8116 : params.addParam<bool>("show_action_dependencies", false, "Print out the action dependencies");
37 8116 : params.addParam<bool>("show_actions", false, "Print out the actions being executed");
38 6087 : params.addParam<bool>(
39 4058 : "show_parser", false, "Shows parser block extraction and debugging information");
40 6087 : params.addParam<bool>(
41 : "show_material_props",
42 4058 : false,
43 : "Print out the material properties supplied for each block, face, neighbor, and/or sideset");
44 6087 : params.addParam<bool>("show_chain_control_data",
45 4058 : false,
46 : "Print out the chain control data on every time step setup");
47 6087 : params.addParam<bool>("show_controllable",
48 4058 : false,
49 : "Print out the controllable parameters from all input parameters");
50 8116 : params.addParam<bool>("show_mesh_meta_data", false, "Print out the available mesh meta data");
51 6087 : params.addParam<bool>(
52 4058 : "show_reporters", false, "Print out information about the declared and requested Reporters");
53 4058 : params.addParam<bool>(
54 4058 : "show_mesh_generators", false, "Print out the mesh generators being executed");
55 :
56 2029 : ExecFlagEnum print_on = MooseUtils::getDefaultExecFlagEnum();
57 2029 : print_on.addAvailableFlags(EXEC_TRANSFER);
58 2029 : print_on.addAvailableFlags(EXEC_FAILED);
59 2029 : print_on.addAvailableFlags(EXEC_ALWAYS);
60 8116 : params.addParam<ExecFlagEnum>(
61 : "show_execution_order",
62 : print_on,
63 : "Print more information about the order of execution during calculations");
64 12174 : params.addDeprecatedParam<bool>(
65 : "pid_aux",
66 : "Add a AuxVariable named \"pid\" that shows the processors and partitioning",
67 : "pid_aux is deprecated, use output_process_domains");
68 6087 : params.addParam<bool>(
69 : "output_process_domains",
70 4058 : false,
71 : "Add a AuxVariable named \"pid\" that shows the partitioning for each process");
72 6087 : params.addParam<bool>(
73 4058 : "show_functors", false, "Whether to print information about the functors in the problem");
74 6087 : params.addParam<MultiMooseEnum>(
75 : "show_block_restriction",
76 6087 : BlockRestrictionDebugOutput::getScopes("none"),
77 : "Print out active objects like variables supplied for each block.");
78 :
79 2029 : params.addClassDescription("Adds various debugging type output to the simulation system.");
80 :
81 4058 : return params;
82 2029 : }
83 :
84 1824 : SetupDebugAction::SetupDebugAction(const InputParameters & parameters) : Action(parameters)
85 : {
86 3648 : _awh.showActionDependencies(getParam<bool>("show_action_dependencies"));
87 3648 : _awh.showActions(getParam<bool>("show_actions"));
88 5472 : _awh.showParser(getParam<bool>("show_parser"));
89 3648 : _awh.mooseApp().getMeshGeneratorSystem().setVerbose(getParam<bool>("show_mesh_generators"));
90 1824 : }
91 :
92 : void
93 1808 : SetupDebugAction::act()
94 : {
95 : // Material properties
96 1808 : if (_pars.get<bool>("show_material_props"))
97 : {
98 264 : const std::string type = "MaterialPropertyDebugOutput";
99 264 : auto params = _factory.getValidParams(type);
100 528 : _problem->addOutput(type, "_moose_material_property_debug_output", params);
101 264 : }
102 :
103 : // Variable residual norms
104 1808 : if (_pars.get<bool>("show_var_residual_norms"))
105 : {
106 1059 : const std::string type = "VariableResidualNormsDebugOutput";
107 1059 : auto params = _factory.getValidParams(type);
108 : // Add one for every nonlinear system
109 2118 : for (const auto & sys_name : _problem->getNonlinearSystemNames())
110 : {
111 1059 : params.set<NonlinearSystemName>("nl_sys") = sys_name;
112 1059 : _problem->addOutput(type, "_moose_variable_residual_norms_debug_output_" + sys_name, params);
113 : }
114 1059 : }
115 :
116 : // Top residuals
117 1808 : if (_pars.get<unsigned int>("show_top_residuals") > 0)
118 : {
119 27 : const std::string type = "TopResidualDebugOutput";
120 27 : auto params = _factory.getValidParams(type);
121 54 : params.set<unsigned int>("num_residuals") = _pars.get<unsigned int>("show_top_residuals");
122 54 : _problem->addOutput(type, "_moose_top_residual_debug_output", params);
123 27 : }
124 :
125 : // Print full names of mesh meta data
126 5424 : if (getParam<bool>("show_mesh_meta_data"))
127 : {
128 37 : _console << "Mesh meta data:\n";
129 74 : for (auto it = _app.getRestartableDataMapBegin(); it != _app.getRestartableDataMapEnd(); ++it)
130 37 : if (it->first == MooseApp::MESH_META_DATA)
131 378 : for (auto & data : it->second.first)
132 341 : _console << " " << data.name() << std::endl;
133 : }
134 :
135 : // Print Reporter information
136 5424 : if (getParam<bool>("show_reporters"))
137 : {
138 10 : const std::string type = "ReporterDebugOutput";
139 10 : auto params = _factory.getValidParams(type);
140 20 : _problem->addOutput(type, "_moose_reporter_debug_output", params);
141 10 : }
142 :
143 : // Print execution information in all loops
144 5424 : if (parameters().isParamSetByUser("show_execution_order"))
145 816 : _problem->setExecutionPrinting(getParam<ExecFlagEnum>("show_execution_order"));
146 :
147 : // Add pid aux
148 9040 : if (getParam<bool>("output_process_domains") ||
149 7232 : (isParamValid("pid_aux") && getParam<bool>("pid_aux")))
150 : {
151 0 : if (_problem->hasVariable("pid"))
152 0 : paramError("output_process_domains", "Variable with the name \"pid\" already exists");
153 :
154 0 : auto fe_type = FEType(CONSTANT, MONOMIAL);
155 0 : auto type = AddAuxVariableAction::variableType(fe_type);
156 0 : auto var_params = _factory.getValidParams(type);
157 0 : _problem->addAuxVariable(type, "pid", var_params);
158 :
159 0 : InputParameters params = _factory.getValidParams("ProcessorIDAux");
160 0 : params.set<AuxVariableName>("variable") = "pid";
161 0 : params.set<ExecFlagEnum>("execute_on") = {EXEC_INITIAL, EXEC_TIMESTEP_BEGIN};
162 0 : _problem->addAuxKernel("ProcessorIDAux", "pid_aux", params);
163 0 : }
164 :
165 : // Add functor output
166 5424 : if (getParam<bool>("show_functors"))
167 108 : _problem->setFunctorOutput(getParam<bool>("show_functors"));
168 :
169 : // Add chain control data output
170 5424 : if (getParam<bool>("show_chain_control_data"))
171 13 : _problem->setChainControlDataOutput(true);
172 :
173 : // Block-restriction
174 : const MultiMooseEnum & block_restriction_scope =
175 1808 : _pars.get<MultiMooseEnum>("show_block_restriction");
176 5424 : if (block_restriction_scope.isValid() && !block_restriction_scope.contains("none"))
177 : {
178 10 : const std::string type = "BlockRestrictionDebugOutput";
179 10 : auto params = _factory.getValidParams(type);
180 10 : params.set<MultiMooseEnum>("scope") = block_restriction_scope;
181 20 : _problem->addOutput(type, "_moose_block_restriction_debug_output", params);
182 10 : }
183 :
184 : // Controllable output
185 5424 : if (getParam<bool>("show_controllable"))
186 : {
187 10 : const std::string type = "ControlOutput";
188 10 : auto params = _factory.getValidParams(type);
189 20 : _problem->addOutput(type, "_moose_controllable_debug_output", params);
190 10 : }
191 1808 : }
|