www.mooseframework.org
LinearCombinationPostprocessor.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 /****************************************************************/
15 
16 template <>
19 {
21 
22  params.addRequiredParam<std::vector<PostprocessorName>>("pp_names", "List of post-processors");
23  params.addRequiredParam<std::vector<Real>>(
24  "pp_coefs", "List of linear combination coefficients for each post-processor");
25  params.addParam<Real>("b", 0, "Additional value to add to sum");
26 
27  return params;
28 }
29 
31  : GeneralPostprocessor(parameters),
32  _pp_names(getParam<std::vector<PostprocessorName>>("pp_names")),
33  _n_pp(_pp_names.size()),
34  _pp_coefs(getParam<std::vector<Real>>("pp_coefs")),
35  _b_value(getParam<Real>("b"))
36 {
37  if (_pp_coefs.size() != _n_pp)
38  mooseError("The list parameters 'pp_names' and 'pp_coefs' must have the same length");
39 
40  _pp_values.resize(_n_pp);
41  for (unsigned int i = 0; i < _n_pp; i++)
43 }
44 
45 void
47 {
48 }
49 
50 void
52 {
53 }
54 
57 {
58  Real linear_combination = _b_value;
59  for (unsigned int i = 0; i < _n_pp; i++)
60  linear_combination += _pp_coefs[i] * *(_pp_values[i]);
61 
62  return linear_combination;
63 }
std::vector< const PostprocessorValue * > _pp_values
List of post-processor values.
const unsigned int _n_pp
Number of post-processors in linear combination.
virtual const PostprocessorValue & getPostprocessorValueByName(const PostprocessorName &name)
const Real _b_value
Additional value to add to sum.
virtual void initialize() override
Called before execute() is ever called so that data can be cleared.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
InputParameters validParams< GeneralPostprocessor >()
const std::vector< PostprocessorName > & _pp_names
List of names of post-processors to include in linear combination.
This class is here to combine the Postprocessor interface and the base class Postprocessor object alo...
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...
virtual void execute() override
Execute method.
Real PostprocessorValue
MOOSE typedefs.
Definition: MooseTypes.h:73
const std::vector< Real > & _pp_coefs
List of linear combination coefficients for each post-processor value.
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 mooseError(Args &&...args) const
Definition: MooseObject.h:80
virtual PostprocessorValue getValue() override
This will get called to actually grab the final value the postprocessor has calculated.
InputParameters validParams< LinearCombinationPostprocessor >()
LinearCombinationPostprocessor(const InputParameters &parameters)