www.mooseframework.org
OutputInterface.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 "OutputInterface.h"
17 #include "OutputWarehouse.h"
18 #include "MooseApp.h"
19 #include "ActionWarehouse.h"
20 
21 // Define input parameters
22 template <>
25 {
27  params.addParam<std::vector<OutputName>>("outputs",
28  "Vector of output names were you would like "
29  "to restrict the output of variables(s) "
30  "associated with this object");
31 
32  params.addParamNamesToGroup("outputs", "Advanced");
33  std::set<std::string> reserved = {"all", "none"};
34  params.setReservedValues("outputs", reserved);
35 
36  return params;
37 }
38 
39 OutputInterface::OutputInterface(const InputParameters & parameters, bool build_list)
40  : _oi_moose_app(*parameters.get<MooseApp *>("_moose_app")),
41  _oi_output_warehouse(_oi_moose_app.getOutputWarehouse()),
42  _oi_outputs(parameters.get<std::vector<OutputName>>("outputs").begin(),
43  parameters.get<std::vector<OutputName>>("outputs").end())
44 {
45 
46  // By default it is assumed that the variable name associated with 'outputs' is the name
47  // of the block, this is the case for Markers, Indicators, VectorPostprocessors, and
48  // Postprocessors.
49  // However, for Materials this is not the case, so the call to buildOutputHideVariableList must be
50  // disabled, the build_list allows for this behavior. The hide lists are handled by
51  // MaterialOutputAction
52  // in this case.
53  //
54  // Variables/AuxVariables also call the buildOutputHideVariableList method later, because when
55  // their actions
56  // are called the Output objects do not exist. This case is handled by the
57  // CheckOutputAction::checkVariableOutput.
58  if (build_list)
59  {
60  std::set<std::string> names_set;
61  names_set.insert(parameters.get<std::string>("_object_name"));
62  buildOutputHideVariableList(names_set);
63  }
64 }
65 
66 void
67 OutputInterface::buildOutputHideVariableList(std::set<std::string> variable_names)
68 {
69  // Set of available names
70  const std::set<OutputName> & avail = _oi_output_warehouse.getOutputNames();
71 
72  // Check for 'none'; hide variables on all outputs
73  if (_oi_outputs.find("none") != _oi_outputs.end())
74  for (const auto & name : avail)
75  _oi_output_warehouse.addInterfaceHideVariables(name, variable_names);
76 
77  // Check for empty and 'all' in 'outputs' parameter; do not perform any variable restrictions in
78  // these cases
79  else if (_oi_outputs.empty() || _oi_outputs.find("all") != _oi_outputs.end())
80  return;
81 
82  // Limit the variable output to Output objects listed
83  else
84  {
85  // Create a list of outputs where the variable should be hidden
86  std::set<OutputName> hide;
87  std::set_difference(avail.begin(),
88  avail.end(),
89  _oi_outputs.begin(),
90  _oi_outputs.end(),
91  std::inserter(hide, hide.begin()));
92 
93  // If 'outputs' is specified add the object name to the list of items to hide
94  for (const auto & name : hide)
95  _oi_output_warehouse.addInterfaceHideVariables(name, variable_names);
96  }
97 }
98 
99 const std::set<OutputName> &
101 {
102  return _oi_outputs;
103 }
OutputWarehouse & _oi_output_warehouse
Reference to the OutputWarehouse for populating the Output object hide lists.
Base class for MOOSE-based applications.
Definition: MooseApp.h:58
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
OutputInterface(const InputParameters &parameters, bool build_list=true)
Handles &#39;outputs&#39; parameter for objects that desire control of variable outputs.
InputParameters emptyInputParameters()
std::set< OutputName > _oi_outputs
The set of Output object names listed in the &#39;outputs&#39; parameter.
void buildOutputHideVariableList(std::set< std::string > variable_names)
Builds hide lists for output objects NOT listed in the &#39;outputs&#39; parameter.
void setReservedValues(const std::string &name, const std::set< std::string > &reserved)
Provide a set of reserved values for a parameter.
const std::set< OutputName > & getOutputNames()
Get a complete set of all output object names.
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an option parameter and a documentation string to the InputParameters object...
void addInterfaceHideVariables(const std::string &output_name, const std::set< std::string > &variable_names)
Insert variable names for hiding via the OutoutInterface.
InputParameters validParams< OutputInterface >()
const std::set< OutputName > & getOutputs()
Get the list of output objects that this class is restricted.
void addParamNamesToGroup(const std::string &space_delim_names, const std::string group_name)
This method takes a space delimited list of parameter names and adds them to the specified group name...