forked from idaholab/moose
/
SetupDebugAction.C
122 lines (107 loc) · 4.17 KB
/
SetupDebugAction.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
//* This file is part of the MOOSE framework
//* https://www.mooseframework.org
//*
//* All rights reserved, see COPYRIGHT for full restrictions
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
//*
//* Licensed under LGPL 2.1, please see LICENSE for details
//* https://www.gnu.org/licenses/lgpl-2.1.html
#include "SetupDebugAction.h"
#include "FEProblem.h"
#include "ActionWarehouse.h"
#include "Factory.h"
#include "Output.h"
#include "MooseApp.h"
#include "MooseObjectAction.h"
#include "ActionFactory.h"
#include "AddAuxVariableAction.h"
registerMooseAction("MooseApp", SetupDebugAction, "add_output");
defineLegacyParams(SetupDebugAction);
InputParameters
SetupDebugAction::validParams()
{
InputParameters params = Action::validParams();
params.addParam<unsigned int>(
"show_top_residuals", 0, "The number of top residuals to print out (0 = no output)");
params.addParam<bool>(
"show_var_residual_norms",
false,
"Print the residual norms of the individual solution variables at each nonlinear iteration");
params.addParam<bool>("show_actions", false, "Print out the actions being executed");
params.addParam<bool>(
"show_parser", false, "Shows parser block extraction and debugging information");
params.addParam<bool>(
"show_material_props",
false,
"Print out the material properties supplied for each block, face, neighbor, and/or sideset");
params.addParam<bool>("show_mesh_meta_data", false, "Print out the available mesh meta data");
params.addParam<bool>(
"show_reporters", false, "Print out information about the declared and requested Reporters");
params.addParam<bool>(
"pid_aux",
false,
"Add a AuxVariable named \"pid\" that shows the processors and partitioning");
params.addClassDescription(
"Adds various debugging type Output objects to the simulation system.");
return params;
}
SetupDebugAction::SetupDebugAction(InputParameters parameters) : Action(parameters)
{
_awh.showActions(getParam<bool>("show_actions"));
_awh.showParser(getParam<bool>("show_parser"));
}
void
SetupDebugAction::act()
{
// Material properties
if (_pars.get<bool>("show_material_props"))
{
const std::string type = "MaterialPropertyDebugOutput";
auto params = _factory.getValidParams(type);
_problem->addOutput(type, "_moose_material_property_debug_output", params);
}
// Variable residusl norms
if (_pars.get<bool>("show_var_residual_norms"))
{
const std::string type = "VariableResidualNormsDebugOutput";
auto params = _factory.getValidParams(type);
_problem->addOutput(type, "_moose_variable_residual_norms_debug_output", params);
}
// Top residuals
if (_pars.get<unsigned int>("show_top_residuals") > 0)
{
const std::string type = "TopResidualDebugOutput";
auto params = _factory.getValidParams(type);
params.set<unsigned int>("num_residuals") = _pars.get<unsigned int>("show_top_residuals");
_problem->addOutput(type, "_moose_top_residual_debug_output", params);
}
// Print full names of mesh meta data
if (getParam<bool>("show_mesh_meta_data"))
{
_console << "Mesh meta data:\n";
for (auto it = _app.getRestartableDataMapBegin(); it != _app.getRestartableDataMapEnd(); ++it)
if (it->first == MooseApp::MESH_META_DATA)
for (auto & pair : it->second.first)
_console << " " << pair.first << std::endl;
}
// Print Reporter information
if (getParam<bool>("show_reporters"))
{
const std::string type = "ReporterDebugOutput";
auto params = _factory.getValidParams(type);
_problem->addOutput(type, "_moose_reporter_debug_output", params);
}
// Add pid aux
if (getParam<bool>("pid_aux"))
{
if (_problem->hasVariable("pid"))
paramError("pid_aux", "Variable with the name \"pid\" already exists");
auto fe_type = FEType(CONSTANT, MONOMIAL);
auto type = AddAuxVariableAction::determineType(fe_type, 1);
auto var_params = _factory.getValidParams(type);
_problem->addAuxVariable(type, "pid", var_params);
InputParameters params = _factory.getValidParams("ProcessorIDAux");
params.set<AuxVariableName>("variable") = "pid";
_problem->addAuxKernel("ProcessorIDAux", "pid_aux", params);
}
}