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 /*
2 // @HEADER
3 // ***********************************************************************
4 //
5 // Stokhos Package
6 // Copyright (2009) Sandia Corporation
7 //
8 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
9 // license for use of this work by or on behalf of the U.S. Government.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact Eric T. Phipps (etphipp@sandia.gov).
39 //
40 // ***********************************************************************
41 // @HEADER
42 */
43 
44 #include <Teuchos_RCP.hpp>
46 
48 
49 #include "Stokhos_Epetra.hpp"
50 
51 #include "Epetra_LocalMap.h"
52 
54 {
56 
57  Teuchos::ParameterList& problemParams =
58  appParams->sublist("Problem");
59  problemParams.set("Name", "Heat Nonlinear Source");
60 
61  // Boundary conditions
62  problemParams.set("Left BC", 0.0);
63  problemParams.set("Right BC", 0.0);
64 
65  // Source function
66  Teuchos::ParameterList& sourceParams =
67  problemParams.sublist("Source Function");
68  sourceParams.set("Name", "Constant");
69  sourceParams.set("Constant Value", 1.0);
70 
71  // Material
72  Teuchos::ParameterList& matParams =
73  problemParams.sublist("Material Function");
74  matParams.set("Name", "KL Exponential Random Field");
75  matParams.set("Mean", 1.0);
76  matParams.set("Standard Deviation", 0.5);
77  matParams.set("Number of KL Terms", num_KL);
78  Teuchos::Array<double> a(1), b(1), L(1);
79  a[0] = 0.0; b[0] = 1.0; L[0] = 1.0;
80  matParams.set("Domain Lower Bounds", a);
81  matParams.set("Domain Upper Bounds", b);
82  matParams.set("Correlation Lengths", L);
83 
84  // Response functions
85  Teuchos::ParameterList& responseParams =
86  problemParams.sublist("Response Functions");
87  responseParams.set("Number", 1);
88  responseParams.set("Response 0", "Solution Average");
89 
90  // Setup stochastic Galerkin algorithmic parameters
92  Teuchos::rcp(&(appParams->sublist("SG Parameters")),false);
93  if (!full_expansion) {
94  sgParams->set("Parameter Expansion Type", "Linear");
95  sgParams->set("Jacobian Expansion Type", "Linear");
96  }
97  Teuchos::ParameterList& sgOpParams =
98  sgParams->sublist("SG Operator");
99  sgOpParams.set("Operator Method", "Matrix Free");
100  Teuchos::ParameterList& sgPrecParams =
101  sgParams->sublist("SG Preconditioner");
102  sgPrecParams.set("Preconditioner Method", "Mean-based");
103  sgPrecParams.set("Mean Preconditioner Type", "ML");
104  Teuchos::ParameterList& precParams =
105  sgPrecParams.sublist("Mean Preconditioner Parameters");
106  precParams.set("default values", "SA");
107 
108  return appParams;
109 }
110 
112 {
113  // Create Stochastic Galerkin basis and expansion
115  for(int i=0; i<num_KL; i++)
116  bases[i] = Teuchos::rcp(new Stokhos::LegendreBasis<int,double>(porder));
117 
120 
121  return basis;
122 }
123 
125 buildBasis(int num_KL,const std::vector<int> & order)
126 {
127  TEUCHOS_ASSERT(num_KL==int(order.size()));
128 
130  for(int i=0; i<num_KL; i++)
131  bases[i] = Teuchos::rcp(new Stokhos::LegendreBasis<int,double>(order[i]));
132 
135 
136  return basis;
137 }
138 
139 
141  const Teuchos::RCP<const Epetra_Comm> & globalComm,
143 {
144  Teuchos::ParameterList parallelParams;
145  parallelParams.set("Number of Spatial Processors", globalComm->NumProc());
146 
148  if (full_expansion)
149  Cijk = basis->computeTripleProductTensor();
150  else
151  Cijk = basis->computeLinearTripleProductTensor();
152 
153  Teuchos::RCP<Stokhos::ParallelData> sg_parallel_data
154  = Teuchos::rcp(new Stokhos::ParallelData(basis, Cijk, globalComm,
155  parallelParams));
156 
157  return sg_parallel_data;
158 }
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)
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
RCP< ParameterList > sublist(const RCP< ParameterList > &paramList, const std::string &name, bool mustAlreadyExist=false, const std::string &docString="")
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)