10#ifndef __Teko_TpetraHelpers_hpp__
11#define __Teko_TpetraHelpers_hpp__
16#include "Teko_ConfigDefs.hpp"
19#include "Teuchos_RCP.hpp"
22#include "Thyra_LinearOpBase.hpp"
23#include "Thyra_VectorBase.hpp"
24#include "Thyra_TpetraMultiVector.hpp"
25#include "Thyra_DefaultSpmdMultiVector.hpp"
28#include "Tpetra_Map.hpp"
29#include "Tpetra_Vector.hpp"
30#include "Tpetra_CrsMatrix.hpp"
34typedef Teuchos::RCP<const Thyra::LinearOpBase<ST> > LinearOp;
35typedef Teuchos::RCP<Thyra::LinearOpBase<ST> > ModifiableLinearOp;
37namespace TpetraHelpers {
48void fillDefaultSpmdMultiVector(Teuchos::RCP<Thyra::TpetraMultiVector<ST, LO, GO, NT> >& spmdMV,
49 Teuchos::RCP<Tpetra::MultiVector<ST, LO, GO, NT> >& tpetraMV);
61const Teuchos::RCP<const Thyra::LinearOpBase<ST> > thyraDiagOp(
62 const Teuchos::RCP<
const Tpetra::Vector<ST, LO, GO, NT> >& tv,
63 const Tpetra::Map<LO, GO, NT>& map,
const std::string& lbl =
"ANYM");
75const Teuchos::RCP<Thyra::LinearOpBase<ST> > thyraDiagOp(
76 const Teuchos::RCP<Tpetra::Vector<ST, LO, GO, NT> >& tv,
const Tpetra::Map<LO, GO, NT>& map,
77 const std::string& lbl =
"ANYM");
88void identityRowIndices(
const Tpetra::Map<LO, GO, NT>& rowMap,
89 const Tpetra::CrsMatrix<ST, LO, GO, NT>& mat, std::vector<GO>& outIndices);
101void zeroMultiVectorRowIndices(Tpetra::MultiVector<ST, LO, GO, NT>& mv,
102 const std::vector<GO>& zeroIndices);
106bool isTpetraLinearOp(
const Teko::LinearOp& op);
117Teuchos::RCP<const Tpetra::CrsMatrix<ST, LO, GO, NT> > getTpetraCrsMatrix(
const Teko::LinearOp& op,
118 ST* scalar,
bool* transp);
123Teuchos::RCP<Tpetra::CrsMatrix<ST, LO, GO, NT> > materializeTpetraCrsMatrix(
124 const Teko::LinearOp& op);
129Teko::ModifiableLinearOp materializeTpetraLinearOp(
const Teko::LinearOp& op,
130 const Teko::ModifiableLinearOp& destOp);
147 const Teuchos::RCP<
const Tpetra::Operator<ST, LO, GO, NT> >& op);
159 void apply(
const Tpetra::MultiVector<ST, LO, GO, NT>& X, Tpetra::MultiVector<ST, LO, GO, NT>& Y,
160 Teuchos::ETransp mode = Teuchos::NO_TRANS, ST alpha = Teuchos::ScalarTraits<ST>::one(),
161 ST beta = Teuchos::ScalarTraits<ST>::zero())
const;
165 Tpetra::MultiVector<ST, LO, GO, NT>& ,
166 Teuchos::ETransp = Teuchos::NO_TRANS,
167 ST = Teuchos::ScalarTraits<ST>::one(),
168 ST = Teuchos::ScalarTraits<ST>::zero())
const {
169 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::runtime_error,
170 "Can't call applyInverse on a ZeroedOperator");
174 double NormInf()
const {
return -1.0; }
177 bool UseTranspose()
const {
return false; }
180 bool HasNormInf()
const {
return false; }
183 Teuchos::RCP<const Tpetra::Map<LO, GO, NT> > getDomainMap()
const {
184 return tpetraOp_->getDomainMap();
188 Teuchos::RCP<const Tpetra::Map<LO, GO, NT> > getRangeMap()
const {
189 return tpetraOp_->getRangeMap();
195 std::vector<GO> zeroIndices_;
196 const Teuchos::RCP<const Tpetra::Operator<ST, LO, GO, NT> > tpetraOp_;
int SetUseTranspose(bool)
Can't transpose a ZeroedOperator.
virtual ~ZeroedOperator()
Do nothing destructor.
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.
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.