Stokhos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Stokhos_QuadratureFactoryImp.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Stokhos Package
4 //
5 // Copyright 2009 NTESS and the Stokhos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #include "Teuchos_Assert.hpp"
11 
12 #include "Stokhos_BasisFactory.hpp"
15 #include "Stokhos_ProductBasis.hpp"
16 
17 template <typename ordinal_type, typename value_type>
21 {
22  // Check if quadrature is already there
23  Teuchos::ParameterList& quadParams = sgParams.sublist("Quadrature");
25  quadParams.template get< Teuchos::RCP<const Stokhos::Quadrature<ordinal_type,value_type> > >("Stochastic Galerkin Quadrature", Teuchos::null);
26  if (quad != Teuchos::null)
27  return quad;
28 
29  // Get basis
30  Teuchos::ParameterList& basisParams = sgParams.sublist("Basis");
32  if (basisParams.template isType< Teuchos::RCP< const Stokhos::OrthogPolyBasis<ordinal_type,value_type> > >("Stochastic Galerkin Basis"))
33  basis = basisParams.template get< Teuchos::RCP<const Stokhos::OrthogPolyBasis<ordinal_type,value_type> > >("Stochastic Galerkin Basis");
34  else
37 
38  // Create quadrature
39  std::string quad_type = quadParams.get("Type", "Tensor Product");
40  if (quad_type == "Tensor Product") {
41  if (quadParams.isType<ordinal_type>("Quadrature Order")) {
42  ordinal_type order = quadParams.get<ordinal_type>("Quadrature Order");
43  quad =
45  }
46  else {
47  quad =
49  }
50  }
51  else if (quad_type == "Sparse Grid") {
52 #ifdef HAVE_STOKHOS_DAKOTA
53  ordinal_type level = quadParams.get("Sparse Grid Level", 0);
54  value_type dup_tol = quadParams.get("Duplicate Tolerance", 1e-12);
55  ordinal_type growth = quadParams.get<ordinal_type>(
56  "Growth Rule", Pecos::SLOW_RESTRICTED_GROWTH);
57  quad =
58  Teuchos::rcp(new Stokhos::SparseGridQuadrature<ordinal_type,value_type>(
59  product_basis, level, dup_tol, growth));
60 #else
62  std::endl <<
63  "Error! Stokhos::QuadratureFactory::create(): " <<
64  "Sparse Grid Quadrature requires Dakota!" << std::endl);
65 #endif
66  }
67  else
69  std::endl <<
70  "Error! Stokhos::QuadratureFactory::create(): " <<
71  "Invalid quadrature type " << quad_type << std::endl);
72 
73  quadParams.set("Stochastic Galerkin Quadrature", quad);
74  return quad;
75 }
T & get(ParameterList &l, const std::string &name)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
RCP< ParameterList > sublist(const RCP< ParameterList > &paramList, const std::string &name, bool mustAlreadyExist=false, const std::string &docString="")
ParameterList & set(std::string const &name, T &&value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
Abstract base class for multivariate orthogonal polynomials.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Abstract base class for multivariate orthogonal polynomials generated from tensor products of univari...
bool isType(const std::string &name) const
static Teuchos::RCP< const Stokhos::OrthogPolyBasis< ordinal_type, value_type > > create(Teuchos::ParameterList &sgParams)
Generate multivariate basis.
static Teuchos::RCP< const Stokhos::Quadrature< ordinal_type, value_type > > create(Teuchos::ParameterList &sgParams)
Generate quadrature object.
Defines quadrature for a tensor product basis by tensor products of 1-D quadrature rules...