www.mooseframework.org
TestDistributionPostprocessor.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 #include "Distribution.h"
12 
13 registerMooseObject("StochasticToolsTestApp", TestDistributionPostprocessor);
14 
17 {
19  params.addRequiredParam<DistributionName>(
20  "distribution", "The distribution which supplies the postprocessor value.");
21  params.addRequiredParam<Real>(
22  "value", "A value to pass to the cdf, pdf, or quantile function of the given distribution.");
23 
24  MooseEnum method("cdf pdf quantile");
25  params.addParam<MooseEnum>("method", method, "The distribution method to call.");
26  return params;
27 }
28 
30  : GeneralPostprocessor(parameters),
31  _distribution(getDistribution("distribution")),
32  _value(getParam<Real>("value")),
33  _distribution_method(getParam<MooseEnum>("method"))
34 {
35 }
36 
39 {
40  if (_distribution_method == "pdf")
41  return _distribution.pdf(_value);
42  else if (_distribution_method == "cdf")
43  return _distribution.cdf(_value);
44  else if (_distribution_method == "quantile")
46  mooseError("This should be possible to reach, what did you do!");
47 }
virtual Real pdf(const Real &x) const=0
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
const Real & _value
The value to supply to method.
void addRequiredParam(const std::string &name, const std::string &doc_string)
static InputParameters validParams()
Real PostprocessorValue
virtual Real cdf(const Real &x) const=0
Test object for testing distribution capabilities.
const Distribution & _distribution
Object of statistics distribution.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const MooseEnum & _distribution_method
The distribution method to call.
registerMooseObject("StochasticToolsTestApp", TestDistributionPostprocessor)
TestDistributionPostprocessor(const InputParameters &parameters)
void mooseError(Args &&... args) const
virtual PostprocessorValue getValue() const override
virtual Real quantile(const Real &y) const=0