Teko  Version of the Day
 All Classes Files Functions Variables Pages
Teko_BlockDiagonalInverseOp.hpp
1 // @HEADER
2 // *****************************************************************************
3 // Teko: A package for block and physics based preconditioning
4 //
5 // Copyright 2010 NTESS and the Teko contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef __Teko_BlockDiagonalInverseOp_hpp__
11 #define __Teko_BlockDiagonalInverseOp_hpp__
12 
13 #include "Teko_Utilities.hpp"
14 #include "Teko_BlockImplicitLinearOp.hpp"
15 
16 namespace Teko {
17 
26  public:
36  BlockDiagonalInverseOp(BlockedLinearOp &A, const std::vector<LinearOp> &invDiag);
37 
38  BlockDiagonalInverseOp() = delete;
40 
42 
43 
45  virtual VectorSpace range() const { return productRange_; }
46 
48  virtual VectorSpace domain() const { return productDomain_; }
49 
62  virtual void implicitApply(const BlockedMultiVector &x, BlockedMultiVector &y,
63  const double alpha = 1.0, const double beta = 0.0) const;
64 
78  virtual void implicitApply(const Thyra::EOpTransp M_trans, const BlockedMultiVector &x,
79  BlockedMultiVector &y, const double alpha = 1.0,
80  const double beta = 0.0) const;
82 
83  virtual void describe(Teuchos::FancyOStream &out_arg,
84  const Teuchos::EVerbosityLevel verbLevel) const;
85 
86  protected:
87  // fundamental operators to use
88  std::vector<LinearOp> invDiag_;
89 
90  Teuchos::RCP<const Thyra::ProductVectorSpaceBase<double> >
92  Teuchos::RCP<const Thyra::ProductVectorSpaceBase<double> >
94 
95  // scratch space...so we don't have to reallocate
96  mutable BlockedMultiVector srcScrap_;
97  mutable BlockedMultiVector dstScrap_;
98  mutable bool allocated = false;
99 };
100 
101 inline LinearOp createBlockDiagonalInverseOp(BlockedLinearOp &A,
102  const std::vector<LinearOp> &invDiag) {
103  return Teuchos::rcp(new BlockDiagonalInverseOp(A, invDiag));
104 }
105 
106 inline LinearOp createBlockDiagonalInverseOp(BlockedLinearOp &A,
107  const std::vector<LinearOp> &invDiag,
108  const std::string &str) {
109  Teuchos::RCP<Thyra::LinearOpBase<double> > result =
110  Teuchos::rcp(new BlockDiagonalInverseOp(A, invDiag));
111  result->setObjectLabel(str);
112 
113  return result;
114 }
115 
116 } // end namespace Teko
117 
118 #endif
This linear operator computes the inverse of a diagonal matrix.
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.
A virtual class that simplifies the construction of custom operators.
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.