54 label(
"Stokhos Approximate Gauss-Seidel Preconditioner"),
57 epetraCijk(epetraCijk_),
60 prec_factory(prec_factory_),
65 Cijk(epetraCijk->getParallelCijk()),
68 only_use_linear(
true),
72 scale_op = params_->
get(
"Scale Operator by Inverse Basis Norms",
true);
73 symmetric = params_->
get(
"Symmetric Gauss-Seidel",
false);
89 mean_prec = prec_factory->compute(sg_poly->getCoeffPtr(0));
90 label = std::string(
"Stokhos Approximate Gauss-Seidel Preconditioner:\n") +
91 std::string(
" ***** ") +
92 std::string(mean_prec->Label());
99 useTranspose = UseTheTranspose;
100 sg_op->SetUseTranspose(UseTheTranspose);
101 mean_prec->SetUseTranspose(UseTheTranspose);
110 return sg_op->Apply(Input, Result);
117 #ifdef STOKHOS_TEUCHOS_TIME_MONITOR
124 bool made_copy =
false;
125 if (Input.Values() == Result.Values()) {
130 int m = input->NumVectors();
131 if (mat_vec_tmp ==
Teuchos::null || mat_vec_tmp->NumVectors() != m)
133 if (rhs_block ==
Teuchos::null || rhs_block->NumVectors() != m)
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);
143 int k_limit = sg_poly->size();
145 k_limit = sg_poly->basis()->dimension() + 1;
148 rhs_block->Update(1.0, input_block, 0.0);
151 i_it!=Cijk->i_end(); ++i_it) {
157 #ifdef STOKHOS_TEUCHOS_TIME_MONITOR
160 mean_prec->ApplyInverse(*(rhs_block->GetBlock(i)), *res_i);
163 int i_gid = epetraCijk->GRID(i);
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) {
172 int j_gid = epetraCijk->GCID(j);
174 bool on_proc = epetraCijk->myGRID(j_gid);
182 (*sg_poly)[k].Apply(*res_i, *mat_vec_tmp);
184 j_it != Cijk->j_end(k_it); ++j_it) {
186 int j_gid = epetraCijk->GCID(j);
187 double c = value(j_it);
195 bool on_proc = epetraCijk->myGRID(j_gid);
197 rhs_block->GetBlock(j)->Update(-c, *mat_vec_tmp, 1.0);
210 i_it!=Cijk->i_rend(); ++i_it) {
216 #ifdef STOKHOS_TEUCHOS_TIME_MONITOR
219 mean_prec->ApplyInverse(*(rhs_block->GetBlock(i)), *res_i);
222 int i_gid = epetraCijk->GRID(i);
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) {
231 int j_gid = epetraCijk->GCID(j);
233 bool on_proc = epetraCijk->myGRID(j_gid);
241 (*sg_poly)[k].Apply(*res_i, *mat_vec_tmp);
243 j_it != Cijk->j_end(k_it); ++j_it) {
245 int j_gid = epetraCijk->GCID(j);
246 double c = value(j_it);
250 bool on_proc = epetraCijk->myGRID(j_gid);
252 rhs_block->GetBlock(j)->Update(-c, *mat_vec_tmp, 1.0);
272 return sg_op->NormInf();
280 return const_cast<char*
>(label.c_str());
294 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. ...