Stokhos Package Browser (Single Doxygen Collection)
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
src
Stokhos_KL_OneDExponentialEigenPair.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_KL_ONE_D_EXPONENTIAL_EIGENPAIR_HPP
43
#define STOKHOS_KL_ONE_D_EXPONENTIAL_EIGENPAIR_HPP
44
45
#include <iostream>
46
#include <cmath>
47
48
#include "Kokkos_Core.hpp"
49
50
namespace
Stokhos
{
51
53
namespace
KL
{
54
56
template
<
typename
eigen_function_type>
57
struct
OneDEigenPair
{
58
typedef
typename
eigen_function_type::value_type
value_type
;
59
eigen_function_type
eig_func
;
60
value_type
eig_val
;
61
};
// struct OneDEigenPair
62
64
72
template
<
typename
Value>
73
class
ExponentialOneDEigenFunction
{
74
public
:
75
76
typedef
Value
value_type
;
77
79
enum
TYPE
{
80
SIN
,
81
COS
82
};
83
85
KOKKOS_INLINE_FUNCTION
86
ExponentialOneDEigenFunction
() :
87
type
(
SIN
),
a
(0),
b
(0),
A
(0),
omega
(0),
dim_name
(0) {}
88
90
KOKKOS_INLINE_FUNCTION
91
ExponentialOneDEigenFunction
(
TYPE
type_,
const
value_type
& a_,
92
const
value_type
& b_,
93
const
value_type
& omega_,
94
const
int
dim_name_) :
95
type
(type_),
a
((b_-a_)/2.0),
b
((b_+a_)/2.0),
omega
(omega_),
96
dim_name
(dim_name_) {
97
if
(
type
==
SIN
)
98
A
= 1.0/std::sqrt(
a
- std::sin(2.*
omega
*
a
)/(2.*
omega
));
99
else
100
A
= 1.0/std::sqrt(
a
+ std::sin(2.*
omega
*
a
)/(2.*
omega
));
101
}
102
104
KOKKOS_INLINE_FUNCTION
105
~ExponentialOneDEigenFunction
() {}
106
108
template
<
typename
po
int
_type>
109
KOKKOS_INLINE_FUNCTION
110
point_type
111
evaluate
(
const
point_type& x)
const
{
112
if
(
type
==
SIN
)
113
return
A
*
sin
(
omega
*(x-
b
));
114
return
A
*
cos
(
omega
*(x-
b
));
115
}
116
118
void
print
(std::ostream& os)
const
{
119
os <<
A
<<
" * "
;
120
if
(
type
==
SIN
)
121
os <<
"sin("
;
122
else
123
os <<
"cos("
;
124
os <<
omega
<<
" * (x_"
<<
dim_name
<<
" - "
<<
b
<<
"))"
;
125
}
126
128
KOKKOS_INLINE_FUNCTION
129
TYPE
getType
()
const
{
return
type
; }
130
132
KOKKOS_INLINE_FUNCTION
133
value_type
getFrequency
()
const
{
return
omega
; }
134
136
KOKKOS_INLINE_FUNCTION
137
value_type
getMultiplier
()
const
{
return
A
; }
138
140
KOKKOS_INLINE_FUNCTION
141
value_type
getShift
()
const
{
return
b
; }
142
143
protected
:
144
146
TYPE
type
;
147
149
value_type
a
;
150
152
value_type
b
;
153
155
value_type
A
;
156
158
value_type
omega
;
159
161
int
dim_name
;
162
};
163
164
}
// namespace KL
165
166
}
// namespace Stokhos
167
168
#endif
// STOKHOS_KL_ONE_D_EXPONENTIALEIGENPAIR_HPP
cos
cos(expr.val())
sin
sin(expr.val())
Stokhos::KL::ExponentialOneDEigenFunction< value_type >::value_type
value_type value_type
Definition
Stokhos_KL_OneDExponentialEigenPair.hpp:76
Stokhos::KL::ExponentialOneDEigenFunction::ExponentialOneDEigenFunction
KOKKOS_INLINE_FUNCTION ExponentialOneDEigenFunction(TYPE type_, const value_type &a_, const value_type &b_, const value_type &omega_, const int dim_name_)
Constructor.
Definition
Stokhos_KL_OneDExponentialEigenPair.hpp:91
Stokhos::KL::ExponentialOneDEigenFunction< value_type >::omega
value_type omega
Definition
Stokhos_KL_OneDExponentialEigenPair.hpp:158
Stokhos::KL::ExponentialOneDEigenFunction::evaluate
KOKKOS_INLINE_FUNCTION point_type evaluate(const point_type &x) const
Evaluate eigenfunction.
Definition
Stokhos_KL_OneDExponentialEigenPair.hpp:111
Stokhos::KL::ExponentialOneDEigenFunction::getType
KOKKOS_INLINE_FUNCTION TYPE getType() const
Return type.
Definition
Stokhos_KL_OneDExponentialEigenPair.hpp:129
Stokhos::KL::ExponentialOneDEigenFunction::TYPE
TYPE
Enum identifying the type of eigenfunction.
Definition
Stokhos_KL_OneDExponentialEigenPair.hpp:79
Stokhos::KL::ExponentialOneDEigenFunction< value_type >::SIN
@ SIN
Definition
Stokhos_KL_OneDExponentialEigenPair.hpp:80
Stokhos::KL::ExponentialOneDEigenFunction< value_type >::COS
@ COS
Definition
Stokhos_KL_OneDExponentialEigenPair.hpp:81
Stokhos::KL::ExponentialOneDEigenFunction< value_type >::a
value_type a
Definition
Stokhos_KL_OneDExponentialEigenPair.hpp:149
Stokhos::KL::ExponentialOneDEigenFunction< value_type >::type
TYPE type
Definition
Stokhos_KL_OneDExponentialEigenPair.hpp:146
Stokhos::KL::ExponentialOneDEigenFunction::~ExponentialOneDEigenFunction
KOKKOS_INLINE_FUNCTION ~ExponentialOneDEigenFunction()
Destructor.
Definition
Stokhos_KL_OneDExponentialEigenPair.hpp:105
Stokhos::KL::ExponentialOneDEigenFunction< value_type >::dim_name
int dim_name
Definition
Stokhos_KL_OneDExponentialEigenPair.hpp:161
Stokhos::KL::ExponentialOneDEigenFunction::getMultiplier
KOKKOS_INLINE_FUNCTION value_type getMultiplier() const
Return multiplier.
Definition
Stokhos_KL_OneDExponentialEigenPair.hpp:137
Stokhos::KL::ExponentialOneDEigenFunction< value_type >::A
value_type A
Definition
Stokhos_KL_OneDExponentialEigenPair.hpp:155
Stokhos::KL::ExponentialOneDEigenFunction::print
void print(std::ostream &os) const
Print eigenfunction.
Definition
Stokhos_KL_OneDExponentialEigenPair.hpp:118
Stokhos::KL::ExponentialOneDEigenFunction::getFrequency
KOKKOS_INLINE_FUNCTION value_type getFrequency() const
Return frequency.
Definition
Stokhos_KL_OneDExponentialEigenPair.hpp:133
Stokhos::KL::ExponentialOneDEigenFunction< value_type >::b
value_type b
Definition
Stokhos_KL_OneDExponentialEigenPair.hpp:152
Stokhos::KL::ExponentialOneDEigenFunction::getShift
KOKKOS_INLINE_FUNCTION value_type getShift() const
Get shift.
Definition
Stokhos_KL_OneDExponentialEigenPair.hpp:141
Stokhos::KL::ExponentialOneDEigenFunction::ExponentialOneDEigenFunction
KOKKOS_INLINE_FUNCTION ExponentialOneDEigenFunction()
Default Constructor.
Definition
Stokhos_KL_OneDExponentialEigenPair.hpp:86
Stokhos::KL
Namespace for analytic KL expansions.
Definition
Stokhos_KL_ExponentialRandomField.hpp:54
Stokhos
Top-level namespace for Stokhos classes and functions.
Definition
Stokhos_AbstractPreconditionerFactory.hpp:48
Stokhos::KL::OneDEigenPair
Container for one-dimensional eigenfunction and eigenvalue.
Definition
Stokhos_KL_OneDExponentialEigenPair.hpp:57
Stokhos::KL::OneDEigenPair< one_d_eigen_func_type >::eig_val
value_type eig_val
Definition
Stokhos_KL_OneDExponentialEigenPair.hpp:60
Stokhos::KL::OneDEigenPair< one_d_eigen_func_type >::value_type
one_d_eigen_func_type::value_type value_type
Definition
Stokhos_KL_OneDExponentialEigenPair.hpp:58
Stokhos::KL::OneDEigenPair< one_d_eigen_func_type >::eig_func
one_d_eigen_func_type eig_func
Definition
Stokhos_KL_OneDExponentialEigenPair.hpp:59
Generated by
1.17.0