www.mooseframework.org
AdvancedOutput.h
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 #ifndef ADVANCEDOUTPUT_H
16 #define ADVANCEDOUTPUT_H
17 
18 // MOOSE includes
19 #include "AdvancedOutputUtils.h" // OutputDataWarehouse
20 #include "MooseTypes.h"
21 #include "UserObject.h"
23 #include "FileOutput.h"
24 
25 // Forward declarations
26 class OutputWarehouse;
27 class FileOutput;
28 class PetscOutput;
29 class Console;
30 class TransientMultiApp;
31 
40 class AdvancedOutput : public FileOutput
41 {
42 public:
51 
55  virtual ~AdvancedOutput();
56 
60  virtual bool hasOutput();
61 
67  bool hasOutput(const ExecFlagType & type);
68 
75 
88  const std::set<std::string> & getNodalVariableOutput();
89 
96 
102  const std::set<std::string> & getElementalVariableOutput();
103 
109  bool hasScalarOutput();
110 
116  const std::set<std::string> & getScalarOutput();
117 
123  bool hasPostprocessorOutput();
124 
130  const std::set<std::string> & getPostprocessorOutput();
131 
138 
145  const std::set<std::string> & getVectorPostprocessorOutput();
146 
177  static InputParameters enableOutputTypes(const std::string & names = std::string());
178 
182  const OutputOnWarehouse & advancedExecuteOn() const;
183 
184 protected:
189  virtual void initialSetup();
190 
195  virtual bool shouldOutput(const ExecFlagType & type);
196 
207  virtual void output(const ExecFlagType & type);
208 
214  virtual void outputNodalVariables();
215 
221  virtual void outputElementalVariables();
222 
228  virtual void outputScalarVariables();
229 
235  virtual void outputPostprocessors();
236 
241  virtual void outputVectorPostprocessors();
242 
248  virtual void outputInput();
249 
255  virtual void outputSystemInformation();
256 
257 private:
261  void initAvailableLists();
262 
269  void initExecutionTypes(const std::string & name, MultiMooseEnum & input);
270 
277  void initShowHideLists(const std::vector<VariableName> & show,
278  const std::vector<VariableName> & hide);
279 
285  template <typename postprocessor_type>
286  void initPostprocessorOrVectorPostprocessorLists(const std::string & execute_data_name);
287 
292  void initOutputList(OutputData & data);
293 
298  bool wantOutput(const std::string & name, const ExecFlagType & type);
299 
313  static void addValidParams(InputParameters & params, const MultiMooseEnum & types);
314 
319  bool hasOutputHelper(const std::string & name);
320 
325 
328 
330  std::map<std::string, Real> _last_execute_time;
331 
332  // Allow complete access
333  friend class OutputWarehouse;
334  friend class Console;
335  friend class TransientMultiApp;
336 };
337 
338 // Helper function for initAvailableLists, templated on warehouse type and postprocessor_type
339 template <typename postprocessor_type>
340 void
342 {
343 
344  // Get the UserObjectWarhouse
346 
347  // Convenience reference to the OutputData being operated on (should used "postprocessors" or
348  // "vector_postprocessors")
349  OutputData & execute_data = _execute_data[execute_data_name];
350 
351  // Build the input file parameter name (i.e. "output_postprocessors_on" or
352  // "output_vector_postprocessors_on")
353  std::ostringstream oss;
354  oss << "execute_" << execute_data_name << "_on";
355  std::string execute_on_name = oss.str();
356 
357  // True if the postprocessors has been limited using 'outputs' parameter
358  bool has_limited_pps = false;
359 
360  // Loop through each of the execution flags
361  const auto & objects = warehouse.getActiveObjects();
362  for (const auto & object : objects)
363  {
364  // Store the name in the available postprocessors, if it does not already exist in the list
365  std::shared_ptr<postprocessor_type> pps = std::dynamic_pointer_cast<postprocessor_type>(object);
366  if (!pps)
367  continue;
368 
369  execute_data.available.insert(pps->PPName());
370 
371  // Extract the list of outputs
372  const auto & pps_outputs = pps->getOutputs();
373 
374  // Check that the outputs lists are valid
375  _app.getOutputWarehouse().checkOutputs(pps_outputs);
376 
377  // Check that the output object allows postprocessor output,
378  // account for "all" keyword (if it is present assume "all" was desired)
379  if (pps_outputs.find(name()) != pps_outputs.end() ||
380  pps_outputs.find("all") != pps_outputs.end())
381  {
382  if (!_advanced_execute_on.contains(execute_data_name) ||
383  (_advanced_execute_on[execute_data_name].isValid() &&
384  _advanced_execute_on[execute_data_name].contains("none")))
385  mooseWarning(
386  "Postprocessor '",
387  pps->PPName(),
388  "' has requested to be output by the '",
389  name(),
390  "' output, but postprocessor output is not support by this type of output object.");
391  }
392 
393  // Set the flag state for postprocessors that utilize 'outputs' parameter
394  if (!pps_outputs.empty() && pps_outputs.find("all") == pps_outputs.end())
395  has_limited_pps = true;
396  }
397 
398  // Produce the warning when 'outputs' is used, but postprocessor output is disabled
399  if (has_limited_pps && isParamValid(execute_on_name))
400  {
401  const MultiMooseEnum & pp_on = getParam<MultiMooseEnum>(execute_on_name);
402  if (pp_on.contains("none"))
403  {
404  if (execute_on_name == "execute_postprocessors_on")
405  mooseWarning("A Postprocessor utilizes the 'outputs' parameter; however, postprocessor "
406  "output is disabled for the '",
407  name(),
408  "' output object.");
409  else if (execute_on_name == "execute_vectorpostprocessors_on")
410  mooseWarning("A VectorPostprocessor utilizes the 'outputs' parameter; however, vector "
411  "postprocessor output is disabled for the '",
412  name(),
413  "' output object.");
414  }
415  }
416 }
417 
418 #endif /* ADVANCEDOUTPUT_H */
const std::string & name() const
Get the name of the object.
Definition: MooseObject.h:47
virtual void outputVectorPostprocessors()
Performs output of VectorPostprocessors The child class must define this method to output the VectorP...
virtual void outputSystemInformation()
const std::set< std::string > & getPostprocessorOutput()
The list of postprocessor names that are set for output.
bool hasPostprocessorOutput()
Returns true if there exists postprocessors for output.
virtual bool hasOutput()
Returns true if any of the other has methods return true.
void mooseWarning(Args &&...args) const
Definition: MooseObject.h:89
std::map< std::string, Real > _last_execute_time
Storage for the last output time for the various output types, this is used to avoid duplicate output...
bool hasVectorPostprocessorOutput()
Returns true if there exists VectorPostprocessors for output.
OutputOnWarehouse _advanced_execute_on
Storage for the individual component execute flags.
Definition: Output.h:237
AdvancedOutput(const InputParameters &parameters)
Class constructor.
An output object for writing to the console (screen)
Definition: Console.h:30
virtual void outputElementalVariables()
Performs output of elemental nonlinear variables The child class must define this method to output th...
A helper warehouse for storing OutputData objects for the various output types.
void initExecutionTypes(const std::string &name, MultiMooseEnum &input)
Initialize the possible execution types.
bool hasOutputHelper(const std::string &name)
Helper method for checking if output types exists.
void initShowHideLists(const std::vector< VariableName > &show, const std::vector< VariableName > &hide)
Parses the user-supplied input for hiding and showing variables and postprocessors into a list for ea...
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
OutputDataWarehouse _execute_data
Storage structures for the various output types.
MultiApp Implementation for Transient Apps.
virtual ~AdvancedOutput()
Class destructor.
const std::set< std::string > & getVectorPostprocessorOutput()
The list of VectorPostprocessor names that are set for output.
A structure for storing the various lists that contain the names of the items to be exported...
void initOutputList(OutputData &data)
Initializes the list of items to be output using the available, show, and hide lists.
bool contains(const std::string &value) const
Contains methods for seeing if a value is in the MultiMooseEnum.
virtual void outputScalarVariables()
Performs output of scalar variables The child class must define this method to output the scalar vari...
void initAvailableLists()
Initializes the available lists for each of the output types.
bool hasNodalVariableOutput()
Returns true if there exists nodal nonlinear variables for output.
virtual void outputNodalVariables()
Performs output of nodal nonlinear variables The child class must define this method to output the no...
bool contains(const std::string &name)
A method for testing of a key exists.
const std::set< std::string > & getScalarOutput()
The list of scalar variables names that are set for output.
std::set< std::string > available
A list of all possible outputs.
virtual void output(const ExecFlagType &type)
A single call to this function should output all the necessary data for a single timestep.
virtual void outputInput()
Performs the output of the input file By default this method does nothing and is not called...
const ExecuteMooseObjectWarehouse< UserObject > & getUserObjects()
Return the storage of all UserObjects.
static void addValidParams(InputParameters &params, const MultiMooseEnum &types)
Method for defining the available parameters based on the types of outputs.
virtual bool shouldOutput(const ExecFlagType &type)
Handles logic for determining if a step should be output.
FEProblemBase * _problem_ptr
Pointer the the FEProblemBase object for output object (use this)
Definition: Output.h:171
void initPostprocessorOrVectorPostprocessorLists(const std::string &execute_data_name)
Helper function for initAvailableLists, templated on warehouse type and postprocessor_type.
A helper warehouse class for storing the "execute_on" settings for the various output types...
bool hasScalarOutput()
Returns true if there exists scalar variables for output.
void checkOutputs(const std::set< OutputName > &names)
Test that the output names exist.
const OutputOnWarehouse & advancedExecuteOn() const
Get the current advanced &#39;execute_on&#39; selections for display.
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
Definition: MooseObject.h:67
static InputParameters enableOutputTypes(const std::string &names=std::string())
A method for enabling individual output type control.
bool hasElementalVariableOutput()
Returns true if there exists elemental nonlinear variables for output.
Class for storing and utilizing output objects.
bool wantOutput(const std::string &name, const ExecFlagType &type)
Handles logic for determining if a step should be output.
Based class for output objects.
MatType type
virtual void initialSetup()
Initialization method.
virtual void outputPostprocessors()
Performs output of postprocessors The child class must define this method to output the postprocessor...
MooseApp & _app
The MooseApp this object is associated with.
Definition: MooseObject.h:108
const InputParameters & parameters() const
Get the parameters of the object.
Definition: MooseObject.h:53
const std::set< std::string > & getElementalVariableOutput()
The list of elemental nonlinear variables names that are set for output.
static MultiMooseEnum getOutputTypes()
Get the supported types of output (e.g., postprocessors, etc.)
const std::set< std::string > & getNodalVariableOutput()
The list of nodal nonlinear variables names that are set for output.
ExecFlagType
Execution flags - when is the object executed/evaluated.
Definition: MooseTypes.h:90
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
An outputter with filename support.
Definition: FileOutput.h:32
Adds the ability to output on every nonlinear and/or linear residual.
Definition: PetscOutput.h:30
const std::vector< std::shared_ptr< T > > & getActiveObjects(THREAD_ID tid=0) const
Retrieve complete vector to the active all/block/boundary restricted objects for a given thread...
OutputWarehouse & getOutputWarehouse()
Get the OutputWarehouse objects.
Definition: MooseApp.C:841