10 #ifndef __Teko_TpetraHelpers_hpp__
11 #define __Teko_TpetraHelpers_hpp__
16 #include "Teko_ConfigDefs.hpp"
18 #ifdef TEKO_HAVE_EPETRA
20 #include "Epetra_Operator.h"
21 #include "Epetra_CrsMatrix.h"
22 #include "Epetra_MultiVector.h"
26 #include "Teuchos_RCP.hpp"
29 #include "Thyra_VectorBase.hpp"
30 #include "Thyra_TpetraMultiVector.hpp"
31 #include "Thyra_DefaultSpmdMultiVector.hpp"
34 #include "Tpetra_Map.hpp"
35 #include "Tpetra_Vector.hpp"
36 #include "Tpetra_CrsMatrix.hpp"
40 typedef Teuchos::RCP<const Thyra::LinearOpBase<double> > LinearOp;
42 namespace TpetraHelpers {
53 void fillDefaultSpmdMultiVector(Teuchos::RCP<Thyra::TpetraMultiVector<ST, LO, GO, NT> >& spmdMV,
54 Teuchos::RCP<Tpetra::MultiVector<ST, LO, GO, NT> >& tpetraMV);
66 const Teuchos::RCP<const Thyra::LinearOpBase<ST> > thyraDiagOp(
67 const Teuchos::RCP<
const Tpetra::Vector<ST, LO, GO, NT> >& tv,
68 const Tpetra::Map<LO, GO, NT>& map,
const std::string& lbl =
"ANYM");
80 const Teuchos::RCP<Thyra::LinearOpBase<ST> > thyraDiagOp(
81 const Teuchos::RCP<Tpetra::Vector<ST, LO, GO, NT> >& tv,
const Tpetra::Map<LO, GO, NT>& map,
82 const std::string& lbl =
"ANYM");
93 void identityRowIndices(
const Tpetra::Map<LO, GO, NT>& rowMap,
94 const Tpetra::CrsMatrix<ST, LO, GO, NT>& mat, std::vector<GO>& outIndices);
106 void zeroMultiVectorRowIndices(Tpetra::MultiVector<ST, LO, GO, NT>& mv,
107 const std::vector<GO>& zeroIndices);
111 bool isTpetraLinearOp(
const Teko::LinearOp& op);
122 Teuchos::RCP<const Tpetra::CrsMatrix<ST, LO, GO, NT> > getTpetraCrsMatrix(
const Teko::LinearOp& op,
123 ST* scalar,
bool* transp);
125 #ifdef TEKO_HAVE_EPETRA
134 Teuchos::RCP<const Tpetra::CrsMatrix<ST, LO, GO, NT> > epetraCrsMatrixToTpetra(
135 const Teuchos::RCP<const Epetra_CrsMatrix> A_e,
136 const Teuchos::RCP<
const Teuchos::Comm<int> > comm);
138 Teuchos::RCP<Tpetra::CrsMatrix<ST, LO, GO, NT> > nonConstEpetraCrsMatrixToTpetra(
139 const Teuchos::RCP<Epetra_CrsMatrix> A_e,
const Teuchos::RCP<
const Teuchos::Comm<int> > comm);
141 Teuchos::RCP<const Tpetra::Map<LO, GO, NT> > epetraMapToTpetra(
142 const Epetra_Map eMap,
const Teuchos::RCP<
const Teuchos::Comm<int> > comm);
143 #endif // TEKO_HAVE_EPETRA
160 const Teuchos::RCP<
const Tpetra::Operator<ST, LO, GO, NT> >& op);
172 void apply(
const Tpetra::MultiVector<ST, LO, GO, NT>& X, Tpetra::MultiVector<ST, LO, GO, NT>& Y,
173 Teuchos::ETransp mode = Teuchos::NO_TRANS, ST alpha = Teuchos::ScalarTraits<ST>::one(),
174 ST beta = Teuchos::ScalarTraits<ST>::zero())
const;
178 Tpetra::MultiVector<ST, LO, GO, NT>& ,
179 Teuchos::ETransp = Teuchos::NO_TRANS,
180 ST = Teuchos::ScalarTraits<ST>::one(),
181 ST = Teuchos::ScalarTraits<ST>::zero())
const {
182 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::runtime_error,
183 "Can't call applyInverse on a ZeroedOperator");
187 double NormInf()
const {
return -1.0; }
190 bool UseTranspose()
const {
return false; }
193 bool HasNormInf()
const {
return false; }
196 Teuchos::RCP<const Tpetra::Map<LO, GO, NT> > getDomainMap()
const {
197 return tpetraOp_->getDomainMap();
201 Teuchos::RCP<const Tpetra::Map<LO, GO, NT> > getRangeMap()
const {
202 return tpetraOp_->getRangeMap();
208 std::vector<GO> zeroIndices_;
209 const Teuchos::RCP<const Tpetra::Operator<ST, LO, GO, NT> > tpetraOp_;
void apply(const Tpetra::MultiVector< ST, LO, GO, NT > &X, Tpetra::MultiVector< ST, LO, GO, NT > &Y, Teuchos::ETransp mode=Teuchos::NO_TRANS, ST alpha=Teuchos::ScalarTraits< ST >::one(), ST beta=Teuchos::ScalarTraits< ST >::zero()) const
Perform a matrix-vector product with certain rows zeroed out.
int SetUseTranspose(bool)
Can't transpose a ZeroedOperator.
ZeroedOperator(const std::vector< GO > &zeroIndices, const Teuchos::RCP< const Tpetra::Operator< ST, LO, GO, NT > > &op)
Constructor for a ZeroedOperator.
void applyInverse(const Tpetra::MultiVector< ST, LO, GO, NT > &, Tpetra::MultiVector< ST, LO, GO, NT > &, Teuchos::ETransp=Teuchos::NO_TRANS, ST=Teuchos::ScalarTraits< ST >::one(), ST=Teuchos::ScalarTraits< ST >::zero()) const
Can't call ApplyInverse on a zeroed operator.
virtual ~ZeroedOperator()
Do nothing destructor.