https://mooseframework.inl.gov
Loading...
Searching...
No Matches
VectorOfVectorCalculators.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
11
12namespace StochasticTools
13{
14
15template <typename InType, typename OutType>
16std::vector<std::vector<std::vector<OutType>>>
17Percentile<std::vector<std::vector<InType>>, std::vector<std::vector<OutType>>>::compute(
18 const std::vector<std::vector<InType>> & data, const bool is_distributed)
19{
20 // Bootstrap estimates
21 const auto values = this->computeBootstrapEstimates(data, is_distributed);
22
23 // Extract percentiles
24 std::vector<std::vector<std::vector<OutType>>> output;
25 if (this->processor_id() == 0)
26 for (const Real & level : this->_levels)
27 {
28 long unsigned int index = std::lrint(level * (this->_replicates - 1));
29 output.push_back(values[index]);
30 }
31
32 return output;
33}
34
35template <typename InType, typename OutType>
36std::unique_ptr<
37 BootstrapCalculator<std::vector<std::vector<InType>>, std::vector<std::vector<OutType>>>>
39 build(const MooseEnum & item,
40 const libMesh::ParallelObject & other,
41 const std::vector<Real> & levels,
42 unsigned int replicates,
43 unsigned int seed,
44 StochasticTools::Calculator<std::vector<std::vector<InType>>,
45 std::vector<std::vector<OutType>>> & calc)
46{
47 std::unique_ptr<
48 BootstrapCalculator<std::vector<std::vector<InType>>, std::vector<std::vector<OutType>>>>
49 ptr = nullptr;
50 if (item == "percentile")
51 ptr = std::make_unique<
52 Percentile<std::vector<std::vector<InType>>, std::vector<std::vector<OutType>>>>(
53 other, item, levels, replicates, seed, calc);
54 else
55 ::mooseError("Failed to create Statistics::BootstrapCalculator object for ", item);
56
57 return ptr;
58}
59
60#define createVectorOfVectorCalculators(InType, OutType) \
61 template class Percentile<std::vector<std::vector<InType>>, std::vector<std::vector<OutType>>>; \
62 template struct BootstrapCalculatorBuilder<std::vector<std::vector<InType>>, \
63 std::vector<std::vector<OutType>>>
64
65createVectorOfVectorCalculators(std::vector<Real>, Real);
66}
std::array< Real, 2 > values
Base class for computing bootstrap confidence level intervals.
Enum for batch type in stochastic tools MultiApp.
createVectorOfVectorCalculators(std::vector< Real >, Real)