47 #ifndef __Teko_TpetraHelpers_hpp__
48 #define __Teko_TpetraHelpers_hpp__
54 #include "Epetra_Operator.h"
55 #include "Epetra_CrsMatrix.h"
56 #include "Epetra_MultiVector.h"
59 #include "Teuchos_RCP.hpp"
62 #include "Thyra_VectorBase.hpp"
63 #include "Thyra_TpetraMultiVector.hpp"
64 #include "Thyra_DefaultSpmdMultiVector.hpp"
67 #include "Teko_ConfigDefs.hpp"
68 #include "Tpetra_Map.hpp"
69 #include "Tpetra_Vector.hpp"
70 #include "Tpetra_CrsMatrix.hpp"
74 typedef Teuchos::RCP<const Thyra::LinearOpBase<double> > LinearOp;
76 namespace TpetraHelpers {
87 void fillDefaultSpmdMultiVector(Teuchos::RCP<Thyra::TpetraMultiVector<ST,LO,GO,NT> > & spmdMV,
88 Teuchos::RCP<Tpetra::MultiVector<ST,LO,GO,NT> > & tpetraMV);
100 const Teuchos::RCP<const Thyra::LinearOpBase<ST> > thyraDiagOp(
const Teuchos::RCP<
const Tpetra::Vector<ST,LO,GO,NT> > & tv,
101 const Tpetra::Map<LO,GO,NT> & map,
const std::string & lbl=
"ANYM");
113 const Teuchos::RCP<Thyra::LinearOpBase<ST> > thyraDiagOp(
const Teuchos::RCP<Tpetra::Vector<ST,LO,GO,NT> > & tv,
114 const Tpetra::Map<LO,GO,NT> & map,
const std::string & lbl=
"ANYM");
125 void identityRowIndices(
const Tpetra::Map<LO,GO,NT> & rowMap,
const Tpetra::CrsMatrix<ST,LO,GO,NT> & mat,std::vector<GO> & outIndices);
137 void zeroMultiVectorRowIndices(Tpetra::MultiVector<ST,LO,GO,NT> & mv,
const std::vector<GO> & zeroIndices);
141 bool isTpetraLinearOp(
const Teko::LinearOp & op);
151 Teuchos::RCP<const Tpetra::CrsMatrix<ST,LO,GO,NT> > getTpetraCrsMatrix(
const Teko::LinearOp & op, ST *scalar,
bool *transp);
160 Teuchos::RCP<const Tpetra::CrsMatrix<ST,LO,GO,NT> > epetraCrsMatrixToTpetra(
const Teuchos::RCP<const Epetra_CrsMatrix> A_e,
const Teuchos::RCP<
const Teuchos::Comm<int> > comm);
162 Teuchos::RCP<Tpetra::CrsMatrix<ST,LO,GO,NT> > nonConstEpetraCrsMatrixToTpetra(
const Teuchos::RCP<Epetra_CrsMatrix> A_e,
const Teuchos::RCP<
const Teuchos::Comm<int> > comm);
164 Teuchos::RCP<const Tpetra::Map<LO,GO,NT> > epetraMapToTpetra(
const Epetra_Map eMap,
const Teuchos::RCP<
const Teuchos::Comm<int> > comm);
180 ZeroedOperator(
const std::vector<GO> & zeroIndices,
const Teuchos::RCP<
const Tpetra::Operator<ST,LO,GO,NT> > & op);
192 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;
195 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
196 { TEUCHOS_TEST_FOR_EXCEPTION(
true,std::runtime_error,
"Can't call applyInverse on a ZeroedOperator"); }
199 double NormInf()
const {
return -1.0; }
202 bool UseTranspose()
const {
return false;}
205 bool HasNormInf()
const {
return false;}
208 Teuchos::RCP<const Tpetra::Map<LO,GO,NT> > getDomainMap()
const {
return tpetraOp_->getDomainMap(); }
211 Teuchos::RCP<const Tpetra::Map<LO,GO,NT> > getRangeMap()
const {
return tpetraOp_->getRangeMap(); }
216 std::vector<GO> zeroIndices_;
217 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.