17 #include "libmesh/quadrature.h" 28 "Compute statistical values of a given VectorPostprocessor objects and vectors.");
30 params.
addParam<std::vector<VectorPostprocessorName>>(
31 "vectorpostprocessors",
32 "List of VectorPostprocessor(s) to utilized for statistic computations.");
34 params.
addParam<std::vector<ReporterName>>(
35 "reporters", {},
"List of Reporter values to utilized for statistic computations.");
41 "The statistic(s) to compute for each of the supplied vector postprocessors.");
46 "ci_method", ci,
"The method to use for computing confidence level intervals.");
50 std::vector<Real>({0.1, 0.9}),
51 "A vector of confidence levels to consider, values must be in (0, 1).");
55 "The number of replicates to use when computing confidence level intervals.");
56 params.
addParam<
unsigned int>(
"ci_seed",
58 "The random number generator seed used for creating replicates " 59 "while computing confidence level intervals.");
66 _ci_method(getParam<
MooseEnum>(
"ci_method")),
67 _ci_levels(getParam<
std::vector<
Real>>(
"ci_levels")),
68 _ci_replicates(getParam<unsigned
int>(
"ci_replicates")),
69 _ci_seed(getParam<unsigned
int>(
"ci_seed")),
77 "If the 'ci_method' parameter is supplied then the 'ci_levels' must also be " 78 "supplied with values in (0, 1).");
81 paramError(
"ci_levels",
"The supplied levels must be greater than zero.");
84 paramError(
"ci_levels",
"The supplied levels must be less than 1.0");
88 (
getParam<std::vector<ReporterName>>(
"reporters").empty() &&
89 getParam<std::vector<VectorPostprocessorName>>(
"vectorpostprocessors").empty()))
91 "The 'vectorpostprocessors' and/or 'reporters' parameters must be defined and non-empty.");
103 std::vector<std::string> unsupported_types;
104 const auto & reporter_names = getParam<std::vector<ReporterName>>(
"reporters");
105 for (
const auto & r_name : reporter_names)
114 unsupported_types.emplace_back(r_name.getCombinedName());
117 if (!unsupported_types.empty())
119 "The following reporter value(s) do not have a type supported by the " 120 "StatisticsReporter:\n",
127 const auto & vpp_names = getParam<std::vector<VectorPostprocessorName>>(
"vectorpostprocessors");
128 for (
const auto & vpp_name : vpp_names)
132 const std::set<std::string> & vpp_vectors = vpp_object.
getVectorNames();
133 for (
const auto & vec_name : vpp_vectors)
136 declareValueHelper<std::vector<Real>,
Real>(r_name);
149 json[
"confidence_intervals"] = {{
"method",
_ci_method},
155 template <
typename InType,
typename OutType>
160 const auto & data = getReporterValueByName<InType>(r_name);
163 const std::string s_name =
177 declareValueByName<std::pair<OutType, std::vector<OutType>>,
184 StatisticsReporter::declareValueHelper<std::vector<Real>,
Real>(
const ReporterName & r_name);
186 StatisticsReporter::declareValueHelper<std::vector<int>,
Real>(
const ReporterName & r_name);
std::string join(Iterator begin, Iterator end, const std::string &delimiter)
T & declareValueByName(const ReporterValueName &value_name, Args &&... args)
StatisticsReporter(const InputParameters ¶meters)
const ReporterMode REPORTER_MODE_ROOT
ReporterContext that utilizes a Calculator object to compute its value and confidence levels...
const unsigned int & _ci_seed
Compute several metrics for supplied data.
void declareValueHelper(const ReporterName &r_name)
Helper for adding statistic reporter values.
virtual void store(nlohmann::json &json) const override
static InputParameters validParams()
const std::vector< Real > & _ci_levels
const unsigned int & _ci_replicates
virtual void store(nlohmann::json &json) const
bool isParamValid(const std::string &name) const
const ReporterData & getReporterData() const
bool _initialized
Whether or not initialize() has been called for reporter value declaration.
registerMooseObject("StochasticToolsApp", StatisticsReporter)
const T & getParam(const std::string &name) const
const VectorPostprocessor & getVectorPostprocessorObjectByName(const std::string &object_name, const THREAD_ID tid=0) const
static InputParameters validParams()
void paramError(const std::string ¶m, Args... args) const
const std::string & getObjectName() const
const MooseEnum & _ci_method
const ReporterProducerEnum & getReporterMode(const ReporterName &reporter_name) const
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual void initialize() final
This is where the reporter values are declared Note: unfortunetly this cannot be in the constructor s...
FEProblemBase & _fe_problem
void mooseError(Args &&... args) const
const std::string & getValueName() const
const MultiMooseEnum & _compute_stats
virtual bool isValid() const override
const std::set< std::string > & getVectorNames() const
void ErrorVector unsigned int
bool hasReporterValueByName(const ReporterName &reporter_name) const