10#include "Teko_DiagonalPreconditionerOp.hpp"
12#include "TpetraExt_PointToBlockDiagPermute_decl.hpp"
13#include "Thyra_TpetraThyraWrappers.hpp"
14#include "Tpetra_MultiVector.hpp"
17using Teuchos::rcp_const_cast;
18using Teuchos::rcp_dynamic_cast;
19using Teuchos::rcpFromRef;
21using Thyra::MultiVectorBase;
25DiagonalPreconditionerOp::DiagonalPreconditionerOp(
26 Teuchos::RCP<Tpetra::Ext::PointToBlockDiagPermute<ST, LO, GO, NT> > BDP,
27 const VectorSpace range,
const VectorSpace domain)
28 : BDP_(BDP), range_(range), domain_(domain) {}
30void DiagonalPreconditionerOp::implicitApply(
const MultiVector& x, MultiVector& y,
31 const double alpha,
const double beta)
const {
32 TEUCHOS_TEST_FOR_EXCEPTION(BDP_ == Teuchos::null, std::runtime_error,
33 "DiagonalPreconditionerOp::implicitApply: null BDP_");
35 RCP<Tpetra::CrsMatrix<ST, LO, GO, NT> > H = BDP_->createCrsMatrix();
36 TEUCHOS_TEST_FOR_EXCEPTION(H == Teuchos::null, std::runtime_error,
37 "DiagonalPreconditionerOp::implicitApply: null block diagonal matrix");
39 RCP<const Tpetra::MultiVector<ST, LO, GO, NT> > x_ =
40 Thyra::TpetraOperatorVectorExtraction<ST, LO, GO, NT>::getConstTpetraMultiVector(x);
41 RCP<Tpetra::MultiVector<ST, LO, GO, NT> > y_ =
42 Thyra::TpetraOperatorVectorExtraction<ST, LO, GO, NT>::getTpetraMultiVector(y);
44 TEUCHOS_ASSERT(x_ != Teuchos::null);
45 TEUCHOS_ASSERT(y_ != Teuchos::null);
56 update(alpha, y, beta, y0);
60void DiagonalPreconditionerOp::describe(Teuchos::FancyOStream& out_arg,
61 const Teuchos::EVerbosityLevel verbLevel)
const {
65 case Teuchos::VERB_DEFAULT:
66 case Teuchos::VERB_LOW: out_arg << this->description() << std::endl;
break;
67 case Teuchos::VERB_MEDIUM:
68 case Teuchos::VERB_HIGH:
69 case Teuchos::VERB_EXTREME: {
70 if (BDP_ != Teuchos::null) {
71 RCP<Tpetra::CrsMatrix<ST, LO, GO, NT> > H = BDP_->createCrsMatrix();
72 if (H != Teuchos::null) H->describe(out_arg, verbLevel);
76 default: TEUCHOS_TEST_FOR_EXCEPT(
true);
void scale(const double alpha, MultiVector &x)
Scale a multivector by a constant.
MultiVector deepcopy(const MultiVector &v)
Perform a deep copy of the vector.