46#ifndef XPETRA_REORDEREDBLOCKEDCRSMATRIX_HPP
47#define XPETRA_REORDEREDBLOCKEDCRSMATRIX_HPP
49#include <KokkosCompat_DefaultNode.hpp>
56#include "Xpetra_BlockedMultiVector.hpp"
58#include "Xpetra_CrsMatrixWrap.hpp"
70 template <
class Scalar,
83#undef XPETRA_REORDEREDBLOCKEDCRSMATRIX_SHORT
122 size_t numBlocks = brm->GetNumBlocks();
131 map = fullRangeMapExtractor->getMap(Teuchos::as<size_t>(leaf->GetIndex()),
false);
134 std::vector<Teuchos::RCP<const Map> > subMaps (numBlocks, Teuchos::null);
136 for(
size_t i = 0; i < numBlocks; i++) {
168 if(
fullOp_->getLocalNumRows() != this->getLocalNumRows()) {
182 bool bCopyResultX =
false;
183 bool bCopyResultY =
false;
213 if (refbX == Teuchos::null &&
fullOp_->getLocalNumRows() == this->getLocalNumRows())
227 if (tmpbY == Teuchos::null &&
fullOp_->getLocalNumRows() == this->getLocalNumRows()) {
245 if (bCopyResultX ==
true) {
250 if (bCopyResultY ==
true) {
273 std::string
description()
const {
return "ReorderedBlockedCrsMatrix"; }
281 out <<
"ReorderedBlockMatrix is fillComplete" << std::endl;
283 out <<
"fullRowMap" << std::endl;
290 out <<
"Xpetra::ReorderedBlockedCrsMatrix is NOT fillComplete" << std::endl;
295 out <<
"Block(" << r <<
"," << c <<
")" << std::endl;
309template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
317 size_t numBlocks = brm->GetNumBlocks();
325 map = fullRangeMapExtractor->getMap(Teuchos::as<size_t>(leaf->GetIndex()), bThyraMode);
328 std::vector<Teuchos::RCP<const Xpetra::Map<LocalOrdinal,GlobalOrdinal,Node> > > subMaps (numBlocks, Teuchos::null);
330 for(
size_t i = 0; i < numBlocks; i++) {
355template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
366 size_t rowSz = rowMgr->GetNumBlocks();
367 size_t colSz = colMgr->GetNumBlocks();
371 if(rowSz == 0 && colSz == 0) {
379 if (mat == Teuchos::null)
return Teuchos::null;
383 if(matwrap != Teuchos::null) {
388 std::vector<Teuchos::RCP<const Map> > rowSubMaps (1, submap);
393 std::vector<Teuchos::RCP<const Map> > colSubMaps (1, submap2);
397 rbmat->setMatrix(0,0,mat);
400 rbmat = Teuchos::rcp_dynamic_cast<BlockedCrsMatrix>(mat);
403 TEUCHOS_ASSERT(mat->getLocalNumEntries() == rbmat->getLocalNumEntries());
409 std::vector<Teuchos::RCP<const Map> > rowSubMaps (rowSz, Teuchos::null);
410 for(
size_t i = 0; i < rowSz; i++) {
423 std::vector<Teuchos::RCP<const Map> > rowSubMaps (1, submap);
429 std::vector<Teuchos::RCP<const Map> > colSubMaps (colSz, Teuchos::null);
430 for(
size_t j = 0; j < colSz; j++) {
443 std::vector<Teuchos::RCP<const Map> > colSubMaps (1, submap);
451 if (rowSz == 0 && colSz > 0) {
452 for(
size_t j = 0; j < colSz; j++) {
455 rbmat->setMatrix(0,j,Teuchos::rcp_const_cast<Matrix>(submat));
456 if(submat != Teuchos::null) cntNNZ += submat->getLocalNumEntries();
458 }
else if (rowSz > 0 && colSz == 0) {
459 for(
size_t i = 0; i < rowSz; i++) {
462 rbmat->setMatrix(i,0,Teuchos::rcp_const_cast<Matrix>(submat));
463 if(submat != Teuchos::null) cntNNZ += submat->getLocalNumEntries();
466 for(
size_t i = 0; i < rowSz; i++) {
468 for(
size_t j = 0; j < colSz; j++) {
471 rbmat->setMatrix(i,j,Teuchos::rcp_const_cast<Matrix>(submat));
472 if(submat != Teuchos::null) cntNNZ += submat->getLocalNumEntries();
478 rbmat->fillComplete();
484template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
493 TEUCHOS_ASSERT(bmat->getRangeMapExtractor()->getThyraMode() ==
true);
494 TEUCHOS_ASSERT(bmat->getDomainMapExtractor()->getThyraMode() ==
true);
497 size_t rowSz = rowMgr->GetNumBlocks();
498 size_t colSz = colMgr->GetNumBlocks();
502 if(rowSz == 0 && colSz == 0) {
510 if(mat == Teuchos::null)
return Teuchos::null;
514 if(matwrap != Teuchos::null) {
521 std::vector<Teuchos::RCP<const Map> > rowXpSubMaps (1, xpsubmap);
522 std::vector<Teuchos::RCP<const Map> > rowTySubMaps (1, thysubmap);
530 std::vector<Teuchos::RCP<const Map> > colXpSubMaps (1, xpsubmap2);
531 std::vector<Teuchos::RCP<const Map> > colTySubMaps (1, tysubmap2);
538 rbmat->setMatrix(0,0,mat);
541 rbmat = Teuchos::rcp_dynamic_cast<BlockedCrsMatrix>(mat);
544 TEUCHOS_ASSERT(mat->getLocalNumEntries() == rbmat->getLocalNumEntries());
550 std::vector<Teuchos::RCP<const Map> > rowXpSubMaps (rowSz, Teuchos::null);
551 std::vector<Teuchos::RCP<const Map> > rowTySubMaps (rowSz, Teuchos::null);
552 for(
size_t i = 0; i < rowSz; i++) {
568 std::vector<Teuchos::RCP<const Map> > rowXpSubMaps (1, xpsubmap);
569 std::vector<Teuchos::RCP<const Map> > rowTySubMaps (1, thysubmap);
576 std::vector<Teuchos::RCP<const Map> > colXpSubMaps (colSz, Teuchos::null);
577 std::vector<Teuchos::RCP<const Map> > colTySubMaps (colSz, Teuchos::null);
578 for(
size_t j = 0; j < colSz; j++) {
594 std::vector<Teuchos::RCP<const Map> > colXpSubMaps (1, xpsubmap);
595 std::vector<Teuchos::RCP<const Map> > colTySubMaps (1, tysubmap);
605 if (rowSz == 0 && colSz > 0) {
606 for(
size_t j = 0; j < colSz; j++) {
609 rbmat->setMatrix(0,j,Teuchos::rcp_const_cast<Matrix>(submat));
610 if(submat != Teuchos::null) cntNNZ += submat->getLocalNumEntries();
612 }
else if (rowSz > 0 && colSz == 0) {
613 for(
size_t i = 0; i < rowSz; i++) {
616 rbmat->setMatrix(i,0,Teuchos::rcp_const_cast<Matrix>(submat));
617 if(submat != Teuchos::null) cntNNZ += submat->getLocalNumEntries();
620 for(
size_t i = 0; i < rowSz; i++) {
622 for(
size_t j = 0; j < colSz; j++) {
625 rbmat->setMatrix(i,j,Teuchos::rcp_const_cast<Matrix>(submat));
626 if(submat != Teuchos::null) cntNNZ += submat->getLocalNumEntries();
633 rbmat->fillComplete();
637template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
639 TEUCHOS_ASSERT(bmat->getRangeMapExtractor()->getThyraMode() == bmat->getDomainMapExtractor()->getThyraMode());
641 if(bmat->getRangeMapExtractor()->getThyraMode() ==
false) {
653#define XPETRA_REORDEREDBLOCKEDCRSMATRIX_SHORT
static const EVerbosityLevel verbLevel_default
void swap(RCP< T > &r_ptr)
Teuchos::RCP< Matrix > getMatrix(size_t r, size_t c) const
return block (r,c)
virtual size_t Rows() const
number of row blocks
bool isFillComplete() const
Returns true if fillComplete() has been called and the matrix is in compute mode.
RCP< const Map > getRangeMap() const
Returns the Map associated with the range of this operator.
virtual void apply(const MultiVector &X, MultiVector &Y, Teuchos::ETransp mode, Scalar alpha, Scalar beta, bool sumInterfaceValues, const RCP< Xpetra::Import< LocalOrdinal, GlobalOrdinal, Node > > ®ionInterfaceImporter, const Teuchos::ArrayRCP< LocalOrdinal > ®ionInterfaceLIDs) const
sparse matrix-multivector multiplication for the region layout matrices (currently no blocked impleme...
virtual size_t Cols() const
number of column blocks
Xpetra utility class for common map-related routines.
static Teuchos::RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > concatenateMaps(const std::vector< Teuchos::RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > > &subMaps)
Helper function to concatenate several maps.
Xpetra-specific matrix class.
virtual void update(const Scalar &alpha, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Scalar &beta)=0
Update multi-vector values with scaled values of A, this = beta*this + alpha*A.
LocalOrdinal local_ordinal_type
virtual void apply(const MultiVector &X, MultiVector &Y, Teuchos::ETransp mode, Scalar alpha, Scalar beta, bool sumInterfaceValues, const RCP< Xpetra::Import< LocalOrdinal, GlobalOrdinal, Node > > ®ionInterfaceImporter, const Teuchos::ArrayRCP< LocalOrdinal > ®ionInterfaceLIDs) const
sparse matrix-multivector multiplication for the region layout matrices (currently no blocked impleme...
GlobalOrdinal global_ordinal_type
std::string description() const
Return a simple one-line description of this object.
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Print the object with some verbosity level to an FancyOStream object.
virtual void apply(const MultiVector &X, MultiVector &Y, Teuchos::ETransp mode=Teuchos::NO_TRANS, Scalar alpha=ScalarTraits< Scalar >::one(), Scalar beta=ScalarTraits< Scalar >::zero()) const
Computes the sparse matrix-multivector multiplication.
Teuchos::RCP< const Xpetra::BlockReorderManager > brm_
ReorderedBlockedCrsMatrix(Teuchos::RCP< const MapExtractor > &rangeMaps, Teuchos::RCP< const MapExtractor > &domainMaps, size_t npr, Teuchos::RCP< const Xpetra::BlockReorderManager > brm, Teuchos::RCP< const Xpetra::BlockedCrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > bmat)
Constructor.
Teuchos::RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > mergeSubBlockMaps(Teuchos::RCP< const Xpetra::BlockReorderManager > brm)
Teuchos::RCP< const Xpetra::BlockReorderManager > getBlockReorderManager()
Returns internal BlockReorderManager object.
virtual ~ReorderedBlockedCrsMatrix()
Destructor.
Teuchos::RCP< const Xpetra::BlockedCrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > fullOp_
#define TEUCHOS_ASSERT(assertion_test)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Teuchos::RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > mergeSubBlockMaps(Teuchos::RCP< const Xpetra::BlockReorderManager > brm, Teuchos::RCP< const Xpetra::BlockedCrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > bmat, bool bThyraMode)
Teuchos::RCP< const Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > buildReorderedBlockedCrsMatrix(Teuchos::RCP< const Xpetra::BlockReorderManager > brm, Teuchos::RCP< const Xpetra::BlockedCrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > bmat)
Teuchos::RCP< const Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > mergeSubBlocks(Teuchos::RCP< const Xpetra::BlockReorderManager > rowMgr, Teuchos::RCP< const Xpetra::BlockReorderManager > colMgr, Teuchos::RCP< const Xpetra::BlockedCrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > bmat)
Teuchos::RCP< const Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > mergeSubBlocksThyra(Teuchos::RCP< const Xpetra::BlockReorderManager > rowMgr, Teuchos::RCP< const Xpetra::BlockReorderManager > colMgr, Teuchos::RCP< const Xpetra::BlockedCrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > bmat)
Teuchos::RCP< const Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > buildReorderedBlockedMultiVector(Teuchos::RCP< const Xpetra::BlockReorderManager > brm, Teuchos::RCP< const Xpetra::BlockedMultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > bvec)