Loading [MathJax]/extensions/tex2jax.js
https://mooseframework.inl.gov
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends
PolynomialChaos.h
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 
10 #pragma once
11 
12 #include "SurrogateModel.h"
13 #include "PolynomialQuadrature.h"
14 #include "QuadratureSampler.h"
15 
16 #include "Distribution.h"
17 #include "nlohmann/json.h"
18 
20 {
21 public:
25  virtual Real evaluate(const std::vector<Real> & x) const override;
26 
28  std::size_t getNumberOfParameters() const { return _poly.size(); }
29 
31  std::size_t getNumberofCoefficients() const { return _tuple.size(); }
32 
35  const std::vector<std::vector<unsigned int>> & getPolynomialOrders() const;
36  unsigned int getPolynomialOrder(const unsigned int dim, const unsigned int i) const;
38 
40  const std::vector<Real> & getCoefficients() const;
41 
43  virtual Real computeMean() const;
44 
46  virtual Real computeStandardDeviation() const;
47 
49  Real powerExpectation(const unsigned int n) const;
50 
52  Real computeDerivative(const unsigned int dim, const std::vector<Real> & x) const;
57  Real computePartialDerivative(const std::vector<unsigned int> & dim,
58  const std::vector<Real> & x) const;
59 
61  Real computeSobolIndex(const std::set<unsigned int> & ind) const;
62  Real computeSobolTotal(const unsigned int dim) const;
63 
64  void store(nlohmann::json & json) const;
65 
66 private:
76  mutable dof_id_type _n_local_coeff = std::numeric_limits<dof_id_type>::max();
79  void linearPartitionCoefficients() const;
81 
82  // The following items are loaded from a SurrogateTrainer using getModelData
83 
85  const unsigned int & _order;
86 
88  const unsigned int & _ndim;
89 
91  const std::size_t & _ncoeff;
92 
94  const std::vector<std::vector<unsigned int>> & _tuple;
95 
97  const std::vector<Real> & _coeff;
98 
100  const std::vector<std::unique_ptr<const PolynomialQuadrature::Polynomial>> & _poly;
101 
102  friend void to_json(nlohmann::json & json, const PolynomialChaos * const & pc);
103 };
virtual Real computeMean() const
Evaluate mean: = E[u].
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
dof_id_type _local_coeff_end
std::size_t getNumberofCoefficients() const
Number of terms in expansion.
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()
virtual Real evaluate(const std::vector< Real > &x) const
Evaluate surrogate model given a row of parameters.
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 /.
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
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 InputParameters & parameters() const
const std::vector< Real > & getCoefficients() const
Access computed expansion coefficients.
PolynomialChaos(const InputParameters &parameters)
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.
uint8_t dof_id_type
const unsigned int & _ndim
Total number of parameters/dimensions.
friend void to_json(nlohmann::json &json, const PolynomialChaos *const &pc)