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 
16 {
18 
19  params.addRequiredParam<std::vector<PostprocessorName>>("pp_names", "List of post-processors");
20  params.addRequiredParam<std::vector<Real>>(
21  "pp_coefs", "List of linear combination coefficients for each post-processor");
22  params.addParam<Real>("b", 0, "Additional value to add to sum");
23  params.addClassDescription(
24  "Computes a linear combination between an arbitrary number of post-processors");
25  return params;
26 }
27 
29  : GeneralPostprocessor(parameters),
30  _n_pp(coupledPostprocessors("pp_names")),
31  _pp_coefs(getParam<std::vector<Real>>("pp_coefs")),
32  _b_value(getParam<Real>("b"))
33 {
34  if (_pp_coefs.size() != _n_pp)
35  mooseError("The list parameters 'pp_names' and 'pp_coefs' must have the same length");
36 
37  _pp_values.resize(_n_pp);
38  for (unsigned int i = 0; i < _n_pp; i++)
39  _pp_values[i] = &getPostprocessorValue("pp_names", i);
40 }
41 
42 void
44 {
45 }
46 
47 void
49 {
50 }
51 
54 {
55  Real linear_combination = _b_value;
56  for (unsigned int i = 0; i < _n_pp; i++)
57  linear_combination += _pp_coefs[i] * *(_pp_values[i]);
58 
59  return linear_combination;
60 }
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 PostprocessorValue getValue() const override
This will get called to actually grab the final value the postprocessor has calculated.
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...
This class is here to combine the Postprocessor interface and the base class Postprocessor object alo...
const PostprocessorValue & getPostprocessorValue(const std::string &param_name, const unsigned int index=0) const
doco-normal-methods-begin Retrieve the value of a Postprocessor or one of it&#39;s old or older values ...
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...
static InputParameters validParams()
virtual void execute() override
Execute method.
Real PostprocessorValue
various MOOSE typedefs
Definition: MooseTypes.h:191
const std::vector< Real > & _pp_coefs
List of linear combination coefficients for each post-processor value.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
registerMooseObject("MooseApp", LinearCombinationPostprocessor)
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
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 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...
LinearCombinationPostprocessor(const InputParameters &parameters)