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_problem.hpp
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 #ifndef TWOD_DIFFUSION_PROBLEM_HPP
11 #define TWOD_DIFFUSION_PROBLEM_HPP
12 
13 #include "Teuchos_RCP.hpp"
14 #include "Teuchos_Array.hpp"
15 
16 #include "Epetra_Map.h"
17 #include "Epetra_LocalMap.h"
18 #include "Epetra_Import.h"
19 #include "Epetra_CrsGraph.h"
20 #include "Epetra_CrsMatrix.h"
21 
22 #include "Stokhos.hpp"
23 #include "Stokhos_Epetra.hpp"
24 
27 public:
28 
31  const Teuchos::RCP<const Epetra_Comm>& comm, int n, int d,
32  double s = 0.1, double mu = 0.2,
35  bool log_normal = false,
36  bool eliminate_bcs = false);
37 
40 
43 
46 
49 
52 
55  get_p_names(int l) const;
56 
59 
62 
65 
67  void computeResidual(const Epetra_Vector& x,
68  const Epetra_Vector& p,
69  Epetra_Vector& f);
70 
72  void computeJacobian(const Epetra_Vector& x,
73  const Epetra_Vector& p,
74  Epetra_Operator& J);
75 
77  void computeResponse(const Epetra_Vector& x,
78  const Epetra_Vector& p,
79  Epetra_Vector& g);
80 
86 
91 
96 
98 
101 
102 protected:
103 
105  template <typename FuncT>
106  void fillMatrices(const FuncT& func, int sz);
107 
109  void compute_A(const Epetra_Vector& p);
110 
111 protected:
112 
113  double h;
114  struct MeshPoint {
115  MeshPoint() : up(-1), down(-1), left(-1), right(-1), boundary(false) {}
116  double x, y;
117  int up, down, left, right;
118  bool boundary;
119  };
122 
126 
129 
132 
135 
138 
141 
144 
147 
150 
153 
156 
159 
162 
165 
168 
169 };
170 
171 #endif // TWOD_DIFFUSION_ME_HPP
A container class storing an orthogonal polynomial whose coefficients are vectors, operators, or in general any type that would have an expensive copy constructor.
void computeSGJacobian(const Stokhos::EpetraVectorOrthogPoly &x_sg, const Stokhos::EpetraVectorOrthogPoly &p_sg, Stokhos::EpetraOperatorOrthogPoly &J_sg)
Compute Jacobian.
Teuchos::Array< Teuchos::RCP< Epetra_CrsMatrix > > A_k
KL coefficients of operator.
Teuchos::RCP< Epetra_Map > x_map
Solution vector map.
Teuchos::RCP< Epetra_Operator > create_W() const
Create W = alpha*M + beta*J matrix.
Teuchos::RCP< const Epetra_Map > get_g_map(int j) const
Return response function map.
Teuchos::RCP< const Epetra_Map > get_p_map(int l) const
Return parameter vector map.
Teuchos::RCP< Epetra_CrsMatrix > A
Matrix to store deterministic operator.
Teuchos::Array< int > bcIndices
void computeResidual(const Epetra_Vector &x, const Epetra_Vector &p, Epetra_Vector &f)
Compute residual.
void computeResponse(const Epetra_Vector &x, const Epetra_Vector &p, Epetra_Vector &g)
Compute response.
Teuchos::RCP< const Epetra_Vector > get_p_init(int l) const
Return initial parameters.
void computeSGResponse(const Stokhos::EpetraVectorOrthogPoly &x_sg, const Stokhos::EpetraVectorOrthogPoly &p_sg, Stokhos::EpetraVectorOrthogPoly &g_sg)
Compute SG response.
Teuchos::RCP< Epetra_Map > g_map
Response vector map.
Teuchos::RCP< Epetra_Map > p_map
Parameter vector map.
Teuchos::RCP< const Epetra_Map > get_x_map() const
Return solution vector map.
void computeJacobian(const Epetra_Vector &x, const Epetra_Vector &p, Epetra_Operator &J)
Compute Jacobian.
Teuchos::RCP< Epetra_Vector > p_init
Initial parameters.
Abstract base class for orthogonal polynomial-based expansions.
Teuchos::Array< MeshPoint > mesh
A container class storing an orthogonal polynomial whose coefficients are vectors, operators, or in general any type that would have an expensive copy constructor.
Teuchos::Array< double > basis_vals
Array to store values of basis at a point.
Teuchos::RCP< const Epetra_Vector > get_x_init() const
Return initial solution.
Teuchos::RCP< Epetra_Vector > x_init
Initial guess.
Teuchos::RCP< const Epetra_Map > get_f_map() const
Return residual vector map.
Teuchos::RCP< Epetra_Import > importer
Importer to overlapped distribution.
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.
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.
Teuchos::RCP< const Teuchos::Array< std::string > > get_p_names(int l) const
Return array of parameter names.
ScalarType f(const Teuchos::Array< ScalarType > &x, double a, double b)
Teuchos::Array< double > point
Array to store a point for basis evaluation.
Teuchos::RCP< Epetra_CrsMatrix > get_mean() const
Get mean matrix.
Teuchos::RCP< Epetra_Vector > b
Deterministic RHS.
void compute_A(const Epetra_Vector &p)
Compute A matrix.
void fillMatrices(const FuncT &func, int sz)
Fill coefficient matrix given function to evaluate diffusion coefficient.
Teuchos::RCP< Teuchos::Array< std::string > > p_names
Parameter names.
int n
Teuchos::RCP< Epetra_CrsGraph > graph
Jacobian graph.
ScalarType g(const Teuchos::Array< ScalarType > &x, const ScalarType &y)
void computeSGResidual(const Stokhos::EpetraVectorOrthogPoly &x_sg, const Stokhos::EpetraVectorOrthogPoly &p_sg, Stokhos::OrthogPolyExpansion< int, double > &expn, Stokhos::EpetraVectorOrthogPoly &f_sg)
Compute SG residual.
A linear 2-D diffusion problem.