46#include <Xpetra_Matrix.hpp>
47#include <Xpetra_CrsMatrixWrap.hpp>
48#include <Xpetra_BlockedCrsMatrix.hpp>
49#include <Xpetra_EpetraMultiVector.hpp>
54#if defined(HAVE_MUELU_SERIAL) and defined(HAVE_MUELU_EPETRA)
61 const Xpetra::EpetraMultiVectorT<GO,NO> eX(rcpFromRef(
const_cast<Epetra_MultiVector&
>(X)));
62 Xpetra::EpetraMultiVectorT<GO,NO> eY(rcpFromRef(Y));
66 RCP<Xpetra::EpetraMultiVectorT<GO,NO> > tmpY = Teuchos::rcp(
new Xpetra::EpetraMultiVectorT<GO,NO>(eY.getMap(), eY.getNumVectors()));
69 bool initialGuessZero =
true;
72 Hierarchy_->Iterate(eX, *tmpY, 1, initialGuessZero);
74 eY.update(1.0, *tmpY, 0.0);
80 bool initialGuessZero =
true;
82 Hierarchy_->Iterate(eX, eY, 1, initialGuessZero);
85 }
catch (std::exception& e) {
87 std::cerr <<
"Caught an exception in MueLu::EpetraOperator::ApplyInverse():" << std::endl
88 << e.what() << std::endl;
95 RCP<Matrix> A = Hierarchy_->GetLevel(0)->Get<RCP<Matrix> >(
"A");
98 RCP<Xpetra::BlockedCrsMatrix<SC, LO, GO, NO> > epbA = Teuchos::rcp_dynamic_cast<Xpetra::BlockedCrsMatrix<SC, LO, GO, NO> >(A);
99 if (epbA != Teuchos::null) {
100 RCP<const Xpetra::Matrix<SC, LO, GO, NO> > blockMat = epbA->getMatrix(0,0);
101 RCP<const Xpetra::CrsMatrixWrap<SC, LO, GO, NO> > blockCrsWrap = Teuchos::rcp_dynamic_cast<const Xpetra::CrsMatrixWrap<SC, LO, GO, NO> >(blockMat);
102 if (blockCrsWrap == Teuchos::null)
103 throw Exceptions::BadCast(
"MueLu::EpetraOperator::Comm(): Cast from block (0,0) to CrsMatrixWrap failed. Could be a block matrix. TODO implement recursive support for block matrices.");
104 RCP<const Xpetra::EpetraCrsMatrixT<GO,NO>> tmp_ECrsMtx = rcp_dynamic_cast<const Xpetra::EpetraCrsMatrixT<GO,NO> >(blockCrsWrap->getCrsMatrix());
105 if (tmp_ECrsMtx == Teuchos::null)
106 throw Exceptions::BadCast(
"MueLu::EpetraOperator::Comm(): Cast from Xpetra::CrsMatrix to Xpetra::EpetraCrsMatrix failed");
107 RCP<Epetra_CrsMatrix> epA = tmp_ECrsMtx->getEpetra_CrsMatrixNonConst();
111 RCP<const Xpetra::CrsMatrixWrap<SC,LO,GO,NO> > crsOp = rcp_dynamic_cast<const Xpetra::CrsMatrixWrap<SC,LO,GO,NO> >(A);
112 if (crsOp == Teuchos::null)
113 throw Exceptions::BadCast(
"Cast from Xpetra::Matrix to Xpetra::CrsMatrixWrap failed");
114 const RCP<const Xpetra::EpetraCrsMatrixT<GO,NO>> &tmp_ECrsMtx = rcp_dynamic_cast<const Xpetra::EpetraCrsMatrixT<GO,NO>>(crsOp->getCrsMatrix());
115 if (tmp_ECrsMtx == Teuchos::null)
116 throw Exceptions::BadCast(
"Cast from Xpetra::CrsMatrix to Xpetra::EpetraCrsMatrix failed");
117 return tmp_ECrsMtx->getEpetra_CrsMatrixNonConst()->Comm();
120const Epetra_Map& EpetraOperator::OperatorDomainMap()
const {
121 RCP<Xpetra::Matrix<SC,LO,GO,NO> > A = Hierarchy_->GetLevel(0)->Get<RCP<Matrix> >(
"A");
123 RCP<Xpetra::BlockedCrsMatrix<SC, LO, GO, NO> > epbA = Teuchos::rcp_dynamic_cast<Xpetra::BlockedCrsMatrix<SC, LO, GO, NO> >(A);
124 if (epbA != Teuchos::null)
125 return Xpetra::toEpetra(epbA->getFullDomainMap());
127 RCP<const Xpetra::CrsMatrixWrap<SC,LO,GO,NO> > crsOp = rcp_dynamic_cast<const Xpetra::CrsMatrixWrap<SC,LO,GO,NO> >(A);
128 if (crsOp == Teuchos::null)
129 throw Exceptions::BadCast(
"Cast from Xpetra::Matrix to Xpetra::CrsMatrixWrap failed");
130 const RCP<const Xpetra::EpetraCrsMatrixT<GO,NO>> &tmp_ECrsMtx = rcp_dynamic_cast<const Xpetra::EpetraCrsMatrixT<GO,NO>>(crsOp->getCrsMatrix());
131 if (tmp_ECrsMtx == Teuchos::null)
132 throw Exceptions::BadCast(
"Cast from Xpetra::CrsMatrix to Xpetra::EpetraCrsMatrix failed");
133 return tmp_ECrsMtx->getEpetra_CrsMatrixNonConst()->DomainMap();
136const Epetra_Map & EpetraOperator::OperatorRangeMap()
const {
137 RCP<Xpetra::Matrix<SC,LO,GO,NO> > A = Hierarchy_->GetLevel(0)->Get<RCP<Matrix> >(
"A");
139 RCP<Xpetra::BlockedCrsMatrix<SC, LO, GO, NO> > epbA = Teuchos::rcp_dynamic_cast<Xpetra::BlockedCrsMatrix<SC, LO, GO, NO> >(A);
140 if (epbA != Teuchos::null)
141 return Xpetra::toEpetra(epbA->getFullRangeMap());
143 RCP<const Xpetra::CrsMatrixWrap<SC,LO,GO,NO> > crsOp = rcp_dynamic_cast<const Xpetra::CrsMatrixWrap<SC,LO,GO,NO> >(A);
144 if (crsOp == Teuchos::null)
145 throw Exceptions::BadCast(
"Cast from Xpetra::Matrix to Xpetra::CrsMatrixWrap failed");
146 const RCP<const Xpetra::EpetraCrsMatrixT<GO,NO>> &tmp_ECrsMtx = rcp_dynamic_cast<const Xpetra::EpetraCrsMatrixT<GO,NO>>(crsOp->getCrsMatrix());
147 if (tmp_ECrsMtx == Teuchos::null)
148 throw Exceptions::BadCast(
"Cast from Xpetra::CrsMatrix to Xpetra::EpetraCrsMatrix failed");
149 return tmp_ECrsMtx->getEpetra_CrsMatrixNonConst()->RangeMap();
Namespace for MueLu classes and methods.