Stokhos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Stokhos_SparseGridQuadratureUnitTest.cpp
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 
14 
15 #include "Stokhos.hpp"
17 
18 namespace SparseGridQuadratureUnitTest {
19 
20  // Common setup for unit tests
21  template <typename OrdinalType, typename ValueType>
22  struct UnitTestSetup {
24  const OrdinalType d;
25  const OrdinalType p;
26 
27  UnitTestSetup() : d(2), p(5) {
28 
29  // Create product basis
31  for (OrdinalType i=0; i<d; i++)
32  bases[i] =
34  p, true, Stokhos::MODERATE_GROWTH));
35  basis =
37  }
38 
39  };
40 
42 
43 #ifdef HAVE_STOKHOS_DAKOTA
44 
45  TEUCHOS_UNIT_TEST( Stokhos_SparseGridQuadrature, NumPoints ) {
46  const Stokhos::SparseGridQuadrature<int,double> quad(
47  setup.basis, setup.p, 1e-12, Pecos::MODERATE_RESTRICTED_GROWTH);
48  const Teuchos::Array<double>& weights = quad.getQuadWeights();
49  int nqp = weights.size();
50  int nqp_gold = 181;
51 
52  if (nqp == nqp_gold)
53  success = true;
54  else
55  success = false;
56 
57  out << std::endl
58  << "Check: quad_weight.size() = " << nqp << " == " << nqp_gold
59  << " : ";
60  if (success) out << "Passed.";
61  else
62  out << "Failed!";
63  out << std::endl;
64  }
65 
66 #endif
67 
68  TEUCHOS_UNIT_TEST( Stokhos_SmolyakSparseGridQuadrature, NumPoints ) {
69  const Stokhos::TotalOrderIndexSet<int> index_set(setup.d, setup.p);
71  setup.basis, index_set, 1e-12);
72  const Teuchos::Array<double>& weights = quad.getQuadWeights();
73  int nqp = weights.size();
74  int nqp_gold = 181;
75 
76  if (nqp == nqp_gold)
77  success = true;
78  else
79  success = false;
80 
81  out << std::endl
82  << "Check: quad_weight.size() = " << nqp << " == " << nqp_gold
83  << " : ";
84  if (success) out << "Passed.";
85  else
86  out << "Failed!";
87  out << std::endl;
88  }
89 
90 }
91 
92 int main( int argc, char* argv[] ) {
93  Teuchos::GlobalMPISession mpiSession(&argc, &argv);
95 }
Teuchos::RCP< const Stokhos::CompletePolynomialBasis< OrdinalType, ValueType > > basis
Defines quadrature for a tensor product basis by Smolyak sparse grids.
virtual const Teuchos::Array< value_type > & getQuadWeights() const
Get quadrature weights.
static int runUnitTestsFromMain(int argc, char *argv[])
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
int main(int argc, char **argv)
An isotropic total order index set.
size_type size() const
TEUCHOS_UNIT_TEST(Stokhos_SmolyakSparseGridQuadrature, NumPoints)