Stokhos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Stokhos_QuadraturePseudoSpectralExpansionUnitTest.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 PseudoSpectralExpansionUnitTest {
19 
20  // Common setup for unit tests that defines what pseudospectral expansion
21  // we are testing
22  template <typename OrdinalType, typename ValueType>
23  struct UnitTestSetup {
24 
26  ValueType rtol, atol;
27  ValueType crtol, catol;
28  OrdinalType sz;
35  ValueType a;
36 
38  rtol = 1e-4;
39  atol = 1e-5;
40  crtol = 1e-12;
41  catol = 1e-12;
42  a = 3.1;
43  const OrdinalType d = 2;
44  const OrdinalType p = 7;
45 
46  // Create product basis
48  for (OrdinalType i=0; i<d; i++)
49  bases[i] =
51 
52  basis =
53  Teuchos::rcp(new product_basis_type(bases));
54 
55  // Tensor product quadrature
56  quad =
58 
59  // Tensor product pseudospectral operator
61  ps_op =
63 
64  // Triple product tensor
65  Cijk = basis->computeTripleProductTensor();
66  Cijk_linear = basis->computeLinearTripleProductTensor();
67 
68  // Quadrature expansion
69  exp =
71  exp_linear =
73 
74  // Create approximation
75  sz = basis->size();
76  x.reset(basis);
77  y.reset(basis);
78  u.reset(basis);
79  u2.reset(basis);
80  cx.reset(basis, 1);
81  x.term(0, 0) = 1.0;
82  cx.term(0, 0) = a;
83  cu.reset(basis);
84  cu2.reset(basis, 1);
85  sx.reset(basis, d+1);
86  su.reset(basis, d+1);
87  su2.reset(basis, d+1);
88  for (OrdinalType i=0; i<d; i++) {
89  x.term(i, 1) = 0.1;
90  sx.term(i, 1) = 0.0;
91  }
92  y.term(0, 0) = 2.0;
93  for (OrdinalType i=0; i<d; i++)
94  y.term(i, 1) = 0.25;
95  }
96 
97  };
98 
99  // typedef int OrdinalType;
100  // typedef double ValueType;
102 
103 }
104 
105 // Include unit tests for the above setup class
107 
108 int main( int argc, char* argv[] ) {
109  Teuchos::GlobalMPISession mpiSession(&argc, &argv);
111 }
Teuchos::RCP< Stokhos::PseudoSpectralOrthogPolyExpansion< OrdinalType, ValueType > > exp_linear
Multivariate orthogonal polynomial basis generated from a total order tensor product of univariate po...
Teuchos::RCP< const Stokhos::Quadrature< OrdinalType, ValueType > > quad
static int runUnitTestsFromMain(int argc, char *argv[])
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
void reset(const Teuchos::RCP< const Stokhos::OrthogPolyBasis< ordinal_type, value_type > > &new_basis, ordinal_type sz=0)
Reset to a new basis.
int main(int argc, char **argv)
Teuchos::RCP< Stokhos::Sparse3Tensor< int, double > > Cijk_linear
Teuchos::RCP< const Stokhos::PseudoSpectralOperator< OrdinalType, ValueType > > ps_op
Teuchos::RCP< Stokhos::PseudoSpectralOrthogPolyExpansion< OrdinalType, ValueType > > exp
An operator for building pseudo-spectral coefficients using an arbitrary quadrature rule...
Defines quadrature for a tensor product basis by tensor products of 1-D quadrature rules...
reference term(ordinal_type dimension, ordinal_type order)
Get coefficient term for given dimension and order.