Stokhos Package Browser (Single Doxygen Collection)  Version of the Day
twoD_diffusion_problem.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Stokhos Package
5 // Copyright (2009) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Eric T. Phipps (etphipp@sandia.gov).
38 //
39 // ***********************************************************************
40 // @HEADER
41 
42 #ifndef TWOD_DIFFUSION_PROBLEM_HPP
43 #define TWOD_DIFFUSION_PROBLEM_HPP
44 
45 #include "Teuchos_RCP.hpp"
46 #include "Teuchos_Array.hpp"
47 
48 #include "Epetra_Map.h"
49 #include "Epetra_LocalMap.h"
50 #include "Epetra_Import.h"
51 #include "Epetra_CrsGraph.h"
52 #include "Epetra_CrsMatrix.h"
53 
54 #include "Stokhos.hpp"
55 #include "Stokhos_Epetra.hpp"
56 
59 public:
60 
63  const Teuchos::RCP<const Epetra_Comm>& comm, int n, int d,
64  double s = 0.1, double mu = 0.2,
66  Teuchos::null,
67  bool log_normal = false,
68  bool eliminate_bcs = false);
69 
72 
75 
78 
81 
84 
87  get_p_names(int l) const;
88 
91 
94 
97 
99  void computeResidual(const Epetra_Vector& x,
100  const Epetra_Vector& p,
101  Epetra_Vector& f);
102 
104  void computeJacobian(const Epetra_Vector& x,
105  const Epetra_Vector& p,
106  Epetra_Operator& J);
107 
109  void computeResponse(const Epetra_Vector& x,
110  const Epetra_Vector& p,
111  Epetra_Vector& g);
112 
118 
123 
128 
130 
133 
134 protected:
135 
137  template <typename FuncT>
138  void fillMatrices(const FuncT& func, int sz);
139 
141  void compute_A(const Epetra_Vector& p);
142 
143 protected:
144 
145  double h;
146  struct MeshPoint {
147  MeshPoint() : up(-1), down(-1), left(-1), right(-1), boundary(false) {}
148  double x, y;
149  int up, down, left, right;
150  bool boundary;
151  };
154 
158 
161 
164 
167 
170 
173 
176 
179 
182 
185 
188 
191 
194 
197 
200 
201 };
202 
203 #endif // TWOD_DIFFUSION_ME_HPP
twoD_diffusion_problem::b
Teuchos::RCP< Epetra_Vector > b
Deterministic RHS.
Definition: twoD_diffusion_problem.hpp:187
twoD_diffusion_problem
A linear 2-D diffusion problem.
Definition: twoD_diffusion_problem.hpp:58
twoD_diffusion_problem::get_p_init
Teuchos::RCP< const Epetra_Vector > get_p_init(int l) const
Return initial parameters.
Definition: twoD_diffusion_problem.cpp:374
g
ScalarType g(const Teuchos::Array< ScalarType > &x, const ScalarType &y)
Definition: gram_schmidt_example3.cpp:109
twoD_diffusion_problem::x_map
Teuchos::RCP< Epetra_Map > x_map
Solution vector map.
Definition: twoD_diffusion_problem.hpp:160
twoD_diffusion_problem::compute_A
void compute_A(const Epetra_Vector &p)
Compute A matrix.
Definition: twoD_diffusion_problem.cpp:570
twoD_diffusion_problem::p_names
Teuchos::RCP< Teuchos::Array< std::string > > p_names
Parameter names.
Definition: twoD_diffusion_problem.hpp:178
twoD_diffusion_problem::MeshPoint::x
double x
Definition: twoD_diffusion_problem.hpp:148
twoD_diffusion_problem::MeshPoint::right
int right
Definition: twoD_diffusion_problem.hpp:149
Teuchos_RCP.hpp
twoD_diffusion_problem::bcIndices
Teuchos::Array< int > bcIndices
Definition: twoD_diffusion_problem.hpp:153
twoD_diffusion_problem::computeResponse
void computeResponse(const Epetra_Vector &x, const Epetra_Vector &p, Epetra_Vector &g)
Compute response.
Definition: twoD_diffusion_problem.cpp:424
Stokhos::EpetraOperatorOrthogPoly
A container class storing an orthogonal polynomial whose coefficients are vectors,...
Definition: Stokhos_EpetraOperatorOrthogPoly.hpp:55
twoD_diffusion_problem::MeshPoint::left
int left
Definition: twoD_diffusion_problem.hpp:149
twoD_diffusion_problem::computeSGResidual
void computeSGResidual(const Stokhos::EpetraVectorOrthogPoly &x_sg, const Stokhos::EpetraVectorOrthogPoly &p_sg, Stokhos::OrthogPolyExpansion< int, double > &expn, Stokhos::EpetraVectorOrthogPoly &f_sg)
Compute SG residual.
Definition: twoD_diffusion_problem.cpp:435
twoD_diffusion_problem::computeSGResponse
void computeSGResponse(const Stokhos::EpetraVectorOrthogPoly &x_sg, const Stokhos::EpetraVectorOrthogPoly &p_sg, Stokhos::EpetraVectorOrthogPoly &g_sg)
Compute SG response.
Definition: twoD_diffusion_problem.cpp:493
twoD_diffusion_problem::computeJacobian
void computeJacobian(const Epetra_Vector &x, const Epetra_Vector &p, Epetra_Operator &J)
Compute Jacobian.
Definition: twoD_diffusion_problem.cpp:410
twoD_diffusion_problem::MeshPoint::down
int down
Definition: twoD_diffusion_problem.hpp:149
twoD_diffusion_problem::get_p_map
Teuchos::RCP< const Epetra_Map > get_p_map(int l) const
Return parameter vector map.
Definition: twoD_diffusion_problem.cpp:328
twoD_diffusion_problem::p_map
Teuchos::RCP< Epetra_Map > p_map
Parameter vector map.
Definition: twoD_diffusion_problem.hpp:169
Epetra_LocalMap.h
Stokhos_Epetra.hpp
Stokhos.hpp
Epetra_CrsMatrix.h
twoD_diffusion_problem::computeSGJacobian
void computeSGJacobian(const Stokhos::EpetraVectorOrthogPoly &x_sg, const Stokhos::EpetraVectorOrthogPoly &p_sg, Stokhos::EpetraOperatorOrthogPoly &J_sg)
Compute Jacobian.
Definition: twoD_diffusion_problem.cpp:478
twoD_diffusion_problem::mesh
Teuchos::Array< MeshPoint > mesh
Definition: twoD_diffusion_problem.hpp:152
twoD_diffusion_problem::get_x_init
Teuchos::RCP< const Epetra_Vector > get_x_init() const
Return initial solution.
Definition: twoD_diffusion_problem.cpp:367
Stokhos::OrthogPolyExpansion< int, double >
twoD_diffusion_problem::A_k
Teuchos::Array< Teuchos::RCP< Epetra_CrsMatrix > > A_k
KL coefficients of operator
Definition: twoD_diffusion_problem.hpp:184
Teuchos_Array.hpp
twoD_diffusion_problem::MeshPoint::MeshPoint
MeshPoint()
Definition: twoD_diffusion_problem.hpp:147
twoD_diffusion_problem::get_mean
Teuchos::RCP< Epetra_CrsMatrix > get_mean() const
Get mean matrix.
Definition: twoD_diffusion_problem.hpp:132
twoD_diffusion_problem::importer
Teuchos::RCP< Epetra_Import > importer
Importer to overlapped distribution.
Definition: twoD_diffusion_problem.hpp:163
Teuchos::RCP< const Epetra_Comm >
Teuchos::Array
twoD_diffusion_problem::sg_kx_vec_all
Teuchos::Array< Teuchos::RCP< Epetra_Vector > > sg_kx_vec_all
Vectors to store matrix-vector products in SG residual calculation.
Definition: twoD_diffusion_problem.hpp:190
twoD_diffusion_problem::A
Teuchos::RCP< Epetra_CrsMatrix > A
Matrix to store deterministic operator.
Definition: twoD_diffusion_problem.hpp:193
Stokhos::EpetraVectorOrthogPoly
A container class storing an orthogonal polynomial whose coefficients are vectors,...
Definition: Stokhos_EpetraVectorOrthogPoly.hpp:55
twoD_diffusion_problem::g_map
Teuchos::RCP< Epetra_Map > g_map
Response vector map.
Definition: twoD_diffusion_problem.hpp:172
twoD_diffusion_problem::computeResidual
void computeResidual(const Epetra_Vector &x, const Epetra_Vector &p, Epetra_Vector &f)
Compute residual.
Definition: twoD_diffusion_problem.cpp:398
twoD_diffusion_problem::p_init
Teuchos::RCP< Epetra_Vector > p_init
Initial parameters.
Definition: twoD_diffusion_problem.hpp:175
twoD_diffusion_problem::MeshPoint::y
double y
Definition: twoD_diffusion_problem.hpp:148
twoD_diffusion_problem::MeshPoint::boundary
bool boundary
Definition: twoD_diffusion_problem.hpp:150
twoD_diffusion_problem::get_p_names
Teuchos::RCP< const Teuchos::Array< std::string > > get_p_names(int l) const
Return array of parameter names.
Definition: twoD_diffusion_problem.cpp:354
j
j
Definition: Sacado_Fad_Exp_MP_Vector.hpp:527
Epetra_Vector
twoD_diffusion_problem::get_f_map
Teuchos::RCP< const Epetra_Map > get_f_map() const
Return residual vector map.
Definition: twoD_diffusion_problem.cpp:321
Epetra_Import.h
f
ScalarType f(const Teuchos::Array< ScalarType > &x, double a, double b)
Definition: gram_schmidt_example3.cpp:98
twoD_diffusion_problem::basis_vals
Teuchos::Array< double > basis_vals
Array to store values of basis at a point.
Definition: twoD_diffusion_problem.hpp:199
cusp::detail::device::x
const IndexType const IndexType const IndexType const IndexType const ValueType const ValueType * x
Definition: csr_vector.h:260
twoD_diffusion_problem::fillMatrices
void fillMatrices(const FuncT &func, int sz)
Fill coefficient matrix given function to evaluate diffusion coefficient.
Definition: twoD_diffusion_problem.cpp:507
twoD_diffusion_problem::h
double h
Definition: twoD_diffusion_problem.hpp:145
twoD_diffusion_problem::MeshPoint::up
int up
Definition: twoD_diffusion_problem.hpp:149
twoD_diffusion_problem::basis
Teuchos::RCP< const Stokhos::OrthogPolyBasis< int, double > > basis
Definition: twoD_diffusion_problem.hpp:155
twoD_diffusion_problem::graph
Teuchos::RCP< Epetra_CrsGraph > graph
Jacobian graph.
Definition: twoD_diffusion_problem.hpp:181
twoD_diffusion_problem::create_W
Teuchos::RCP< Epetra_Operator > create_W() const
Create W = alpha*M + beta*J matrix.
Definition: twoD_diffusion_problem.cpp:387
twoD_diffusion_problem::x_init
Teuchos::RCP< Epetra_Vector > x_init
Initial guess.
Definition: twoD_diffusion_problem.hpp:166
twoD_diffusion_problem::get_x_map
Teuchos::RCP< const Epetra_Map > get_x_map() const
Return solution vector map.
Definition: twoD_diffusion_problem.cpp:314
Epetra_CrsGraph.h
twoD_diffusion_problem::eliminate_bcs
bool eliminate_bcs
Definition: twoD_diffusion_problem.hpp:157
twoD_diffusion_problem::log_normal
bool log_normal
Definition: twoD_diffusion_problem.hpp:156
twoD_diffusion_problem::twoD_diffusion_problem
twoD_diffusion_problem(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)
Constructor.
Definition: twoD_diffusion_problem.cpp:160
Epetra_Map.h
twoD_diffusion_problem::MeshPoint
Definition: twoD_diffusion_problem.hpp:146
twoD_diffusion_problem::get_g_map
Teuchos::RCP< const Epetra_Map > get_g_map(int j) const
Return response function map.
Definition: twoD_diffusion_problem.cpp:341
Epetra_Operator
n
int n
twoD_diffusion_problem::point
Teuchos::Array< double > point
Array to store a point for basis evaluation.
Definition: twoD_diffusion_problem.hpp:196
Stokhos::OrthogPolyBasis< int, double >