Stokhos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Stokhos_TensorProductPseudoSpectralExpansionUnitTest.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 {
25  ValueType rtol, atol;
26  ValueType crtol, catol;
27  OrdinalType sz;
34  ValueType a;
35 
37  rtol = 1e-4;
38  atol = 1e-5;
39  crtol = 1e-12;
40  catol = 1e-12;
41  a = 3.1;
42  const OrdinalType d = 2;
43  const OrdinalType p = 7;
44 
45  // Create product basis
47  for (OrdinalType i=0; i<d; i++)
48  bases[i] =
50 
51  basis =
52  Teuchos::rcp(new product_basis_type(bases));
53 
54  // Tensor product quadrature
55  quad =
57 
58  // Tensor product pseudospectral operator
60  ps_op =
62 
63  // Triple product tensor
64  Cijk = basis->computeTripleProductTensor();
65  Cijk_linear = basis->computeLinearTripleProductTensor();
66 
67  // Quadrature expansion
68  exp =
70  exp_linear =
72 
73  // Create approximation
74  sz = basis->size();
75  x.reset(basis);
76  y.reset(basis);
77  u.reset(basis);
78  u2.reset(basis);
79  cx.reset(basis, 1);
80  x.term(0, 0) = 1.0;
81  cx.term(0, 0) = a;
82  cu.reset(basis);
83  cu2.reset(basis, 1);
84  sx.reset(basis, d+1);
85  su.reset(basis, d+1);
86  su2.reset(basis, d+1);
87  for (OrdinalType i=0; i<d; i++) {
88  x.term(i, 1) = 0.1;
89  sx.term(i, 1) = 0.0;
90  }
91  y.term(0, 0) = 2.0;
92  for (OrdinalType i=0; i<d; i++)
93  y.term(i, 1) = 0.25;
94  }
95 
96  };
97 
98  // typedef int OrdinalType;
99  // typedef double ValueType;
101 
102 }
103 
104 // Include unit tests for the above setup class
106 
107 int main( int argc, char* argv[] ) {
108  Teuchos::GlobalMPISession mpiSession(&argc, &argv);
110 }
Teuchos::RCP< Stokhos::PseudoSpectralOrthogPolyExpansion< OrdinalType, ValueType > > exp_linear
Stokhos::TensorProductBasis< OrdinalType, ValueType > product_basis_type
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.
Multivariate orthogonal polynomial basis generated from a tensor product of univariate polynomials...
int main(int argc, char **argv)
Teuchos::RCP< Stokhos::Sparse3Tensor< int, double > > Cijk_linear
Teuchos::RCP< const Stokhos::PseudoSpectralOperator< OrdinalType, ValueType > > ps_op
An operator for building pseudo-spectral coefficients using tensor-product quadrature.
Teuchos::RCP< Stokhos::PseudoSpectralOrthogPolyExpansion< OrdinalType, ValueType > > exp
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.