MUQ  0.4.3
muq::Approximation::PCEFactory Class Reference

Factory class for constructing a pseudo-spectral polynomial chaos approximation using a fixed quadrature rule. More...

#include <PCEFactory.h>

Detailed Description

Factory class for constructing a pseudo-spectral polynomial chaos approximation using a fixed quadrature rule.

Definition at line 22 of file PCEFactory.h.

Public Member Functions

 PCEFactory (std::vector< std::shared_ptr< Quadrature >> const &quadTypesIn, std::vector< std::shared_ptr< IndexedScalarBasis >> const &polyTypesIn)
 
 PCEFactory (std::vector< std::shared_ptr< Quadrature >> const &quadTypesIn, std::shared_ptr< muq::Utilities::MultiIndex > const &quadOrders, std::vector< std::shared_ptr< IndexedScalarBasis >> const &polyTypesIn)
 
 PCEFactory (std::vector< std::shared_ptr< Quadrature >> const &quadTypesIn, std::shared_ptr< muq::Utilities::MultiIndex > const &quadOrders, std::vector< std::shared_ptr< IndexedScalarBasis >> const &polyTypesIn, std::shared_ptr< muq::Utilities::MultiIndexSet > const &polyMultisIn)
 
std::shared_ptr< PolynomialChaosExpansionCompute (std::shared_ptr< muq::Modeling::ModPiece > const &model)
 
std::shared_ptr< PolynomialChaosExpansionCompute (std::vector< Eigen::VectorXd > const &quadEvals)
 
std::shared_ptr< PolynomialChaosExpansionCompute (std::vector< std::reference_wrapper< const Eigen::VectorXd >> const &quadEvals)
 
std::shared_ptr< PolynomialChaosExpansionCompute (std::vector< Eigen::VectorXd > const &quadEvals, std::shared_ptr< muq::Utilities::MultiIndex > const &quadOrders)
 
std::shared_ptr< PolynomialChaosExpansionCompute (std::vector< std::reference_wrapper< const Eigen::VectorXd >> const &quadEvals, std::shared_ptr< muq::Utilities::MultiIndex > const &quadOrders)
 
std::vector< Eigen::VectorXd > const & QuadPts () const
 
std::vector< Eigen::VectorXd > const & QuadPts (std::shared_ptr< muq::Utilities::MultiIndex > const &quadOrders)
 

Constructor & Destructor Documentation

◆ PCEFactory() [1/3]

PCEFactory::PCEFactory ( std::vector< std::shared_ptr< Quadrature >> const &  quadTypesIn,
std::vector< std::shared_ptr< IndexedScalarBasis >> const &  polyTypesIn 
)

Definition at line 9 of file PCEFactory.cpp.

References quadTypes.

◆ PCEFactory() [2/3]

PCEFactory::PCEFactory ( std::vector< std::shared_ptr< Quadrature >> const &  quadTypesIn,
std::shared_ptr< muq::Utilities::MultiIndex > const &  quadOrders,
std::vector< std::shared_ptr< IndexedScalarBasis >> const &  polyTypesIn 
)

Constructs a factory using a prespecified tensor product quadrature rule. The terms in the polynomial expansion are chosen from the quadrature rule. Polynomial terms that can be integrated exactly are used.

Parameters
[in]quadTypesInA vector of one dimensional quadrature rules for each input dimension.
[in]quadOrdersA multiindex holding the quadrature order in each direction.
[in]polyTypesInA vector of one dimensional polynomial families used to define the multivariate polynomials used in a PCE expansion.

Definition at line 19 of file PCEFactory.cpp.

References Setup().

◆ PCEFactory() [3/3]

PCEFactory::PCEFactory ( std::vector< std::shared_ptr< Quadrature >> const &  quadTypesIn,
std::shared_ptr< muq::Utilities::MultiIndex > const &  quadOrders,
std::vector< std::shared_ptr< IndexedScalarBasis >> const &  polyTypesIn,
std::shared_ptr< muq::Utilities::MultiIndexSet > const &  polyMultisIn 
)

Constructs a factory using a tensor product quadrature rule and independently specified polynomial terms. This allows users to employ the "classic" pseudo-spectral approach for computing polynomial chaos expansion. Coefficients for each terms defined in polyTypesIn will be computed using the quadrature rule defined by the tensor product quadrature rule defined by quadTypesIn and quadOrders. Note that you should carefully choose polyMultisIn and quadTypesIn because significant approximation errors can arise if terms in the polynomial approximation cannot be integrated exactly by the quadrature rule.

Parameters
[in]quadTypesInA vector of one dimensional quadrature rules for each input dimension.
[in]quadOrdersA multiindex holding the quadrature order in each direction.
[in]polyTypesInA vector of one dimensional polynomial families used to define the multivariate polynomials used in a PCE expansion.
[in]polyMultisInA multindex set defining the polynomial expansion this factory should generate.

Definition at line 56 of file PCEFactory.cpp.

References polyMultis, and Setup().

Member Function Documentation

◆ Compute() [1/5]

std::shared_ptr< PolynomialChaosExpansion > PCEFactory::Compute ( std::shared_ptr< muq::Modeling::ModPiece > const &  model)

Computes a polynomial chaos approximation to the given model.

Parameters
[in]modelA ModPiece implementing the model we wish to approximate.
Returns
A polynomial chaos expansion constructed from the polynomials and qudrature rules given to the PCEFactory constructor.

Definition at line 65 of file PCEFactory.cpp.

References nlohmann::detail::dtoa_impl::k, and quadPts.

Referenced by Compute(), and muq::Approximation::AdaptiveSmolyakPCE::ComputeOneTerm().

◆ Compute() [2/5]

std::shared_ptr< PolynomialChaosExpansion > PCEFactory::Compute ( std::vector< Eigen::VectorXd > const &  quadEvals)
Computes a polynomial chaos approximation using evaluations of the model at
the quadrature points returned by PCEFactory::QuadPts.  In most cases, it is
preferrable to call the Compute function with ModPiece argument, which will
help avoid potential issues matching the model evaluation points with the
quadrature points.   However, in some cases (e.g., when parallel model evaluations
used) it is advantageous to manually compute the model evaluations and compute
the expansion with this function.   This function is typically used in a workflow
like the following code snippet:
// Set up quadrature types, orders, etc...
PCEFactory factory(quadTypes, quadOrders, polyTypes);
std::vector<Eigen::VectorXd> const& quadPts = factory.QuadPts();
std::vector<Eigen::VectorXd> const& quadEvals(quadPts.size());
for(int i=0; i<quadPts.size(); ++i)
quadEvals.at(i) = model->Evaluate(quadPts.at(i))(0);
std::shared_ptr<PolynomialChaosExpansion> pce = factory.Compute(quadEvals);
PCEFactory(std::vector< std::shared_ptr< Quadrature >> const &quadTypesIn, std::vector< std::shared_ptr< IndexedScalarBasis >> const &polyTypesIn)
Definition: PCEFactory.cpp:9
std::vector< Eigen::VectorXd > quadPts
Definition: PCEFactory.h:128
std::vector< std::shared_ptr< Quadrature > > quadTypes
Definition: PCEFactory.h:122
std::vector< std::shared_ptr< IndexedScalarBasis > > polyTypes
Definition: PCEFactory.h:123

Definition at line 93 of file PCEFactory.cpp.

References Compute().

◆ Compute() [3/5]

std::shared_ptr< PolynomialChaosExpansion > PCEFactory::Compute ( std::vector< Eigen::VectorXd > const &  quadEvals,
std::shared_ptr< muq::Utilities::MultiIndex > const &  quadOrders 
)

Definition at line 79 of file PCEFactory.cpp.

References Compute(), and Setup().

◆ Compute() [4/5]

std::shared_ptr< PolynomialChaosExpansion > PCEFactory::Compute ( std::vector< std::reference_wrapper< const Eigen::VectorXd >> const &  quadEvals)

Definition at line 102 of file PCEFactory.cpp.

References nlohmann::detail::dtoa_impl::k, polyMultis, polyTypes, quadPts, and quadWts.

◆ Compute() [5/5]

std::shared_ptr< PolynomialChaosExpansion > PCEFactory::Compute ( std::vector< std::reference_wrapper< const Eigen::VectorXd >> const &  quadEvals,
std::shared_ptr< muq::Utilities::MultiIndex > const &  quadOrders 
)

Definition at line 86 of file PCEFactory.cpp.

References Compute(), and Setup().

◆ QuadPts() [1/2]

std::vector<Eigen::VectorXd> const& muq::Approximation::PCEFactory::QuadPts ( ) const
inline

Returns the quadrature points in the tensor product quadrature rule.

Definition at line 107 of file PCEFactory.h.

References quadPts.

Referenced by muq::Approximation::AdaptiveSmolyakPCE::OneTermPoints(), and QuadPts().

◆ QuadPts() [2/2]

std::vector< Eigen::VectorXd > const & PCEFactory::QuadPts ( std::shared_ptr< muq::Utilities::MultiIndex > const &  quadOrders)

Definition at line 125 of file PCEFactory.cpp.

References QuadPts(), and Setup().

◆ Setup()

void PCEFactory::Setup ( std::shared_ptr< muq::Utilities::MultiIndex > const &  quadOrders)
protected

Sets up the tensor product quadrature and polynomial expansions based on the specified quadrature order.

Definition at line 30 of file PCEFactory.cpp.

References muq::Approximation::FullTensorQuadrature::Compute(), muq::Approximation::Quadrature::Points(), polyMultis, quadOrdersCache, quadPts, quadTypes, quadWts, tensQuad, and muq::Approximation::Quadrature::Weights().

Referenced by Compute(), PCEFactory(), and QuadPts().

Member Data Documentation

◆ polyMultis

std::shared_ptr<muq::Utilities::MultiIndexSet> muq::Approximation::PCEFactory::polyMultis
protected

Definition at line 126 of file PCEFactory.h.

Referenced by Compute(), PCEFactory(), and Setup().

◆ polyTypes

std::vector<std::shared_ptr<IndexedScalarBasis> > muq::Approximation::PCEFactory::polyTypes
protected

Definition at line 123 of file PCEFactory.h.

Referenced by Compute().

◆ quadOrdersCache

std::shared_ptr<muq::Utilities::MultiIndex> muq::Approximation::PCEFactory::quadOrdersCache
protected

Definition at line 119 of file PCEFactory.h.

Referenced by Setup().

◆ quadPts

std::vector<Eigen::VectorXd> muq::Approximation::PCEFactory::quadPts
protected

Definition at line 128 of file PCEFactory.h.

Referenced by Compute(), QuadPts(), and Setup().

◆ quadTypes

std::vector<std::shared_ptr<Quadrature> > muq::Approximation::PCEFactory::quadTypes
protected

Definition at line 122 of file PCEFactory.h.

Referenced by PCEFactory(), and Setup().

◆ quadWts

Eigen::VectorXd muq::Approximation::PCEFactory::quadWts
protected

Definition at line 129 of file PCEFactory.h.

Referenced by Compute(), and Setup().

◆ tensQuad

FullTensorQuadrature muq::Approximation::PCEFactory::tensQuad
protected

Definition at line 124 of file PCEFactory.h.

Referenced by Setup().


The documentation for this class was generated from the following files: