13 template <
typename InType,
typename OutType>
15 const std::string &
name,
21 template <
typename InType,
typename OutType>
28 template <
typename InType,
typename OutType>
34 _amat.resize(data.size(), data.size());
35 if (_amat.n() < 2 || (_resample && _amat.n() % 2 != 0))
36 mooseError(
"Size of input data is inconsistent with Sobol resampling scheme.");
38 mooseAssert(_amat.n() == data.size(),
"Size of data updating SobolCalculator has changed.");
42 _amat(r,
c) += data[r] * data[
c];
45 template <
typename InType,
typename OutType>
50 std::size_t s = _amat.n();
54 this->_communicator.max(s);
57 mooseAssert(_amat.n() == s,
"Size of data updating SobolCalculator has changed.");
58 this->_communicator.sum(_amat.get_values());
62 const std::size_t n = (s - 2) / (_resample ? 2 : 1);
65 DenseMatrix<OutType>
S(n, n);
66 std::vector<OutType> ST(n);
70 auto E = _amat(0, s - 1);
71 auto V = _amat(s - 1, s - 1) - E;
72 for (std::size_t i = 0; i < n; ++i)
74 auto U0 = _amat(i + 1, s - 1);
77 auto U1 = _amat(0, i + n + 1);
78 S(i, i) = (((U0 + U1) / 2) - E) / V;
81 S(i, i) = (U0 - E) / V;
87 auto E = _amat(0, s - 1);
88 auto V = _amat(0, 0) - E;
89 for (std::size_t i = 0; i < n; ++i)
91 auto U0 = _amat(0, i + 1);
94 auto U1 = _amat(i + n + 1, s - 1);
95 ST[i] = 1 - (((U0 + U1) / 2) - E) / V;
98 ST[i] = 1 - (U0 - E) / V;
105 for (std::size_t i = 0; i < n; ++i)
107 auto E = _amat(i + 1, i + n + 1);
108 for (std::size_t
j = 0;
j < i; ++
j)
110 auto V = _amat(
j + n + 1,
j + n + 1) - E;
111 auto U0 = _amat(i + 1,
j + n + 1);
112 auto U1 = _amat(
j + 1, i + n + 1);
113 auto Sc = (((U0 + U1) / 2) - E) / V;
114 auto S2 = Sc -
S(i, i) -
S(
j,
j);
123 _sobol.reserve(n * (n + 3) / 2);
125 _sobol.reserve(2 * n);
128 for (std::size_t i = 0; i < n; ++i)
129 _sobol.push_back(
S(i, i));
132 for (std::size_t i = 0; i < n; ++i)
133 _sobol.push_back(ST[i]);
138 for (std::size_t i = 0; i < n; ++i)
139 for (std::size_t
j = i + 1;
j < n; ++
j)
140 _sobol.push_back(
S(i,
j));
void mooseError(Args &&... args)
std::vector< T > resample(const std::vector< T > &data, MooseRandom &generator, const std::size_t seed_index=0)
static const std::string S
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
IntRange< T > make_range(T beg, T end)
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
auto index_range(const T &sizable)