Line data Source code
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 "LinearCombinationPostprocessor.h" 11 : 12 : registerMooseObject("MooseApp", LinearCombinationPostprocessor); 13 : 14 : InputParameters 15 14369 : LinearCombinationPostprocessor::validParams() 16 : { 17 14369 : InputParameters params = GeneralPostprocessor::validParams(); 18 : 19 14369 : params.addRequiredParam<std::vector<PostprocessorName>>("pp_names", "List of post-processors"); 20 14369 : params.addRequiredParam<std::vector<Real>>( 21 : "pp_coefs", "List of linear combination coefficients for each post-processor"); 22 14369 : params.addParam<Real>("b", 0, "Additional value to add to sum"); 23 14369 : params.addClassDescription( 24 : "Computes a linear combination between an arbitrary number of post-processors"); 25 14369 : return params; 26 0 : } 27 : 28 52 : LinearCombinationPostprocessor::LinearCombinationPostprocessor(const InputParameters & parameters) 29 : : GeneralPostprocessor(parameters), 30 52 : _n_pp(coupledPostprocessors("pp_names")), 31 52 : _pp_coefs(getParam<std::vector<Real>>("pp_coefs")), 32 104 : _b_value(getParam<Real>("b")) 33 : { 34 52 : if (_pp_coefs.size() != _n_pp) 35 0 : mooseError("The list parameters 'pp_names' and 'pp_coefs' must have the same length"); 36 : 37 52 : _pp_values.resize(_n_pp); 38 104 : for (unsigned int i = 0; i < _n_pp; i++) 39 52 : _pp_values[i] = &getPostprocessorValue("pp_names", i); 40 52 : } 41 : 42 : void 43 48 : LinearCombinationPostprocessor::initialize() 44 : { 45 48 : } 46 : 47 : void 48 48 : LinearCombinationPostprocessor::execute() 49 : { 50 48 : } 51 : 52 : PostprocessorValue 53 48 : LinearCombinationPostprocessor::getValue() const 54 : { 55 48 : Real linear_combination = _b_value; 56 96 : for (unsigned int i = 0; i < _n_pp; i++) 57 48 : linear_combination += _pp_coefs[i] * *(_pp_values[i]); 58 : 59 48 : return linear_combination; 60 : }