46 #ifndef XPETRA_REORDEREDBLOCKEDCRSMATRIX_HPP
47 #define XPETRA_REORDEREDBLOCKEDCRSMATRIX_HPP
56 #include "Xpetra_BlockedMultiVector.hpp"
58 #include "Xpetra_CrsMatrixWrap.hpp"
70 template <
class Scalar,
83 #undef XPETRA_REORDEREDBLOCKEDCRSMATRIX_SHORT
124 size_t numBlocks = brm->GetNumBlocks();
133 map = fullRangeMapExtractor->getMap(Teuchos::as<size_t>(leaf->GetIndex()),
false);
136 std::vector<Teuchos::RCP<const Map> > subMaps (numBlocks, Teuchos::null);
138 for(
size_t i = 0; i < numBlocks; i++) {
165 if(
fullOp_->getNodeNumRows() != this->getNodeNumRows()) {
179 bool bCopyResultX =
false;
180 bool bCopyResultY =
false;
210 if (refbX == Teuchos::null &&
fullOp_->getNodeNumRows() == this->getNodeNumRows())
224 if (tmpbY == Teuchos::null &&
fullOp_->getNodeNumRows() == this->getNodeNumRows()) {
242 if (bCopyResultX ==
true) {
247 if (bCopyResultY ==
true) {
270 std::string
description()
const {
return "ReorderedBlockedCrsMatrix"; }
279 out <<
"ReorderedBlockMatrix is fillComplete" << std::endl;
281 out <<
"fullRowMap" << std::endl;
288 out <<
"Xpetra::ReorderedBlockedCrsMatrix is NOT fillComplete" << std::endl;
293 out <<
"Block(" << r <<
"," << c <<
")" << std::endl;
307 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
315 size_t numBlocks = brm->GetNumBlocks();
323 map = fullRangeMapExtractor->getMap(Teuchos::as<size_t>(leaf->GetIndex()), bThyraMode);
326 std::vector<Teuchos::RCP<const Xpetra::Map<LocalOrdinal,GlobalOrdinal,Node> > > subMaps (numBlocks, Teuchos::null);
328 for(
size_t i = 0; i < numBlocks; i++) {
353 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
364 size_t rowSz = rowMgr->GetNumBlocks();
365 size_t colSz = colMgr->GetNumBlocks();
369 if(rowSz == 0 && colSz == 0) {
377 if (mat == Teuchos::null)
return Teuchos::null;
381 if(matwrap != Teuchos::null) {
386 std::vector<Teuchos::RCP<const Map> > rowSubMaps (1, submap);
391 std::vector<Teuchos::RCP<const Map> > colSubMaps (1, submap2);
395 rbmat->setMatrix(0,0,mat);
398 rbmat = Teuchos::rcp_dynamic_cast<BlockedCrsMatrix>(mat);
401 TEUCHOS_ASSERT(mat->getNodeNumEntries() == rbmat->getNodeNumEntries());
407 std::vector<Teuchos::RCP<const Map> > rowSubMaps (rowSz, Teuchos::null);
408 for(
size_t i = 0; i < rowSz; i++) {
421 std::vector<Teuchos::RCP<const Map> > rowSubMaps (1, submap);
427 std::vector<Teuchos::RCP<const Map> > colSubMaps (colSz, Teuchos::null);
428 for(
size_t j = 0; j < colSz; j++) {
441 std::vector<Teuchos::RCP<const Map> > colSubMaps (1, submap);
449 if (rowSz == 0 && colSz > 0) {
450 for(
size_t j = 0; j < colSz; j++) {
453 rbmat->setMatrix(0,j,Teuchos::rcp_const_cast<Matrix>(submat));
454 if(submat != Teuchos::null) cntNNZ += submat->getNodeNumEntries();
456 }
else if (rowSz > 0 && colSz == 0) {
457 for(
size_t i = 0; i < rowSz; i++) {
460 rbmat->setMatrix(i,0,Teuchos::rcp_const_cast<Matrix>(submat));
461 if(submat != Teuchos::null) cntNNZ += submat->getNodeNumEntries();
464 for(
size_t i = 0; i < rowSz; i++) {
466 for(
size_t j = 0; j < colSz; j++) {
469 rbmat->setMatrix(i,j,Teuchos::rcp_const_cast<Matrix>(submat));
470 if(submat != Teuchos::null) cntNNZ += submat->getNodeNumEntries();
476 rbmat->fillComplete();
482 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
491 TEUCHOS_ASSERT(bmat->getRangeMapExtractor()->getThyraMode() ==
true);
492 TEUCHOS_ASSERT(bmat->getDomainMapExtractor()->getThyraMode() ==
true);
495 size_t rowSz = rowMgr->GetNumBlocks();
496 size_t colSz = colMgr->GetNumBlocks();
500 if(rowSz == 0 && colSz == 0) {
508 if(mat == Teuchos::null)
return Teuchos::null;
512 if(matwrap != Teuchos::null) {
519 std::vector<Teuchos::RCP<const Map> > rowXpSubMaps (1, xpsubmap);
520 std::vector<Teuchos::RCP<const Map> > rowTySubMaps (1, thysubmap);
528 std::vector<Teuchos::RCP<const Map> > colXpSubMaps (1, xpsubmap2);
529 std::vector<Teuchos::RCP<const Map> > colTySubMaps (1, tysubmap2);
536 rbmat->setMatrix(0,0,mat);
539 rbmat = Teuchos::rcp_dynamic_cast<BlockedCrsMatrix>(mat);
542 TEUCHOS_ASSERT(mat->getNodeNumEntries() == rbmat->getNodeNumEntries());
548 std::vector<Teuchos::RCP<const Map> > rowXpSubMaps (rowSz, Teuchos::null);
549 std::vector<Teuchos::RCP<const Map> > rowTySubMaps (rowSz, Teuchos::null);
550 for(
size_t i = 0; i < rowSz; i++) {
566 std::vector<Teuchos::RCP<const Map> > rowXpSubMaps (1, xpsubmap);
567 std::vector<Teuchos::RCP<const Map> > rowTySubMaps (1, thysubmap);
574 std::vector<Teuchos::RCP<const Map> > colXpSubMaps (colSz, Teuchos::null);
575 std::vector<Teuchos::RCP<const Map> > colTySubMaps (colSz, Teuchos::null);
576 for(
size_t j = 0; j < colSz; j++) {
592 std::vector<Teuchos::RCP<const Map> > colXpSubMaps (1, xpsubmap);
593 std::vector<Teuchos::RCP<const Map> > colTySubMaps (1, tysubmap);
603 if (rowSz == 0 && colSz > 0) {
604 for(
size_t j = 0; j < colSz; j++) {
607 rbmat->setMatrix(0,j,Teuchos::rcp_const_cast<Matrix>(submat));
608 if(submat != Teuchos::null) cntNNZ += submat->getNodeNumEntries();
610 }
else if (rowSz > 0 && colSz == 0) {
611 for(
size_t i = 0; i < rowSz; i++) {
614 rbmat->setMatrix(i,0,Teuchos::rcp_const_cast<Matrix>(submat));
615 if(submat != Teuchos::null) cntNNZ += submat->getNodeNumEntries();
618 for(
size_t i = 0; i < rowSz; i++) {
620 for(
size_t j = 0; j < colSz; j++) {
623 rbmat->setMatrix(i,j,Teuchos::rcp_const_cast<Matrix>(submat));
624 if(submat != Teuchos::null) cntNNZ += submat->getNodeNumEntries();
631 rbmat->fillComplete();
635 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
637 TEUCHOS_ASSERT(bmat->getRangeMapExtractor()->getThyraMode() == bmat->getDomainMapExtractor()->getThyraMode());
639 if(bmat->getRangeMapExtractor()->getThyraMode() ==
false) {
651 #define XPETRA_REORDEREDBLOCKEDCRSMATRIX_SHORT