https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Classes | Enumerations | Functions
StochasticTools Namespace Reference

Enum for batch type in stochastic tools MultiApp. More...

Classes

class  BiasCorrectedAccelerated
 
class  BiasCorrectedAccelerated< std::vector< InType >, std::vector< OutType > >
 
class  BootstrapCalculator
 Base class for computing bootstrap confidence level intervals. More...
 
struct  BootstrapCalculatorBuilder
 
struct  BootstrapCalculatorBuilder< std::vector< InType >, std::vector< OutType > >
 
struct  BootstrapCalculatorBuilder< std::vector< std::vector< InType > >, std::vector< std::vector< OutType > > >
 
class  Calculator
 
struct  CalculatorBuilder
 
struct  CalculatorBuilder< std::vector< InType >, std::vector< OutType > >
 
struct  canDefaultGather
 Custom type trait that has a value of true for types that can be gathered. More...
 
struct  canDefaultGather< std::vector< T > >
 
struct  canStochasticGather
 
struct  canStochasticGather< std::vector< T > >
 
class  CartesianProduct
 
class  DistributedData
 Templated class that specifies a distributed storage of a vector of given objects. More...
 
class  GaussianProcess
 Utility class dedicated to hold structures and functions commont to Gaussian Processes. More...
 
class  L2Norm
 
class  Max
 
class  Mean
 
class  MeanAbsoluteValue
 
class  Median
 
class  Min
 
class  MultiDimPolynomialGenerator
 Class containing functionalitties to generate the degress of the 1D Polynomials within every term of a multi-dimensional polynomial. More...
 
class  Percentile
 
class  Percentile< std::vector< InType >, std::vector< OutType > >
 
class  Percentile< std::vector< std::vector< InType > >, std::vector< std::vector< OutType > > >
 
class  POD
 Class which computes a Proper Orthogonal Decomposition (POD) for snapshots stored in ParallelSolutionStorage. More...
 
class  Ratio
 
class  SobolCalculator
 Calculator for computing Sobol sensitivity indices according to the paper by Saltelli (2002) https://doi.org/10.1016/S0010-4655(02)00280-1. More...
 
class  SobolCalculator< std::vector< InType >, std::vector< OutType > >
 
class  Standardizer
 Class for standardizing data (centering and scaling) More...
 
class  StdDev
 
class  StdErr
 
class  Sum
 
class  VectorCalculator
 
class  WeightedCartesianProduct
 

Enumerations

enum class  MultiAppMode { NORMAL = 0 , BATCH_RESET = 1 , BATCH_RESTORE = 2 }
 

Functions

MooseEnum makeBootstrapCalculatorEnum ()
 
template<typename InType , typename OutType >
std::unique_ptr< BootstrapCalculator< InType, OutType > > makeBootstrapCalculator (const MooseEnum &, const libMesh::ParallelObject &, const std::vector< Real > &, unsigned int, unsigned int, StochasticTools::Calculator< InType, OutType > &)
 
MultiMooseEnum makeCalculatorEnum ()
 
template<typename InType = std::vector<Real>, typename OutType = Real>
std::unique_ptr< Calculator< InType, OutType > > makeCalculator (const MooseEnumItem &item, const libMesh::ParallelObject &other)
 
template<typename T >
void stochasticGather (const libMesh::Parallel::Communicator &, processor_id_type, T &)
 
template<typename T , typename std::enable_if< canDefaultGather< std::vector< T > >::value, int >::type = 0>
void stochasticGather (const libMesh::Parallel::Communicator &comm, processor_id_type root_id, std::vector< T > &val)
 
template<typename T , typename std::enable_if< canStochasticGather< std::vector< std::vector< T > > >::value, int >::type = 0>
void stochasticGather (const libMesh::Parallel::Communicator &comm, processor_id_type root_id, std::vector< std::vector< T > > &val)
 
template<typename T >
void stochasticGather (const libMesh::Parallel::Communicator &comm, processor_id_type root_id, std::vector< std::basic_string< T > > &val)
 
template<typename A >
void stochasticGather (const libMesh::Parallel::Communicator &comm, processor_id_type root_id, std::vector< bool, A > &val)
 
template<typename T >
void stochasticAllGather (const libMesh::Parallel::Communicator &, T &)
 
template<typename T , typename std::enable_if< canDefaultGather< std::vector< T > >::value, int >::type = 0>
void stochasticAllGather (const libMesh::Parallel::Communicator &comm, std::vector< T > &val)
 
template<typename T , typename std::enable_if< canStochasticGather< std::vector< std::vector< T > > >::value, int >::type = 0>
void stochasticAllGather (const libMesh::Parallel::Communicator &comm, std::vector< std::vector< T > > &val)
 
template<typename T >
void stochasticAllGather (const libMesh::Parallel::Communicator &comm, std::vector< std::basic_string< T > > &val)
 
template<typename A >
void stochasticAllGather (const libMesh::Parallel::Communicator &comm, std::vector< bool, A > &val)
 
template<typename T >
void inplaceSort (std::vector< T > &values)
 
template<typename T >
void inplaceSort (std::vector< std::vector< T > > &values)
 
template<typename T >
std::vector< std::vector< T > > reshapeVector (const std::vector< T > &vec, std::size_t n, bool row_major)
 Reshape a vector into matrix-like vector of vectors.
 
 createBootstrapCalculators (std::vector< Real >, Real)
 
 createBootstrapCalculators (std::vector< int >, Real)
 
 createCalculators (std::vector< Real >, Real)
 
 createCalculators (std::vector< int >, Real)
 
 createVectorCalculators (std::vector< Real >, Real)
 
 createVectorOfVectorCalculators (std::vector< Real >, Real)
 

Detailed Description

Enum for batch type in stochastic tools MultiApp.

Polynomials and quadratures based on defined distributions for Polynomial Chaos.

Enumeration Type Documentation

◆ MultiAppMode

enum class StochasticTools::MultiAppMode
strong
Enumerator
NORMAL 
BATCH_RESET 
BATCH_RESTORE 

Definition at line 15 of file StochasticToolsTypes.h.

Function Documentation

◆ createBootstrapCalculators() [1/2]

StochasticTools::createBootstrapCalculators ( std::vector< int ,
Real   
)

◆ createBootstrapCalculators() [2/2]

StochasticTools::createBootstrapCalculators ( std::vector< Real >  ,
Real   
)

◆ createCalculators() [1/2]

StochasticTools::createCalculators ( std::vector< int ,
Real   
)

◆ createCalculators() [2/2]

StochasticTools::createCalculators ( std::vector< Real >  ,
Real   
)

◆ createVectorCalculators()

StochasticTools::createVectorCalculators ( std::vector< Real >  ,
Real   
)

◆ createVectorOfVectorCalculators()

StochasticTools::createVectorOfVectorCalculators ( std::vector< Real >  ,
Real   
)

◆ inplaceSort() [1/2]

template<typename T >
void StochasticTools::inplaceSort ( std::vector< std::vector< T > > &  values)

Definition at line 224 of file StochasticToolsUtils.h.

225{
226 if (values.empty())
227 return;
228
229 const std::size_t sz = values[0].size();
230 mooseAssert(std::find_if(values.begin(),
231 values.end(),
232 [&sz](const std::vector<T> & val)
233 { return val.size() != sz; }) == values.end(),
234 "All vectors must be same size to sort.");
235
236 std::vector<T> vals(values.size());
237 for (const auto & i : make_range(sz))
238 {
239 for (const auto & k : index_range(values))
240 vals[k] = values[k][i];
241 inplaceSort(vals);
242 for (const auto & k : index_range(values))
243 values[k][i] = std::move(vals[k]);
244 }
245}
std::array< Real, 2 > values
void inplaceSort(std::vector< T > &values)

◆ inplaceSort() [2/2]

template<typename T >
void StochasticTools::inplaceSort ( std::vector< T > &  values)

Definition at line 218 of file StochasticToolsUtils.h.

219{
220 std::sort(values.begin(), values.end());
221}

Referenced by StochasticTools::BootstrapCalculator< InType, OutType >::computeBootstrapEstimates(), and inplaceSort().

◆ makeBootstrapCalculator()

template<typename InType , typename OutType >
std::unique_ptr< BootstrapCalculator< InType, OutType > > StochasticTools::makeBootstrapCalculator ( const MooseEnum item,
const libMesh::ParallelObject other,
const std::vector< Real > &  levels,
unsigned int  replicates,
unsigned int  seed,
StochasticTools::Calculator< InType, OutType > &  calc 
)

Definition at line 183 of file BootstrapCalculators.h.

189{
191 item, other, levels, replicates, seed, calc);
192}

Referenced by TEST(), TEST(), and TEST().

◆ makeBootstrapCalculatorEnum()

MooseEnum StochasticTools::makeBootstrapCalculatorEnum ( )

Definition at line 17 of file BootstrapCalculators.C.

18{
19 return MooseEnum("percentile=0 bca=1");
20}

Referenced by StatisticsReporter::validParams(), and Statistics::validParams().

◆ makeCalculator()

template<typename InType = std::vector<Real>, typename OutType = Real>
std::unique_ptr< Calculator< InType, OutType > > StochasticTools::makeCalculator ( const MooseEnumItem item,
const libMesh::ParallelObject other 
)

◆ makeCalculatorEnum()

MultiMooseEnum StochasticTools::makeCalculatorEnum ( )

Definition at line 16 of file Calculators.C.

17{
18 return MultiMooseEnum(
19 "min=0 max=1 sum=2 mean=3 stddev=4 norm2=5 ratio=6 stderr=7 median=8 meanabs=9");
20}

Referenced by ParameterStudyAction::validParams(), StatisticsReporter::validParams(), and Statistics::validParams().

◆ reshapeVector()

template<typename T >
std::vector< std::vector< T > > StochasticTools::reshapeVector ( const std::vector< T > &  vec,
std::size_t  n,
bool  row_major 
)

Reshape a vector into matrix-like vector of vectors.

Parameters
vecInput vector to reshape
nLeading dimension size, number of columns if row-major, number of rows if column-major
row_majorTrue if
vecis in row-major format see https://en.wikipedia.org/wiki/Row-_and_column-major_order
Returns
vector of vectors representing reshaped vector ([row][col])

Definition at line 259 of file StochasticToolsUtils.h.

260{
261 const auto nelem = vec.size();
262 const auto nrow = row_major ? nelem / n : n;
263 const auto ncol = row_major ? n : nelem / n;
264 if (nelem % n != 0)
265 ::mooseError(
266 "Reshaping dimensions (", nrow, ", ", ncol, ") does not match vector size (", nelem, ").");
267
268 std::vector<std::vector<T>> mat(nrow, std::vector<T>(ncol));
269 for (const auto & i : make_range(nrow))
270 for (const auto & j : make_range(ncol))
271 {
272 const auto k = row_major ? (i * ncol + j) : (j * nrow + i);
273 mat[i][j] = vec[k];
274 }
275 return mat;
276}
for(PetscInt i=0;i< nvars;++i)

Referenced by AdaptiveMonteCarloDecision::execute(), SobolStatistics::execute(), SobolReporterContext< InType, OutType >::finalize(), and sobolidx().

◆ stochasticAllGather() [1/5]

template<typename T >
void StochasticTools::stochasticAllGather ( const libMesh::Parallel::Communicator ,
T  
)

Definition at line 141 of file StochasticToolsUtils.h.

142{
143 ::mooseError("Cannot gather values of type ", MooseUtils::prettyCppType<T>());
144}

Referenced by StochasticReporterContext< T >::finalize(), and stochasticAllGather().

◆ stochasticAllGather() [2/5]

template<typename A >
void StochasticTools::stochasticAllGather ( const libMesh::Parallel::Communicator comm,
std::vector< bool, A > &  val 
)

Definition at line 201 of file StochasticToolsUtils.h.

202{
203 std::vector<unsigned short int> temp(val.size());
204 for (std::size_t i = 0; i < val.size(); ++i)
205 temp[i] = val[i] ? 1 : 0;
206 comm.allgather(temp);
207 val.resize(temp.size());
208 for (std::size_t i = 0; i < temp.size(); ++i)
209 val[i] = temp[i] == 1;
210}
void allgather(const T &send_data, std::vector< T, A > &recv_data) const

◆ stochasticAllGather() [3/5]

template<typename T >
void StochasticTools::stochasticAllGather ( const libMesh::Parallel::Communicator comm,
std::vector< std::basic_string< T > > &  val 
)

Definition at line 193 of file StochasticToolsUtils.h.

195{
196 comm.allgather(val);
197}

◆ stochasticAllGather() [4/5]

template<typename T , typename std::enable_if< canStochasticGather< std::vector< std::vector< T > > >::value, int >::type = 0>
void StochasticTools::stochasticAllGather ( const libMesh::Parallel::Communicator comm,
std::vector< std::vector< T > > &  val 
)

Definition at line 156 of file StochasticToolsUtils.h.

157{
158 // Get local vector sizes
159 std::size_t num_local_vecs = val.size();
160 std::vector<std::size_t> val_sizes;
161 val_sizes.reserve(num_local_vecs);
162 std::size_t num_local_vals = 0;
163 for (const auto & v : val)
164 {
165 val_sizes.push_back(v.size());
166 num_local_vals += v.size();
167 }
168
169 // Flatten the local vector of vectors
170 std::vector<T> val_exp;
171 val_exp.reserve(num_local_vals);
172 for (auto & v : val)
173 std::copy(v.begin(), v.end(), std::back_inserter(val_exp));
174
175 // Gather the vector sizes and the flattened vector
176 comm.allgather(val_sizes);
177 stochasticAllGather(comm, val_exp);
178
179 // Build the vector of vectors from the gathered flatten vector
180 val.resize(val_sizes.size());
181 std::size_t ind = 0;
182 for (std::size_t i = 0; i < val_sizes.size(); ++i)
183 {
184 val[i].resize(val_sizes[i]);
185 std::move(val_exp.begin() + ind, val_exp.begin() + ind + val_sizes[i], val[i].begin());
186 ind += val_sizes[i];
187 }
188}
const double v

◆ stochasticAllGather() [5/5]

template<typename T , typename std::enable_if< canDefaultGather< std::vector< T > >::value, int >::type = 0>
void StochasticTools::stochasticAllGather ( const libMesh::Parallel::Communicator comm,
std::vector< T > &  val 
)

Definition at line 148 of file StochasticToolsUtils.h.

149{
150 comm.allgather(val);
151}

◆ stochasticGather() [1/5]

template<typename T >
void StochasticTools::stochasticGather ( const libMesh::Parallel::Communicator ,
processor_id_type  ,
T  
)

Definition at line 49 of file StochasticToolsUtils.h.

50{
51 ::mooseError("Cannot gather values of type ", MooseUtils::prettyCppType<T>());
52}

Referenced by StochasticReporterContext< T >::finalize(), and stochasticGather().

◆ stochasticGather() [2/5]

template<typename A >
void StochasticTools::stochasticGather ( const libMesh::Parallel::Communicator comm,
processor_id_type  root_id,
std::vector< bool, A > &  val 
)

Definition at line 120 of file StochasticToolsUtils.h.

123{
124 std::vector<unsigned short int> temp(val.size());
125 for (std::size_t i = 0; i < val.size(); ++i)
126 temp[i] = val[i] ? 1 : 0;
127 comm.gather(root_id, temp);
128 if (comm.rank() == root_id)
129 {
130 val.resize(temp.size());
131 for (std::size_t i = 0; i < temp.size(); ++i)
132 val[i] = temp[i] == 1;
133 }
134}
processor_id_type rank() const
void gather(const unsigned int root_id, const T &send_data, std::vector< T, A > &recv) const

◆ stochasticGather() [3/5]

template<typename T >
void StochasticTools::stochasticGather ( const libMesh::Parallel::Communicator comm,
processor_id_type  root_id,
std::vector< std::basic_string< T > > &  val 
)

Definition at line 108 of file StochasticToolsUtils.h.

111{
112 std::vector<std::basic_string<T>> val_gath = val;
113 comm.allgather(val_gath);
114 if (comm.rank() == root_id)
115 val = std::move(val_gath);
116}

◆ stochasticGather() [4/5]

template<typename T , typename std::enable_if< canStochasticGather< std::vector< std::vector< T > > >::value, int >::type = 0>
void StochasticTools::stochasticGather ( const libMesh::Parallel::Communicator comm,
processor_id_type  root_id,
std::vector< std::vector< T > > &  val 
)

Definition at line 66 of file StochasticToolsUtils.h.

69{
70 // Get local vector sizes
71 std::size_t num_local_vecs = val.size();
72 std::vector<std::size_t> val_sizes;
73 val_sizes.reserve(num_local_vecs);
74 std::size_t num_local_vals = 0;
75 for (const auto & v : val)
76 {
77 val_sizes.push_back(v.size());
78 num_local_vals += v.size();
79 }
80
81 // Flatten the local vector of vectors
82 std::vector<T> val_exp;
83 val_exp.reserve(num_local_vals);
84 for (auto & v : val)
85 std::copy(v.begin(), v.end(), std::back_inserter(val_exp));
86
87 // Gather the vector sizes and the flattened vector
88 comm.gather(root_id, val_sizes);
89 stochasticGather(comm, root_id, val_exp);
90
91 // Build the vector of vectors from the gathered flatten vector
92 if (comm.rank() == root_id)
93 {
94 val.resize(val_sizes.size());
95 std::size_t ind = num_local_vals;
96 for (std::size_t i = num_local_vecs; i < val_sizes.size(); ++i)
97 {
98 val[i].resize(val_sizes[i]);
99 std::move(val_exp.begin() + ind, val_exp.begin() + ind + val_sizes[i], val[i].begin());
100 ind += val_sizes[i];
101 }
102 }
103}

◆ stochasticGather() [5/5]

template<typename T , typename std::enable_if< canDefaultGather< std::vector< T > >::value, int >::type = 0>
void StochasticTools::stochasticGather ( const libMesh::Parallel::Communicator comm,
processor_id_type  root_id,
std::vector< T > &  val 
)

Definition at line 56 of file StochasticToolsUtils.h.

59{
60 comm.gather(root_id, val);
61}