Stokhos Package Browser (Single Doxygen Collection) Version of the Day
Loading...
Searching...
No Matches
Stokhos_MatrixFreeOperator.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_MATRIX_FREE_OPERATOR_HPP
43#define STOKHOS_MATRIX_FREE_OPERATOR_HPP
44
46#include "EpetraExt_MultiComm.h"
49#include "Epetra_Map.h"
50#include "Epetra_Import.h"
51#include "Teuchos_ParameterList.hpp"
52#include "Teuchos_Array.hpp"
53
54namespace Stokhos {
55
61
62 public:
63
66 const Teuchos::RCP<const EpetraExt::MultiComm>& sg_comm,
67 const Teuchos::RCP<const Stokhos::OrthogPolyBasis<int,double> >& sg_basis,
68 const Teuchos::RCP<const Stokhos::EpetraSparse3Tensor>& epetraCijk,
69 const Teuchos::RCP<const Epetra_Map>& domain_base_map,
70 const Teuchos::RCP<const Epetra_Map>& range_base_map,
71 const Teuchos::RCP<const Epetra_Map>& domain_sg_map,
72 const Teuchos::RCP<const Epetra_Map>& range_sg_map,
73 const Teuchos::RCP<Teuchos::ParameterList>& params);
74
76 virtual ~MatrixFreeOperator();
77
79 double countApplyFlops() const;
80
83
85 virtual void setupOperator(
86 const Teuchos::RCP<Stokhos::EpetraOperatorOrthogPoly >& poly);
87
89 virtual Teuchos::RCP< Stokhos::EpetraOperatorOrthogPoly >
91
93 virtual Teuchos::RCP<const Stokhos::EpetraOperatorOrthogPoly >
94 getSGPolynomial() const;
95
97
100
102 virtual int SetUseTranspose(bool UseTranspose);
103
108 virtual int Apply(const Epetra_MultiVector& Input,
109 Epetra_MultiVector& Result) const;
110
115 virtual int ApplyInverse(const Epetra_MultiVector& X,
116 Epetra_MultiVector& Y) const;
117
119 virtual double NormInf() const;
120
122 virtual const char* Label () const;
123
125 virtual bool UseTranspose() const;
126
131 virtual bool HasNormInf() const;
132
137 virtual const Epetra_Comm & Comm() const;
138
143 virtual const Epetra_Map& OperatorDomainMap () const;
144
149 virtual const Epetra_Map& OperatorRangeMap () const;
150
152
153 private:
154
157
160
161 protected:
162
164 std::string label;
165
167 Teuchos::RCP<const EpetraExt::MultiComm> sg_comm;
168
170 Teuchos::RCP<const Stokhos::OrthogPolyBasis<int,double> > sg_basis;
171
173 Teuchos::RCP<const Stokhos::EpetraSparse3Tensor> epetraCijk;
174
176 Teuchos::RCP<const Epetra_Map> domain_base_map;
177
179 Teuchos::RCP<const Epetra_Map> range_base_map;
180
182 Teuchos::RCP<const Epetra_Map> domain_sg_map;
183
185 Teuchos::RCP<const Epetra_Map> range_sg_map;
186
189
191 Teuchos::RCP<Epetra_Map> global_col_map;
192
194 Teuchos::RCP<Epetra_Map> global_col_map_trans;
195
197 Teuchos::RCP<const Epetra_BlockMap> stoch_col_map;
198
200 Teuchos::RCP<Epetra_Import> col_importer;
201
203 Teuchos::RCP<Epetra_Import> col_importer_trans;
204
207
209 Teuchos::RCP<const Cijk_type> Cijk;
210
212 Teuchos::RCP<Stokhos::EpetraOperatorOrthogPoly > block_ops;
213
216
219
222
225
228
231
234
237
239 mutable Teuchos::RCP<Epetra_MultiVector> input_col;
240
242 mutable Teuchos::RCP<Epetra_MultiVector> input_col_trans;
243
245 mutable Teuchos::Array< Teuchos::RCP<const Epetra_MultiVector> > input_block;
246
248 mutable Teuchos::Array< Teuchos::RCP<Epetra_MultiVector> > result_block;
249
251 mutable Teuchos::RCP<Epetra_MultiVector> tmp;
252
254 mutable Teuchos::RCP<Epetra_MultiVector> tmp_trans;
255
258
261
262 }; // class MatrixFreeOperator
263
264} // namespace Stokhos
265
266#endif // STOKHOS_MATRIX_FREE_OPERATOR_HPP
An Epetra operator representing the block stochastic Galerkin operator.
virtual const char * Label() const
Returns a character string describing the operator.
int num_blocks
Number of Jacobian blocks (not necessarily equal to expansion_size)
Teuchos::RCP< const Epetra_Map > range_base_map
Stores range base map.
std::string label
Label for operator.
Teuchos::RCP< Epetra_Import > col_importer
Importer from domain map to column map.
MatrixFreeOperator(const MatrixFreeOperator &)
Private to prohibit copying.
Teuchos::RCP< const Epetra_Map > range_sg_map
Stores range SG map.
Cijk_type::k_iterator k_end
Ending k iterator.
Teuchos::RCP< Epetra_MultiVector > input_col_trans
Temporary to store result of importing input into column map (transpose)
virtual bool HasNormInf() const
Returns true if the this object can provide an approximate Inf-norm, false otherwise.
Teuchos::RCP< Epetra_MultiVector > tmp
Temporary multivector used in Apply()
bool useTranspose
Flag indicating whether transpose was selected.
Teuchos::RCP< const Epetra_BlockMap > stoch_col_map
Stores stochastic part of column map.
Teuchos::RCP< const Epetra_Map > domain_sg_map
Stores domain SG map.
Teuchos::Array< Teuchos::RCP< Epetra_MultiVector > > result_block
MultiVectors for each block for Apply() result.
bool include_mean
Flag indicating whether to include mean term.
Teuchos::RCP< const Cijk_type > Cijk
Stores triple product tensor.
virtual void setupOperator(const Teuchos::RCP< Stokhos::EpetraOperatorOrthogPoly > &poly)
Setup operator.
Teuchos::RCP< const Stokhos::OrthogPolyBasis< int, double > > sg_basis
Stochastic Galerking basis.
virtual const Epetra_Map & OperatorRangeMap() const
Returns the Epetra_Map object associated with the range of this matrix operator.
Teuchos::RCP< Epetra_Map > global_col_map_trans
Stores operator column SG map for transpose.
virtual Teuchos::RCP< Stokhos::EpetraOperatorOrthogPoly > getSGPolynomial()
Get SG polynomial.
Teuchos::Array< Teuchos::RCP< const Epetra_MultiVector > > input_block
MultiVectors for each block for Apply() input.
Teuchos::RCP< Epetra_MultiVector > tmp_trans
Temporary multivector used in Apply() for transpose.
virtual double NormInf() const
Returns an approximate infinity norm of the operator matrix.
Teuchos::RCP< Epetra_MultiVector > input_col
Temporary to store result of importing input into column map.
bool scale_op
Flag indicating whether operator be scaled with <\psi_i^2>
bool use_block_apply
Flag indicating whether to use block Epetra_MultiVector apply.
virtual int Apply(const Epetra_MultiVector &Input, Epetra_MultiVector &Result) const
Returns the result of a Epetra_Operator applied to a Epetra_MultiVector Input in Result as described ...
bool is_stoch_parallel
Whether we have parallelism over stochastic blocks.
virtual int ApplyInverse(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Returns the result of the inverse of the operator applied to a Epetra_MultiVector Input in Result as ...
Cijk_type::k_iterator k_begin
Starting k iterator.
bool only_use_linear
Flag indicating whether to only use linear terms.
Teuchos::RCP< Epetra_Map > global_col_map
Stores operator column SG map.
int expansion_size
Number of terms in expansion.
Teuchos::RCP< Stokhos::EpetraOperatorOrthogPoly > block_ops
Stores operators.
virtual const Epetra_Comm & Comm() const
Returns a reference to the Epetra_Comm communicator associated with this operator.
Teuchos::RCP< const Epetra_Map > domain_base_map
Stores domain base map.
double countApplyFlops() const
Return number of FLOPS for each call to Apply()
Teuchos::RCP< Epetra_Import > col_importer_trans
Importer from range map to column map.
virtual const Epetra_Map & OperatorDomainMap() const
Returns the Epetra_Map object associated with the domain of this matrix operator.
virtual int SetUseTranspose(bool UseTranspose)
Set to true if the transpose of the operator is requested.
Stokhos::Sparse3Tensor< int, double > Cijk_type
Short-hand for Cijk.
Teuchos::RCP< const Stokhos::EpetraSparse3Tensor > epetraCijk
Stores Epetra Cijk tensor.
MatrixFreeOperator & operator=(const MatrixFreeOperator &)
Private to prohibit copying.
virtual bool UseTranspose() const
Returns the current UseTranspose setting.
int max_num_mat_vec
Maximum number of matvecs in Apply.
Teuchos::RCP< const EpetraExt::MultiComm > sg_comm
Stores SG parallel communicator.
Abstract base class for multivariate orthogonal polynomials.
An abstract class to represent a generic stochastic Galerkin operator as an Epetra_Operator.
Data structure storing a sparse 3-tensor C(i,j,k) in a a compressed format.
Top-level namespace for Stokhos classes and functions.
Bi-directional iterator for traversing a sparse array.