https://mooseframework.inl.gov
SumPostprocessor.C
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 #include "SumPostprocessor.h"
11 
12 registerMooseObject("ThermalHydraulicsApp", SumPostprocessor);
13 
16 {
18  params.addClassDescription("Sums the values of several postprocessors");
19  params.addParam<std::vector<PostprocessorName>>("values", "List of postprocessors to add");
20  params.addDeprecatedParam<PostprocessorName>("a", "First postprocessor", "Use 'values' instead.");
21  params.addDeprecatedParam<PostprocessorName>(
22  "b", "Second postprocessor", "Use 'values' instead.");
23 
24  return params;
25 }
26 
28  : GeneralPostprocessor(parameters)
29 {
30  if (isParamValid("a") && isParamValid("b"))
31  {
32  _values.push_back(&getPostprocessorValue("a"));
33  _values.push_back(&getPostprocessorValue("b"));
34  }
35  else if (isParamValid("values"))
36  {
37  const std::vector<PostprocessorName> & pps_names =
38  getParam<std::vector<PostprocessorName>>("values");
39  for (auto & name : pps_names)
41  }
42  else
43  mooseError("Use 'values' parameter to specify postprocessor names that will be added up.");
44 }
45 
46 void
48 {
49 }
50 
51 void
53 {
54 }
55 
58 {
59  Real sum = 0;
60  for (auto & v : _values)
61  sum += *v;
62  return sum;
63 }
void addDeprecatedParam(const std::string &name, const T &value, const std::string &doc_string, const std::string &deprecation_message)
registerMooseObject("ThermalHydraulicsApp", SumPostprocessor)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
const PostprocessorValue & getPostprocessorValue(const std::string &param_name, const unsigned int index=0) const
virtual void initialize() override
virtual const std::string & name() const
bool isParamValid(const std::string &name) const
static InputParameters validParams()
Real PostprocessorValue
virtual const PostprocessorValue & getPostprocessorValueByName(const PostprocessorName &name) const
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static const std::string v
Definition: NS.h:84
SumPostprocessor(const InputParameters &parameters)
virtual void execute() override
static InputParameters validParams()
virtual PostprocessorValue getValue() const override
void mooseError(Args &&... args) const
void addClassDescription(const std::string &doc_string)
Computes a sum of postprocessor values.
std::vector< const PostprocessorValue * > _values
Postprocessors to add up.