www.mooseframework.org
VectorOfPostprocessors.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 #include "VectorOfPostprocessors.h"
16 #include "PostprocessorInterface.h"
17 
18 template <>
21 {
23 
24  params.addRequiredParam<std::vector<PostprocessorName>>(
25  "postprocessors", "The postprocessors whose values are to be reported");
26  params.addClassDescription("Outputs the values of an arbitrary user-specified set of "
27  "postprocessors as a vector in the order specified by the user");
28 
29  return params;
30 }
31 
33  : GeneralVectorPostprocessor(parameters),
34  _pp_vec(declareVector(MooseUtils::shortName(parameters.get<std::string>("_object_name"))))
35 {
36  std::vector<PostprocessorName> pps_names(
37  getParam<std::vector<PostprocessorName>>("postprocessors"));
38  _pp_vec.resize(pps_names.size());
39  for (const auto & pps_name : pps_names)
40  {
41  if (!hasPostprocessorByName(pps_name))
42  mooseError(
43  "In VectorOfPostprocessors, postprocessor with name: ", pps_name, " does not exist");
45  }
46 }
47 
48 void
50 {
51  _pp_vec.clear();
52 }
53 
54 void
56 {
57  for (const auto & ppv : _postprocessor_values)
58  _pp_vec.push_back(*ppv);
59 }
InputParameters validParams< VectorOfPostprocessors >()
virtual const PostprocessorValue & getPostprocessorValueByName(const PostprocessorName &name)
This class is here to combine the VectorPostprocessor interface and the base class VectorPostprocesso...
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
virtual void initialize() override
Initialize, clears the postprocessor vector.
VectorPostprocessorValue & _pp_vec
The VectorPostprocessorValue object where the results are stored.
void addRequiredParam(const std::string &name, const std::string &doc_string)
This method adds a parameter and documentation string to the InputParameters object that will be extr...
std::string shortName(const std::string &name)
Function for stripping name after the file / in parser block.
Definition: MooseUtils.C:325
bool hasPostprocessorByName(const PostprocessorName &name)
Determine if the Postprocessor exists.
InputParameters validParams< GeneralVectorPostprocessor >()
const T & getParam(const std::string &name) const
Retrieve a parameter for the object.
Definition: MooseObject.h:122
std::vector< const PostprocessorValue * > _postprocessor_values
The vector of PostprocessorValue objects that are used to get the values of the postprocessors.
VectorOfPostprocessors(const InputParameters &parameters)
Class constructor.
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump...
void mooseError(Args &&...args) const
Definition: MooseObject.h:80
virtual void execute() override
Populates the postprocessor vector of values with the supplied postprocessors.