www.mooseframework.org
AdvancedOutputUtils.h
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
9 
10 #pragma once
11 
12 // MOOSE includes
13 #include "MooseError.h"
14 #include "ExecFlagEnum.h"
15 
16 // Forward declarations
17 class InputParameters;
18 
27 struct OutputData
28 {
30  std::set<std::string> available;
31 
33  std::set<std::string> show;
34 
36  std::set<std::string> hide;
37 
39  std::set<std::string> output;
40 
42  void reset();
43 };
44 
59 template <typename T>
61 {
62 public:
67 
71  T & operator[](const std::string & name)
72  {
73  // Locate the map entry, error if it is not found
74  typename std::map<std::string, T>::iterator iter = _map.find(name);
75  if (iter == _map.end())
76  mooseError("Unknown map key ", name);
77  return iter->second;
78  }
79 
81 
84  typename std::map<std::string, T>::iterator begin() { return _map.begin(); }
85  typename std::map<std::string, T>::iterator end() { return _map.end(); }
86  typename std::map<std::string, T>::iterator find(const std::string & name)
87  {
88  return _map.find(name);
89  }
90  typename std::map<std::string, T>::const_iterator begin() const { return _map.begin(); }
91  typename std::map<std::string, T>::const_iterator end() const { return _map.end(); }
92  const typename std::map<std::string, T>::const_iterator find(const std::string & name) const
93  {
94  return _map.find(name);
95  }
97 
101  bool contains(const std::string & name) const { return find(name) != end(); }
102 
103 protected:
105  typename std::map<std::string, T> _map;
106 };
107 
127 class OutputOnWarehouse : public OutputMapWrapper<ExecFlagEnum>
128 {
129 public:
135  OutputOnWarehouse(const ExecFlagEnum & execute_on, const InputParameters & parameters);
136 };
137 
146 class OutputDataWarehouse : public OutputMapWrapper<OutputData>
147 {
148 public:
149  static InputParameters validParams();
150 
155 
162  bool hasShowList() { return _has_show_list; }
163 
170  void setHasShowList(bool value) { _has_show_list = value; }
171 
175  void reset();
176 
177 private:
178  // True when the input file contains a show/hide list
180 };
std::string name(const ElemQuality q)
std::set< std::string > output
A list of the outputs to write.
std::map< std::string, T >::const_iterator begin() const
A MultiMooseEnum object to hold "execute_on" flags.
Definition: ExecFlagEnum.h:21
static InputParameters validParams()
std::map< std::string, T > _map
Data storage.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:299
A helper warehouse for storing OutputData objects for the various output types.
std::map< std::string, T >::const_iterator end() const
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
A structure for storing the various lists that contain the names of the items to be exported...
T & operator[](const std::string &name)
A map accessor that errors if the key is not found.
In newer versions of Clang calling operator[] on a map with a component that has a default constructo...
bool hasShowList()
False when the show lists for all variables is empty.
void reset()
Clear existing lists for re-initialization.
void reset()
Clear existing sets for re-initialization.
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
OutputOnWarehouse(const ExecFlagEnum &execute_on, const InputParameters &parameters)
Constructor.
std::set< std::string > available
A list of all possible outputs.
bool contains(const std::string &name) const
A method for testing of a key exists.
A helper warehouse class for storing the "execute_on" settings for the various output types...
std::set< std::string > hide
User-supplied list of outputs to hide.
std::map< std::string, T >::iterator end()
std::map< std::string, T >::iterator begin()
Provide iterator and find access to the underlying map data.
const std::map< std::string, T >::const_iterator find(const std::string &name) const
std::set< std::string > show
User-supplied list of outputs to display.
OutputDataWarehouse()
Populate the OutputData structures for all output types that are &#39;variable&#39; based.
OutputMapWrapper()
Constructor.
std::map< std::string, T >::iterator find(const std::string &name)
void setHasShowList(bool value)
Set the show list bool.