https://mooseframework.inl.gov
Loading...
Searching...
No Matches
CheckOutputAction.C
Go to the documentation of this file.
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// MOOSE includes
11#include "CheckOutputAction.h"
12#include "Material.h"
13#include "MooseApp.h"
14#include "Console.h"
15#include "CommonOutputAction.h"
16#include "MooseVariableFEBase.h"
17#include "MooseVariableScalar.h"
18#include "AuxiliarySystem.h"
19#include "NonlinearSystemBase.h"
20
21registerMooseAction("MooseApp", CheckOutputAction, "check_output");
22
25{
27 return params;
28}
29
31
32void
34{
35 // Perform the various output related checks
36 checkVariableOutput("add_variable");
37 checkVariableOutput("add_aux_variable");
41}
42
43void
45{
46 if (_problem.get() == nullptr)
47 return;
48
49 if (task == "add_variable")
50 {
51 for (const auto i : make_range(_problem->numNonlinearSystems()))
52 {
53 const auto & field_vars = _problem->getNonlinearSystemBase(i).getVariables(/*tid =*/0);
54 for (const auto & var : field_vars)
55 {
56 std::set<OutputName> outputs = var->getOutputs();
58 }
59
60 const auto & scalar_vars = _problem->getNonlinearSystemBase(i).getScalarVariables(/*tid =*/0);
61 for (const auto & var : scalar_vars)
62 {
63 std::set<OutputName> outputs = var->getOutputs();
65 }
66 }
67 }
68
69 else if (task == "add_aux_variable")
70 {
71 const auto & field_vars = _problem->getAuxiliarySystem().getVariables(/*tid =*/0);
72 for (const auto & var : field_vars)
73 {
74 std::set<OutputName> outputs = var->getOutputs();
76 }
77
78 const auto & scalar_vars = _problem->getAuxiliarySystem().getScalarVariables(/*tid =*/0);
79 for (const auto & var : scalar_vars)
80 {
81 std::set<OutputName> outputs = var->getOutputs();
83 }
84 }
85}
86
87void
89{
90 // Do nothing if _problem is NULL (this is the case for coupled problems)
91 // Do not produce warning, you will get a warning from OutputAction
92 if (_problem.get() == NULL)
93 return;
94
95 // A complete list of all Material objects
96 const auto & materials = _problem->getMaterialWarehouse().getActiveObjects();
97
98 // TODO include boundary materials
99
100 // Loop through each material object
101 for (const auto & mat : materials)
102 {
103 // Extract the names of the output objects to which the material properties will be exported
104 std::set<OutputName> outputs = mat->getOutputs();
105
106 // Check that the outputs exist, and that the output types support material output
107 _app.getOutputWarehouse().checkOutputs(outputs, /* supports_material_output = */ true);
108 }
109}
110
111void
113{
114 // Warning if multiple Console objects are added with 'output_screen=true' in the input file
115 std::vector<Console *> console_ptrs = _app.getOutputWarehouse().getOutputs<Console>();
116 unsigned int num_screen_outputs = 0;
117 for (const auto & console : console_ptrs)
118 if (console->getParam<bool>("output_screen"))
119 num_screen_outputs++;
120
121 if (num_screen_outputs > 1)
122 mooseWarning("Multiple (",
123 num_screen_outputs,
124 ") Console output objects are writing to the "
125 "screen, this will likely cause duplicate "
126 "messages printed.");
127}
128
129void
131{
132
133 // Search for the existence of a Console output object
134 bool has_console = false;
135 std::vector<Console *> ptrs = _app.getOutputWarehouse().getOutputs<Console>();
136 for (const auto & console : ptrs)
137 if (console->getParam<bool>("output_screen"))
138 {
139 has_console = true;
140 break;
141 }
142
143 // If a Console outputter is found then all the correct handling of performance logs are
144 // handled within the object(s), so do nothing
145 if (!has_console)
147}
registerMooseAction("MooseApp", CheckOutputAction, "check_output")
Base class for actions.
Definition Action.h:38
static InputParameters validParams()
Definition Action.C:26
MooseApp & _app
The MOOSE application this is associated with.
Definition MooseBase.h:375
std::shared_ptr< FEProblemBase > & _problem
Convenience reference to a problem this action works on.
Definition Action.h:178
Action for checking that "outputs" is properly populated for Materials.
void checkConsoleOutput()
Performs Console Output object related checks.
CheckOutputAction(const InputParameters &params)
virtual void act() override
Method to add objects to the simulation or perform other setup tasks.
void checkVariableOutput(const std::string &task)
Performs check for "outputs" option for Variables and AuxVariables blocks.
void checkPerfLogOutput()
Performs PerfLog output settings.
void checkMaterialOutput()
Performs a set of checks on each of the Material objects that the "outputs" parameters has valid valu...
static InputParameters validParams()
An output object for writing to the console (screen)
Definition Console.h:19
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
OutputWarehouse & getOutputWarehouse()
Get the OutputWarehouse objects.
Definition MooseApp.C:2409
std::vector< T * > getOutputs(const std::vector< OutputName > &names)
Return a vector of objects by names.
void checkOutputs(const std::set< OutputName > &names, const bool supports_material_output=false)
Test that the output names exist.
void mooseWarning(Args &&... args) const
void disable_logging()
PerfLog perflog("libMesh", #ifdef LIBMESH_ENABLE_PERFORMANCE_LOGGING true #else false #endif)