www.mooseframework.org
CheckOutputAction.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 // MOOSE includes
11 #include "CheckOutputAction.h"
12 #include "Material.h"
13 #include "MooseApp.h"
14 #include "Console.h"
15 #include "CommonOutputAction.h"
16 #include "AddVariableAction.h"
17 
18 registerMooseAction("MooseApp", CheckOutputAction, "check_output");
19 
20 template <>
23 {
25  return params;
26 }
27 
29 
30 void
32 {
33  // Perform the various output related checks
34  checkVariableOutput("add_variable");
35  checkVariableOutput("add_aux_variable");
39 }
40 
41 void
42 CheckOutputAction::checkVariableOutput(const std::string & task)
43 {
44  // Loop through the actions for the given task
45  const auto & actions = _awh.getActionListByName(task);
46  for (const auto & act : actions)
47  {
48  // Cast the object to AddVariableAction so that that
49  // OutputInterface::buildOutputHideVariableList may be called
50  AddVariableAction * ptr = dynamic_cast<AddVariableAction *>(act);
51 
52  // If the cast fails move to the next action, this is the case with NodalNormals which is also
53  // associated with
54  // the "add_aux_variable" task.
55  if (ptr == NULL)
56  continue;
57 
58  // Create the hide list for the action
59  std::set<std::string> names_set;
60  names_set.insert(ptr->name());
61  ptr->buildOutputHideVariableList(names_set);
62  }
63 }
64 
65 void
67 {
68  // Do nothing if _problem is NULL (this is the case for coupled problems)
69  // Do not produce warning, you will get a warning from OutputAction
70  if (_problem.get() == NULL)
71  return;
72 
73  // A complete list of all Material objects
74  const auto & materials = _problem->getMaterialWarehouse().getActiveObjects();
75 
76  // TODO include boundary materials
77 
78  // Loop through each material object
79  for (const auto & mat : materials)
80  {
81  // Extract the names of the output objects to which the material properties will be exported
82  std::set<OutputName> outputs = mat->getOutputs();
83 
84  // Check that the outputs exist
86  }
87 }
88 
89 void
91 {
92  // Warning if multiple Console objects are added with 'output_screen=true' in the input file
93  std::vector<Console *> console_ptrs = _app.getOutputWarehouse().getOutputs<Console>();
94  unsigned int num_screen_outputs = 0;
95  for (const auto & console : console_ptrs)
96  if (console->getParam<bool>("output_screen"))
97  num_screen_outputs++;
98 
99  if (num_screen_outputs > 1)
100  mooseWarning("Multiple (",
101  num_screen_outputs,
102  ") Console output objects are writing to the "
103  "screen, this will likely cause duplicate "
104  "messages printed.");
105 }
106 
107 void
109 {
110 
111  // Search for the existence of a Console output object
112  bool has_console = false;
113  std::vector<Console *> ptrs = _app.getOutputWarehouse().getOutputs<Console>();
114  for (const auto & console : ptrs)
115  if (console->getParam<bool>("output_screen"))
116  {
117  has_console = true;
118  break;
119  }
120 
121  // If a Console outputter is found then all the correct handling of performance logs are
122  // handled within the object(s), so do nothing
123  if (!has_console)
124  {
125  Moose::perf_log.disable_logging();
126  libMesh::perflog.disable_logging();
127  }
128 }
ActionWarehouse & _awh
Reference to ActionWarehouse where we store object build by actions.
Definition: Action.h:207
void checkMaterialOutput()
Preforms a set of checks on each of the Material objects that the "outputs" parameters has valid valu...
const std::string & name() const
The name of the action.
Definition: Action.h:76
Adds nonlinear variable.
An output object for writing to the console (screen)
Definition: Console.h:24
void mooseWarning(Args &&... args)
Emit a warning message with the given stringified, concatenated args.
Definition: MooseError.h:219
std::vector< T * > getOutputs(const std::vector< OutputName > &names)
Return a vector of objects by names.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
const std::list< Action * > & getActionListByName(const std::string &task) const
Retrieve a constant list of Action pointers associated with the passed in task.
void checkVariableOutput(const std::string &task)
Performs check for "outputs" option for Variables and AuxVariables blocks.
void checkConsoleOutput()
Performs Console Output object related checks.
Base class for actions.
Definition: Action.h:35
void checkPerfLogOutput()
Performs PerfLog output settings.
Action for checking that "outputs" is properly populated for Materials.
PerfLog perf_log
Perflog to be used by applications.
registerMooseAction("MooseApp", CheckOutputAction, "check_output")
void checkOutputs(const std::set< OutputName > &names)
Test that the output names exist.
void buildOutputHideVariableList(std::set< std::string > variable_names)
Builds hide lists for output objects NOT listed in the &#39;outputs&#39; parameter.
CheckOutputAction(InputParameters params)
Class constructor.
InputParameters validParams< CheckOutputAction >()
std::shared_ptr< FEProblemBase > & _problem
Convenience reference to a problem this action works on.
Definition: Action.h:216
virtual void act() override
Method to add objects to the simulation or perform other setup tasks.
MooseApp & _app
The MOOSE application this is associated with.
Definition: Action.h:183
OutputWarehouse & getOutputWarehouse()
Get the OutputWarehouse objects.
Definition: MooseApp.C:1055
InputParameters validParams< Action >()
Definition: Action.C:22