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
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++) {
163 if(
fullOp_->getNodeNumRows() != this->getNodeNumRows()) {
177 bool bCopyResultX =
false;
178 bool bCopyResultY =
false;
208 if (refbX == Teuchos::null &&
fullOp_->getNodeNumRows() == this->getNodeNumRows())
222 if (tmpbY == Teuchos::null &&
fullOp_->getNodeNumRows() == this->getNodeNumRows()) {
240 if (bCopyResultX ==
true) {
245 if (bCopyResultY ==
true) {
268 std::string
description()
const {
return "ReorderedBlockedCrsMatrix"; }
276 out <<
"ReorderedBlockMatrix is fillComplete" << std::endl;
278 out <<
"fullRowMap" << std::endl;
285 out <<
"Xpetra::ReorderedBlockedCrsMatrix is NOT fillComplete" << std::endl;
290 out <<
"Block(" << r <<
"," << c <<
")" << std::endl;
304 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
312 size_t numBlocks = brm->GetNumBlocks();
320 map = fullRangeMapExtractor->getMap(Teuchos::as<size_t>(leaf->GetIndex()), bThyraMode);
323 std::vector<Teuchos::RCP<const Xpetra::Map<LocalOrdinal,GlobalOrdinal,Node> > > subMaps (numBlocks, Teuchos::null);
325 for(
size_t i = 0; i < numBlocks; i++) {
350 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
361 size_t rowSz = rowMgr->GetNumBlocks();
362 size_t colSz = colMgr->GetNumBlocks();
366 if(rowSz == 0 && colSz == 0) {
374 if (mat == Teuchos::null)
return Teuchos::null;
378 if(matwrap != Teuchos::null) {
383 std::vector<Teuchos::RCP<const Map> > rowSubMaps (1, submap);
388 std::vector<Teuchos::RCP<const Map> > colSubMaps (1, submap2);
392 rbmat->setMatrix(0,0,mat);
395 rbmat = Teuchos::rcp_dynamic_cast<BlockedCrsMatrix>(mat);
398 TEUCHOS_ASSERT(mat->getNodeNumEntries() == rbmat->getNodeNumEntries());
404 std::vector<Teuchos::RCP<const Map> > rowSubMaps (rowSz, Teuchos::null);
405 for(
size_t i = 0; i < rowSz; i++) {
418 std::vector<Teuchos::RCP<const Map> > rowSubMaps (1, submap);
424 std::vector<Teuchos::RCP<const Map> > colSubMaps (colSz, Teuchos::null);
425 for(
size_t j = 0; j < colSz; j++) {
438 std::vector<Teuchos::RCP<const Map> > colSubMaps (1, submap);
446 if (rowSz == 0 && colSz > 0) {
447 for(
size_t j = 0; j < colSz; j++) {
450 rbmat->setMatrix(0,j,Teuchos::rcp_const_cast<Matrix>(submat));
451 if(submat != Teuchos::null) cntNNZ += submat->getNodeNumEntries();
453 }
else if (rowSz > 0 && colSz == 0) {
454 for(
size_t i = 0; i < rowSz; i++) {
457 rbmat->setMatrix(i,0,Teuchos::rcp_const_cast<Matrix>(submat));
458 if(submat != Teuchos::null) cntNNZ += submat->getNodeNumEntries();
461 for(
size_t i = 0; i < rowSz; i++) {
463 for(
size_t j = 0; j < colSz; j++) {
466 rbmat->setMatrix(i,j,Teuchos::rcp_const_cast<Matrix>(submat));
467 if(submat != Teuchos::null) cntNNZ += submat->getNodeNumEntries();
473 rbmat->fillComplete();
479 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
488 TEUCHOS_ASSERT(bmat->getRangeMapExtractor()->getThyraMode() ==
true);
489 TEUCHOS_ASSERT(bmat->getDomainMapExtractor()->getThyraMode() ==
true);
492 size_t rowSz = rowMgr->GetNumBlocks();
493 size_t colSz = colMgr->GetNumBlocks();
497 if(rowSz == 0 && colSz == 0) {
505 if(mat == Teuchos::null)
return Teuchos::null;
509 if(matwrap != Teuchos::null) {
516 std::vector<Teuchos::RCP<const Map> > rowXpSubMaps (1, xpsubmap);
517 std::vector<Teuchos::RCP<const Map> > rowTySubMaps (1, thysubmap);
525 std::vector<Teuchos::RCP<const Map> > colXpSubMaps (1, xpsubmap2);
526 std::vector<Teuchos::RCP<const Map> > colTySubMaps (1, tysubmap2);
533 rbmat->setMatrix(0,0,mat);
536 rbmat = Teuchos::rcp_dynamic_cast<BlockedCrsMatrix>(mat);
539 TEUCHOS_ASSERT(mat->getNodeNumEntries() == rbmat->getNodeNumEntries());
545 std::vector<Teuchos::RCP<const Map> > rowXpSubMaps (rowSz, Teuchos::null);
546 std::vector<Teuchos::RCP<const Map> > rowTySubMaps (rowSz, Teuchos::null);
547 for(
size_t i = 0; i < rowSz; i++) {
563 std::vector<Teuchos::RCP<const Map> > rowXpSubMaps (1, xpsubmap);
564 std::vector<Teuchos::RCP<const Map> > rowTySubMaps (1, thysubmap);
571 std::vector<Teuchos::RCP<const Map> > colXpSubMaps (colSz, Teuchos::null);
572 std::vector<Teuchos::RCP<const Map> > colTySubMaps (colSz, Teuchos::null);
573 for(
size_t j = 0; j < colSz; j++) {
589 std::vector<Teuchos::RCP<const Map> > colXpSubMaps (1, xpsubmap);
590 std::vector<Teuchos::RCP<const Map> > colTySubMaps (1, tysubmap);
600 if (rowSz == 0 && colSz > 0) {
601 for(
size_t j = 0; j < colSz; j++) {
604 rbmat->setMatrix(0,j,Teuchos::rcp_const_cast<Matrix>(submat));
605 if(submat != Teuchos::null) cntNNZ += submat->getNodeNumEntries();
607 }
else if (rowSz > 0 && colSz == 0) {
608 for(
size_t i = 0; i < rowSz; i++) {
611 rbmat->setMatrix(i,0,Teuchos::rcp_const_cast<Matrix>(submat));
612 if(submat != Teuchos::null) cntNNZ += submat->getNodeNumEntries();
615 for(
size_t i = 0; i < rowSz; i++) {
617 for(
size_t j = 0; j < colSz; j++) {
620 rbmat->setMatrix(i,j,Teuchos::rcp_const_cast<Matrix>(submat));
621 if(submat != Teuchos::null) cntNNZ += submat->getNodeNumEntries();
628 rbmat->fillComplete();
632 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
634 TEUCHOS_ASSERT(bmat->getRangeMapExtractor()->getThyraMode() == bmat->getDomainMapExtractor()->getThyraMode());
636 if(bmat->getRangeMapExtractor()->getThyraMode() ==
false) {
648 #define XPETRA_REORDEREDBLOCKEDCRSMATRIX_SHORT
static const EVerbosityLevel verbLevel_default
void swap(RCP< T > &r_ptr)
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=Teuchos::NO_TRANS, Scalar alpha=ScalarTraits< Scalar >::one(), Scalar beta=ScalarTraits< Scalar >::zero()) const
Computes the sparse matrix-multivector multiplication.
virtual size_t Cols() const
number of column blocks
Teuchos::RCP< Matrix > getMatrix(size_t r, size_t c) const
return block (r,c)
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
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)
bool is_null(const boost::shared_ptr< T > &p)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
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 > > 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::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 > > 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::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > buildReorderedBlockedMultiVector(Teuchos::RCP< const Xpetra::BlockReorderManager > brm, Teuchos::RCP< const Xpetra::BlockedMultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > bvec)