Stokhos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Stokhos_PseudoSpectralOrthogPolyExpansion.hpp
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 
10 #ifndef STOKHOS_PSEUDOSPECTRAL_ORTHOG_POLY_EXPANSION_HPP
11 #define STOKHOS_PSEUDOSPECTRAL_ORTHOG_POLY_EXPANSION_HPP
12 
15 
16 #include "Teuchos_RCP.hpp"
17 #include "Teuchos_Array.hpp"
19 
20 namespace Stokhos {
21 
23  template <typename ordinal_type, typename value_type,
24  typename point_compare_type =
25  typename DefaultPointCompare<ordinal_type,value_type>::type,
27  value_type> >
29  public OrthogPolyExpansionBase<ordinal_type, value_type, node_type> {
30  public:
31 
38 
41 
42  void timesEqual(
44  const value_type& x);
45  void divideEqual(
47  const value_type& x);
48 
49  void timesEqual(
52  void divideEqual(
55 
56 
61  const value_type& a,
65  const value_type& b);
70  const value_type& a,
74  const value_type& b);
75 
90  const value_type& a,
94  const value_type& b);
117  const value_type& a,
121  const value_type& b);
128 
129  template <typename FuncT>
130  void nary_op(const FuncT& func,
133 
134  template <typename ExprT1, typename ExprT2>
135  value_type compute_times_coeff(ordinal_type k, const ExprT1& a,
136  const ExprT2& b) const;
137 
138  template <typename ExprT1, typename ExprT2>
140  const ExprT2& b) const;
141 
142  private:
143 
144  // Prohibit copying
146 
147  // Prohibit Assignment
149 
150  protected:
151 
154 
157 
160 
163 
166 
169 
172 
175 
178 
181 
184 
185  public:
186 
188  template <typename FuncT>
189  void unary_op(
190  const FuncT& func,
193 
195  template <typename FuncT>
196  void binary_op(
197  const FuncT& func,
201 
203  template <typename FuncT>
204  void binary_op(
205  const FuncT& func,
207  const value_type& a,
209 
211  template <typename FuncT>
212  void binary_op(
213  const FuncT& func,
216  const value_type& b);
217 
218  protected:
219 
220  struct times_quad_func {
221  value_type operator() (const value_type& a, const value_type& b) const {
222  return a * b;
223  }
224  };
225 
226  struct div_quad_func {
227  value_type operator() (const value_type& a, const value_type& b) const {
228  return a / b;
229  }
230  };
231 
232  struct exp_quad_func {
233  value_type operator() (const value_type& a) const {
234  return std::exp(a);
235  }
236  };
237 
238  struct log_quad_func {
239  value_type operator() (const value_type& a) const {
240  return std::log(a);
241  }
242  };
243 
244  struct log10_quad_func {
245  value_type operator() (const value_type& a) const {
246  return std::log10(a);
247  }
248  };
249 
250  struct sqrt_quad_func {
251  value_type operator() (const value_type& a) const {
252  return std::sqrt(a);
253  }
254  };
255 
256  struct cbrt_quad_func {
257  value_type operator() (const value_type& a) const {
258  return std::cbrt(a);
259  }
260  };
261 
262  struct pow_quad_func {
263  value_type operator() (const value_type& a, const value_type& b) const {
264  return std::pow(a,b);
265  }
266  };
267 
268  struct cos_quad_func {
269  value_type operator() (const value_type& a) const {
270  return std::cos(a);
271  }
272  };
273 
274  struct sin_quad_func {
275  value_type operator() (const value_type& a) const {
276  return std::sin(a);
277  }
278  };
279 
280  struct tan_quad_func {
281  value_type operator() (const value_type& a) const {
282  return std::tan(a);
283  }
284  };
285 
286  struct cosh_quad_func {
287  value_type operator() (const value_type& a) const {
288  return std::cosh(a);
289  }
290  };
291 
292  struct sinh_quad_func {
293  value_type operator() (const value_type& a) const {
294  return std::sinh(a);
295  }
296  };
297 
298  struct tanh_quad_func {
299  value_type operator() (const value_type& a) const {
300  return std::tanh(a);
301  }
302  };
303 
304  struct acos_quad_func {
305  value_type operator() (const value_type& a) const {
306  return std::acos(a);
307  }
308  };
309 
310  struct asin_quad_func {
311  value_type operator() (const value_type& a) const {
312  return std::asin(a);
313  }
314  };
315 
316  struct atan_quad_func {
317  value_type operator() (const value_type& a) const {
318  return std::atan(a);
319  }
320  };
321 
322  struct atan2_quad_func {
323  value_type operator() (const value_type& a, const value_type& b) const {
324  return std::atan2(a,b);
325  }
326  };
327 
328  struct acosh_quad_func {
329  value_type operator() (const value_type & a) const {
330  return std::log(a+std::sqrt(a*a-value_type(1.0)));
331  }
332  };
333 
334  struct asinh_quad_func {
335  value_type operator() (const value_type& a) const {
336  return std::log(a+std::sqrt(a*a+value_type(1.0)));
337  }
338  };
339 
340  struct atanh_quad_func {
341  value_type operator() (const value_type& a) const {
342  return 0.5*std::log((value_type(1.0)+a)/(value_type(1.0)-a));
343  }
344  };
345 
346  }; // class PseudoSpectralOrthogPolyExpansion
347 
348 } // namespace Stokhos
349 
351 
352 #endif // STOKHOS_QUADORTHOGPOLYEXPANSION_HPP
KOKKOS_INLINE_FUNCTION PCE< Storage > sqrt(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > tan(const PCE< Storage > &a)
void log10(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
Teuchos::RCP< const OrthogPolyBasis< ordinal_type, value_type > > basis
Basis.
Teuchos::RCP< Teuchos::ParameterList > params
Parameter list.
KOKKOS_INLINE_FUNCTION PCE< Storage > sinh(const PCE< Storage > &a)
void tanh(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
Data structure storing a sparse 3-tensor C(i,j,k) in a a compressed format.
SDV avals
Temporary array for values of first argument at quad points.
KOKKOS_INLINE_FUNCTION PCE< Storage > pow(const PCE< Storage > &a, const PCE< Storage > &b)
void exp(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
Base class for consolidating common expansion implementations.
void nary_op(const FuncT &func, OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > **a)
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 acos(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > tanh(const PCE< Storage > &a)
SDV fvals
Temporary array for values of operation at quad points.
KOKKOS_INLINE_FUNCTION PCE< Storage > cbrt(const PCE< Storage > &a)
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.
void sqrt(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
void log(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > acos(const PCE< Storage > &a)
atan2(expr1.val(), expr2.val())
Kokkos::Serial node_type
void atan(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
Abstract base class for multivariate orthogonal polynomials.
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
void sin(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
value_type operator()(const value_type &a, const value_type &b) const
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)
value_type operator()(const value_type &a, const value_type &b) const
void atan2(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)
bool use_quad_for_division
Use quadrature for division functions.
KOKKOS_INLINE_FUNCTION PCE< Storage > cosh(const PCE< Storage > &a)
void tan(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
value_type operator()(const value_type &a, const value_type &b) const
SDV bvals
Temporary array for values of second argument at quad points.
void atanh(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
OrthogPolyExpansionBase< ordinal_type, value_type, node_type >::Cijk_type Cijk_type
Short-hand for Cijk.
void timesEqual(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const value_type &x)
KOKKOS_INLINE_FUNCTION PCE< Storage > atan(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > exp(const PCE< Storage > &a)
void cos(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
void cosh(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
Class to store coefficients of a projection onto an orthogonal polynomial basis.
void cbrt(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
Teuchos::Array< Teuchos::Array< SDV > > navals
Temporary array for values of n-ary arguments at quad points.
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)
Teuchos::RCP< const PseudoSpectralOperator< ordinal_type, value_type, point_compare_type > > ps_op
Pseudospectral operator.
KOKKOS_INLINE_FUNCTION PCE< Storage > sin(const PCE< Storage > &a)
void divideEqual(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const value_type &x)
void asinh(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
void sinh(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
PseudoSpectralOrthogPolyExpansion & operator=(const PseudoSpectralOrthogPolyExpansion &b)
Teuchos::RCP< const Stokhos::Sparse3Tensor< ordinal_type, value_type > > Cijk
Triple-product tensor.
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.
KOKKOS_INLINE_FUNCTION PCE< Storage > log(const PCE< Storage > &a)
Orthogonal polynomial expansions based on numerical quadrature.
KOKKOS_INLINE_FUNCTION PCE< Storage > log10(const PCE< Storage > &a)
value_type compute_times_coeff(ordinal_type k, const ExprT1 &a, const ExprT2 &b) const
void asin(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
void acosh(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > asin(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > cos(const PCE< Storage > &a)
Teuchos::SerialDenseVector< ordinal_type, value_type > SDV
Short-hand for SerialDenseVector.
value_type operator()(const value_type &a, const value_type &b) const