22 label(
"Stokhos Approximate Gauss-Seidel Preconditioner"),
25 epetraCijk(epetraCijk_),
28 prec_factory(prec_factory_),
33 Cijk(epetraCijk->getParallelCijk()),
36 only_use_linear(
true),
40 scale_op = params_->
get(
"Scale Operator by Inverse Basis Norms",
true);
41 symmetric = params_->
get(
"Symmetric Gauss-Seidel",
false);
57 mean_prec = prec_factory->compute(sg_poly->getCoeffPtr(0));
58 label = std::string(
"Stokhos Approximate Gauss-Seidel Preconditioner:\n") +
59 std::string(
" ***** ") +
60 std::string(mean_prec->Label());
67 useTranspose = UseTheTranspose;
68 sg_op->SetUseTranspose(UseTheTranspose);
69 mean_prec->SetUseTranspose(UseTheTranspose);
78 return sg_op->Apply(Input, Result);
85 #ifdef STOKHOS_TEUCHOS_TIME_MONITOR
92 bool made_copy =
false;
93 if (Input.Values() == Result.Values()) {
98 int m = input->NumVectors();
99 if (mat_vec_tmp ==
Teuchos::null || mat_vec_tmp->NumVectors() != m)
101 if (rhs_block ==
Teuchos::null || rhs_block->NumVectors() != m)
103 Teuchos::rcp(
new EpetraExt::BlockMultiVector(*base_map, *sg_map, m));
106 EpetraExt::BlockMultiVector input_block(
View, *base_map, *input);
107 EpetraExt::BlockMultiVector result_block(
View, *base_map, Result);
109 result_block.PutScalar(0.0);
111 int k_limit = sg_poly->size();
113 k_limit = sg_poly->basis()->dimension() + 1;
116 rhs_block->Update(1.0, input_block, 0.0);
119 i_it!=Cijk->i_end(); ++i_it) {
125 #ifdef STOKHOS_TEUCHOS_TIME_MONITOR
128 mean_prec->ApplyInverse(*(rhs_block->GetBlock(i)), *res_i);
131 int i_gid = epetraCijk->GRID(i);
133 k_it != Cijk->k_end(i_it); ++k_it) {
135 if (k!=0 && k<k_limit) {
136 bool do_mat_vec =
false;
138 j_it != Cijk->j_end(k_it); ++j_it) {
140 int j_gid = epetraCijk->GCID(j);
142 bool on_proc = epetraCijk->myGRID(j_gid);
150 (*sg_poly)[k].Apply(*res_i, *mat_vec_tmp);
152 j_it != Cijk->j_end(k_it); ++j_it) {
154 int j_gid = epetraCijk->GCID(j);
155 double c = value(j_it);
163 bool on_proc = epetraCijk->myGRID(j_gid);
165 rhs_block->GetBlock(j)->Update(-c, *mat_vec_tmp, 1.0);
178 i_it!=Cijk->i_rend(); ++i_it) {
184 #ifdef STOKHOS_TEUCHOS_TIME_MONITOR
187 mean_prec->ApplyInverse(*(rhs_block->GetBlock(i)), *res_i);
190 int i_gid = epetraCijk->GRID(i);
192 k_it != Cijk->k_end(i_it); ++k_it) {
194 if (k!=0 && k<k_limit) {
195 bool do_mat_vec =
false;
197 j_it != Cijk->j_end(k_it); ++j_it) {
199 int j_gid = epetraCijk->GCID(j);
201 bool on_proc = epetraCijk->myGRID(j_gid);
209 (*sg_poly)[k].Apply(*res_i, *mat_vec_tmp);
211 j_it != Cijk->j_end(k_it); ++j_it) {
213 int j_gid = epetraCijk->GCID(j);
214 double c = value(j_it);
218 bool on_proc = epetraCijk->myGRID(j_gid);
220 rhs_block->GetBlock(j)->Update(-c, *mat_vec_tmp, 1.0);
240 return sg_op->NormInf();
248 return const_cast<char*
>(label.c_str());
262 return sg_op->HasNormInf();
#define TEUCHOS_FUNC_TIME_MONITOR(FUNCNAME)
T & get(ParameterList &l, const std::string &name)
virtual bool HasNormInf() const
Returns true if the this object can provide an approximate Inf-norm, false otherwise.
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.
virtual ~ApproxGaussSeidelPreconditioner()
Destructor.
virtual const Epetra_Map & OperatorRangeMap() const
Returns the Epetra_Map object associated with the range of this matrix operator.
Bi-directional iterator for traversing a sparse array.
Bi-directional reverse iterator for traversing a sparse array.
bool symmetric
Use symmetric Gauss-Seidel.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
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 ...
bool scale_op
Flag indicating whether operator be scaled with <^2>
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 ...
virtual Teuchos::RCP< Stokhos::EpetraOperatorOrthogPoly > getSGPolynomial()=0
Get SG polynomial.
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 bool UseTranspose() const
Returns the current UseTranspose setting.
virtual int SetUseTranspose(bool UseTranspose)
Set to true if the transpose of the operator is requested.
virtual void setupPreconditioner(const Teuchos::RCP< Stokhos::SGOperator > &sg_op, const Epetra_Vector &x)
Setup preconditioner.
virtual double NormInf() const
Returns an approximate infinity norm of the operator matrix.
virtual const char * Label() const
Returns a character string describing the operator.
virtual const Epetra_Map & OperatorDomainMap() const
Returns the Epetra_Map object associated with the domain of this matrix operator. ...