10 #include "Teko_BlockDiagonalInverseOp.hpp"
12 #include "Teuchos_Utils.hpp"
18 BlockDiagonalInverseOp::BlockDiagonalInverseOp(BlockedLinearOp& A,
19 const std::vector<LinearOp>& invDiag)
22 int blocks = blockRowCount(A);
23 TEUCHOS_ASSERT(blocks > 0);
24 TEUCHOS_ASSERT(blocks == blockColCount(A));
25 TEUCHOS_ASSERT(blocks == (
int)
invDiag_.size());
36 const double alpha,
const double beta)
const {
42 const BlockedMultiVector& src, BlockedMultiVector& dst,
43 const double alpha,
const double beta)
const {
44 int blocks = blockCount(src);
46 TEUCHOS_ASSERT(blocks == (
int)
invDiag_.size());
49 srcScrap_ = deepcopy(src);
50 dstScrap_ = deepcopy(dst);
55 Thyra::assign<double>(srcScrap_.ptr(), *src);
56 BlockedMultiVector dstCopy;
58 Thyra::assign<double>(dstScrap_.ptr(), *dst);
65 std::vector<MultiVector> dstVec;
66 std::vector<MultiVector> scrapVec;
67 for (
int b = 0; b < blocks; b++) {
68 dstVec.push_back(getBlock(b, dstCopy));
69 scrapVec.push_back(getBlock(b, srcScrap_));
72 if (M_trans == Thyra::NOTRANS) {
73 for (
int b = 0; b < blocks; b++) {
74 applyOp(
invDiag_[b], scrapVec[b], dstVec[b]);
76 }
else if (M_trans == Thyra::TRANS || M_trans == Thyra::CONJTRANS) {
77 for (
int b = 0; b < blocks; b++) {
78 applyTransposeOp(
invDiag_[b], scrapVec[b], dstVec[b]);
81 TEUCHOS_TEST_FOR_EXCEPT(
true);
86 update(alpha, dstCopy, beta, dst);
87 else if (alpha != 1.0)
91 void BlockDiagonalInverseOp::describe(Teuchos::FancyOStream& out_arg,
92 const Teuchos::EVerbosityLevel verbLevel)
const {
95 RCP<Teuchos::FancyOStream> out = rcp(&out_arg,
false);
98 case Teuchos::VERB_DEFAULT:
99 case Teuchos::VERB_LOW: *out << this->description() << std::endl;
break;
100 case Teuchos::VERB_MEDIUM:
101 case Teuchos::VERB_HIGH:
102 case Teuchos::VERB_EXTREME: {
103 *out << Teuchos::Describable::description() <<
"{"
104 <<
"rangeDim=" << this->
range()->dim() <<
",domainDim=" << this->
domain()->dim()
108 *out <<
"[invDiag Operators]:\n";
110 for (
auto i = 0U; i <
invDiag_.size(); i++) {
111 *out <<
"[invD(" << i <<
")] = ";
112 *out << Teuchos::describe(*
invDiag_[i], verbLevel);
117 default: TEUCHOS_TEST_FOR_EXCEPT(
true);
virtual VectorSpace domain() const
Domain space of this operator.
Teuchos::RCP< const Thyra::ProductVectorSpaceBase< double > > productRange_
Range vector space.
virtual void implicitApply(const BlockedMultiVector &x, BlockedMultiVector &y, const double alpha=1.0, const double beta=0.0) const
Perform a matrix vector multiply with this operator.
std::vector< LinearOp > invDiag_
(Approximate) Inverses of the diagonal operators
virtual VectorSpace range() const
Range space of this operator.
Teuchos::RCP< const Thyra::ProductVectorSpaceBase< double > > productDomain_
Domain vector space.