Stokhos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Stokhos_InterlacedTestSupport.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 <Teuchos_RCP.hpp>
12 
14 
15 #include "Stokhos_Epetra.hpp"
16 
17 #include "Epetra_LocalMap.h"
18 
20 {
22 
23  Teuchos::ParameterList& problemParams =
24  appParams->sublist("Problem");
25  problemParams.set("Name", "Heat Nonlinear Source");
26 
27  // Boundary conditions
28  problemParams.set("Left BC", 0.0);
29  problemParams.set("Right BC", 0.0);
30 
31  // Source function
32  Teuchos::ParameterList& sourceParams =
33  problemParams.sublist("Source Function");
34  sourceParams.set("Name", "Constant");
35  sourceParams.set("Constant Value", 1.0);
36 
37  // Material
38  Teuchos::ParameterList& matParams =
39  problemParams.sublist("Material Function");
40  matParams.set("Name", "KL Exponential Random Field");
41  matParams.set("Mean", 1.0);
42  matParams.set("Standard Deviation", 0.5);
43  matParams.set("Number of KL Terms", num_KL);
44  Teuchos::Array<double> a(1), b(1), L(1);
45  a[0] = 0.0; b[0] = 1.0; L[0] = 1.0;
46  matParams.set("Domain Lower Bounds", a);
47  matParams.set("Domain Upper Bounds", b);
48  matParams.set("Correlation Lengths", L);
49 
50  // Response functions
51  Teuchos::ParameterList& responseParams =
52  problemParams.sublist("Response Functions");
53  responseParams.set("Number", 1);
54  responseParams.set("Response 0", "Solution Average");
55 
56  // Setup stochastic Galerkin algorithmic parameters
58  Teuchos::rcp(&(appParams->sublist("SG Parameters")),false);
59  if (!full_expansion) {
60  sgParams->set("Parameter Expansion Type", "Linear");
61  sgParams->set("Jacobian Expansion Type", "Linear");
62  }
63  Teuchos::ParameterList& sgOpParams =
64  sgParams->sublist("SG Operator");
65  sgOpParams.set("Operator Method", "Matrix Free");
66  Teuchos::ParameterList& sgPrecParams =
67  sgParams->sublist("SG Preconditioner");
68  sgPrecParams.set("Preconditioner Method", "Mean-based");
69  sgPrecParams.set("Mean Preconditioner Type", "ML");
70  Teuchos::ParameterList& precParams =
71  sgPrecParams.sublist("Mean Preconditioner Parameters");
72  precParams.set("default values", "SA");
73 
74  return appParams;
75 }
76 
78 {
79  // Create Stochastic Galerkin basis and expansion
81  for(int i=0; i<num_KL; i++)
82  bases[i] = Teuchos::rcp(new Stokhos::LegendreBasis<int,double>(porder));
83 
86 
87  return basis;
88 }
89 
91 buildBasis(int num_KL,const std::vector<int> & order)
92 {
93  TEUCHOS_ASSERT(num_KL==int(order.size()));
94 
96  for(int i=0; i<num_KL; i++)
97  bases[i] = Teuchos::rcp(new Stokhos::LegendreBasis<int,double>(order[i]));
98 
101 
102  return basis;
103 }
104 
105 
107  const Teuchos::RCP<const Epetra_Comm> & globalComm,
109 {
110  Teuchos::ParameterList parallelParams;
111  parallelParams.set("Number of Spatial Processors", globalComm->NumProc());
112 
114  if (full_expansion)
115  Cijk = basis->computeTripleProductTensor();
116  else
117  Cijk = basis->computeLinearTripleProductTensor();
118 
119  Teuchos::RCP<Stokhos::ParallelData> sg_parallel_data
120  = Teuchos::rcp(new Stokhos::ParallelData(basis, Cijk, globalComm,
121  parallelParams));
122 
123  return sg_parallel_data;
124 }
Teuchos::RCP< Stokhos::ParallelData > buildParallelData(bool full_expansion, int num_KL, const Teuchos::RCP< const Epetra_Comm > &globalComm, const Teuchos::RCP< const Stokhos::CompletePolynomialBasis< int, double > > &basis)
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)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Teuchos::RCP< Teuchos::ParameterList > buildAppParams(int num_KL, bool full_expansion)
Legendre polynomial basis.
Teuchos::RCP< const Stokhos::CompletePolynomialBasis< int, double > > buildBasis(int num_KL, int porder)
virtual int NumProc() const =0
#define TEUCHOS_ASSERT(assertion_test)