Stokhos Package Browser (Single Doxygen Collection)
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
src
Stokhos_QuadratureFactoryImp.hpp
Go to the documentation of this file.
1
// $Id$
2
// $Source$
3
// @HEADER
4
// ***********************************************************************
5
//
6
// Stokhos Package
7
// Copyright (2009) Sandia Corporation
8
//
9
// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
10
// license for use of this work by or on behalf of the U.S. Government.
11
//
12
// Redistribution and use in source and binary forms, with or without
13
// modification, are permitted provided that the following conditions are
14
// met:
15
//
16
// 1. Redistributions of source code must retain the above copyright
17
// notice, this list of conditions and the following disclaimer.
18
//
19
// 2. Redistributions in binary form must reproduce the above copyright
20
// notice, this list of conditions and the following disclaimer in the
21
// documentation and/or other materials provided with the distribution.
22
//
23
// 3. Neither the name of the Corporation nor the names of the
24
// contributors may be used to endorse or promote products derived from
25
// this software without specific prior written permission.
26
//
27
// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
28
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
31
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
32
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
33
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
34
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
35
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
36
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
37
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38
//
39
// Questions? Contact Eric T. Phipps (etphipp@sandia.gov).
40
//
41
// ***********************************************************************
42
// @HEADER
43
44
#include "Teuchos_Assert.hpp"
45
46
#include "
Stokhos_BasisFactory.hpp
"
47
#include "
Stokhos_TensorProductQuadrature.hpp
"
48
#include "
Stokhos_SparseGridQuadrature.hpp
"
49
#include "
Stokhos_ProductBasis.hpp
"
50
51
template
<
typename
ordinal_type,
typename
value_type>
52
Teuchos::RCP<const Stokhos::Quadrature<ordinal_type, value_type> >
53
Stokhos::QuadratureFactory<ordinal_type, value_type>::
54
create
(Teuchos::ParameterList& sgParams)
55
{
56
// Check if quadrature is already there
57
Teuchos::ParameterList& quadParams = sgParams.sublist(
"Quadrature"
);
58
Teuchos::RCP<const Stokhos::Quadrature<ordinal_type,value_type> > quad =
59
quadParams.template get< Teuchos::RCP<const Stokhos::Quadrature<ordinal_type,value_type> > >(
"Stochastic Galerkin Quadrature"
, Teuchos::null);
60
if
(quad != Teuchos::null)
61
return
quad;
62
63
// Get basis
64
Teuchos::ParameterList& basisParams = sgParams.sublist(
"Basis"
);
65
Teuchos::RCP< const Stokhos::OrthogPolyBasis<ordinal_type,value_type> > basis;
66
if
(basisParams.template isType< Teuchos::RCP<
const
Stokhos::OrthogPolyBasis<ordinal_type,value_type>
> >(
"Stochastic Galerkin Basis"
))
67
basis = basisParams.template get< Teuchos::RCP<const Stokhos::OrthogPolyBasis<ordinal_type,value_type> > >(
"Stochastic Galerkin Basis"
);
68
else
69
basis =
Stokhos::BasisFactory<ordinal_type,value_type>::create
(sgParams);
70
Teuchos::RCP<const Stokhos::ProductBasis<ordinal_type,value_type> > product_basis = Teuchos::rcp_dynamic_cast<const Stokhos::ProductBasis<ordinal_type,value_type> >(basis,
true
);
71
72
// Create quadrature
73
std::string quad_type = quadParams.get(
"Type"
,
"Tensor Product"
);
74
if
(quad_type ==
"Tensor Product"
) {
75
if
(quadParams.isType<
ordinal_type
>(
"Quadrature Order"
)) {
76
ordinal_type
order = quadParams.get<
ordinal_type
>(
"Quadrature Order"
);
77
quad =
78
Teuchos::rcp(
new
Stokhos::TensorProductQuadrature<ordinal_type,value_type>
(product_basis, order));
79
}
80
else
{
81
quad =
82
Teuchos::rcp(
new
Stokhos::TensorProductQuadrature<ordinal_type,value_type>
(product_basis));
83
}
84
}
85
else
if
(quad_type ==
"Sparse Grid"
) {
86
#ifdef HAVE_STOKHOS_DAKOTA
87
ordinal_type
level = quadParams.get(
"Sparse Grid Level"
, 0);
88
value_type
dup_tol = quadParams.get(
"Duplicate Tolerance"
, 1e-12);
89
ordinal_type
growth = quadParams.get<
ordinal_type
>(
90
"Growth Rule"
, Pecos::SLOW_RESTRICTED_GROWTH);
91
quad =
92
Teuchos::rcp(
new
Stokhos::SparseGridQuadrature<ordinal_type,value_type>(
93
product_basis, level, dup_tol, growth));
94
#else
95
TEUCHOS_TEST_FOR_EXCEPTION(
true
, Teuchos::Exceptions::InvalidParameter,
96
std::endl <<
97
"Error! Stokhos::QuadratureFactory::create(): "
<<
98
"Sparse Grid Quadrature requires Dakota!"
<< std::endl);
99
#endif
100
}
101
else
102
TEUCHOS_TEST_FOR_EXCEPTION(
true
, Teuchos::Exceptions::InvalidParameter,
103
std::endl <<
104
"Error! Stokhos::QuadratureFactory::create(): "
<<
105
"Invalid quadrature type "
<< quad_type << std::endl);
106
107
quadParams.set(
"Stochastic Galerkin Quadrature"
, quad);
108
return
quad;
109
}
Stokhos_BasisFactory.hpp
Stokhos_ProductBasis.hpp
Stokhos_SparseGridQuadrature.hpp
Stokhos_TensorProductQuadrature.hpp
Stokhos::BasisFactory::create
static Teuchos::RCP< const Stokhos::OrthogPolyBasis< ordinal_type, value_type > > create(Teuchos::ParameterList &sgParams)
Generate multivariate basis.
Definition
Stokhos_BasisFactoryImp.hpp:62
Stokhos::OrthogPolyBasis
Abstract base class for multivariate orthogonal polynomials.
Definition
Stokhos_OrthogPolyBasis.hpp:74
Stokhos::ordinal_type
Stokhos::QuadratureFactory::create
static Teuchos::RCP< const Stokhos::Quadrature< ordinal_type, value_type > > create(Teuchos::ParameterList &sgParams)
Generate quadrature object.
Definition
Stokhos_QuadratureFactoryImp.hpp:54
Stokhos::TensorProductQuadrature
Defines quadrature for a tensor product basis by tensor products of 1-D quadrature rules.
Definition
Stokhos_TensorProductQuadrature.hpp:58
Generated by
1.17.0