Stokhos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
twoD_diffusion_ME.cpp
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 #include "twoD_diffusion_ME.hpp"
11 
13 #include "EpetraExt_MatrixMatrix.h"
14 #include "Teuchos_Assert.hpp"
16 
17 namespace {
18 
19  // Functor representing a diffusion function given by a KL expansion
20  struct KL_Diffusion_Func {
21  double mean;
22  mutable Teuchos::Array<double> point;
24 
25  KL_Diffusion_Func(double xyLeft, double xyRight,
26  double mean_, double std_dev,
27  double L, int num_KL) : mean(mean_), point(2)
28  {
29  Teuchos::ParameterList rfParams;
30  rfParams.set("Number of KL Terms", num_KL);
31  rfParams.set("Mean", mean);
32  rfParams.set("Standard Deviation", std_dev);
33  int ndim = 2;
34  Teuchos::Array<double> domain_upper(ndim), domain_lower(ndim),
35  correlation_length(ndim);
36  for (int i=0; i<ndim; i++) {
37  domain_upper[i] = xyRight;
38  domain_lower[i] = xyLeft;
39  correlation_length[i] = L;
40  }
41  rfParams.set("Domain Upper Bounds", domain_upper);
42  rfParams.set("Domain Lower Bounds", domain_lower);
43  rfParams.set("Correlation Lengths", correlation_length);
44 
45  rf =
47  }
48 
49  ~KL_Diffusion_Func() {
50  }
51 
52  double operator() (double x, double y, int k) const {
53  if (k == 0)
54  return mean;
55  point[0] = x;
56  point[1] = y;
57  return rf->evaluate_eigenfunction(point, k-1);
58  }
59  };
60 
61  // Functor representing a diffusion function given by a KL expansion
62  // where the basis is normalized
63  template <typename DiffusionFunc>
64  struct Normalized_KL_Diffusion_Func {
65  const DiffusionFunc& func;
66  int d;
67  Teuchos::Array<double> psi_0, psi_1;
68 
69  Normalized_KL_Diffusion_Func(
70  const DiffusionFunc& func_,
72  func(func_),
73  d(basis.dimension()),
74  psi_0(basis.size()),
75  psi_1(basis.size())
76  {
77  Teuchos::Array<double> zero(d), one(d);
78  for(int k=0; k<d; k++) {
79  zero[k] = 0.0;
80  one[k] = 1.0;
81  }
82  basis.evaluateBases(zero, psi_0);
83  basis.evaluateBases(one, psi_1);
84  }
85 
86  double operator() (double x, double y, int k) const {
87  if (k == 0) {
88  double val = func(x, y, 0);
89  for (int i=1; i<=d; i++)
90  val -= psi_0[i]/(psi_1[i]-psi_0[i])*func(x, y, i);
91  val /= psi_0[0];
92  return val;
93  }
94  else
95  return 1.0/(psi_1[k]-psi_0[k])*func(x, y, k);
96  }
97  };
98 
99  // Functor representing a diffusion function given by a log-normal PC expansion
100  template <typename DiffusionFunc>
101  struct LogNormal_Diffusion_Func {
102  double mean;
103  const DiffusionFunc& func;
105 
106  LogNormal_Diffusion_Func(
107  double mean_,
108  const DiffusionFunc& func_,
109  const Teuchos::RCP<const Stokhos::ProductBasis<int, double> > prodbasis_)
110  : mean(mean_), func(func_), prodbasis(prodbasis_) {}
111 
112  double operator() (double x, double y, int k) const {
113  int d = prodbasis->dimension();
114  const Teuchos::Array<double>& norms = prodbasis->norm_squared();
115  const Stokhos::MultiIndex<int> multiIndex = prodbasis->term(k);
116  double sum_g = 0.0, efval;
117  for (int l=0; l<d; l++) {
118  sum_g += std::pow(func(x,y,l+1),2);
119  }
120  efval = std::exp(mean + 0.5*sum_g)/norms[k];
121  for (int l=0; l<d; l++) {
122  efval *= std::pow(func(x,y,l+1),multiIndex[l]);
123  }
124  return efval;
125  }
126  };
127 
128 }
129 
132  const Teuchos::RCP<const Epetra_Comm>& comm, int n, int d,
133  double s, double mu,
135  bool log_normal_,
136  bool eliminate_bcs_,
137  const Teuchos::RCP<Teuchos::ParameterList>& precParams_) :
138  mesh(n*n),
139  basis(basis_),
140  log_normal(log_normal_),
141  eliminate_bcs(eliminate_bcs_),
142  precParams(precParams_)
143 {
144  Kokkos::initialize();
145 
147  // Construct the mesh.
148  // The mesh is uniform and the nodes are numbered
149  // LEFT to RIGHT, DOWN to UP.
150  //
151  // 5-6-7-8-9
152  // | | | | |
153  // 0-1-2-3-4
155  double xyLeft = -.5;
156  double xyRight = .5;
157  h = (xyRight - xyLeft)/((double)(n-1));
158  Teuchos::Array<int> global_dof_indices;
159  for (int j=0; j<n; j++) {
160  double y = xyLeft + j*h;
161  for (int i=0; i<n; i++) {
162  double x = xyLeft + i*h;
163  int idx = j*n+i;
164  mesh[idx].x = x;
165  mesh[idx].y = y;
166  if (i == 0 || i == n-1 || j == 0 || j == n-1)
167  mesh[idx].boundary = true;
168  if (i != 0)
169  mesh[idx].left = idx-1;
170  if (i != n-1)
171  mesh[idx].right = idx+1;
172  if (j != 0)
173  mesh[idx].down = idx-n;
174  if (j != n-1)
175  mesh[idx].up = idx+n;
176  if (!(eliminate_bcs && mesh[idx].boundary))
177  global_dof_indices.push_back(idx);
178  }
179  }
180 
181  // Solution vector map
182  int n_global_dof = global_dof_indices.size();
183  int n_proc = comm->NumProc();
184  int proc_id = comm->MyPID();
185  int n_my_dof = n_global_dof / n_proc;
186  if (proc_id == n_proc-1)
187  n_my_dof += n_global_dof % n_proc;
188  int *my_dof = global_dof_indices.getRawPtr() + proc_id*(n_global_dof / n_proc);
189  x_map =
190  Teuchos::rcp(new Epetra_Map(n_global_dof, n_my_dof, my_dof, 0, *comm));
191 
192  // Initial guess, initialized to 0.0
193  x_init = Teuchos::rcp(new Epetra_Vector(*x_map));
194  x_init->PutScalar(0.0);
195 
196  // Parameter vector map
197  p_map = Teuchos::rcp(new Epetra_LocalMap(d, 0, *comm));
198 
199  // Response vector map
200  g_map = Teuchos::rcp(new Epetra_LocalMap(1, 0, *comm));
201 
202  // Initial parameters
204  p_init->PutScalar(0.0);
205 
206  // Parameter names
208  for (int i=0;i<d;i++) {
209  std::stringstream ss;
210  ss << "KL Random Variable " << i+1;
211  (*p_names)[i] = ss.str();
212  }
213 
214  // Build Jacobian graph
215  int NumMyElements = x_map->NumMyElements();
216  int *MyGlobalElements = x_map->MyGlobalElements();
217  graph = Teuchos::rcp(new Epetra_CrsGraph(Copy, *x_map, 5));
218  for (int i=0; i<NumMyElements; ++i ) {
219 
220  // Center
221  int global_idx = MyGlobalElements[i];
222  graph->InsertGlobalIndices(global_idx, 1, &global_idx);
223 
224  if (!mesh[global_idx].boundary) {
225  // Down
226  if (!(eliminate_bcs && mesh[mesh[global_idx].down].boundary))
227  graph->InsertGlobalIndices(global_idx, 1, &mesh[global_idx].down);
228 
229  // Left
230  if (!(eliminate_bcs && mesh[mesh[global_idx].left].boundary))
231  graph->InsertGlobalIndices(global_idx, 1, &mesh[global_idx].left);
232 
233  // Right
234  if (!(eliminate_bcs && mesh[mesh[global_idx].right].boundary))
235  graph->InsertGlobalIndices(global_idx, 1, &mesh[global_idx].right);
236 
237  // Up
238  if (!(eliminate_bcs && mesh[mesh[global_idx].up].boundary))
239  graph->InsertGlobalIndices(global_idx, 1, &mesh[global_idx].up);
240  }
241  }
242  graph->FillComplete();
244 
245  KL_Diffusion_Func klFunc(xyLeft, xyRight, mu, s, 1.0, d);
246  if (!log_normal) {
247  // Fill coefficients of KL expansion of operator
248  if (basis == Teuchos::null) {
249  fillMatrices(klFunc, d+1);
250  }
251  else {
252  Normalized_KL_Diffusion_Func<KL_Diffusion_Func> nklFunc(klFunc, *basis);
253  fillMatrices(nklFunc, d+1);
254  }
255  }
256  else {
257  // Fill coefficients of PC expansion of operator
258  int sz = basis->size();
260  Teuchos::rcp_dynamic_cast<const Stokhos::ProductBasis<int, double> >(
261  basis, true);
262  LogNormal_Diffusion_Func<KL_Diffusion_Func> lnFunc(mu, klFunc, prodbasis);
263  fillMatrices(lnFunc, sz);
264  }
265 
266  // Construct deterministic operator
268 
269  // Construct the RHS vector.
270  b = Teuchos::rcp(new Epetra_Vector(*x_map));
271  for( int i=0 ; i<NumMyElements; ++i ) {
272  int global_idx = MyGlobalElements[i];
273  if (mesh[global_idx].boundary)
274  (*b)[i] = 0;
275  else
276  (*b)[i] = 1;
277  }
278 
279  if (basis != Teuchos::null) {
280  point.resize(d);
281  basis_vals.resize(basis->size());
282  }
283 
284  if (precParams != Teuchos::null) {
285  std::string name = precParams->get("Preconditioner Type", "Ifpack");
287  Teuchos::rcp(&(precParams->sublist("Preconditioner Parameters")), false);
288  precFactory =
290  }
291 }
292 
295 {
296  Kokkos::finalize();
297 }
298 
299 // Overridden from EpetraExt::ModelEvaluator
300 
303 get_x_map() const
304 {
305  return x_map;
306 }
307 
310 get_f_map() const
311 {
312  return x_map;
313 }
314 
317 get_p_map(int l) const
318 {
320  std::logic_error,
321  std::endl <<
322  "Error! twoD_diffusion_ME::get_p_map(): " <<
323  "Invalid parameter index l = " << l << std::endl);
324 
325  return p_map;
326 }
327 
330 get_g_map(int l) const
331 {
333  std::logic_error,
334  std::endl <<
335  "Error! twoD_diffusion_ME::get_g_map(): " <<
336  "Invalid parameter index l = " << l << std::endl);
337 
338  return g_map;
339 }
340 
343 get_p_names(int l) const
344 {
346  std::logic_error,
347  std::endl <<
348  "Error! twoD_diffusion_ME::get_p_names(): " <<
349  "Invalid parameter index l = " << l << std::endl);
350 
351  return p_names;
352 }
353 
356 get_x_init() const
357 {
358  return x_init;
359 }
360 
363 get_p_init(int l) const
364 {
366  std::logic_error,
367  std::endl <<
368  "Error! twoD_diffusion_ME::get_p_init(): " <<
369  "Invalid parameter index l = " << l << std::endl);
370 
371  return p_init;
372 }
373 
376 create_W() const
377 {
380  AA->FillComplete();
381  AA->OptimizeStorage();
382  return AA;
383 }
384 
388 {
389  if (precFactory != Teuchos::null) {
391  precFactory->compute(A, false);
392  return Teuchos::rcp(new EpetraExt::ModelEvaluator::Preconditioner(precOp,
393  true));
394  }
395  return Teuchos::null;
396 }
397 
398 EpetraExt::ModelEvaluator::InArgs
401 {
402  InArgsSetup inArgs;
403  inArgs.setModelEvalDescription("TwoD Diffusion Model Evaluator");
404 
405  // Deterministic InArgs
406  inArgs.setSupports(IN_ARG_x,true);
407  inArgs.set_Np(1); // 1 parameter vector
408 
409  // Stochastic InArgs
410  inArgs.setSupports(IN_ARG_x_sg,true);
411  inArgs.setSupports(IN_ARG_p_sg, 0, true); // 1 SG parameter vector
412  inArgs.setSupports(IN_ARG_sg_basis,true);
413  inArgs.setSupports(IN_ARG_sg_quadrature,true);
414  inArgs.setSupports(IN_ARG_sg_expansion,true);
415 
416  // Multipoint InArgs
417  inArgs.setSupports(IN_ARG_x_mp,true);
418  inArgs.setSupports(IN_ARG_p_mp, 0, true); // 1 MP parameter vector
419 
420  return inArgs;
421 }
422 
423 EpetraExt::ModelEvaluator::OutArgs
426 {
427  OutArgsSetup outArgs;
428  outArgs.setModelEvalDescription("TwoD Diffusion Model Evaluator");
429 
430  // Deterministic OutArgs
431  outArgs.set_Np_Ng(1, 1);
432  outArgs.setSupports(OUT_ARG_f,true);
433  outArgs.setSupports(OUT_ARG_W,true);
434  if (precFactory != Teuchos::null)
435  outArgs.setSupports(OUT_ARG_WPrec,true);
436 
437  // Stochastic OutArgs
438  outArgs.setSupports(OUT_ARG_f_sg,true);
439  outArgs.setSupports(OUT_ARG_W_sg,true);
440  outArgs.setSupports(OUT_ARG_g_sg, 0, true);
441 
442  // Multipoint OutArgs
443  outArgs.setSupports(OUT_ARG_f_mp,true);
444  outArgs.setSupports(OUT_ARG_W_mp,true);
445  outArgs.setSupports(OUT_ARG_g_mp, 0, true);
446 
447  return outArgs;
448 }
449 
450 void
452 evalModel(const InArgs& inArgs, const OutArgs& outArgs) const
453 {
454 
455  //
456  // Determinisic calculation
457  //
458 
459  // Solution vector
460  Teuchos::RCP<const Epetra_Vector> det_x = inArgs.get_x();
461 
462  // Parameters
463  Teuchos::RCP<const Epetra_Vector> p = inArgs.get_p(0);
464  if (p == Teuchos::null)
465  p = p_init;
466 
467  Teuchos::RCP<Epetra_Vector> f = outArgs.get_f();
468  Teuchos::RCP<Epetra_Operator> W = outArgs.get_W();
469  Teuchos::RCP<Epetra_Operator> WPrec = outArgs.get_WPrec();
470  if (f != Teuchos::null || W != Teuchos::null || WPrec != Teuchos::null) {
471  if (basis != Teuchos::null) {
472  for (int i=0; i<point.size(); i++)
473  point[i] = (*p)[i];
474  basis->evaluateBases(point, basis_vals);
475  A->PutScalar(0.0);
476  for (int k=0;k<A_k.size();k++)
477  EpetraExt::MatrixMatrix::Add((*A_k[k]), false, basis_vals[k], *A, 1.0);
478  }
479  else {
480  *A = *(A_k[0]);
481  for (int k=1;k<A_k.size();k++)
482  EpetraExt::MatrixMatrix::Add((*A_k[k]), false, (*p)[k-1], *A, 1.0);
483  }
484  A->FillComplete();
485  A->OptimizeStorage();
486  }
487 
488  // Residual
489  if (f != Teuchos::null) {
491  A->Apply(*det_x,*kx);
492  f->Update(1.0,*kx,-1.0, *b, 0.0);
493  }
494 
495  // Jacobian
496  if (W != Teuchos::null) {
498  Teuchos::rcp_dynamic_cast<Epetra_CrsMatrix>(W, true);
499  *jac = *A;
500  jac->FillComplete();
501  jac->OptimizeStorage();
502  }
503 
504  // Preconditioner
505  if (WPrec != Teuchos::null)
506  precFactory->recompute(A, WPrec);
507 
508  // Responses (mean value)
509  Teuchos::RCP<Epetra_Vector> g = outArgs.get_g(0);
510  if (g != Teuchos::null) {
511  (det_x->MeanValue(&(*g)[0]));
512  (*g)[0] *= double(det_x->GlobalLength()) / double(mesh.size());
513  }
514 
515  //
516  // Stochastic Galerkin calculation
517  //
518 
519  // Stochastic solution vector
520  InArgs::sg_const_vector_t x_sg = inArgs.get_x_sg();
521 
522  // Stochastic parameters
523  InArgs::sg_const_vector_t p_sg = inArgs.get_p_sg(0);
524 
525  // Stochastic residual
526  OutArgs::sg_vector_t f_sg = outArgs.get_f_sg();
527  if (f_sg != Teuchos::null) {
528 
529  // Get stochastic expansion data
531  inArgs.get_sg_expansion();
533  Teuchos::RCP<const Cijk_type> Cijk = expn->getTripleProduct();
534  const Teuchos::Array<double>& norms = basis->norm_squared();
535 
536  if (sg_kx_vec_all.size() != basis->size()) {
537  sg_kx_vec_all.resize(basis->size());
538  for (int i=0;i<basis->size();i++) {
540  }
541  }
542  f_sg->init(0.0);
543 
544  Cijk_type::k_iterator k_begin = Cijk->k_begin();
545  Cijk_type::k_iterator k_end = Cijk->k_end();
546  for (Cijk_type::k_iterator k_it=k_begin; k_it!=k_end; ++k_it) {
547  int k = Stokhos::index(k_it);
548  for (Cijk_type::kj_iterator j_it = Cijk->j_begin(k_it);
549  j_it != Cijk->j_end(k_it); ++j_it) {
550  int j = Stokhos::index(j_it);
551  A_k[k]->Apply((*x_sg)[j],*(sg_kx_vec_all[j]));
552  }
553  for (Cijk_type::kj_iterator j_it = Cijk->j_begin(k_it);
554  j_it != Cijk->j_end(k_it); ++j_it) {
555  int j = Stokhos::index(j_it);
556  for (Cijk_type::kji_iterator i_it = Cijk->i_begin(j_it);
557  i_it != Cijk->i_end(j_it); ++i_it) {
558  int i = Stokhos::index(i_it);
559  double c = Stokhos::value(i_it); // C(i,j,k)
560  (*f_sg)[i].Update(1.0*c/norms[i],*(sg_kx_vec_all[j]),1.0);
561  }
562  }
563  } //End
564  (*f_sg)[0].Update(-1.0,*b,1.0);
565  }
566 
567  // Stochastic Jacobian
568  OutArgs::sg_operator_t W_sg = outArgs.get_W_sg();
569  if (W_sg != Teuchos::null) {
570  for (int i=0; i<W_sg->size(); i++) {
572  Teuchos::rcp_dynamic_cast<Epetra_CrsMatrix>(W_sg->getCoeffPtr(i), true);
573  *jac = *A_k[i];
574  jac->FillComplete();
575  jac->OptimizeStorage();
576  }
577  }
578 
579  // Stochastic responses
581  outArgs.get_g_sg(0);
582  if (g_sg != Teuchos::null) {
583  int sz = x_sg->size();
584  for (int i=0; i<sz; i++) {
585  (*x_sg)[i].MeanValue(&(*g_sg)[i][0]);
586  (*g_sg)[i][0] *= double((*x_sg)[i].GlobalLength()) / double(mesh.size());
587  }
588  }
589 
590  //
591  // Multi-point calculation
592  //
593 
594  // Stochastic solution vector
595  mp_const_vector_t x_mp = inArgs.get_x_mp();
596 
597  // Stochastic parameters
598  mp_const_vector_t p_mp = inArgs.get_p_mp(0);
599 
600  // Stochastic residual
601  mp_vector_t f_mp = outArgs.get_f_mp();
602  mp_operator_t W_mp = outArgs.get_W_mp();
603  if (f_mp != Teuchos::null || W_mp != Teuchos::null) {
604  int num_mp = x_mp->size();
605  for (int i=0; i<num_mp; i++) {
606  // Compute operator
607  if (basis != Teuchos::null) {
608  for (int k=0; k<point.size(); k++)
609  point[k] = (*p_mp)[i][k];
610  basis->evaluateBases(point, basis_vals);
611  A->PutScalar(0.0);
612  for (int k=0;k<A_k.size();k++)
613  EpetraExt::MatrixMatrix::Add((*A_k[k]), false, basis_vals[k], *A,
614  1.0);
615  }
616  else {
617  *A = *(A_k[0]);
618  for (int k=1;k<A_k.size();k++)
619  EpetraExt::MatrixMatrix::Add((*A_k[k]), false, (*p_mp)[i][k-1], *A,
620  1.0);
621  }
622 
623  A->FillComplete();
624  A->OptimizeStorage();
625 
626  // Compute residual
627  if (f_mp != Teuchos::null) {
628  A->Apply((*x_mp)[i], (*f_mp)[i]);
629  (*f_mp)[i].Update(-1.0, *b, 1.0);
630  }
631 
632  // Copy operator
633  if (W_mp != Teuchos::null) {
635  Teuchos::rcp_dynamic_cast<Epetra_CrsMatrix>(W_mp->getCoeffPtr(i),
636  true);
637  *jac = *A;
638  jac->FillComplete();
639  jac->OptimizeStorage();
640  }
641  }
642  }
643 
644  // Multipoint responses
645  mp_vector_t g_mp = outArgs.get_g_mp(0);
646  if (g_mp != Teuchos::null) {
647  int sz = x_mp->size();
648  for (int i=0; i<sz; i++) {
649  (*x_mp)[i].MeanValue(&(*g_mp)[i][0]);
650  (*g_mp)[i][0] *= double((*x_mp)[i].GlobalLength()) / double(mesh.size());
651  }
652  }
653 
654 }
655 
Teuchos::RCP< const Epetra_Vector > get_x_init() const
Return initial solution.
void evalModel(const InArgs &inArgs, const OutArgs &outArgs) const
Evaluate model on InArgs.
KOKKOS_INLINE_FUNCTION PCE< Storage > pow(const PCE< Storage > &a, const PCE< Storage > &b)
T & get(ParameterList &l, const std::string &name)
Teuchos::Array< Teuchos::RCP< Epetra_CrsMatrix > > A_k
KL coefficients of operator.
Teuchos::RCP< Epetra_Vector > x_init
Initial guess.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Teuchos::RCP< Epetra_Map > p_map
Parameter vector map.
RCP< ParameterList > sublist(const RCP< ParameterList > &paramList, const std::string &name, bool mustAlreadyExist=false, const std::string &docString="")
ParameterList & set(std::string const &name, T &&value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
virtual void evaluateBases(const Teuchos::ArrayView< const value_type > &point, Teuchos::Array< value_type > &basis_vals) const =0
Evaluate basis polynomials at given point point.
int InsertGlobalIndices(int_type GlobalRow, int NumIndices, int_type *Indices)
virtual void recompute(const Teuchos::RCP< Epetra_Operator > &mat, const Teuchos::RCP< Epetra_Operator > &prec)=0
Recompute preconditioner operator for a new matrix.
virtual int MyPID() const =0
int FillComplete(bool OptimizeDataStorage=true)
Teuchos::RCP< const Epetra_Vector > get_p_init(int l) const
Return initial parameters.
A multidimensional index.
Teuchos::RCP< Stokhos::AbstractPreconditionerFactory > precFactory
Teuchos::RCP< Epetra_CrsGraph > graph
Jacobian graph.
Teuchos::Array< MeshPoint > mesh
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Teuchos::RCP< Teuchos::ParameterList > precParams
virtual Teuchos::RCP< Epetra_Operator > compute(const Teuchos::RCP< Epetra_Operator > &mat, bool compute_prec=true)=0
Compute preconditioner operator.
Teuchos::Array< double > basis_vals
Array to store values of basis at a point.
void resize(size_type new_size, const value_type &x=value_type())
~twoD_diffusion_ME()
Destructor.
virtual const Teuchos::Array< value_type > & norm_squared() const =0
Return array storing norm-squared of each basis polynomial.
Teuchos::RCP< const Epetra_Map > get_p_map(int l) const
Return parameter vector map.
KOKKOS_INLINE_FUNCTION PCE< Storage > exp(const PCE< Storage > &a)
Teuchos::RCP< const Epetra_Map > get_g_map(int j) const
Return response function map.
Teuchos::RCP< Epetra_Map > x_map
Solution vector map.
Stokhos::Sparse3Tensor< int, double > Cijk_type
Teuchos::RCP< Epetra_CrsMatrix > A
Matrix to store deterministic operator.
twoD_diffusion_ME(const Teuchos::RCP< const Epetra_Comm > &comm, int n, int d, double s=0.1, double mu=0.2, const Teuchos::RCP< const Stokhos::OrthogPolyBasis< int, double > > &basis=Teuchos::null, bool log_normal=false, bool eliminate_bcs=false, const Teuchos::RCP< Teuchos::ParameterList > &precParams=Teuchos::null)
Constructor.
Teuchos::RCP< Epetra_Operator > create_W() const
Create W = alpha*M + beta*J matrix.
An class for building preconditioners.
expr val()
void push_back(const value_type &x)
InArgs createInArgs() const
Create InArgs.
OutArgs createOutArgs() const
Create OutArgs.
virtual int NumProc() const =0
Teuchos::RCP< Epetra_Vector > p_init
Initial parameters.
ScalarType f(const Teuchos::Array< ScalarType > &x, double a, double b)
size_type size() const
Teuchos::RCP< EpetraExt::ModelEvaluator::Preconditioner > create_WPrec() const
Create preconditioner for W.
Class representing a KL expansion of an exponential random field.
Teuchos::RCP< const Epetra_Map > get_x_map() const
Return solution vector map.
Teuchos::RCP< Epetra_Vector > b
Deterministic RHS.
Teuchos::RCP< Teuchos::Array< std::string > > p_names
Parameter names.
Teuchos::Array< double > point
Array to store a point for basis evaluation.
void fillMatrices(const FuncT &func, int sz)
Fill coefficient matrix given function to evaluate diffusion coefficient.
ordinal_type size() const
Return size.
Teuchos::RCP< const Teuchos::Array< std::string > > get_p_names(int l) const
Return array of parameter names.
Teuchos::RCP< Epetra_Map > g_map
Response vector map.
virtual ordinal_type size() const =0
Return total size of basis.
Teuchos::RCP< const Stokhos::OrthogPolyBasis< int, double > > basis
Teuchos::Array< Teuchos::RCP< Epetra_Vector > > sg_kx_vec_all
Vectors to store matrix-vector products in SG residual calculation.
ScalarType g(const Teuchos::Array< ScalarType > &x, const ScalarType &y)
Teuchos::RCP< const Epetra_Map > get_f_map() const
Return residual vector map.