Stokhos Package Browser (Single Doxygen Collection) Version of the Day
Loading...
Searching...
No Matches
Stokhos_PseudoSpectralOrthogPolyExpansion.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#ifndef STOKHOS_PSEUDOSPECTRAL_ORTHOG_POLY_EXPANSION_HPP
45#define STOKHOS_PSEUDOSPECTRAL_ORTHOG_POLY_EXPANSION_HPP
46
49
50#include "Teuchos_RCP.hpp"
51#include "Teuchos_Array.hpp"
52#include "Teuchos_SerialDenseVector.hpp"
53
54namespace Stokhos {
55
57 template <typename ordinal_type, typename value_type,
58 typename point_compare_type =
61 value_type> >
63 public OrthogPolyExpansionBase<ordinal_type, value_type, node_type> {
64 public:
65
68 const Teuchos::RCP<const OrthogPolyBasis<ordinal_type, value_type> >& basis,
71 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
72
75
76 void timesEqual(
78 const value_type& x);
79 void divideEqual(
81 const value_type& x);
82
83 void timesEqual(
86 void divideEqual(
89
90
95 const value_type& a,
99 const value_type& b);
104 const value_type& a,
108 const value_type& b);
109
124 const value_type& a,
128 const value_type& b);
151 const value_type& a,
155 const value_type& b);
162
163 template <typename FuncT>
164 void nary_op(const FuncT& func,
167
168 template <typename ExprT1, typename ExprT2>
169 value_type compute_times_coeff(ordinal_type k, const ExprT1& a,
170 const ExprT2& b) const;
171
172 template <typename ExprT1, typename ExprT2>
173 value_type fast_compute_times_coeff(ordinal_type k, const ExprT1& a,
174 const ExprT2& b) const;
175
176 private:
177
178 // Prohibit copying
180
181 // Prohibit Assignment
183
184 protected:
185
188
190 Teuchos::RCP<const PseudoSpectralOperator<ordinal_type, value_type, point_compare_type> > ps_op;
191
194
197
199 ordinal_type sz;
200
202 ordinal_type nqp;
203
205 typedef Teuchos::SerialDenseVector<ordinal_type,value_type> SDV;
206
209
212
214 Teuchos::Array< Teuchos::Array< SDV > > navals;
215
218
219 public:
220
222 template <typename FuncT>
223 void unary_op(
224 const FuncT& func,
227
229 template <typename FuncT>
230 void binary_op(
231 const FuncT& func,
235
237 template <typename FuncT>
238 void binary_op(
239 const FuncT& func,
241 const value_type& a,
243
245 template <typename FuncT>
246 void binary_op(
247 const FuncT& func,
250 const value_type& b);
251
252 protected:
253
255 value_type operator() (const value_type& a, const value_type& b) const {
256 return a * b;
257 }
258 };
259
261 value_type operator() (const value_type& a, const value_type& b) const {
262 return a / b;
263 }
264 };
265
267 value_type operator() (const value_type& a) const {
268 return std::exp(a);
269 }
270 };
271
273 value_type operator() (const value_type& a) const {
274 return std::log(a);
275 }
276 };
277
279 value_type operator() (const value_type& a) const {
280 return std::log10(a);
281 }
282 };
283
285 value_type operator() (const value_type& a) const {
286 return std::sqrt(a);
287 }
288 };
289
291 value_type operator() (const value_type& a) const {
292 return std::cbrt(a);
293 }
294 };
295
297 value_type operator() (const value_type& a, const value_type& b) const {
298 return std::pow(a,b);
299 }
300 };
301
303 value_type operator() (const value_type& a) const {
304 return std::cos(a);
305 }
306 };
307
309 value_type operator() (const value_type& a) const {
310 return std::sin(a);
311 }
312 };
313
315 value_type operator() (const value_type& a) const {
316 return std::tan(a);
317 }
318 };
319
321 value_type operator() (const value_type& a) const {
322 return std::cosh(a);
323 }
324 };
325
327 value_type operator() (const value_type& a) const {
328 return std::sinh(a);
329 }
330 };
331
333 value_type operator() (const value_type& a) const {
334 return std::tanh(a);
335 }
336 };
337
339 value_type operator() (const value_type& a) const {
340 return std::acos(a);
341 }
342 };
343
345 value_type operator() (const value_type& a) const {
346 return std::asin(a);
347 }
348 };
349
351 value_type operator() (const value_type& a) const {
352 return std::atan(a);
353 }
354 };
355
357 value_type operator() (const value_type& a, const value_type& b) const {
358 return std::atan2(a,b);
359 }
360 };
361
363 value_type operator() (const value_type & a) const {
364 return std::log(a+std::sqrt(a*a-value_type(1.0)));
365 }
366 };
367
369 value_type operator() (const value_type& a) const {
370 return std::log(a+std::sqrt(a*a+value_type(1.0)));
371 }
372 };
373
375 value_type operator() (const value_type& a) const {
376 return 0.5*std::log((value_type(1.0)+a)/(value_type(1.0)-a));
377 }
378 };
379
380 }; // class PseudoSpectralOrthogPolyExpansion
381
382} // namespace Stokhos
383
385
386#endif // STOKHOS_QUADORTHOGPOLYEXPANSION_HPP
Kokkos::Serial node_type
Class to store coefficients of a projection onto an orthogonal polynomial basis.
Abstract base class for multivariate orthogonal polynomials.
Base class for consolidating common expansion implementations.
Teuchos::RCP< const Stokhos::Sparse3Tensor< ordinal_type, value_type > > Cijk
Triple-product tensor.
Teuchos::RCP< Teuchos::ParameterList > params
Parameter list.
Teuchos::RCP< const OrthogPolyBasis< ordinal_type, value_type > > basis
Basis.
An operator interface for building pseudo-spectral approximations.
Orthogonal polynomial expansions based on numerical quadrature.
SDV bvals
Temporary array for values of second argument at quad points.
Teuchos::Array< Teuchos::Array< SDV > > navals
Temporary array for values of n-ary arguments at quad points.
PseudoSpectralOrthogPolyExpansion & operator=(const PseudoSpectralOrthogPolyExpansion &b)
PseudoSpectralOrthogPolyExpansion(const PseudoSpectralOrthogPolyExpansion &)
void binary_op(const FuncT &func, OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a, const OrthogPolyApprox< ordinal_type, value_type, node_type > &b)
Nonlinear binary function.
value_type fast_compute_times_coeff(ordinal_type k, const ExprT1 &a, const ExprT2 &b) const
value_type compute_times_coeff(ordinal_type k, const ExprT1 &a, const ExprT2 &b) const
void divideEqual(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const value_type &x)
Teuchos::RCP< const PseudoSpectralOperator< ordinal_type, value_type, point_compare_type > > ps_op
Pseudospectral operator.
SDV fvals
Temporary array for values of operation at quad points.
SDV avals
Temporary array for values of first argument at quad points.
void divide(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a, const OrthogPolyApprox< ordinal_type, value_type, node_type > &b)
void times(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a, const OrthogPolyApprox< ordinal_type, value_type, node_type > &b)
OrthogPolyExpansionBase< ordinal_type, value_type, node_type >::Cijk_type Cijk_type
Short-hand for Cijk.
bool use_quad_for_division
Use quadrature for division functions.
void unary_op(const FuncT &func, OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
Nonlinear unary function.
void pow(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a, const OrthogPolyApprox< ordinal_type, value_type, node_type > &b)
void nary_op(const FuncT &func, OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > **a)
void timesEqual(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const value_type &x)
Teuchos::SerialDenseVector< ordinal_type, value_type > SDV
Short-hand for SerialDenseVector.
PseudoSpectralOrthogPolyExpansion(const Teuchos::RCP< const OrthogPolyBasis< ordinal_type, value_type > > &basis, const Teuchos::RCP< const Stokhos::Sparse3Tensor< ordinal_type, value_type > > &Cijk, const Teuchos::RCP< const PseudoSpectralOperator< ordinal_type, value_type, point_compare_type > > &ps_op, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
Constructor.
Data structure storing a sparse 3-tensor C(i,j,k) in a a compressed format.
Top-level namespace for Stokhos classes and functions.
LexographicLess< TensorProductElement< ordinal_type, value_type >, FloatingPointLess< value_type > > type
value_type operator()(const value_type &a, const value_type &b) const
value_type operator()(const value_type &a, const value_type &b) const
value_type operator()(const value_type &a, const value_type &b) const
value_type operator()(const value_type &a, const value_type &b) const