71 CLP.
setDocString(
"This example tests the / operator.\n");
73 CLP.
setOption(
"dim", &d,
"Stochastic dimension");
75 CLP.
setOption(
"order", &p,
"Polynomial order");
77 CLP.
setOption(
"samples", &n,
"Number of samples");
79 CLP.
setOption(
"shift", &shift,
"Shift point");
80 double tolerance = 1e-6;
81 CLP.
setOption(
"tolerance", &tolerance,
"Tolerance in Iterative Solver");
83 CLP.
setOption(
"prec_level", &prec_level,
"Level in Schur Complement Prec 0->Solve A0u0=g0 with division; 1->Form 1x1 Schur Complement");
85 CLP.
setOption(
"max_it_div", &max_it_div,
"Maximum # of iterations for division iterative solver");
86 bool equilibrate =
true;
87 CLP.
setOption(
"equilibrate",
"noequilibrate", &equilibrate,
88 "Equilibrate the linear system");
97 "Preconditioner Method");
99 CLP.
setOption(
"schur_option", &schur_option,
103 CLP.
setOption(
"prec_option", &prec_option,
106 CLP.
parse( argc, argv );
109 Array< RCP<const Stokhos::OneDOrthogPolyBasis<int,double> > > bases(d);
110 for (
int i=0; i<d; i++) {
113 RCP<const Stokhos::CompletePolynomialBasis<int,double> > basis =
117 RCP<const Stokhos::Quadrature<int,double> > quad =
121 RCP<Stokhos::Sparse3Tensor<int,double> > Cijk =
122 basis->computeTripleProductTensor();
131 alg_params->
set(
"Division Tolerance", tolerance);
132 alg_params->
set(
"prec_iter", prec_level);
133 alg_params->
set(
"max_it_div", max_it_div);
135 alg_params->
set(
"Division Strategy",
"Dense Direct");
136 else if (solve_method ==
GMRES)
137 alg_params->
set(
"Division Strategy",
"GMRES");
138 else if (solve_method ==
CG)
139 alg_params->
set(
"Division Strategy",
"CG");
142 if (prec_method ==
None)
143 alg_params->
set(
"Prec Strategy",
"None");
144 else if (prec_method ==
Diag)
145 alg_params->
set(
"Prec Strategy",
"Diag");
146 else if (prec_method ==
Jacobi)
147 alg_params->
set(
"Prec Strategy",
"Jacobi");
148 else if (prec_method ==
GS)
149 alg_params->
set(
"Prec Strategy",
"GS");
150 else if (prec_method ==
Schur)
151 alg_params->
set(
"Prec Strategy",
"Schur");
153 if (schur_option ==
diag)
154 alg_params->
set(
"Schur option",
"diag");
156 alg_params->
set(
"Schur option",
"full");
157 if (prec_option ==
linear)
158 alg_params->
set(
"Prec option",
"linear");
160 alg_params->
set(
"Use Quadrature for Division",
false);
163 alg_params->
set(
"Equilibrate", 1);
165 alg_params->
set(
"Equilibrate", 0);
171 basis, Cijk, quad, alg_params));
174 pce_type u_quad(quad_expn), v_quad(quad_expn);
175 u_quad.term(0,0) = 0.0;
176 for (
int i=0; i<d; i++) {
177 u_quad.term(i,1) = 1.0;
179 pce_type u_alg(alg_expn), v_alg(alg_expn);
180 u_alg.term(0,0) = 0.0;
181 for (
int i=0; i<d; i++) {
182 u_alg.term(i,1) = 1.0;
191 v_alg = 1.0 /
std::exp(shift + u_alg);
192 v_quad = 1.0 /
std::exp(shift + u_quad);
202 double h = 2.0 / (n-1);
203 double err_quad = 0.0;
204 double err_alg = 0.0;
205 for (
int i=0; i<n; i++) {
207 double x = -1.0 + h*i;
209 for (
int j=0;
j<d;
j++)
211 double up = u_quad.evaluate(pt);
212 double vp = 1.0/(shift+up);
213 double vp_quad = v_quad.evaluate(pt);
214 double vp_alg = v_alg.evaluate(pt);
218 double point_err_quad =
std::abs(vp-vp_quad);
219 double point_err_alg =
std::abs(vp-vp_alg);
220 if (point_err_quad > err_quad) err_quad = point_err_quad;
221 if (point_err_alg > err_alg) err_alg = point_err_alg;
223 std::cout <<
"\tL_infty norm of quadrature error = " << err_quad
225 std::cout <<
"\tL_infty norm of solver error = " << err_alg
230 std::cout <<
"\nExample Passed!" << std::endl;
234 catch (std::exception& e) {
235 std::cout << e.what() << std::endl;
const int num_division_solver
const Division_Solver Division_solver_values[]
const Prec_option Prec_option_values[]
const Division_Prec Division_prec_values[]
Sacado::ETPCE::OrthogPoly< double, Stokhos::StandardStorage< int, double > > pce_type
const char * schur_option_names[]
const char * division_prec_names[]
const char * prec_option_names[]
ParameterList & set(std::string const &name, T &&value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
const char * division_solver_names[]
const Schur_option Schur_option_values[]
const int num_division_prec
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
static void summarize(Ptr< const Comm< int > > comm, std::ostream &out=std::cout, const bool alwaysWriteLocal=false, const bool writeGlobalStats=true, const bool writeZeroTimers=true, const ECounterSetOp setOp=Intersection, const std::string &filter="", const bool ignoreZeroTimers=false)
void setOption(const char option_true[], const char option_false[], bool *option_val, const char documentation[]=NULL)
EParseCommandLineReturn parse(int argc, char *argv[], std::ostream *errout=&std::cerr) const
KOKKOS_INLINE_FUNCTION PCE< Storage > abs(const PCE< Storage > &a)
const int num_schur_option
KOKKOS_INLINE_FUNCTION PCE< Storage > exp(const PCE< Storage > &a)
Legendre polynomial basis.
int main(int argc, char **argv)
void setDocString(const char doc_string[])
const int num_prec_option
Defines quadrature for a tensor product basis by tensor products of 1-D quadrature rules...