22 template <
typename Value,
typename Device = Kokkos::DefaultExecutionSpace>
28 typedef Kokkos::View<value_type*,execution_space>
point_type;
29 typedef Kokkos::View<value_type*,execution_space>
rv_type;
30 typedef Kokkos::View<value_type*,execution_space>
result_type;
37 rf(rf_),
x(x_),
rv(rv_),
y(
"y",1)
39 Kokkos::parallel_for(1, *
this);
42 KOKKOS_INLINE_FUNCTION
57 solverParams.
set(
"Number of KL Terms", M);
58 solverParams.
set(
"Mean", 1.0);
59 solverParams.
set(
"Standard Deviation", 0.1);
62 correlation_length(ndim);
63 for (
int i=0; i<ndim; i++) {
64 domain_upper[i] = 1.0;
65 domain_lower[i] = 0.0;
66 correlation_length[i] = 10.0;
68 solverParams.
set(
"Domain Upper Bounds", domain_upper);
69 solverParams.
set(
"Domain Lower Bounds", domain_lower);
70 solverParams.
set(
"Correlation Lengths", correlation_length);
76 for (
int i=0; i<ndim; i++)
77 x[i] = (domain_upper[i] + domain_lower[i])/2.0 +
78 0.1*(domain_upper[i] - domain_lower[i])/2.0;
80 for (
int i=0; i<M; i++)
82 double result = rf.
evaluate(x, rvar);
83 std::cout <<
"result (host) = " << result << std::endl;
86 typedef Kokkos::View<double*> view_type;
87 typedef view_type::HostMirror host_view_type;
88 view_type x_view(
"x", ndim);
90 for (
int i=0; i<ndim; i++)
93 view_type rvar_view(
"rvar", M);
95 for (
int i=0; i<M; i++)
96 host_rvar(i) = rvar[i];
101 double result2 = host_y(0);
102 std::cout <<
"result (device)= " << result2 << std::endl;
104 catch (std::exception& e) {
105 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.
void print(std::ostream &os) const
Print KL expansion.
ParameterList & set(std::string const &name, T &&value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
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