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
10 #pragma once
12 // MOOSE includes
13 #include "AdvancedOutputUtils.h" // OutputDataWarehouse
14 #include "MooseTypes.h"
15 #include "UserObject.h"
17 #include "FileOutput.h"
19 // Forward declarations
20 class OutputWarehouse;
21 class FileOutput;
22 class PetscOutput;
23 class Console;
24 class TransientMultiApp;
26 class AdvancedOutput;
28 template <>
39 class AdvancedOutput : public FileOutput
40 {
41 public:
54  virtual ~AdvancedOutput();
59  virtual bool hasOutput();
66  bool hasOutput(const ExecFlagType & type);
87  const std::set<std::string> & getNodalVariableOutput();
101  const std::set<std::string> & getElementalVariableOutput();
108  bool hasScalarOutput();
115  const std::set<std::string> & getScalarOutput();
122  bool hasPostprocessorOutput();
129  const std::set<std::string> & getPostprocessorOutput();
144  const std::set<std::string> & getVectorPostprocessorOutput();
176  static InputParameters enableOutputTypes(const std::string & names = std::string());
181  const OutputOnWarehouse & advancedExecuteOn() const;
183 protected:
188  virtual void initialSetup();
194  virtual bool shouldOutput(const ExecFlagType & type);
206  virtual void output(const ExecFlagType & type);
213  virtual void outputNodalVariables();
220  virtual void outputElementalVariables();
227  virtual void outputScalarVariables();
234  virtual void outputPostprocessors();
240  virtual void outputVectorPostprocessors();
247  virtual void outputInput();
254  virtual void outputSystemInformation();
261 private:
265  void initAvailableLists();
273  void initExecutionTypes(const std::string & name, ExecFlagEnum & input);
281  void initShowHideLists(const std::vector<VariableName> & show,
282  const std::vector<VariableName> & hide);
289  template <typename postprocessor_type>
290  void initPostprocessorOrVectorPostprocessorLists(const std::string & execute_data_name);
296  void initOutputList(OutputData & data);
302  bool wantOutput(const std::string & name, const ExecFlagType & type);
317  static void addValidParams(InputParameters & params, const MultiMooseEnum & types);
323  bool hasOutputHelper(const std::string & name);
334  std::map<std::string, Real> _last_execute_time;
336  // Allow complete access
337  friend class OutputWarehouse;
338  friend class Console;
339  friend class TransientMultiApp;
340 };
342 // Helper function for initAvailableLists, templated on warehouse type and postprocessor_type
343 template <typename postprocessor_type>
344 void
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];
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();
357  // True if the postprocessors has been limited using 'outputs' parameter
358  bool has_limited_pps = false;
360  std::vector<UserObject *> objs;
362  .query()
363  .condition<AttribSystem>("UserObject")
364  .condition<AttribThread>(0)
365  .queryInto(objs);
367  for (const auto & obj : objs)
368  {
369  auto pps = dynamic_cast<postprocessor_type *>(obj);
370  if (!pps)
371  continue;
373  execute_data.available.insert(pps->PPName());
375  // Extract the list of outputs
376  const auto & pps_outputs = pps->getOutputs();
378  // Check that the outputs lists are valid
379  _app.getOutputWarehouse().checkOutputs(pps_outputs);
381  // Check that the output object allows postprocessor output,
382  // account for "all" keyword (if it is present assume "all" was desired)
383  if (pps_outputs.find(name()) != pps_outputs.end() ||
384  pps_outputs.find("all") != pps_outputs.end())
385  {
386  if (!_advanced_execute_on.contains(execute_data_name) ||
387  (_advanced_execute_on[execute_data_name].isValid() &&
388  _advanced_execute_on[execute_data_name].contains("none")))
389  mooseWarning(
390  "Postprocessor '",
391  pps->PPName(),
392  "' has requested to be output by the '",
393  name(),
394  "' output, but postprocessor output is not support by this type of output object.");
395  }
397  // Set the flag state for postprocessors that utilize 'outputs' parameter
398  if (!pps_outputs.empty() && pps_outputs.find("all") == pps_outputs.end())
399  has_limited_pps = true;
400  }
402  // Produce the warning when 'outputs' is used, but postprocessor output is disabled
403  if (has_limited_pps && isParamValid(execute_on_name))
404  {
405  const ExecFlagEnum & pp_on = getParam<ExecFlagEnum>(execute_on_name);
406  if (pp_on.contains(EXEC_NONE))
407  {
408  if (execute_on_name == "execute_postprocessors_on")
409  mooseWarning("A Postprocessor utilizes the 'outputs' parameter; however, postprocessor "
410  "output is disabled for the '",
411  name(),
412  "' output object.");
413  else if (execute_on_name == "execute_vectorpostprocessors_on")
414  mooseWarning("A VectorPostprocessor utilizes the 'outputs' parameter; however, vector "
415  "postprocessor output is disabled for the '",
416  name(),
417  "' output object.");
418  }
419  }
420 }
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.
A MultiMooseEnum object to hold "execute_on" flags.
Definition: ExecFlagEnum.h:24
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:242
void mooseWarning(Args &&... args) const
Definition: MooseObject.h:155
AdvancedOutput(const InputParameters &parameters)
Class constructor.
An output object for writing to the console (screen)
Definition: Console.h:24
virtual void outputElementalVariables()
Performs output of elemental nonlinear variables The child class must define this method to output th...
InputParameters validParams< AdvancedOutput >()
A helper warehouse for storing OutputData objects for the various output types.
const ExecFlagType EXEC_NONE
bool hasOutputHelper(const std::string &name)
Helper method for checking if output types exists.
bool _elemental_as_nodal
Flags to control nodal output.
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.
virtual void outputScalarVariables()
Performs output of scalar variables The child class must define this method to output the scalar vari...
Query & condition(Args &&... args)
Adds a new condition to the query.
Definition: TheWarehouse.h:157
const std::string & type() const
Get the type of this object.
Definition: MooseObject.h:53
const OutputOnWarehouse & advancedExecuteOn() const
Get the current advanced &#39;execute_on&#39; selections for display.
void initAvailableLists()
Initializes the available lists for each of the output types.
bool contains(const std::string &value) const
Contains methods for seeing if a value is in the MultiMooseEnum.
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.
TheWarehouse & theWarehouse() const
std::set< std::string > available
A list of all possible outputs.
const InputParameters & parameters() const
Get the parameters of the object.
Definition: MooseObject.h:65
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...
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:167
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.
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.
virtual void initialSetup()
Initialization method.
Class for containing MooseEnum item information.
Definition: MooseEnumItem.h:21
virtual void outputPostprocessors()
Performs output of postprocessors The child class must define this method to output the postprocessor...
Query query()
query creates and returns an initialized a query object for querying objects from the warehouse...
Definition: TheWarehouse.h:239
MooseApp & _app
The MooseApp this object is associated with.
Definition: MooseObject.h:177
const std::string & name() const
Get the name of the object.
Definition: MooseObject.h:59
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.
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:26
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
Definition: MooseObject.h:89
Adds the ability to output on every nonlinear and/or linear residual.
Definition: PetscOutput.h:24
void initExecutionTypes(const std::string &name, ExecFlagEnum &input)
Initialize the possible execution types.
OutputWarehouse & getOutputWarehouse()
Get the OutputWarehouse objects.
Definition: MooseApp.C:1055