https://mooseframework.inl.gov
AdvancedOutput.h
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 #pragma once
11 
12 // MOOSE includes
13 #include "AdvancedOutputUtils.h" // OutputDataWarehouse
14 #include "MooseTypes.h"
15 #include "UserObject.h"
17 #include "FileOutput.h"
18 
19 // Forward declarations
20 class OutputWarehouse;
21 class FileOutput;
22 class PetscOutput;
23 class Console;
24 class TransientMultiApp;
25 
34 class AdvancedOutput : public FileOutput
35 {
36 public:
38 
47 
51  virtual ~AdvancedOutput();
52 
56  virtual bool hasOutput();
57 
63  bool hasOutput(const ExecFlagType & type);
64 
71 
84  const std::set<std::string> & getNodalVariableOutput();
85 
92 
98  const std::set<std::string> & getElementalVariableOutput();
99 
105  bool hasScalarOutput();
106 
112  const std::set<std::string> & getScalarOutput();
113 
119  bool hasPostprocessorOutput();
120 
126  const std::set<std::string> & getPostprocessorOutput();
127 
134 
141  const std::set<std::string> & getVectorPostprocessorOutput();
142 
148  bool hasReporterOutput();
149 
155  const std::set<std::string> & getReporterOutput();
156 
187  static InputParameters enableOutputTypes(const std::string & names = std::string());
188 
192  const OutputOnWarehouse & advancedExecuteOn() const;
193 
194 protected:
196  virtual void initialSetup();
197 
201  virtual void init();
202 
204  void hideAdditionalVariable(const std::string & category, const std::string & var_name)
205  {
206  _execute_data[category].hide.insert(var_name);
207  _execute_data[category].output.erase(var_name);
208  }
209 
214  virtual bool shouldOutput();
215 
226  virtual void output();
227 
233  virtual void outputNodalVariables();
234 
240  virtual void outputElementalVariables();
241 
247  virtual void outputScalarVariables();
248 
254  virtual void outputPostprocessors();
255 
260  virtual void outputVectorPostprocessors();
261 
267  virtual void outputInput();
268 
274  virtual void outputSystemInformation();
275 
281  virtual void outputReporters();
282 
286  void clearLastExecuteTime();
287 
292 
295 
296 private:
300  void initAvailableLists();
301 
308  void initExecutionTypes(const std::string & name, ExecFlagEnum & input);
309 
316  void initShowHideLists(const std::vector<VariableName> & show,
317  const std::vector<VariableName> & hide);
318 
324  template <typename postprocessor_type>
325  void initPostprocessorOrVectorPostprocessorLists(const std::string & execute_data_name);
326 
331  void initOutputList(OutputData & data);
332 
337  bool wantOutput(const std::string & name, const ExecFlagType & type);
338 
352  static void addValidParams(InputParameters & params, const MultiMooseEnum & types);
353 
358  bool hasOutputHelper(const std::string & name);
359 
364 
367 
369  std::map<std::string, Real> & _last_execute_time;
370 
373 
374  // Allow complete access
375  friend class OutputWarehouse;
376  friend class Console;
377  friend class TransientMultiApp;
378 };
379 
380 // Helper function for initAvailableLists, templated on warehouse type and postprocessor_type
381 template <typename postprocessor_type>
382 void
384 {
385  // Convenience reference to the OutputData being operated on (should used "postprocessors" or
386  // "vector_postprocessors")
387  OutputData & execute_data = _execute_data[execute_data_name];
388 
389  // Build the input file parameter name (i.e. "output_postprocessors_on" or
390  // "output_vector_postprocessors_on")
391  std::ostringstream oss;
392  oss << "execute_" << execute_data_name << "_on";
393  std::string execute_on_name = oss.str();
394 
395  std::vector<postprocessor_type *> objs;
396  if constexpr (std::is_same_v<postprocessor_type, Postprocessor>)
398  .query()
400  .condition<AttribThread>(0)
401  .queryIntoUnsorted(objs);
402  else if constexpr (std::is_same_v<postprocessor_type, VectorPostprocessor>)
404  .query()
406  .condition<AttribThread>(0)
407  .queryIntoUnsorted(objs);
408 
409  for (const auto & obj : objs)
410  {
411  execute_data.available.insert(obj->PPName());
412 
413  // Extract the list of outputs
414  const auto & pps_outputs = obj->getOutputs();
415 
416  // Check that the outputs lists are valid
417  _app.getOutputWarehouse().checkOutputs(pps_outputs);
418 
419  // Check that the output object allows postprocessor output,
420  // account for "all" keyword (if it is present assume "all" was desired)
421  if (pps_outputs.find(name()) != pps_outputs.end() ||
422  pps_outputs.find("all") != pps_outputs.end())
423  {
424  if (!_advanced_execute_on.contains(execute_data_name) ||
425  (_advanced_execute_on[execute_data_name].isValid() &&
426  _advanced_execute_on[execute_data_name].isValueSet("none")))
427  {
428  const bool is_pp_type = (execute_data_name == "postprocessors");
429  const std::string pp_type_str = is_pp_type ? "post-processor" : "vector post-processor";
430  mooseWarning("The ",
431  pp_type_str,
432  " '",
433  obj->PPName(),
434  "' has requested to be output by the '",
435  name(),
436  "' output, but ",
437  pp_type_str,
438  " output is disabled for that output object.");
439  }
440  }
441  }
442 }
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:21
bool hasVectorPostprocessorOutput()
Returns true if there exists VectorPostprocessors for output.
const bool _postprocessors_as_reporters
Flags for outputting PP/VPP data as a reporter.
void clearLastExecuteTime()
Clears bookkeeping used to suppress duplicate EXEC_FINAL output at the same time. ...
OutputOnWarehouse _advanced_execute_on
Storage for the individual component execute flags.
Definition: Output.h:277
void checkOutputs(const std::set< OutputName > &names, const bool supports_material_output=false)
Test that the output names exist.
AdvancedOutput(const InputParameters &parameters)
Class constructor.
An output object for writing to the console (screen)
Definition: Console.h:18
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.
const InputParameters & parameters() const
Get the parameters of the object.
Definition: MooseBase.h:131
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.
virtual bool shouldOutput()
Handles logic for determining if a step should be output.
MultiApp Implementation for Transient Apps.
virtual ~AdvancedOutput()
Class destructor.
virtual void output()
A single call to this function should output all the necessary data for a single timestep.
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...
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.
const std::set< std::string > & getReporterOutput()
The list of Reporter names that are set for output.
void mooseWarning(Args &&... args) const
const std::string & name() const
Get the name of the class.
Definition: MooseBase.h:103
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...
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.
virtual void outputInput()
Performs the output of the input file By default this method does nothing and is not called...
bool contains(const std::string &name) const
A method for testing of a key exists.
const bool _vectorpostprocessors_as_reporters
static void addValidParams(InputParameters &params, const MultiMooseEnum &types)
Method for defining the available parameters based on the types of outputs.
FEProblemBase * _problem_ptr
Pointer the the FEProblemBase object for output object (use this)
Definition: Output.h:185
void initPostprocessorOrVectorPostprocessorLists(const std::string &execute_data_name)
Helper function for initAvailableLists, templated on warehouse type and postprocessor_type.
const std::string & type() const
Get the type of this class.
Definition: MooseBase.h:93
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.
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...
MooseApp & _app
The MOOSE application this is associated with.
Definition: MooseBase.h:385
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.
const ReporterData & _reporter_data
Storage for Reporter values.
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 outputReporters()
Output Reporter values.
virtual void initialSetup()
Call init() method on setup.
Class for containing MooseEnum item information.
Definition: MooseEnumItem.h:18
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:467
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.)
void hideAdditionalVariable(const std::string &category, const std::string &var_name)
Add an additional variable to the hide list.
QueryCache & condition(Args &&... args)
Adds a new condition to the query.
Definition: TheWarehouse.h:285
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...
bool hasReporterOutput()
Returns true if there exists Reporter for output.
static InputParameters validParams()
An outputter with filename support.
Definition: FileOutput.h:20
Adds the ability to output on every nonlinear and/or linear residual.
Definition: PetscOutput.h:41
void initExecutionTypes(const std::string &name, ExecFlagEnum &input)
Initialize the possible execution types.
OutputWarehouse & getOutputWarehouse()
Get the OutputWarehouse objects.
Definition: MooseApp.C:2408
virtual void init()
Populates the various data structures needed to control the output.
This is a helper class for managing the storage of declared Reporter object values.
Definition: ReporterData.h:48