Teko  Version of the Day
 All Classes Files Functions Variables Pages
Teko_EpetraHelpers.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_EpetraHelpers_hpp__
11 #define __Teko_EpetraHelpers_hpp__
12 
13 // stl includes
14 #include <string>
15 
16 // Epetra includes
17 #include "Epetra_Operator.h"
18 #include "Epetra_CrsMatrix.h"
19 #include "Epetra_MultiVector.h"
20 
21 // Teuchos includes
22 #include "Teuchos_RCP.hpp"
23 
24 // Thyra includes
25 #include "Thyra_VectorBase.hpp"
26 #include "Thyra_DefaultSpmdMultiVector.hpp"
27 
28 namespace Teko {
29 
30 namespace Epetra {
31 
41 void fillDefaultSpmdMultiVector(Teuchos::RCP<Thyra::DefaultSpmdMultiVector<double> >& spmdMV,
42  Teuchos::RCP<Epetra_MultiVector>& epetraMV);
43 
54 const Teuchos::RCP<const Thyra::LinearOpBase<double> > thyraDiagOp(
55  const Teuchos::RCP<const Epetra_Vector>& ev, const Epetra_Map& map,
56  const std::string& lbl = "ANYM");
57 
68 const Teuchos::RCP<Thyra::LinearOpBase<double> > thyraDiagOp(const Teuchos::RCP<Epetra_Vector>& ev,
69  const Epetra_Map& map,
70  const std::string& lbl = "ANYM");
71 
81 void identityRowIndices(const Epetra_Map& rowMap, const Epetra_CrsMatrix& mat,
82  std::vector<int>& outIndices);
83 
94 void zeroMultiVectorRowIndices(Epetra_MultiVector& mv, const std::vector<int>& zeroIndices);
95 
99 class ZeroedOperator : public Epetra_Operator {
100  public:
110  ZeroedOperator(const std::vector<int>& zeroIndices,
111  const Teuchos::RCP<const Epetra_Operator>& op);
112 
114 
115 
117  virtual ~ZeroedOperator() {}
118 
120  int SetUseTranspose(bool /* useTranspose */) { return -1; }
121 
123  int Apply(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
124 
126  int ApplyInverse(const Epetra_MultiVector& /* X */, Epetra_MultiVector& /* Y */) const {
127  return -1;
128  }
129 
131  double NormInf() const { return -1.0; }
132 
134  const char* Label() const { return label_.c_str(); }
135 
137  bool UseTranspose() const { return false; }
138 
140  bool HasNormInf() const { return false; }
141 
143  const Epetra_Comm& Comm() const { return epetraOp_->Comm(); }
144 
146  const Epetra_Map& OperatorDomainMap() const { return epetraOp_->OperatorDomainMap(); }
147 
149  const Epetra_Map& OperatorRangeMap() const { return epetraOp_->OperatorRangeMap(); }
150 
152 
153  protected:
154  std::vector<int> zeroIndices_;
155  const Teuchos::RCP<const Epetra_Operator> epetraOp_;
156  std::string label_;
157 };
158 
159 } // end namespace Epetra
160 } // end namespace Teko
161 
162 #endif
int SetUseTranspose(bool)
Can&#39;t transpose a ZeroedOperator.
int ApplyInverse(const Epetra_MultiVector &, Epetra_MultiVector &) const
Can&#39;t call ApplyInverse on a zeroed operator.
ZeroedOperator(const std::vector< int > &zeroIndices, const Teuchos::RCP< const Epetra_Operator > &op)
Constructor for a ZeroedOperator.
int Apply(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Perform a matrix-vector product with certain rows zeroed out.
virtual ~ZeroedOperator()
Do nothing destructor.