43#include "Teuchos_TimeMonitor.hpp"
47 const Teuchos::RCP<const EpetraExt::MultiComm>& sg_comm_,
49 const Teuchos::RCP<const Stokhos::EpetraSparse3Tensor>& epetraCijk_,
50 const Teuchos::RCP<const Epetra_Map>& base_map_,
51 const Teuchos::RCP<const Epetra_Map>& sg_map_,
52 const Teuchos::RCP<Stokhos::AbstractPreconditionerFactory>& prec_factory_,
53 const Teuchos::RCP<Teuchos::ParameterList>& params_) :
54 label(
"Stokhos Approximate Gauss-Seidel Preconditioner"),
72 scale_op = params_->get(
"Scale Operator by Inverse Basis Norms",
true);
73 symmetric = params_->get(
"Symmetric Gauss-Seidel",
false);
90 label = std::string(
"Stokhos Approximate Gauss-Seidel Preconditioner:\n") +
91 std::string(
" ***** ") +
100 sg_op->SetUseTranspose(UseTheTranspose);
101 mean_prec->SetUseTranspose(UseTheTranspose);
110 return sg_op->Apply(Input, Result);
117#ifdef STOKHOS_TEUCHOS_TIME_MONITOR
118 TEUCHOS_FUNC_TIME_MONITOR(
"Stokhos: Total Approximate Gauss-Seidel Time");
124 bool made_copy =
false;
135 Teuchos::rcp(
new EpetraExt::BlockMultiVector(*
base_map, *
sg_map, m));
138 EpetraExt::BlockMultiVector input_block(
View, *
base_map, *input);
139 EpetraExt::BlockMultiVector result_block(
View, *
base_map, Result);
141 result_block.PutScalar(0.0);
145 k_limit =
sg_poly->basis()->dimension() + 1;
146 const Teuchos::Array<double>& norms =
sg_basis->norm_squared();
148 rhs_block->Update(1.0, input_block, 0.0);
151 i_it!=
Cijk->i_end(); ++i_it) {
154 Teuchos::RCP<Epetra_MultiVector> res_i = result_block.GetBlock(i);
157#ifdef STOKHOS_TEUCHOS_TIME_MONITOR
158 TEUCHOS_FUNC_TIME_MONITOR(
"Stokhos: Total AGS Deterministic Preconditioner Time");
165 k_it !=
Cijk->k_end(i_it); ++k_it) {
167 if (k!=0 && k<k_limit) {
168 bool do_mat_vec =
false;
170 j_it !=
Cijk->j_end(k_it); ++j_it) {
184 j_it !=
Cijk->j_end(k_it); ++j_it) {
187 double c =
value(j_it);
210 i_it!=
Cijk->i_rend(); ++i_it) {
213 Teuchos::RCP<Epetra_MultiVector> res_i = result_block.GetBlock(i);
216#ifdef STOKHOS_TEUCHOS_TIME_MONITOR
217 TEUCHOS_FUNC_TIME_MONITOR(
"Stokhos: Total AGS Deterministic Preconditioner Time");
224 k_it !=
Cijk->k_end(i_it); ++k_it) {
226 if (k!=0 && k<k_limit) {
227 bool do_mat_vec =
false;
229 j_it !=
Cijk->j_end(k_it); ++j_it) {
243 j_it !=
Cijk->j_end(k_it); ++j_it) {
246 double c =
value(j_it);
272 return sg_op->NormInf();
280 return const_cast<char*
>(
label.c_str());
294 return sg_op->HasNormInf();
virtual bool UseTranspose() const
Returns the current UseTranspose setting.
Teuchos::RCP< Epetra_Operator > mean_prec
Stores mean preconditioner.
Teuchos::RCP< const Cijk_type > Cijk
Pointer to triple product.
virtual bool HasNormInf() const
Returns true if the this object can provide an approximate Inf-norm, false otherwise.
Teuchos::RCP< const Stokhos::EpetraSparse3Tensor > epetraCijk
Stores Epetra Cijk tensor.
Teuchos::RCP< Epetra_MultiVector > mat_vec_tmp
Temporary vector for storing matrix-vector products.
virtual const Epetra_Map & OperatorDomainMap() const
Returns the Epetra_Map object associated with the domain of this matrix operator.
bool only_use_linear
Limit Gauss-Seidel loop to linear terms.
virtual const Epetra_Comm & Comm() const
Returns a reference to the Epetra_Comm communicator associated with this operator.
virtual int SetUseTranspose(bool UseTranspose)
Set to true if the transpose of the operator is requested.
bool useTranspose
Flag indicating whether transpose was selected.
virtual void setupPreconditioner(const Teuchos::RCP< Stokhos::SGOperator > &sg_op, const Epetra_Vector &x)
Setup preconditioner.
Teuchos::RCP< const Stokhos::OrthogPolyBasis< int, double > > sg_basis
Stochastic Galerking basis.
Teuchos::RCP< Stokhos::SGOperator > sg_op
Pointer to the SG operator.
virtual ~ApproxGaussSeidelPreconditioner()
Destructor.
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 ...
virtual double NormInf() const
Returns an approximate infinity norm of the operator matrix.
ApproxGaussSeidelPreconditioner(const Teuchos::RCP< const EpetraExt::MultiComm > &sg_comm, const Teuchos::RCP< const Stokhos::OrthogPolyBasis< int, double > > &sg_basis, const Teuchos::RCP< const Stokhos::EpetraSparse3Tensor > &epetraCijk, const Teuchos::RCP< const Epetra_Map > &base_map, const Teuchos::RCP< const Epetra_Map > &sg_map, const Teuchos::RCP< Stokhos::AbstractPreconditionerFactory > &prec_factory, const Teuchos::RCP< Teuchos::ParameterList > ¶ms)
Constructor.
bool symmetric
Use symmetric Gauss-Seidel.
Teuchos::RCP< Stokhos::AbstractPreconditionerFactory > prec_factory
Stores factory for building mean preconditioner.
std::string label
Label for operator.
Teuchos::RCP< const Epetra_Map > sg_map
Stores SG map.
Teuchos::RCP< const EpetraExt::MultiComm > sg_comm
Stores SG parallel communicator.
Teuchos::RCP< EpetraExt::BlockMultiVector > rhs_block
Temporary vector for storing rhs in Gauss-Seidel loop.
virtual const char * Label() const
Returns a character string describing the operator.
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 scale_op
Flag indicating whether operator be scaled with <\psi_i^2>
Teuchos::RCP< Stokhos::EpetraOperatorOrthogPoly > sg_poly
Pointer to the PCE expansion of Jacobian.
Teuchos::RCP< const Epetra_Map > base_map
Stores base map.
virtual const Epetra_Map & OperatorRangeMap() const
Returns the Epetra_Map object associated with the range of this matrix operator.
Abstract base class for multivariate orthogonal polynomials.
ikj_sparse_array::const_reverse_iterator i_reverse_iterator
j_sparse_array::const_iterator ikj_iterator
kj_sparse_array::const_iterator ik_iterator
ikj_sparse_array::const_iterator i_iterator
SparseArrayIterator< index_iterator, value_iterator >::value_reference value(const SparseArrayIterator< index_iterator, value_iterator > &it)
SparseArrayIterator< index_iterator, value_iterator >::value_type index(const SparseArrayIterator< index_iterator, value_iterator > &it)