54 template <
typename Value,
typename Device = Kokkos::DefaultExecutionSpace>
60 typedef Kokkos::View<value_type*,execution_space>
point_type;
61 typedef Kokkos::View<value_type*,execution_space>
rv_type;
62 typedef Kokkos::View<value_type*,execution_space>
result_type;
69 rf(rf_),
x(x_),
rv(rv_),
y(
"y",1)
71 Kokkos::parallel_for(1, *
this);
74 KOKKOS_INLINE_FUNCTION
89 solverParams.
set(
"Number of KL Terms", M);
90 solverParams.
set(
"Mean", 1.0);
91 solverParams.
set(
"Standard Deviation", 0.1);
94 correlation_length(ndim);
95 for (
int i=0; i<ndim; i++) {
96 domain_upper[i] = 1.0;
97 domain_lower[i] = 0.0;
98 correlation_length[i] = 10.0;
100 solverParams.
set(
"Domain Upper Bounds", domain_upper);
101 solverParams.
set(
"Domain Lower Bounds", domain_lower);
102 solverParams.
set(
"Correlation Lengths", correlation_length);
108 for (
int i=0; i<ndim; i++)
109 x[i] = (domain_upper[i] + domain_lower[i])/2.0 +
110 0.1*(domain_upper[i] - domain_lower[i])/2.0;
112 for (
int i=0; i<M; i++)
114 double result = rf.
evaluate(x, rvar);
115 std::cout <<
"result (host) = " << result << std::endl;
118 typedef Kokkos::View<double*> view_type;
119 typedef view_type::HostMirror host_view_type;
120 view_type x_view(
"x", ndim);
122 for (
int i=0; i<ndim; i++)
125 view_type rvar_view(
"rvar", M);
127 for (
int i=0; i<M; i++)
128 host_rvar(i) = rvar[i];
133 double result2 = host_y(0);
134 std::cout <<
"result (device)= " << result2 << std::endl;
136 catch (std::exception& e) {
137 std::cout << e.what() << std::endl;
KOKKOS_INLINE_FUNCTION void operator()(const unsigned i) const
KOKKOS_INLINE_FUNCTION Teuchos::PromotionTraits< typename rv_type::value_type, value_type >::promote evaluate(const point_type &point, const rv_type &random_variables) const
Evaluate random field at a point.
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
void print(std::ostream &os) const
Print KL expansion.
Kokkos::View< value_type *, execution_space > point_type
void deep_copy(const Stokhos::CrsMatrix< ValueType, DstDevice, Layout > &dst, const Stokhos::CrsMatrix< ValueType, SrcDevice, Layout > &src)
Kokkos::View< value_type *, execution_space > result_type
int main(int argc, char **argv)
Stokhos::KL::ExponentialRandomField< value_type, execution_space > rf_type
Class representing a KL expansion of an exponential random field.
RF(const rf_type &rf_, const point_type &x_, const rv_type &rv_)
Stokhos::CrsMatrix< ValueType, Device, Layout >::HostMirror create_mirror_view(const Stokhos::CrsMatrix< ValueType, Device, Layout > &A)
Kokkos::View< value_type *, execution_space > rv_type