www.mooseframework.org
CheckOutputAction.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14 
15 // MOOSE includes
16 #include "CheckOutputAction.h"
17 #include "Material.h"
18 #include "MooseApp.h"
19 #include "Console.h"
20 #include "CommonOutputAction.h"
21 #include "AddVariableAction.h"
22 
23 template <>
26 {
28  return params;
29 }
30 
32 
33 void
35 {
36  // Perform the various output related checks
37  checkVariableOutput("add_variable");
38  checkVariableOutput("add_aux_variable");
42 }
43 
44 void
45 CheckOutputAction::checkVariableOutput(const std::string & task)
46 {
47  if (_awh.hasActions(task))
48  {
49  // Loop through the actions for the given task
50  const auto & actions = _awh.getActionListByName(task);
51  for (const auto & act : actions)
52  {
53  // Cast the object to AddVariableAction so that that
54  // OutputInterface::buildOutputHideVariableList may be called
55  AddVariableAction * ptr = dynamic_cast<AddVariableAction *>(act);
56 
57  // If the cast fails move to the next action, this is the case with NodalNormals which is also
58  // associated with
59  // the "add_aux_variable" task.
60  if (ptr == NULL)
61  continue;
62 
63  // Create the hide list for the action
64  std::set<std::string> names_set;
65  names_set.insert(ptr->name());
66  ptr->buildOutputHideVariableList(names_set);
67  }
68  }
69 }
70 
71 void
73 {
74  // Do nothing if _problem is NULL (this is the case for coupled problems)
75  // Do not produce warning, you will get a warning from OutputAction
76  if (_problem.get() == NULL)
77  return;
78 
79  // A complete list of all Material objects
80  const auto & materials = _problem->getMaterialWarehouse().getActiveObjects();
81 
82  // TODO include boundary materials
83 
84  // Loop through each material object
85  for (const auto & mat : materials)
86  {
87  // Extract the names of the output objects to which the material properties will be exported
88  std::set<OutputName> outputs = mat->getOutputs();
89 
90  // Check that the outputs exist
92  }
93 }
94 
95 void
97 {
98  // Warning if multiple Console objects are added with 'output_screen=true' in the input file
99  std::vector<Console *> console_ptrs = _app.getOutputWarehouse().getOutputs<Console>();
100  unsigned int num_screen_outputs = 0;
101  for (const auto & console : console_ptrs)
102  if (console->getParam<bool>("output_screen"))
103  num_screen_outputs++;
104 
105  if (num_screen_outputs > 1)
106  mooseWarning("Multiple (",
107  num_screen_outputs,
108  ") Console output objects are writing to the "
109  "screen, this will likely cause duplicate "
110  "messages printed.");
111 }
112 
113 void
115 {
116 
117  // Search for the existence of a Console output object
118  bool has_console = false;
119  std::vector<Console *> ptrs = _app.getOutputWarehouse().getOutputs<Console>();
120  for (const auto & console : ptrs)
121  if (console->getParam<bool>("output_screen"))
122  {
123  has_console = true;
124  break;
125  }
126 
127  // If a Console outputter is found then all the correct handling of performance logs are
128  // handled within the object(s), so do nothing
129  if (!has_console)
130  {
131  Moose::perf_log.disable_logging();
132  libMesh::perflog.disable_logging();
133  }
134 }
ActionWarehouse & _awh
Reference to ActionWarehouse where we store object build by actions.
Definition: Action.h:122
void checkMaterialOutput()
Preforms a set of checks on each of the Material objects that the "outputs" parameters has valid valu...
Adds nonlinear variable.
An output object for writing to the console (screen)
Definition: Console.h:30
const std::list< Action * > & getActionListByName(const std::string &task) const
Retrieve a constant list of Action pointers associated with the passed in task.
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...
bool hasActions(const std::string &task) const
Check if Actions associated with passed in task exist.
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:39
void checkPerfLogOutput()
Performs PerfLog output settings.
PerfLog perf_log
Perflog to be used by applications.
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 >()
const std::string & name() const
The name of the action.
Definition: Action.h:51
std::shared_ptr< FEProblemBase > & _problem
Convenience reference to a problem this action works on.
Definition: Action.h:131
virtual void act() override
MooseApp & _app
The MOOSE application this is associated with.
Definition: Action.h:98
OutputWarehouse & getOutputWarehouse()
Get the OutputWarehouse objects.
Definition: MooseApp.C:840
InputParameters validParams< Action >()
Definition: Action.C:23
void mooseWarning(Args &&...args)
Emit a warning message with the given stringified, concatenated args.
Definition: MooseError.h:194