46 #ifndef XPETRA_REORDEREDBLOCKEDCRSMATRIX_HPP 47 #define XPETRA_REORDEREDBLOCKEDCRSMATRIX_HPP 68 template <
class Scalar,
72 class ReorderedBlockedCrsMatrix :
73 public BlockedCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> {
81 #undef XPETRA_REORDEREDBLOCKEDCRSMATRIX_SHORT 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++) {
170 std::string
description()
const {
return "ReorderedBlockedCrsMatrix"; }
179 out <<
"ReorderedBlockMatrix is fillComplete" << std::endl;
181 out <<
"fullRowMap" << std::endl;
188 out <<
"Xpetra::ReorderedBlockedCrsMatrix is NOT fillComplete" << std::endl;
193 out <<
"Block(" << r <<
"," << c <<
")" << std::endl;
207 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
223 map = fullRangeMapExtractor->getMap(Teuchos::as<size_t>(leaf->
GetIndex()), bThyraMode);
226 std::vector<Teuchos::RCP<const Xpetra::Map<LocalOrdinal,GlobalOrdinal,Node> > > subMaps (numBlocks, Teuchos::null);
228 for(
size_t i = 0; i < numBlocks; i++) {
240 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
256 if(rowSz == 0 && colSz == 0) {
264 if (mat == Teuchos::null)
return Teuchos::null;
268 if(matwrap != Teuchos::null) {
273 std::vector<Teuchos::RCP<const Map> > rowSubMaps (1, submap);
278 std::vector<Teuchos::RCP<const Map> > colSubMaps (1, submap2);
282 rbmat->setMatrix(0,0,mat);
285 rbmat = Teuchos::rcp_dynamic_cast<BlockedCrsMatrix>(mat);
288 TEUCHOS_ASSERT(mat->getNodeNumEntries() == rbmat->getNodeNumEntries());
294 std::vector<Teuchos::RCP<const Map> > rowSubMaps (rowSz, Teuchos::null);
295 for(
size_t i = 0; i < rowSz; i++) {
301 rgMapExtractor =
Teuchos::rcp(
new MapExtractor(rgMergedSubMaps, rowSubMaps,
false));
308 std::vector<Teuchos::RCP<const Map> > rowSubMaps (1, submap);
309 rgMapExtractor =
Teuchos::rcp(
new MapExtractor(submap, rowSubMaps,
false));
314 std::vector<Teuchos::RCP<const Map> > colSubMaps (colSz, Teuchos::null);
315 for(
size_t j = 0; j < colSz; j++) {
321 doMapExtractor =
Teuchos::rcp(
new MapExtractor(doMergedSubMaps, colSubMaps,
false));
328 std::vector<Teuchos::RCP<const Map> > colSubMaps (1, submap);
329 doMapExtractor =
Teuchos::rcp(
new MapExtractor(submap, colSubMaps,
false));
336 if (rowSz == 0 && colSz > 0) {
337 for(
size_t j = 0; j < colSz; j++) {
340 rbmat->setMatrix(0,j,Teuchos::rcp_const_cast<Matrix>(submat));
341 if(submat != Teuchos::null) cntNNZ += submat->getNodeNumEntries();
343 }
else if (rowSz > 0 && colSz == 0) {
344 for(
size_t i = 0; i < rowSz; i++) {
347 rbmat->setMatrix(i,0,Teuchos::rcp_const_cast<Matrix>(submat));
348 if(submat != Teuchos::null) cntNNZ += submat->getNodeNumEntries();
351 for(
size_t i = 0; i < rowSz; i++) {
353 for(
size_t j = 0; j < colSz; j++) {
356 rbmat->setMatrix(i,j,Teuchos::rcp_const_cast<Matrix>(submat));
357 if(submat != Teuchos::null) cntNNZ += submat->getNodeNumEntries();
363 rbmat->fillComplete();
369 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
378 TEUCHOS_ASSERT(bmat->getRangeMapExtractor()->getThyraMode() ==
true);
379 TEUCHOS_ASSERT(bmat->getDomainMapExtractor()->getThyraMode() ==
true);
387 if(rowSz == 0 && colSz == 0) {
395 if(mat == Teuchos::null)
return Teuchos::null;
399 if(matwrap != Teuchos::null) {
406 std::vector<Teuchos::RCP<const Map> > rowXpSubMaps (1, xpsubmap);
407 std::vector<Teuchos::RCP<const Map> > rowTySubMaps (1, thysubmap);
415 std::vector<Teuchos::RCP<const Map> > colXpSubMaps (1, xpsubmap2);
416 std::vector<Teuchos::RCP<const Map> > colTySubMaps (1, tysubmap2);
423 rbmat->setMatrix(0,0,mat);
426 rbmat = Teuchos::rcp_dynamic_cast<BlockedCrsMatrix>(mat);
429 TEUCHOS_ASSERT(mat->getNodeNumEntries() == rbmat->getNodeNumEntries());
435 std::vector<Teuchos::RCP<const Map> > rowXpSubMaps (rowSz, Teuchos::null);
436 std::vector<Teuchos::RCP<const Map> > rowTySubMaps (rowSz, Teuchos::null);
437 for(
size_t i = 0; i < rowSz; i++) {
446 rgMapExtractor =
Teuchos::rcp(
new MapExtractor(rowXpSubMaps, rowTySubMaps));
453 std::vector<Teuchos::RCP<const Map> > rowXpSubMaps (1, xpsubmap);
454 std::vector<Teuchos::RCP<const Map> > rowTySubMaps (1, thysubmap);
456 rgMapExtractor =
Teuchos::rcp(
new MapExtractor(rowXpSubMaps, rowTySubMaps));
461 std::vector<Teuchos::RCP<const Map> > colXpSubMaps (colSz, Teuchos::null);
462 std::vector<Teuchos::RCP<const Map> > colTySubMaps (colSz, Teuchos::null);
463 for(
size_t j = 0; j < colSz; j++) {
472 doMapExtractor =
Teuchos::rcp(
new MapExtractor(colXpSubMaps,colTySubMaps));
479 std::vector<Teuchos::RCP<const Map> > colXpSubMaps (1, xpsubmap);
480 std::vector<Teuchos::RCP<const Map> > colTySubMaps (1, tysubmap);
482 doMapExtractor =
Teuchos::rcp(
new MapExtractor(colXpSubMaps, colTySubMaps));
490 if (rowSz == 0 && colSz > 0) {
491 for(
size_t j = 0; j < colSz; j++) {
494 rbmat->setMatrix(0,j,Teuchos::rcp_const_cast<Matrix>(submat));
495 if(submat != Teuchos::null) cntNNZ += submat->getNodeNumEntries();
497 }
else if (rowSz > 0 && colSz == 0) {
498 for(
size_t i = 0; i < rowSz; i++) {
501 rbmat->setMatrix(i,0,Teuchos::rcp_const_cast<Matrix>(submat));
502 if(submat != Teuchos::null) cntNNZ += submat->getNodeNumEntries();
505 for(
size_t i = 0; i < rowSz; i++) {
507 for(
size_t j = 0; j < colSz; j++) {
510 rbmat->setMatrix(i,j,Teuchos::rcp_const_cast<Matrix>(submat));
511 if(submat != Teuchos::null) cntNNZ += submat->getNodeNumEntries();
518 rbmat->fillComplete();
522 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
524 TEUCHOS_ASSERT(bmat->getRangeMapExtractor()->getThyraMode() == bmat->getDomainMapExtractor()->getThyraMode());
526 if(bmat->getRangeMapExtractor()->getThyraMode() ==
false) {
538 #define XPETRA_REORDEREDBLOCKEDCRSMATRIX_SHORT
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.
bool is_null(const boost::shared_ptr< T > &p)
bool isFillComplete() const
Returns true if fillComplete() has been called and the matrix is in compute mode. ...
Teuchos::RCP< const Xpetra::BlockedCrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > fullOp_
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.
GlobalOrdinal global_ordinal_type
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::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)
std::string description() const
Return a simple one-line description of this object.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > Map
virtual const Teuchos::RCP< BlockReorderManager > GetBlock(int blockIndex)
Get a particular block. If there is no block at this index location return a new one.
static const EVerbosityLevel verbLevel_default
int GetIndex() const
Get the index that is stored in this block/leaf.
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)
virtual ~ReorderedBlockedCrsMatrix()
Destructor.
Teuchos::RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > mergeSubBlockMaps(Teuchos::RCP< const Xpetra::BlockReorderManager > brm)
LocalOrdinal local_ordinal_type
BlockedCrsMatrix(Teuchos::RCP< const MapExtractor > &rangeMaps, Teuchos::RCP< const MapExtractor > &domainMaps, size_t npr, Xpetra::ProfileType pftype=Xpetra::DynamicProfile)
Constructor.
RCP< const Map > getRangeMap() const
Returns the Map associated with the full range of this operator.
Concrete implementation of Xpetra::Matrix.
Teuchos::RCP< Matrix > getMatrix(size_t r, size_t c) const
return block (r,c)
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, Xpetra::ProfileType pftype=Xpetra::DynamicProfile)
Constructor.
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 GetNumBlocks() const
Returns number of subblocks.
#define TEUCHOS_ASSERT(assertion_test)
virtual size_t Rows() const
number of row blocks
virtual size_t Cols() const
number of column blocks
Xpetra-specific matrix class.
Teuchos::RCP< const Xpetra::BlockReorderManager > brm_
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.