Stokhos Package Browser (Single Doxygen Collection) Version of the Day
Loading...
Searching...
No Matches
Stokhos_SGModelEvaluator_Adaptive.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 STOKHOS_SGMODELEVALUATOR_ADAPTIVE_HPP
43#define STOKHOS_SGMODELEVALUATOR_ADAPTIVE_HPP
44
45#include <vector>
46
47#include "EpetraExt_ModelEvaluator.h"
48#include "EpetraExt_MultiComm.h"
49#include "EpetraExt_BlockVector.h"
50
52#include "Teuchos_RCP.hpp"
53#include "Teuchos_Array.hpp"
54#include "Teuchos_ParameterList.hpp"
64
65namespace Stokhos {
66
68
83 public:
84
85 // Constructor
87 const Teuchos::RCP<EpetraExt::ModelEvaluator>& me_,
88 const Teuchos::RCP<Stokhos::AdaptivityManager> & am,
89 const Teuchos::RCP<const Stokhos::Quadrature<int,double> >& sg_quad_,
90 const Teuchos::RCP<Stokhos::OrthogPolyExpansion<int,double> >& sg_exp_,
91 const Teuchos::RCP<const Stokhos::ParallelData>& sg_parallel_data_,
92 bool onlyUseLinear_,int kExpOrder_,
93 const Teuchos::RCP<Teuchos::ParameterList>& params_);
94
95 // Constructor
97 const Teuchos::RCP<EpetraExt::ModelEvaluator>& me,
98 const Teuchos::RCP<const Stokhos::OrthogPolyBasis<int,double> >& sg_master_basis,
99 const std::vector<Teuchos::RCP<const Stokhos::ProductBasis<int,double> > > & sg_row_dof_basis,
100 const Teuchos::RCP<const Stokhos::Quadrature<int,double> >& sg_quad,
102 const Teuchos::RCP<const Stokhos::ParallelData>& sg_parallel_data,
103 bool onlyUseLinear,int kExpOrder,
104 const Teuchos::RCP<Teuchos::ParameterList>& params,
105 bool scaleOP = true);
106
109
110 // inputs
112
114 Teuchos::RCP<const Epetra_Map> get_x_map() const;
115
117 Teuchos::RCP<const Epetra_Map> get_p_map(int l) const;
118
120 Teuchos::RCP<const Teuchos::Array<std::string> >
121 get_p_names(int l) const;
122
124 Teuchos::RCP<const Epetra_Vector> get_x_init() const;
125
127 Teuchos::RCP<const Epetra_Vector> get_p_init(int l) const;
128
129 // outputs
131
133 Teuchos::RCP<const Epetra_Map> get_f_map() const;
134
136 Teuchos::RCP<const Epetra_Map> get_g_map(int l) const;
137
139 Teuchos::RCP<Epetra_Operator> create_W() const;
140
141 // ????
143
145 InArgs createInArgs() const;
146
148 OutArgs createOutArgs() const;
149
151 void evalModel(const InArgs& inArgs, const OutArgs& outArgs) const;
152
154
157
160
162 Teuchos::RCP<const Stokhos::EpetraVectorOrthogPoly> get_x_sg_init() const;
163
165 void set_p_sg_init(int i, const Stokhos::EpetraVectorOrthogPoly& p_sg_in);
166
168 Teuchos::RCP<const Stokhos::EpetraVectorOrthogPoly> get_p_sg_init(int l) const;
169
171
174 Teuchos::Array<int> get_p_sg_map_indices() const;
175
177
180 Teuchos::Array<int> get_g_sg_map_indices() const;
181
183 Teuchos::Array< Teuchos::RCP<const Epetra_Map> > get_g_sg_base_maps() const;
184
186 Teuchos::RCP<const Epetra_BlockMap> get_overlap_stochastic_map() const;
187
189 Teuchos::RCP<const Epetra_BlockMap> get_x_sg_overlap_map() const;
190
192 Teuchos::RCP<const Epetra_Import> get_x_sg_importer() const;
193
195 Teuchos::RCP<Stokhos::EpetraVectorOrthogPoly>
197 const Epetra_Vector* v=NULL) const;
198
200 Teuchos::RCP<Stokhos::EpetraVectorOrthogPoly>
202 const Epetra_Vector* v=NULL) const;
203
205 Teuchos::RCP<Stokhos::EpetraMultiVectorOrthogPoly>
206 create_x_mv_sg(int num_vecs,
208 const Epetra_MultiVector* v = NULL) const;
209
211 Teuchos::RCP<Stokhos::EpetraMultiVectorOrthogPoly>
212 create_x_mv_sg_overlap(int num_vecs,
214 const Epetra_MultiVector* v = NULL) const;
215
217 Teuchos::RCP<Stokhos::EpetraVectorOrthogPoly>
219 const Epetra_Vector * v=0) const;
220
222 Teuchos::RCP<Stokhos::EpetraVectorOrthogPoly>
224 const Epetra_Vector* v = NULL) const;
225
227 Teuchos::RCP<Stokhos::EpetraVectorOrthogPoly>
229 const Epetra_Vector* v = NULL) const;
230
232 Teuchos::RCP<Stokhos::EpetraMultiVectorOrthogPoly>
233 create_f_mv_sg(int num_vecs, Epetra_DataAccess CV = Copy,
234 const Epetra_MultiVector* v = NULL) const;
235
237 Teuchos::RCP<Stokhos::EpetraMultiVectorOrthogPoly>
239 const Epetra_MultiVector* v = NULL) const;
240
242 Teuchos::RCP<Stokhos::EpetraVectorOrthogPoly>
244 const Epetra_Vector* v = NULL) const;
245
247 Teuchos::RCP<Stokhos::EpetraMultiVectorOrthogPoly>
248 create_g_mv_sg(int l, int num_vecs, Epetra_DataAccess CV = Copy,
249 const Epetra_MultiVector* v = NULL) const;
250
252
253 Teuchos::RCP<const Stokhos::AdaptivityManager> getAdaptivityManager() const
254 { return adaptMngr; }
255
256 protected:
257
259 Teuchos::RCP<EpetraExt::ModelEvaluator> me;
260
262 Teuchos::RCP<const Stokhos::OrthogPolyBasis<int, double> > sg_basis;
263
264 std::vector<Teuchos::RCP<const Stokhos::ProductBasis<int,double> > > sg_row_dof_basis;
265
267 Teuchos::RCP<const Stokhos::Quadrature<int,double> > sg_quad;
268
270 Teuchos::RCP<Stokhos::OrthogPolyExpansion<int,double> > sg_exp;
271
273 Teuchos::RCP<Teuchos::ParameterList> params;
274
276 unsigned int num_sg_blocks;
277
279 unsigned int num_W_blocks;
280
282 unsigned int num_p_blocks;
283
286
288 Teuchos::RCP<const Epetra_Map> x_map;
289
291 Teuchos::RCP<const Epetra_Map> f_map;
292
294 Teuchos::RCP<const Stokhos::ParallelData> sg_parallel_data;
295
297 Teuchos::RCP<const EpetraExt::MultiComm> sg_comm;
298
300 Teuchos::RCP<const Stokhos::EpetraSparse3Tensor> epetraCijk;
301
303 Teuchos::RCP<const Stokhos::EpetraSparse3Tensor> serialCijk;
304
305 Teuchos::RCP<const Stokhos::Sparse3Tensor<int,double> > Cijk;
306
308 Teuchos::RCP<const Epetra_BlockMap> stoch_row_map;
309
311 Teuchos::RCP<const Epetra_BlockMap> overlapped_stoch_row_map;
312
314 Teuchos::RCP<const Epetra_BlockMap> overlapped_stoch_p_map;
315
317 Teuchos::RCP<const Epetra_Map> sg_x_map;
318
320 Teuchos::RCP<const Epetra_Map> sg_overlapped_x_map;
321
323 Teuchos::RCP<const Epetra_Map> sg_f_map;
324
326 Teuchos::RCP<const Epetra_Map> sg_overlapped_f_map;
327
329 Teuchos::RCP<const Epetra_Map> adapted_x_map;
330
332 Teuchos::RCP<const Epetra_Map> adapted_overlapped_x_map;
333
335 Teuchos::RCP<const Epetra_Map> adapted_f_map;
336
338 Teuchos::RCP<const Epetra_Map> adapted_overlapped_f_map;
339
341 Teuchos::RCP<Epetra_Import> adapted_overlapped_x_importer;
342
344 Teuchos::RCP<Epetra_Export> adapted_overlapped_f_exporter;
345
347 int num_p;
348
351
353 Teuchos::Array<int> sg_p_index_map;
354
356 Teuchos::Array< Teuchos::RCP<const Epetra_Map> > sg_p_map;
357
359 Teuchos::Array< Teuchos::RCP< Teuchos::Array<std::string> > > sg_p_names;
360
362 int num_g;
363
366
368 Teuchos::Array<int> sg_g_index_map;
369
371 Teuchos::Array< Teuchos::RCP<const Epetra_Map> > sg_g_map;
372
374 Teuchos::RCP< Stokhos::EpetraVectorOrthogPoly > x_dot_sg_blocks;
375
377 Teuchos::RCP< Stokhos::EpetraVectorOrthogPoly > x_sg_blocks;
378
380 mutable Teuchos::RCP< Stokhos::EpetraVectorOrthogPoly > f_sg_blocks;
381
383 mutable Teuchos::RCP< Stokhos::EpetraOperatorOrthogPoly > W_sg_blocks;
384
385 mutable Teuchos::Array< Teuchos::RCP< Stokhos::EpetraMultiVectorOrthogPoly > > dfdp_sg_blocks;
386
388 mutable Teuchos::Array< Teuchos::RCP< Stokhos::EpetraMultiVectorOrthogPoly > > dgdx_dot_sg_blocks;
389
391 mutable Teuchos::Array< Teuchos::RCP< Stokhos::EpetraMultiVectorOrthogPoly > > dgdx_sg_blocks;
392
394 Teuchos::RCP<Stokhos::EpetraVectorOrthogPoly> sg_x_init;
395
397 Teuchos::Array< Teuchos::RCP<Stokhos::EpetraVectorOrthogPoly> > sg_p_init;
398
401
404
406 mutable Teuchos::RCP<Epetra_CrsMatrix> my_W;
407
409 mutable Teuchos::RCP<Epetra_Vector> my_x;
410
412
413 mutable Teuchos::RCP<Stokhos::AdaptivityManager> adaptMngr;
414 };
415
416}
417
418#endif
Epetra_DataAccess
Copy
A container class storing an orthogonal polynomial whose coefficients are vectors,...
Abstract base class for multivariate orthogonal polynomials.
Abstract base class for orthogonal polynomial-based expansions.
Abstract base class for multivariate orthogonal polynomials generated from tensor products of univari...
Abstract base class for quadrature methods.
Base class for stochastic Galerkin model evaluators.
Nonlinear, stochastic Galerkin ModelEvaluator that constructs an adapted Jacobian.
Teuchos::RCP< const Epetra_Vector > get_x_init() const
Return initial solution.
Teuchos::RCP< Stokhos::OrthogPolyExpansion< int, double > > sg_exp
Stochastic Galerkin expansion.
Teuchos::RCP< const Epetra_Import > get_x_sg_importer() const
Return x sg importer.
Teuchos::RCP< Stokhos::EpetraVectorOrthogPoly > create_f_sg(Epetra_DataAccess CV=Copy, const Epetra_Vector *v=NULL) const
Create vector orthog poly using f map and owned sg map.
unsigned int num_sg_blocks
Number of stochastic blocks.
void evalModel(const InArgs &inArgs, const OutArgs &outArgs) const
Evaluate model on InArgs.
Teuchos::RCP< const Epetra_Vector > get_p_init(int l) const
Return initial parameters.
Teuchos::RCP< Stokhos::EpetraMultiVectorOrthogPoly > create_x_mv_sg(int num_vecs, Epetra_DataAccess CV=Copy, const Epetra_MultiVector *v=NULL) const
Create vector orthog poly using x map and owned sg map.
Teuchos::Array< Teuchos::RCP< Stokhos::EpetraVectorOrthogPoly > > sg_p_init
SG initial p.
Teuchos::RCP< const Epetra_Map > sg_f_map
Block SG residual map.
Teuchos::Array< Teuchos::RCP< Teuchos::Array< std::string > > > sg_p_names
SG coefficient parameter names.
Teuchos::RCP< Stokhos::EpetraVectorOrthogPoly > f_sg_blocks
f stochastic Galerkin components
Teuchos::RCP< const Stokhos::EpetraVectorOrthogPoly > get_x_sg_init() const
Return initial SG x.
Teuchos::Array< Teuchos::RCP< Stokhos::EpetraMultiVectorOrthogPoly > > dgdx_dot_sg_blocks
dg/dxdot stochastic Galerkin components
Teuchos::RCP< const Epetra_BlockMap > stoch_row_map
Map for stochastic blocks.
Teuchos::Array< Teuchos::RCP< Stokhos::EpetraMultiVectorOrthogPoly > > dgdx_sg_blocks
dg/dx stochastic Galerkin components
Teuchos::Array< int > sg_p_index_map
Index map between block-p and p_sg maps.
bool eval_W_with_f
Whether to always evaluate W with f.
Teuchos::RCP< Stokhos::EpetraVectorOrthogPoly > x_sg_blocks
x stochastic Galerkin components
Teuchos::RCP< EpetraExt::ModelEvaluator > me
Underlying model evaluator.
std::vector< Teuchos::RCP< const Stokhos::ProductBasis< int, double > > > sg_row_dof_basis
Teuchos::RCP< const Epetra_Map > get_x_map() const
Return solution vector map.
Teuchos::RCP< Stokhos::EpetraOperatorOrthogPoly > W_sg_blocks
W stochastic Galerkin components.
Teuchos::RCP< const Epetra_BlockMap > get_overlap_stochastic_map() const
Return overlap stochastic map.
Teuchos::Array< Teuchos::RCP< Stokhos::EpetraMultiVectorOrthogPoly > > dfdp_sg_blocks
Teuchos::RCP< const Epetra_BlockMap > overlapped_stoch_row_map
Overlapped map for stochastic blocks (local map)
Teuchos::RCP< const Epetra_Map > f_map
Underlying residual map.
Teuchos::RCP< Stokhos::EpetraVectorOrthogPoly > create_x_sg_overlap(Epetra_DataAccess CV=Copy, const Epetra_Vector *v=NULL) const
Create vector orthog poly using x map and overlap sg map.
int num_g_sg
Number of stochastic response vectors.
Teuchos::Array< Teuchos::RCP< const Epetra_Map > > sg_g_map
Block SG response map.
void set_p_sg_init(int i, const Stokhos::EpetraVectorOrthogPoly &p_sg_in)
Set initial parameter polynomial.
Teuchos::RCP< const Epetra_Map > get_g_map(int l) const
Return response map.
Teuchos::RCP< Stokhos::EpetraVectorOrthogPoly > create_g_sg(int l, Epetra_DataAccess CV=Copy, const Epetra_Vector *v=NULL) const
Create vector orthog poly using g map.
Teuchos::RCP< Stokhos::EpetraVectorOrthogPoly > create_f_sg_overlap(Epetra_DataAccess CV=Copy, const Epetra_Vector *v=NULL) const
Create vector orthog poly using f map and overlap sg map.
Teuchos::Array< Teuchos::RCP< const Epetra_Map > > sg_p_map
Block SG parameter map.
Teuchos::RCP< const Teuchos::Array< std::string > > get_p_names(int l) const
Return array of parameter names.
Teuchos::RCP< Epetra_Import > adapted_overlapped_x_importer
Importer from SG to SG-overlapped maps.
unsigned int num_p_blocks
Number of p stochastic blocks (may be smaller than num_sg_blocks)
Teuchos::Array< Teuchos::RCP< const Epetra_Map > > get_g_sg_base_maps() const
Get base maps of SG responses.
Teuchos::RCP< const Epetra_Map > adapted_overlapped_f_map
Adapted block SG overlapped residual map.
unsigned int num_W_blocks
Number of W stochastic blocks (may be smaller than num_sg_blocks)
Teuchos::RCP< const Epetra_Map > sg_overlapped_f_map
Block SG overlapped residual map.
Teuchos::RCP< const Stokhos::ParallelData > sg_parallel_data
Parallel SG data.
Teuchos::RCP< Epetra_Vector > my_x
x pointer for evaluating preconditioner
Teuchos::Array< int > get_g_sg_map_indices() const
Get indices of SG responses.
Teuchos::RCP< const Epetra_Map > sg_overlapped_x_map
Block SG overlapped unknown map.
Teuchos::RCP< const Epetra_Map > adapted_f_map
Adapted block SG residual map.
Teuchos::RCP< Stokhos::AdaptivityManager > adaptMngr
Teuchos::RCP< Stokhos::EpetraVectorOrthogPoly > create_x_sg(Epetra_DataAccess CV=Copy, const Epetra_Vector *v=NULL) const
Create vector orthog poly using x map and owned sg map.
Teuchos::RCP< Epetra_CrsMatrix > my_W
W pointer for evaluating W with f.
Teuchos::Array< int > sg_g_index_map
Index map between block-g and g_sg maps.
Teuchos::RCP< const Stokhos::OrthogPolyBasis< int, double > > sg_basis
Stochastic Galerkin basis.
Teuchos::RCP< const Stokhos::AdaptivityManager > getAdaptivityManager() const
Teuchos::RCP< const Epetra_Map > x_map
Underlying unknown map.
Teuchos::RCP< Stokhos::EpetraMultiVectorOrthogPoly > create_f_mv_sg(int num_vecs, Epetra_DataAccess CV=Copy, const Epetra_MultiVector *v=NULL) const
Create multi-vector orthog poly using f map and owned sg map.
Teuchos::RCP< const Stokhos::Quadrature< int, double > > sg_quad
Stochastic Galerkin quadrature.
Teuchos::RCP< const Stokhos::EpetraVectorOrthogPoly > get_p_sg_init(int l) const
Return initial SG parameters.
Teuchos::RCP< Stokhos::EpetraVectorOrthogPoly > x_dot_sg_blocks
x_dot stochastic Galerkin components
Teuchos::RCP< const Epetra_Map > get_f_map() const
Return residual vector map.
Teuchos::RCP< const Stokhos::Sparse3Tensor< int, double > > Cijk
int num_p_sg
Number of stochastic parameter vectors.
Teuchos::RCP< Teuchos::ParameterList > params
Algorithmic parameters.
Teuchos::RCP< Epetra_Operator > create_W() const
Create W = alpha*M + beta*J matrix.
Teuchos::RCP< const Epetra_BlockMap > get_x_sg_overlap_map() const
Return x sg overlap map.
int num_g
Number of response vectors of underlying model evaluator.
Teuchos::RCP< const Epetra_Map > get_p_map(int l) const
Return parameter vector map.
Teuchos::Array< int > get_p_sg_map_indices() const
Get indices of SG parameters.
Teuchos::RCP< const Epetra_Map > adapted_x_map
Adapted lock SG unknown map.
Teuchos::RCP< const Epetra_Map > sg_x_map
Block SG unknown map.
void set_x_sg_init(const Stokhos::EpetraVectorOrthogPoly &x_sg_in)
Set initial solution polynomial.
Teuchos::RCP< const EpetraExt::MultiComm > sg_comm
Parallel SG communicator.
Teuchos::RCP< Stokhos::EpetraMultiVectorOrthogPoly > create_f_mv_sg_overlap(int num_vecs, Epetra_DataAccess CV=Copy, const Epetra_MultiVector *v=NULL) const
Create multi-vector orthog poly using f map and overlap sg map.
Teuchos::RCP< const Epetra_Map > adapted_overlapped_x_map
Adapated block SG overlapped unknown map.
Teuchos::RCP< Stokhos::EpetraMultiVectorOrthogPoly > create_x_mv_sg_overlap(int num_vecs, Epetra_DataAccess CV=Copy, const Epetra_MultiVector *v=NULL) const
Create vector orthog poly using x map and overlap sg map.
Teuchos::RCP< const Epetra_BlockMap > overlapped_stoch_p_map
Overlapped map for p stochastic blocks (local map)
Teuchos::RCP< Stokhos::EpetraVectorOrthogPoly > create_p_sg(int l, Epetra_DataAccess CV=Copy, const Epetra_Vector *v=0) const
Create vector orthog poly using p map.
int num_p
Number of parameter vectors of underlying model evaluator.
Teuchos::RCP< Stokhos::EpetraMultiVectorOrthogPoly > create_g_mv_sg(int l, int num_vecs, Epetra_DataAccess CV=Copy, const Epetra_MultiVector *v=NULL) const
Create multi-vector orthog poly using g map.
Teuchos::RCP< Stokhos::EpetraVectorOrthogPoly > sg_x_init
SG initial x.
bool supports_x
Whether we support x (and thus f and W)
Teuchos::RCP< Epetra_Export > adapted_overlapped_f_exporter
Exporter from SG-overlapped to SG maps.
Teuchos::RCP< const Stokhos::EpetraSparse3Tensor > serialCijk
Serial Epetra Cijk for dgdx*.
Teuchos::RCP< const Stokhos::EpetraSparse3Tensor > epetraCijk
Epetra Cijk.
Top-level namespace for Stokhos classes and functions.