106 RCP<BlockedCrsMatrix> bA = rcp_dynamic_cast<BlockedCrsMatrix>(A);
107 RCP<BlockedCrsMatrix> bP = rcp_dynamic_cast<BlockedCrsMatrix>(P);
108 TEUCHOS_TEST_FOR_EXCEPTION(bA.is_null() || bP.is_null(),
Exceptions::BadCast,
"Matrices A and P must be of type BlockedCrsMatrix.");
111 RCP<BlockedCrsMatrix> bAP;
112 RCP<BlockedCrsMatrix> bAc;
118 "Block matrix dimensions do not match: "
119 "A is " << bA->Rows() <<
"x" << bA->Cols() <<
120 "P is " << bP->Rows() <<
"x" << bP->Cols());
122 bAP = MatrixMatrix::TwoMatrixMultiplyBlock(*bA,
false, *bP,
false,
GetOStream(
Statistics2),
true,
true);
130 const bool doTranspose =
true;
131 const bool doFillComplete =
true;
132 if (pL.get<
bool>(
"transpose: use implicit") ==
true) {
134 bAc = MatrixMatrix::TwoMatrixMultiplyBlock(*bP, doTranspose, *bAP, !doTranspose,
GetOStream(
Statistics2), doFillComplete, doOptimizeStorage);
138 RCP<BlockedCrsMatrix> bR = rcp_dynamic_cast<BlockedCrsMatrix>(R);
139 TEUCHOS_TEST_FOR_EXCEPTION(bR.is_null(),
Exceptions::BadCast,
"Matrix R must be of type BlockedCrsMatrix.");
142 "Block matrix dimensions do not match: "
143 "R is " << bR->Rows() <<
"x" << bR->Cols() <<
144 "A is " << bA->Rows() <<
"x" << bA->Cols());
147 bAc = MatrixMatrix::TwoMatrixMultiplyBlock(*bR, !doTranspose, *bAP, !doTranspose,
GetOStream(
Statistics2), doFillComplete, doOptimizeStorage);
163 RCP<const FactoryBase> fac = *it;
165 GetOStream(
Runtime0) <<
"BlockRAPFactory: call transfer factory: " << fac->description() << std::endl;
167 fac->CallBuild(coarseLevel);
179 RCP<Matrix> c00 = bAc->getMatrix(0, 0);
180 RCP<Matrix> Aout = MatrixFactory::Build(c00->getRowMap(), c00->getGlobalMaxNumRowEntries());
182 RCP<Vector> diagVec = VectorFactory::Build(c00->getRowMap());
183 c00->getLocalDiagCopy(*diagVec);
184 ArrayRCP<SC> diagVal = diagVec->getDataNonConst(0);
187 for (
size_t row = 0; row < c00->getLocalNumRows(); row++) {
189 GO grid = c00->getRowMap()->getGlobalElement(row);
191 ArrayView<const LO> indices;
192 ArrayView<const SC> vals;
193 c00->getLocalRowView(row, indices, vals);
196 ArrayRCP<GO> indout(indices.size(), Teuchos::OrdinalTraits<GO>::zero());
197 ArrayRCP<SC> valout(indices.size(), Teuchos::ScalarTraits<SC>::zero());
200 for (
size_t i = 0; i < as<size_t>(indices.size()); i++) {
201 GO gcid = c00->getColMap()->getGlobalElement(indices[i]);
203 valout [i] = vals[i];
206 Aout->insertGlobalValues(grid, indout.view(0, indout.size()), valout.view(0, valout.size()));
207 if (diagVal[row] == Teuchos::ScalarTraits<SC>::zero() && repairZeroDiagonals) {
209 Aout->insertGlobalValues(grid, Teuchos::tuple<GO>(grid), Teuchos::tuple<SC>(1.0));
213 Aout->fillComplete(c00->getDomainMap(), c00->getRangeMap());
215 bAc->setMatrix(0, 0, Aout);