Stokhos Package Browser (Single Doxygen Collection) Version of the Day
Loading...
Searching...
No Matches
Stokhos_RecurrenceBasis.hpp
Go to the documentation of this file.
1// @HEADER
2// ***********************************************************************
3//
4// Stokhos Package
5// Copyright (2009) Sandia Corporation
6//
7// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8// license for use of this work by or on behalf of the U.S. Government.
9//
10// Redistribution and use in source and binary forms, with or without
11// modification, are permitted provided that the following conditions are
12// met:
13//
14// 1. Redistributions of source code must retain the above copyright
15// notice, this list of conditions and the following disclaimer.
16//
17// 2. Redistributions in binary form must reproduce the above copyright
18// notice, this list of conditions and the following disclaimer in the
19// documentation and/or other materials provided with the distribution.
20//
21// 3. Neither the name of the Corporation nor the names of the
22// contributors may be used to endorse or promote products derived from
23// this software without specific prior written permission.
24//
25// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36//
37// Questions? Contact Eric T. Phipps (etphipp@sandia.gov).
38//
39// ***********************************************************************
40// @HEADER
41
42#ifndef STOKHOS_RECURRENCEBASIS_HPP
43#define STOKHOS_RECURRENCEBASIS_HPP
44
46
47namespace Stokhos {
48
54
84 template <typename ordinal_type, typename value_type>
86 public OneDOrthogPolyBasis<ordinal_type, value_type> {
87 public:
88
90 virtual ~RecurrenceBasis();
91
93
94
96 virtual ordinal_type order() const;
97
99 virtual ordinal_type size() const;
100
102
106 virtual const Teuchos::Array<value_type>& norm_squared() const;
107
109 virtual const value_type& norm_squared(ordinal_type i) const;
110
112
122 virtual Teuchos::RCP< Stokhos::Dense3Tensor<ordinal_type, value_type> >
124
126
136 virtual
137 Teuchos::RCP< Stokhos::Sparse3Tensor<ordinal_type, value_type> >
138 computeSparseTripleProductTensor(ordinal_type order) const;
139
141
150 virtual Teuchos::RCP< Teuchos::SerialDenseMatrix<ordinal_type, value_type> > computeDerivDoubleProductTensor() const;
151
153
157 virtual void evaluateBases(const value_type& point,
158 Teuchos::Array<value_type>& basis_pts) const;
159
164 virtual value_type evaluate(const value_type& point,
165 ordinal_type order) const;
166
168 virtual void print(std::ostream& os) const;
169
171 virtual const std::string& getName() const;
172
190 virtual void
191 getQuadPoints(ordinal_type quad_order,
192 Teuchos::Array<value_type>& points,
193 Teuchos::Array<value_type>& weights,
194 Teuchos::Array< Teuchos::Array<value_type> >& values) const;
195
200 virtual ordinal_type quadDegreeOfExactness(ordinal_type n) const;
201
203 virtual ordinal_type coefficientGrowth(ordinal_type n) const;
204
206 virtual ordinal_type pointGrowth(ordinal_type n) const;
207
210
212
223
227
229
231 virtual void getRecurrenceCoefficients(Teuchos::Array<value_type>& alpha,
232 Teuchos::Array<value_type>& beta,
233 Teuchos::Array<value_type>& delta,
234 Teuchos::Array<value_type>& gamma) const;
235
237 virtual void evaluateBasesAndDerivatives(const value_type& point,
238 Teuchos::Array<value_type>& vals,
239 Teuchos::Array<value_type>& derivs) const;
240
242 virtual void setQuadZeroTol(value_type tol) {
243 quad_zero_tol = tol; }
244
245 protected:
246
248
256 RecurrenceBasis(const std::string& name, ordinal_type p, bool normalize,
258
260 RecurrenceBasis(ordinal_type p, const RecurrenceBasis& basis);
261
263
272 virtual bool
274 Teuchos::Array<value_type>& alpha,
275 Teuchos::Array<value_type>& beta,
276 Teuchos::Array<value_type>& delta,
277 Teuchos::Array<value_type>& gamma) const = 0;
278
280
284 virtual void setup();
285
288 Teuchos::Array<value_type>& alpha,
289 Teuchos::Array<value_type>& beta,
290 Teuchos::Array<value_type>& delta,
291 Teuchos::Array<value_type>& gamma) const;
292
293 private:
294
295 // Prohibit copying
297
298 // Prohibit Assignment
300
301 protected:
302
304 std::string name;
305
307 ordinal_type p;
308
311
314
316 value_type quad_zero_tol;
317
320
322 Teuchos::Array<value_type> alpha;
323
325 Teuchos::Array<value_type> beta;
326
328 Teuchos::Array<value_type> delta;
329
331 Teuchos::Array<value_type> gamma;
332
334 Teuchos::Array<value_type> norms;
335
336 }; // class RecurrenceBasis
337
338} // Namespace Stokhos
339
340// Include template definitions
342
343#endif
Abstract base class for 1-D orthogonal polynomials.
Implementation of OneDOrthogPolyBasis based on the general three-term recurrence relationship:
virtual ordinal_type order() const
Return order of basis (largest monomial degree ).
RecurrenceBasis & operator=(const RecurrenceBasis &b)
Teuchos::Array< value_type > norms
Norms.
virtual ordinal_type pointGrowth(ordinal_type n) const
Evaluate point growth rule for Smolyak-type bases.
virtual Teuchos::RCP< Stokhos::Dense3Tensor< ordinal_type, value_type > > computeTripleProductTensor() const
Compute triple product tensor.
virtual void setQuadZeroTol(value_type tol)
Set tolerance for zero in quad point generation.
virtual void print(std::ostream &os) const
Print basis to stream os.
virtual value_type evaluate(const value_type &point, ordinal_type order) const
Evaluate basis polynomial given by order order at given point point.
GrowthPolicy growth
Smolyak growth policy.
virtual const Teuchos::Array< value_type > & norm_squared() const
Return array storing norm-squared of each basis polynomial.
OneDOrthogPolyBasis< ordinal_type, value_type >::LevelToOrderFnPtr LevelToOrderFnPtr
Function pointer needed for level_to_order mappings.
value_type quad_zero_tol
Tolerance for quadrature points near zero.
virtual ordinal_type quadDegreeOfExactness(ordinal_type n) const
virtual Teuchos::RCP< Stokhos::Sparse3Tensor< ordinal_type, value_type > > computeSparseTripleProductTensor(ordinal_type order) const
Compute triple product tensor.
virtual Teuchos::RCP< Teuchos::SerialDenseMatrix< ordinal_type, value_type > > computeDerivDoubleProductTensor() const
Compute derivative double product tensor.
virtual ordinal_type size() const
Return total size of basis (given by order() + 1).
virtual void evaluateBases(const value_type &point, Teuchos::Array< value_type > &basis_pts) const
Evaluate each basis polynomial at given point point.
Teuchos::Array< value_type > alpha
Recurrence coefficients.
Teuchos::Array< value_type > beta
Recurrence coefficients.
ordinal_type p
Order of basis.
Teuchos::Array< value_type > gamma
Recurrence coefficients.
virtual ordinal_type coefficientGrowth(ordinal_type n) const
Evaluate coefficient growth rule for Smolyak-type bases.
void normalizeRecurrenceCoefficients(Teuchos::Array< value_type > &alpha, Teuchos::Array< value_type > &beta, Teuchos::Array< value_type > &delta, Teuchos::Array< value_type > &gamma) const
Normalize coefficients.
Teuchos::Array< value_type > delta
Recurrence coefficients.
virtual LevelToOrderFnPtr getSparseGridGrowthRule() const
Get sparse grid level_to_order mapping function.
virtual void evaluateBasesAndDerivatives(const value_type &point, Teuchos::Array< value_type > &vals, Teuchos::Array< value_type > &derivs) const
Evaluate basis polynomials and their derivatives at given point point.
RecurrenceBasis(const RecurrenceBasis &)
virtual void setSparseGridGrowthRule(LevelToOrderFnPtr ptr)
Set sparse grid rule.
virtual bool computeRecurrenceCoefficients(ordinal_type n, Teuchos::Array< value_type > &alpha, Teuchos::Array< value_type > &beta, Teuchos::Array< value_type > &delta, Teuchos::Array< value_type > &gamma) const =0
Compute recurrence coefficients.
virtual void setup()
Setup basis after computing recurrence coefficients.
virtual void getRecurrenceCoefficients(Teuchos::Array< value_type > &alpha, Teuchos::Array< value_type > &beta, Teuchos::Array< value_type > &delta, Teuchos::Array< value_type > &gamma) const
Return recurrence coefficients defined by above formula.
virtual const std::string & getName() const
Return string name of basis.
LevelToOrderFnPtr sparse_grid_growth_rule
Sparse grid growth rule (as determined by Pecos)
std::string name
Name of basis.
virtual void getQuadPoints(ordinal_type quad_order, Teuchos::Array< value_type > &points, Teuchos::Array< value_type > &weights, Teuchos::Array< Teuchos::Array< value_type > > &values) const
Compute quadrature points, weights, and values of basis polynomials at given set of points points.
RecurrenceBasis(const std::string &name, ordinal_type p, bool normalize, GrowthPolicy growth=SLOW_GROWTH)
Constructor to be called by derived classes.
Top-level namespace for Stokhos classes and functions.
GrowthPolicy
Enumerated type for determining Smolyak growth policies.