26 _order(getModelData<unsigned
int>(
"_order")),
27 _ndim(getModelData<unsigned
int>(
"_ndim")),
28 _ncoeff(getModelData<
std::size_t>(
"_ncoeff")),
29 _tuple(getModelData<
std::vector<
std::vector<unsigned
int>>>(
"_tuple")),
30 _coeff(getModelData<
std::vector<
Real>>(
"_coeff")),
39 mooseAssert(
x.size() ==
_ndim,
"Number of inputted parameters does not match PC model.");
44 for (
unsigned int d = 0;
d <
_ndim; ++
d)
45 for (
unsigned int i = 0; i <
_order; ++i)
46 poly_val(
d, i) =
_poly[
d]->compute(i,
x[
d],
false);
49 for (std::size_t i = 0; i <
_ncoeff; ++i)
52 for (
unsigned int d = 0;
d <
_ndim; ++
d)
60 const std::vector<std::vector<unsigned int>> &
72 const std::vector<Real> &
81 mooseAssert(
_coeff.size() > 0,
"The coefficient matrix is empty.");
89 for (std::size_t i = 1; i <
_ncoeff; ++i)
92 for (std::size_t
d = 0;
d <
_ndim; ++
d)
97 return std::sqrt(var);
103 std::vector<StochasticTools::WeightedCartesianProduct<unsigned int, Real>> order;
104 order.reserve(
_ndim);
105 std::vector<std::vector<Real>> c_1d(n, std::vector<Real>(
_coeff.begin() + 1,
_coeff.end()));
106 for (
unsigned int d = 0;
d <
_ndim; ++
d)
108 std::vector<std::vector<unsigned int>> order_1d(n, std::vector<unsigned int>(
_ncoeff - 1));
109 for (std::size_t i = 1; i <
_ncoeff; ++i)
110 for (
unsigned int m = 0; m < n; ++m)
111 order_1d[m][i - 1] =
_tuple[i][
d];
122 Real tmp = order[0].computeWeight(i);
123 for (
unsigned int d = 0;
d <
_ndim; ++
d)
127 std::vector<unsigned int> comb(n);
128 for (
unsigned int m = 0; m < n; ++m)
129 comb[m] = order[
d].computeValue(i, m);
130 tmp *=
_poly[
d]->productIntegral(comb);
146 const std::vector<Real> &
x)
const 148 mooseAssert(
x.size() ==
_ndim,
"Number of inputted parameters does not match PC model.");
151 for (
const auto &
d :
dim)
153 mooseAssert(
d <
_ndim,
"Specified dimension is greater than total number of parameters.");
160 for (
unsigned int d = 0;
d <
_ndim; ++
d)
161 for (
unsigned int i = 0; i <
_order; ++i)
165 for (std::size_t i = 0; i <
_ncoeff; ++i)
168 for (
unsigned int d = 0;
d <
_ndim; ++
d)
186 mooseAssert(ind.size() <=
_ndim,
"Number of indices is greater than number of parameters.");
187 mooseAssert(*ind.rbegin() <
_ndim,
"Maximum index provided exceeds number of parameters.");
193 for (
unsigned int d = 0;
d <
_ndim; ++
d)
195 if ((ind.find(
d) != ind.end() &&
_tuple[i][
d] > 0) ||
196 (ind.find(
d) == ind.end() &&
_tuple[i][
d] == 0))
218 mooseAssert(
dim <
_ndim,
"Requested dimension is greater than number of parameters.");
248 for (
const auto & p :
_poly)
250 nlohmann::json jsonp;
252 json[
"poly"].push_back(jsonp);
virtual Real computeMean() const
Evaluate mean: = E[u].
bool absoluteFuzzyEqual(const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
dof_id_type _local_coeff_begin
Real computePartialDerivative(const std::vector< unsigned int > &dim, const std::vector< Real > &x) const
Evaluates sum of partial derivative of expansion.
std::size_t getNumberOfParameters() const
Access number of dimensions/parameters.
void store(nlohmann::json &json) const
void linearPartitionItems(dof_id_type num_items, dof_id_type num_chunks, dof_id_type chunk_id, dof_id_type &num_local_items, dof_id_type &local_items_begin, dof_id_type &local_items_end)
dof_id_type _local_coeff_end
std::size_t getNumberofCoefficients() const
Number of terms in expansion.
processor_id_type n_processors() const
static InputParameters validParams()
const std::vector< double > x
const std::size_t & _ncoeff
Total number of coefficient (defined by size of _tuple)
const std::vector< std::vector< unsigned int > > & _tuple
A _ndim-by-_ncoeff matrix containing the appropriate one-dimensional polynomial order.
static InputParameters validParams()
dof_id_type _n_local_coeff
Variables calculation and for looping over the computed coefficients in parallel. ...
Real computeDerivative(const unsigned int dim, const std::vector< Real > &x) const
Evaluates partial derivative of expansion: du(x)/dx_dim.
const std::vector< std::vector< unsigned int > > & getPolynomialOrders() const
Access polynomial orders from tuple /.
std::string grad(const std::string &var)
virtual Real evaluate(const std::vector< Real > &x) const override
Evaluate surrogate model given a row of parameters.
Real powerExpectation(const unsigned int n) const
Compute expectation of a certain power of the QoI: E[(u-)^n].
const std::vector< Real > & _coeff
These are the coefficients we are after in the PC expansion.
Real computeSobolIndex(const std::set< unsigned int > &ind) const
Computes Sobol sensitivities S_{i_1,i_2,...,i_s}, where ind = i_1,i_2,...,i_s.
Real computeSobolTotal(const unsigned int dim) const
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Polynomials and quadratures based on defined distributions for Polynomial Chaos.
unsigned int getPolynomialOrder(const unsigned int dim, const unsigned int i) const
const unsigned int & _order
Maximum polynomial order. The sum of 1D polynomial orders does not go above this value.
const std::vector< Real > & getCoefficients() const
Access computed expansion coefficients.
PolynomialChaos(const InputParameters ¶meters)
registerMooseObject("StochasticToolsApp", PolynomialChaos)
processor_id_type processor_id() const
void ErrorVector unsigned int
virtual Real computeStandardDeviation() const
Evaluate standard deviation: = sqrt(E[(u-)^2])
void linearPartitionCoefficients() const
const std::vector< std::unique_ptr< const PolynomialQuadrature::Polynomial > > & _poly
The distributions used for sampling.
const unsigned int & _ndim
Total number of parameters/dimensions.