44 coarseSolver_->Setup(currentLevel);
47 this->GetOStream(
Warnings0) <<
"MueLu::ProjectorSmoother::Setup(): Setup() has already been called" << std::endl;
49 RCP<Matrix> A = Factory::Get<RCP<Matrix> >(currentLevel,
"A");
50 RCP<MultiVector> B = Factory::Get<RCP<MultiVector> >(currentLevel,
"Nullspace");
52 int m = B->getNumVectors();
55 Array<Scalar> br(m), bb(m);
56 RCP<MultiVector> R = MultiVectorFactory::Build(B->getMap(), m);
61 Array<size_t> selectedIndices;
62 for (
int i = 0; i < m; i++) {
63 Scalar rayleigh = br[i] / bb[i];
65 if (Teuchos::ScalarTraits<Scalar>::magnitude(rayleigh) < 1e-12)
66 selectedIndices.push_back(i);
68 this->GetOStream(
Runtime0) <<
"Coarse level orth indices: " << selectedIndices << std::endl;
70#if defined(HAVE_XPETRA_TPETRA)
71#ifdef HAVE_MUELU_TPETRA_INST_INT_INT
73 RCP<const Tpetra::MultiVector<SC, LO, GO, NO> > B_ = toTpetra(B);
76 RCP<Tpetra::MultiVector<SC, LO, GO, NO> > Borth = B_->subCopy(selectedIndices);
77 for (
int i = 0; i < selectedIndices.size(); i++) {
78 RCP<Tpetra::Vector<SC, LO, GO, NO> > Bi = Borth->getVectorNonConst(i);
81 typename Teuchos::ScalarTraits<Scalar>::magnitudeType norm;
82 for (
int k = 0; k < i; k++) {
83 RCP<const Tpetra::Vector<SC, LO, GO, NO> > Bk = Borth->getVector(k);
86 Bi->update(-dot, *Bk, Teuchos::ScalarTraits<Scalar>::one());
90 Bi->scale(Teuchos::ScalarTraits<Scalar>::one() / norm);
93 Borth_ = rcp(
static_cast<MultiVector *
>(
new TpetraMultiVector(Borth)));
95 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Exceptions::RuntimeError,
"Tpetra with GO=int not available. The code in ProjectorSmoother should be rewritten!");
104 coarseSolver_->Apply(X, B, InitialGuessIsZero);
106 int m = Borth_->getNumVectors();
107 int n = X.getNumVectors();
109 RCP<Xpetra::MultiVector<SC, LO, GO, NO> > X_ = Teuchos::rcpFromRef(X);
110 for (
int i = 0; i < n; i++) {
111 RCP<Xpetra::Vector<SC, LO, GO, NO> > Xi = X_->getVectorNonConst(i);
113 Array<Scalar> dot(1);
114 for (
int k = 0; k < m; k++) {
115 RCP<const Xpetra::Vector<SC, LO, GO, NO> > Bk = Borth_->getVector(k);
118 Xi->update(-dot[0], *Bk, Teuchos::ScalarTraits<Scalar>::one());