www.mooseframework.org
VectorOfPostprocessors.C
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 #include "VectorOfPostprocessors.h"
11 #include "PostprocessorInterface.h"
12 
14 
15 template <>
18 {
20 
21  params.addRequiredParam<std::vector<PostprocessorName>>(
22  "postprocessors", "The postprocessors whose values are to be reported");
23  params.addClassDescription("Outputs the values of an arbitrary user-specified set of "
24  "postprocessors as a vector in the order specified by the user");
25 
26  // The value from this VPP is naturally already on every processor
27  // TODO: Make this not the case! See #11415
28  params.set<bool>("_is_broadcast") = true;
29 
30  return params;
31 }
32 
34  : GeneralVectorPostprocessor(parameters),
35  _pp_vec(declareVector(MooseUtils::shortName(parameters.get<std::string>("_object_name"))))
36 {
37  std::vector<PostprocessorName> pps_names(
38  getParam<std::vector<PostprocessorName>>("postprocessors"));
39  _pp_vec.resize(pps_names.size());
40  for (const auto & pps_name : pps_names)
41  {
42  if (!hasPostprocessorByName(pps_name))
43  mooseError(
44  "In VectorOfPostprocessors, postprocessor with name: ", pps_name, " does not exist");
46  }
47 }
48 
49 void
51 {
52  _pp_vec.clear();
53 }
54 
55 void
57 {
58  for (const auto & ppv : _postprocessor_values)
59  _pp_vec.push_back(*ppv);
60 }
InputParameters validParams< VectorOfPostprocessors >()
virtual const PostprocessorValue & getPostprocessorValueByName(const PostprocessorName &name)
This class is here to combine the VectorPostprocessor interface and the base class VectorPostprocesso...
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
virtual void initialize() override
Initialize, clears the postprocessor vector.
void mooseError(Args &&... args) const
Definition: MooseObject.h:147
VectorPostprocessorValue & _pp_vec
The VectorPostprocessorValue object where the results are stored.
const T & getParam(const std::string &name) const
Retrieve a parameter for the object.
Definition: MooseObject.h:191
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:363
bool hasPostprocessorByName(const PostprocessorName &name)
Determine if the Postprocessor exists.
VectorOfPostprocessors is a type of VectorPostprocessor that outputs the values of an arbitrary user-...
InputParameters validParams< GeneralVectorPostprocessor >()
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...
virtual void execute() override
Populates the postprocessor vector of values with the supplied postprocessors.
registerMooseObject("MooseApp", VectorOfPostprocessors)