www.mooseframework.org
LinearCombinationPostprocessor.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 
11 
13 
14 template <>
17 {
19 
20  params.addRequiredParam<std::vector<PostprocessorName>>("pp_names", "List of post-processors");
21  params.addRequiredParam<std::vector<Real>>(
22  "pp_coefs", "List of linear combination coefficients for each post-processor");
23  params.addParam<Real>("b", 0, "Additional value to add to sum");
24 
25  return params;
26 }
27 
29  : GeneralPostprocessor(parameters),
30  _pp_names(getParam<std::vector<PostprocessorName>>("pp_names")),
31  _n_pp(_pp_names.size()),
32  _pp_coefs(getParam<std::vector<Real>>("pp_coefs")),
33  _b_value(getParam<Real>("b"))
34 {
35  if (_pp_coefs.size() != _n_pp)
36  mooseError("The list parameters 'pp_names' and 'pp_coefs' must have the same length");
37 
38  _pp_values.resize(_n_pp);
39  for (unsigned int i = 0; i < _n_pp; i++)
41 }
42 
43 void
45 {
46 }
47 
48 void
50 {
51 }
52 
55 {
56  Real linear_combination = _b_value;
57  for (unsigned int i = 0; i < _n_pp; i++)
58  linear_combination += _pp_coefs[i] * *(_pp_values[i]);
59 
60  return linear_combination;
61 }
std::vector< const PostprocessorValue * > _pp_values
List of post-processor values.
Computes a linear combination between an arbitrary number of post-processors.
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.
void mooseError(Args &&... args) const
Definition: MooseObject.h:147
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:154
const std::vector< Real > & _pp_coefs
List of linear combination coefficients for each post-processor value.
registerMooseObject("MooseApp", LinearCombinationPostprocessor)
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...
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)