17 #include "libmesh/quadrature.h" 28 "Compute statistical values of a given VectorPostprocessor objects and vectors.");
31 "vectorpostprocessors",
32 "List of VectorPostprocessor(s) to utilized for statistic computations.");
38 "The statistic(s) to compute for each of the supplied vector postprocessors.");
43 "ci_method", ci,
"The method to use for computing confidence level intervals.");
46 "ci_levels",
"A vector of confidence levels to consider, values must be in (0, 0.5].");
50 "The number of replicates to use when computing confidence level intervals.");
51 params.
addParam<
unsigned int>(
"ci_seed",
53 "The random number generator seed used for creating replicates " 54 "while computing confidence level intervals.");
59 params.
set<
bool>(
"_auto_boradcast") =
true;
67 _ci_method(getParam<
MooseEnum>(
"ci_method")),
68 _ci_levels(_ci_method.
isValid() ? computeLevels(getParam<
std::vector<
Real>>(
"ci_levels"))
70 _replicates(getParam<unsigned
int>(
"ci_replicates")),
71 _seed(getParam<unsigned
int>(
"ci_seed")),
72 _stat_type_vector(declareVector(
"stat_type"))
85 TIME_SECTION(
"initialSetup", 3,
"Setting Up Statistics");
87 const auto & vpp_names = getParam<std::vector<VectorPostprocessorName>>(
"vectorpostprocessors");
88 for (
const auto & vpp_name : vpp_names)
92 const std::set<std::string> & vpp_vectors = vpp_object.
getVectorNames();
93 for (
const auto & vec_name : vpp_vectors)
99 std::string
name = vpp_name +
"_" + vec_name;
116 TIME_SECTION(
"execute", 3,
"Executing Statistics");
130 std::unique_ptr<StochasticTools::Calculator<std::vector<Real>,
Real>> calc_ptr =
132 _stat_vectors[i]->emplace_back(calc_ptr->compute(data, is_distributed));
136 auto ci_calc_ptr = StochasticTools::makeBootstrapCalculator<std::vector<Real>,
Real>(
138 std::vector<Real> ci = ci_calc_ptr->compute(data, is_distributed);
149 if (levels_in.empty())
151 "If the 'ci_method' parameter is supplied then the 'ci_levels' must also be " 152 "supplied with values in (0, 0.5].");
154 else if (*std::min_element(levels_in.begin(), levels_in.end()) <= 0)
155 paramError(
"ci_levels",
"The supplied levels must be greater than zero.");
157 else if (*std::max_element(levels_in.begin(), levels_in.end()) > 0.5)
158 paramError(
"ci_levels",
"The supplied levels must be less than or equal to 0.5");
160 std::list<Real> levels_out;
161 for (
auto it = levels_in.rbegin(); it != levels_in.rend(); ++it)
164 levels_out.push_back(*it);
168 levels_out.push_front(*it);
169 levels_out.push_back(1 - *it);
172 return std::vector<Real>(levels_out.begin(), levels_out.end());
const std::vector< Real > _ci_levels
Confidence levels to compute (see computeLevels)
void isValid(MooseObject *obj)
const unsigned int _seed
Confidence level seed.
Compute several metrics for supplied VPP vectors.
virtual void initialSetup() override
virtual const std::string & name() const
void initialize() override final
Not used; all parallel computation is wrapped in the Statistics objects.
bool containsCompleteHistory() const
const MooseEnum & _ci_method
Bootstrap Confidence Level method.
static InputParameters validParams()
static InputParameters validParams()
VectorPostprocessorValue & _stat_type_vector
The VPP vector that will hold the statistics identifiers.
const unsigned int _replicates
Confidence level replicates.
registerADMooseObjectDeprecated("StochasticToolsApp", Statistics, "07/01/2021 12:00")
std::vector< std::tuple< std::string, std::string, bool > > _compute_from_names
VPPs names to be computed from (Vectorpostprocessor name, vector name, is_distribute) ...
const MultiMooseEnum & _compute_stats
The selected statistics to compute.
const VectorPostprocessor & getVectorPostprocessorObjectByName(const std::string &object_name, const THREAD_ID tid=0) const
void paramError(const std::string ¶m, Args... args) const
VectorPostprocessorValue & declareVector(const std::string &vector_name)
Statistics(const InputParameters ¶meters)
std::vector< Real > VectorPostprocessorValue
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
FEProblemBase & _fe_problem
std::vector< VectorPostprocessorValue * > _stat_vectors
The VPP vectors being computed.
bool isDistributed() const
std::vector< Real > computeLevels(const std::vector< Real > &levels_in) const
Helper function for converting confidence levels given in (0, 0.5] into levels in (0...
processor_id_type processor_id() const
const VectorPostprocessorValue & getVectorPostprocessorValueByName(const VectorPostprocessorName &name, const std::string &vector_name) const
virtual void execute() override
virtual bool isValid() const override
const std::set< std::string > & getVectorNames() const
void ErrorVector unsigned int