https://mooseframework.inl.gov
Loading...
Searching...
No Matches
VectorPostprocessorReductionValue.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
12#include <limits>
13
15
18{
20
21 params.addRequiredParam<VectorPostprocessorName>(
22 "vectorpostprocessor", "The vectorpostprocessor from which a value is extracted");
23 params.addRequiredParam<std::string>("vector_name",
24 "Name of the vector for which to report a value");
25 params.addParam<MooseEnum>(
26 "value_type",
27 MooseEnum("max=0 min=1 sum=2 average=3", "sum"),
28 "Type of reduction operation. Options are max, min, sum, and average.");
29 params.addClassDescription("Takes a VectorPostprocessor and performs a reduction operation on it "
30 "(max, min, sum, average) and stores as postprocessor.");
31
32 return params;
33}
34
36 const InputParameters & parameters)
37 : GeneralPostprocessor(parameters),
38 _vpp_name(getParam<VectorPostprocessorName>("vectorpostprocessor")),
39 _vector_name(getParam<std::string>("vector_name")),
40 _vpp_values(getVectorPostprocessorValue("vectorpostprocessor", _vector_name)),
41 _value_type(getParam<MooseEnum>("value_type"))
42
43{
44}
45
46Real
48{
49 Real r = 0;
50 switch (_value_type)
51 {
52 case 0:
53 r = std::numeric_limits<Real>::lowest();
54 for (auto & e : _vpp_values)
55 if (e > r)
56 r = e;
57 break;
58
59 case 1:
60 r = std::numeric_limits<Real>::max();
61 for (auto & e : _vpp_values)
62 if (e < r)
63 r = e;
64 break;
65
66 case 2:
67 r = 0;
68 for (auto & e : _vpp_values)
69 r += e;
70 break;
71
72 case 3:
73 r = 0;
74 for (auto & e : _vpp_values)
75 r += e / _vpp_values.size();
76 return r;
77 }
78 return r;
79}
registerMooseObject("MooseApp", VectorPostprocessorReductionValue)
This class is here to combine the Postprocessor interface and the base class Postprocessor object alo...
static InputParameters validParams()
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object.
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...
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.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition MooseEnum.h:55
virtual Real getValue() const override
This will get called to actually grab the final value the postprocessor has calculated.
const MooseEnum _value_type
The type pf reduction operation performed on the vpp.
const VectorPostprocessorValue & _vpp_values
VectorPostprocessorValue object to read a specified component from.
VectorPostprocessorReductionValue(const InputParameters &parameters)