46#ifndef XPETRA_BLOCKEDCRSMATRIX_HPP
47#define XPETRA_BLOCKEDCRSMATRIX_HPP
49#include <KokkosCompat_DefaultNode.hpp>
57#include "Xpetra_MapFactory.hpp"
58#include "Xpetra_MultiVector.hpp"
59#include "Xpetra_BlockedMultiVector.hpp"
60#include "Xpetra_MultiVectorFactory.hpp"
61#include "Xpetra_BlockedVector.hpp"
66#include "Xpetra_MapExtractor.hpp"
71#include "Xpetra_CrsMatrixWrap.hpp"
73#ifdef HAVE_XPETRA_THYRA
74#include <Thyra_ProductVectorSpaceBase.hpp>
75#include <Thyra_VectorSpaceBase.hpp>
76#include <Thyra_LinearOpBase.hpp>
77#include <Thyra_BlockedLinearOpBase.hpp>
78#include <Thyra_PhysicallyBlockedLinearOpBase.hpp>
82#include "Xpetra_VectorFactory.hpp"
91#ifdef HAVE_XPETRA_THYRA
92 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
class ThyraUtils;
97 template <
class Scalar,
102 public Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> {
110#undef XPETRA_BLOCKEDCRSMATRIX_SHORT
126 size_t numEntriesPerRow)
137 for (
size_t r = 0; r <
Rows(); ++r)
138 for (
size_t c = 0; c <
Cols(); ++c)
155 size_t numEntriesPerRow)
164 for (
size_t r = 0; r <
Rows(); ++r)
165 for (
size_t c = 0; c <
Cols(); ++c)
172#ifdef HAVE_XPETRA_THYRA
186 int numRangeBlocks = productRangeSpace->numBlocks();
187 int numDomainBlocks = productDomainSpace->numBlocks();
190 std::vector<Teuchos::RCP<const Map> > subRangeMaps(numRangeBlocks);
191 for (
size_t r=0; r<Teuchos::as<size_t>(numRangeBlocks); ++r) {
192 for (
size_t c=0; c<Teuchos::as<size_t>(numDomainBlocks); ++c) {
193 if (thyraOp->blockExists(r,c)) {
197 Xpetra::ThyraUtils<Scalar,LocalOrdinal,GlobalOrdinal,Node>::toXpetra(const_op);
198 subRangeMaps[r] = xop->getRangeMap();
208 bool bRangeUseThyraStyleNumbering =
false;
209 size_t numAllElements = 0;
210 for(
size_t v = 0; v < subRangeMaps.size(); ++v) {
211 numAllElements += subRangeMaps[v]->getGlobalNumElements();
213 if ( fullRangeMap->getGlobalNumElements() != numAllElements) bRangeUseThyraStyleNumbering =
true;
217 std::vector<Teuchos::RCP<const Xpetra::Map<LocalOrdinal,GlobalOrdinal,Node> > > subDomainMaps(numDomainBlocks);
218 for (
size_t c=0; c<Teuchos::as<size_t>(numDomainBlocks); ++c) {
219 for (
size_t r=0; r<Teuchos::as<size_t>(numRangeBlocks); ++r) {
220 if (thyraOp->blockExists(r,c)) {
224 Xpetra::ThyraUtils<Scalar,LO,GO,Node>::toXpetra(const_op);
225 subDomainMaps[c] = xop->getDomainMap();
232 bool bDomainUseThyraStyleNumbering =
false;
234 for(
size_t v = 0; v < subDomainMaps.size(); ++v) {
235 numAllElements += subDomainMaps[v]->getGlobalNumElements();
237 if (fullDomainMap->getGlobalNumElements() != numAllElements) bDomainUseThyraStyleNumbering =
true;
246 for (
size_t r = 0; r <
Rows(); ++r) {
247 for (
size_t c = 0; c <
Cols(); ++c) {
248 if(thyraOp->blockExists(r,c)) {
253 Xpetra::ThyraUtils<Scalar,LO,GO,Node>::toXpetra(op);
255 Teuchos::rcp_dynamic_cast<Xpetra::CrsMatrixWrap<Scalar,LO,GO,Node> >(xop,
true);
280 std::vector<GlobalOrdinal> gids;
281 for(
size_t tt = 0; tt<subMaps.size(); ++tt) {
285 gids.insert(gids.end(), subMapGids.
begin(), subMapGids.
end());
287 size_t myNumElements = subMap->getLocalNumElements();
288 for(LocalOrdinal l = 0; l < Teuchos::as<LocalOrdinal>(myNumElements); ++l) {
289 GlobalOrdinal gid = subMap->getGlobalElement(l);
300 std::sort(gids.begin(), gids.end());
301 gids.erase(std::unique(gids.begin(), gids.end()), gids.end());
348 getMatrix(0,0)->insertGlobalValues(globalRow, cols, vals);
368 getMatrix(0,0)->insertLocalValues(localRow, cols, vals);
375 XPETRA_MONITOR(
"XpetraBlockedCrsMatrix::removeEmptyProcessesInPlace");
377 getMatrix(0,0)->removeEmptyProcessesInPlace(newMap);
397 getMatrix(0,0)->replaceGlobalValues(globalRow,cols,vals);
413 getMatrix(0,0)->replaceLocalValues(localRow,cols,vals);
422 for (
size_t row = 0; row <
Rows(); row++) {
423 for (
size_t col = 0; col <
Cols(); col++) {
425 getMatrix(row,col)->setAllToScalar(alpha);
434 for (
size_t row = 0; row <
Rows(); row++) {
435 for (
size_t col = 0; col <
Cols(); col++) {
457 for (
size_t row = 0; row <
Rows(); row++) {
458 for (
size_t col = 0; col <
Cols(); col++) {
474 getMatrix(0,0)->fillComplete(domainMap, rangeMap, params);
498 for (
size_t r = 0; r <
Rows(); ++r)
499 for (
size_t c = 0; c <
Cols(); ++c) {
503 if (Ablock != Teuchos::null && !Ablock->isFillComplete())
511 fullrowmap_ =
MapFactory::Build(rangeMap()->lib(), rangeMap()->getGlobalNumElements(), rangeMap()->getLocalElementList(), rangeMap()->getIndexBase(), rangeMap()->getComm());
514 fullcolmap_ = Teuchos::null;
516 std::vector<GO> colmapentries;
517 for (
size_t c = 0; c <
Cols(); ++c) {
520 for (
size_t r = 0; r <
Rows(); ++r) {
523 if (Ablock != Teuchos::null) {
526 copy(colElements.
getRawPtr(), colElements.
getRawPtr() + colElements.
size(), inserter(colset, colset.begin()));
531 colmapentries.reserve(colmapentries.size() + colset.size());
532 copy(colset.begin(), colset.end(), back_inserter(colmapentries));
533 sort(colmapentries.begin(), colmapentries.end());
534 typename std::vector<GO>::iterator gendLocation;
535 gendLocation = std::unique(colmapentries.begin(), colmapentries.end());
536 colmapentries.erase(gendLocation,colmapentries.end());
540 size_t numGlobalElements = 0;
541 Teuchos::reduceAll(*(rangeMap->getComm()), Teuchos::REDUCE_SUM, colmapentries.size(), Teuchos::outArg(numGlobalElements));
545 fullcolmap_ =
MapFactory::Build(rangeMap->lib(), numGlobalElements, aView, 0, rangeMap->getComm());
558 for (
size_t row = 0; row <
Rows(); row++)
559 for (
size_t col = 0; col <
Cols(); col++)
561 globalNumRows +=
getMatrix(row,col)->getGlobalNumRows();
565 return globalNumRows;
575 for (
size_t col = 0; col <
Cols(); col++)
576 for (
size_t row = 0; row <
Rows(); row++)
578 globalNumCols +=
getMatrix(row,col)->getGlobalNumCols();
582 return globalNumCols;
590 for (
size_t row = 0; row <
Rows(); ++row)
591 for (
size_t col = 0; col <
Cols(); col++)
593 nodeNumRows +=
getMatrix(row,col)->getLocalNumRows();
605 for (
size_t row = 0; row <
Rows(); ++row)
606 for (
size_t col = 0; col <
Cols(); ++col)
608 globalNumEntries +=
getMatrix(row,col)->getGlobalNumEntries();
610 return globalNumEntries;
618 for (
size_t row = 0; row <
Rows(); ++row)
619 for (
size_t col = 0; col <
Cols(); ++col)
621 nodeNumEntries +=
getMatrix(row,col)->getLocalNumEntries();
623 return nodeNumEntries;
629 XPETRA_MONITOR(
"XpetraBlockedCrsMatrix::getNumEntriesInLocalRow");
630 GlobalOrdinal gid = this->
getRowMap()->getGlobalElement(localRow);
633 size_t numEntriesInLocalRow = 0;
634 for (
size_t col = 0; col <
Cols(); ++col)
636 numEntriesInLocalRow +=
getMatrix(row,col)->getNumEntriesInLocalRow(lid);
637 return numEntriesInLocalRow;
643 XPETRA_MONITOR(
"XpetraBlockedCrsMatrix::getNumEntriesInGlobalRow");
645 size_t numEntriesInGlobalRow = 0;
646 for (
size_t col = 0; col <
Cols(); ++col)
648 numEntriesInGlobalRow +=
getMatrix(row,col)->getNumEntriesInGlobalRow(globalRow);
649 return numEntriesInGlobalRow;
656 XPETRA_MONITOR(
"XpetraBlockedCrsMatrix::getGlobalMaxNumRowEntries");
659 for (
size_t row = 0; row <
Rows(); row++) {
661 for (
size_t col = 0; col <
Cols(); col++) {
663 globalMaxEntriesBlockRows +=
getMatrix(row,col)->getGlobalMaxNumRowEntries();
666 if(globalMaxEntriesBlockRows > globalMaxEntries)
667 globalMaxEntries = globalMaxEntriesBlockRows;
669 return globalMaxEntries;
676 XPETRA_MONITOR(
"XpetraBlockedCrsMatrix::getLocalMaxNumRowEntries");
677 size_t localMaxEntries = 0;
679 for (
size_t row = 0; row <
Rows(); row++) {
680 size_t localMaxEntriesBlockRows = 0;
681 for (
size_t col = 0; col <
Cols(); col++) {
683 localMaxEntriesBlockRows +=
getMatrix(row,col)->getLocalMaxNumRowEntries();
686 if(localMaxEntriesBlockRows > localMaxEntries)
687 localMaxEntries = localMaxEntriesBlockRows;
689 return localMaxEntries;
698 for (
size_t i = 0; i <
blocks_.size(); ++i)
710 for (
size_t i = 0; i <
blocks_.size(); i++)
719 for (
size_t i = 0; i <
blocks_.size(); i++)
743 size_t &NumEntries)
const {
746 getMatrix(0,0)->getLocalRowCopy(LocalRow, Indices, Values, NumEntries);
765 getMatrix(0,0)->getGlobalRowView(GlobalRow, indices, values);
784 getMatrix(0,0)->getLocalRowView(LocalRow, indices, values);
788 GlobalOrdinal gid = this->
getRowMap()->getGlobalElement(LocalRow);
813 rm->getLocalDiagCopy(diag);
820 "BlockedCrsMatrix::getLocalDiagCopy(): the number of blocks in diag differ from the number of blocks in this operator." );
824 for (
size_t row = 0; row <
Rows(); row++) {
828 rm->getLocalDiagCopy(*rv);
829 bdiag->setMultiVector(row,rv,bdiag->getBlockedMap()->getThyraMode());
847 for (
size_t col = 0; col <
Cols(); ++col) {
857 "BlockedCrsMatrix::leftScale(): the number of blocks in diag differ from the number of blocks in this operator." );
859 for (
size_t row = 0; row <
Rows(); row++) {
863 for (
size_t col = 0; col <
Cols(); ++col) {
866 rm->leftScale(*rscale);
885 for (
size_t row = 0; row <
Rows(); ++row) {
895 "BlockedCrsMatrix::rightScale(): the number of blocks in diag differ from the number of blocks in this operator." );
897 for (
size_t col = 0; col <
Cols(); ++col) {
901 for (
size_t row = 0; row <
Rows(); row++) {
904 rm->rightScale(*rscale);
915 for (
size_t col = 0; col <
Cols(); ++col) {
916 for (
size_t row = 0; row <
Rows(); ++row) {
980 "apply() only supports the following modes: NO_TRANS and TRANS." );
989 bool bBlockedX = (refbX != Teuchos::null) ?
true :
false;
1001 for (
size_t row = 0; row <
Rows(); row++) {
1003 for (
size_t col = 0; col <
Cols(); col++) {
1013 bool bBlockedSubMatrix = Teuchos::rcp_dynamic_cast<BlockedCrsMatrix>(Ablock) == Teuchos::null ? false :
true;
1025 Ablock->apply(*Xblock, *tmpYblock);
1027 Yblock->update(one, *tmpYblock, one);
1034 for (
size_t col = 0; col <
Cols(); col++) {
1037 for (
size_t row = 0; row<
Rows(); row++) {
1045 bool bBlockedSubMatrix = Teuchos::rcp_dynamic_cast<BlockedCrsMatrix>(Ablock) == Teuchos::null ? false :
true;
1055 Yblock->update(one, *tmpYblock, one);
1060 Y.
update(alpha, *tmpY, beta);
1125 "apply() only supports the following modes: NO_TRANS and TRANS." );
1133 bool bBlockedX = (refbX != Teuchos::null) ?
true :
false;
1143 for (
size_t col = 0; col <
Cols(); col++) {
1153 bool bBlockedSubMatrix = Teuchos::rcp_dynamic_cast<BlockedCrsMatrix>(Ablock) == Teuchos::null ? false :
true;
1165 Ablock->apply(*Xblock, *tmpYblock);
1167 Yblock->update(one, *tmpYblock, one);
1173 Y.
update(alpha, *tmpY, beta);
1196 getMatrix(0,0)->doImport(source, importer, CM);
1206 getMatrix(0,0)->doExport(dest, importer, CM);
1216 getMatrix(0,0)->doImport(source, exporter, CM);
1226 getMatrix(0,0)->doExport(dest, exporter, CM);
1238 std::string
description()
const {
return "Xpetra_BlockedCrsMatrix.description()"; }
1242 out <<
"Xpetra::BlockedCrsMatrix: " <<
Rows() <<
" x " <<
Cols() << std::endl;
1245 out <<
"BlockMatrix is fillComplete" << std::endl;
1258 out <<
"BlockMatrix is NOT fillComplete" << std::endl;
1261 for (
size_t r = 0; r <
Rows(); ++r)
1262 for (
size_t c = 0; c <
Cols(); ++c) {
1264 out <<
"Block(" << r <<
"," << c <<
")" << std::endl;
1265 getMatrix(r,c)->describe(out,verbLevel);
1266 }
else out <<
"Block(" << r <<
"," << c <<
") = null" << std::endl;
1274 for (
size_t r = 0; r <
Rows(); ++r)
1275 for (
size_t c = 0; c <
Cols(); ++c) {
1277 std::ostringstream oss; oss<< objectLabel <<
"(" << r <<
"," << c <<
")";
1278 getMatrix(r,c)->setObjectLabel(oss.str());
1287 if (
Rows() == 1 &&
Cols () == 1)
return true;
1321 if (bmat == Teuchos::null)
return mat;
1322 return bmat->getCrsMatrix();
1328 size_t row =
Rows()+1, col =
Cols()+1;
1329 for (
size_t r = 0; r <
Rows(); ++r)
1330 for(
size_t c = 0; c <
Cols(); ++c)
1339 if (bmat == Teuchos::null)
return mm;
1340 return bmat->getInnermostCrsMatrix();
1375 using Teuchos::rcp_dynamic_cast;
1379 "BlockedCrsMatrix::Merge: only implemented for Xpetra-style or Thyra-style numbering. No mixup allowed!" );
1382 "BlockedCrsMatrix::Merge: BlockMatrix must be fill-completed." );
1386 for (LocalOrdinal lclRow = 0; lclRow < lclNumRows; ++lclRow)
1393 for (
size_t i = 0; i <
Rows(); i++) {
1394 for (
size_t j = 0; j <
Cols(); j++) {
1400 if (bMat != Teuchos::null) mat = bMat->Merge();
1402 bMat = Teuchos::rcp_dynamic_cast<const BlockedCrsMatrix>(mat);
1404 "BlockedCrsMatrix::Merge: Merging of blocked sub-operators failed?!" );
1407 if(mat->getLocalNumEntries() == 0)
continue;
1409 this->
Add(*mat, one, *sparse, one);
1415 for (
size_t i = 0; i <
Rows(); i++) {
1416 for (
size_t j = 0; j <
Cols(); j++) {
1421 if (bMat != Teuchos::null) mat = bMat->Merge();
1423 bMat = Teuchos::rcp_dynamic_cast<const BlockedCrsMatrix>(mat);
1425 "BlockedCrsMatrix::Merge: Merging of blocked sub-operators failed?!" );
1449 if(mat->getLocalNumEntries() == 0)
continue;
1451 size_t maxNumEntries = mat->getLocalMaxNumRowEntries();
1459 for (
size_t k = 0; k < mat->getLocalNumRows(); k++) {
1460 GlobalOrdinal rowTGID = trowMap->getGlobalElement(k);
1461 crsMat->getCrsMatrix()->getGlobalRowCopy(rowTGID, inds(), vals(), numEntries);
1464 for (
size_t l = 0; l < numEntries; ++l) {
1465 LocalOrdinal lid = tcolMap->getLocalElement(inds[l]);
1466 inds2[l] = xcolMap->getGlobalElement(lid);
1469 GlobalOrdinal rowXGID = xrowMap->getGlobalElement(k);
1470 sparse->insertGlobalValues(
1471 rowXGID, inds2(0, numEntries),
1472 vals(0, numEntries));
1482 "BlockedCrsMatrix::Merge: Local number of entries of merged matrix does not coincide with local number of entries of blocked operator." );
1485 "BlockedCrsMatrix::Merge: Global number of entries of merged matrix does not coincide with global number of entries of blocked operator." );
1495 return getMatrix(0,0)->getLocalMatrixDevice();
1502 return getMatrix(0,0)->getLocalMatrixHost();
1508#ifdef HAVE_XPETRA_THYRA
1511 Xpetra::ThyraUtils<Scalar,LO,GO,Node>::toThyra(Teuchos::rcpFromRef(*
this));
1515 Teuchos::rcp_dynamic_cast<Thyra::BlockedLinearOpBase<Scalar> >(thOp);
1529 R.
update(STS::one(),B,STS::zero());
1552 "Matrix A is not completed");
1561 if (scalarA == zero)
1567 "BlockedCrsMatrix::Add: matrix A must be of type CrsMatrixWrap.");
1570 size_t maxNumEntries = crsA->getLocalMaxNumRowEntries();
1580 for (
size_t i = 0; i < crsA->getLocalNumRows(); i++) {
1581 GO row = rowGIDs[i];
1582 crsA->getGlobalRowCopy(row, inds(), vals(), numEntries);
1585 for (
size_t j = 0; j < numEntries; ++j)
1613#ifdef HAVE_XPETRA_THYRA
1623#define XPETRA_BLOCKEDCRSMATRIX_SHORT
#define XPETRA_MONITOR(funcName)
#define XPETRA_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
static const EVerbosityLevel verbLevel_default
Teuchos::RCP< const MapExtractor > domainmaps_
full domain map together with all partial domain maps
void doImport(const Matrix &source, const Export &exporter, CombineMode CM)
Import (using an Exporter).
void getGlobalRowView(GlobalOrdinal GlobalRow, ArrayView< const GlobalOrdinal > &indices, ArrayView< const Scalar > &values) const
Extract a const, non-persisting view of global indices in a specified row of the matrix.
virtual ScalarTraits< Scalar >::magnitudeType getFrobeniusNorm() const
Get Frobenius norm of the matrix.
Teuchos::RCP< Matrix > getMatrix(size_t r, size_t c) const
return block (r,c)
Teuchos::RCP< Matrix > getInnermostCrsMatrix()
helper routine recursively returns the first inner-most non-null matrix block from a (nested) blocked...
bool isLocallyIndexed() const
If matrix indices of all matrix blocks are in the local range, this function returns true....
Teuchos::RCP< const MapExtractor > rangemaps_
full range map together with all partial domain maps
RCP< const BlockedMap > getBlockedRangeMap() const
Returns the BlockedMap associated with the range of this operator.
void setMatrix(size_t r, size_t c, Teuchos::RCP< Matrix > mat)
set matrix block
RCP< const BlockedMap > getBlockedDomainMap() const
Returns the BlockedMap associated with the domain of this operator.
virtual size_t Rows() const
number of row blocks
void insertGlobalValues(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Insert matrix entries, using global IDs.
size_t getLocalNumRows() const
Returns the number of matrix rows owned on the calling node.
Teuchos::RCP< Matrix > Merge() const
merge BlockedCrsMatrix blocks in a CrsMatrix
BlockedCrsMatrix(const Teuchos::RCP< const BlockedMap > &rangeMaps, const Teuchos::RCP< const BlockedMap > &domainMaps, size_t numEntriesPerRow)
Constructor.
void fillComplete(const RCP< const Map > &domainMap, const RCP< const Map > &rangeMap, const RCP< ParameterList > ¶ms=null)
Signal that data entry is complete.
bool bDomainThyraMode_
boolean flag, which is true, if BlockedCrsMatrix has been created using Thyra-style numbering for sub...
size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const
Returns the current number of entries on this node in the specified local row.
size_t getLocalNumEntries() const
Returns the local number of entries in this matrix.
RCP< const Map > getRangeMap(size_t i) const
Returns the Map associated with the i'th block range of this operator.
virtual void bgs_apply(const MultiVector &X, MultiVector &Y, size_t row, Teuchos::ETransp mode=Teuchos::NO_TRANS, Scalar alpha=ScalarTraits< Scalar >::one(), Scalar beta=ScalarTraits< Scalar >::zero()) const
Special multiplication routine (for BGS/Jacobi smoother)
void doExport(const Matrix &dest, const Export &exporter, CombineMode CM)
Export (using an Importer).
RCP< const Map > getDomainMap() const
Returns the Map associated with the domain of this operator.
bool hasCrsGraph() const
Supports the getCrsGraph() call.
std::vector< Teuchos::RCP< Matrix > > blocks_
row major matrix block storage
virtual ~BlockedCrsMatrix()
Destructor.
virtual void getLocalRowCopy(LocalOrdinal LocalRow, const ArrayView< LocalOrdinal > &Indices, const ArrayView< Scalar > &Values, size_t &NumEntries) const
Extract a list of entries in a specified local row of the matrix. Put into storage allocated by calli...
RCP< const CrsGraph > getCrsGraph() const
Returns the CrsGraph associated with this matrix.
void replaceGlobalValues(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Replace matrix entries, using global IDs.
void getLocalRowView(LocalOrdinal LocalRow, ArrayView< const LocalOrdinal > &indices, ArrayView< const Scalar > &values) const
Extract a const, non-persisting view of local indices in a specified row of the matrix.
bool isFillComplete() const
Returns true if fillComplete() has been called and the matrix is in compute mode.
Teuchos::RCP< Matrix > getCrsMatrix() const
return unwrap 1x1 blocked operators
GlobalOrdinal global_ordinal_type
RCP< const MapExtractor > getRangeMapExtractor() const
Returns map extractor class for range map.
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...
RCP< const Map > getFullRangeMap() const
Returns the Map associated with the full range of this operator.
void leftScale(const Vector &x)
Left scale matrix using the given vector entries.
virtual void setAllToScalar(const Scalar &alpha)
Set all matrix entries equal to scalar.
RCP< const Map > getRangeMap(size_t i, bool bThyraMode) const
Returns the Map associated with the i'th block range of this operator.
void replaceLocalValues(LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Replace matrix entries, using local IDs.
void doImport(const Matrix &source, const Import &importer, CombineMode CM)
Import.
global_size_t getGlobalNumCols() const
Returns the number of global columns in the matrix.
size_t getLocalMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on this node.
void residual(const MultiVector &X, const MultiVector &B, MultiVector &R) const
Compute a residual R = B - (*this) * X.
bool is_diagonal_
If we're diagonal, a bunch of the extraction stuff should work.
const Teuchos::RCP< const Map > getMap() const
Implements DistObject interface.
LocalOrdinal local_ordinal_type
void Add(const Matrix &A, const Scalar scalarA, Matrix &B, const Scalar scalarB) const
Add a Xpetra::CrsMatrix to another: B = B*scalarB + A*scalarA.
bool bRangeThyraMode_
boolean flag, which is true, if BlockedCrsMatrix has been created using Thyra-style numbering for sub...
BlockedCrsMatrix(Teuchos::RCP< const MapExtractor > &rangeMapExtractor, Teuchos::RCP< const MapExtractor > &domainMapExtractor, size_t numEntriesPerRow)
Constructor.
void scale(const Scalar &alpha)
Scale the current values of a matrix, this = alpha*this.
local_matrix_type getLocalMatrixDevice() const
Access the underlying local Kokkos::CrsMatrix object.
virtual bool haveGlobalConstants() const
Returns true if globalConstants have been computed; false otherwise.
RCP< const Map > getDomainMap(size_t i) const
Returns the Map associated with the i'th block domain of this operator.
LocalOrdinal GetStorageBlockSize() const
Returns the block size of the storage mechanism.
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.
size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const
Returns the current number of entries in the specified (locally owned) global row.
CrsMatrix::local_matrix_type local_matrix_type
void insertLocalValues(LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Insert matrix entries, using local IDs.
void rightScale(const Vector &x)
Right scale matrix using the given vector entries.
void setObjectLabel(const std::string &objectLabel)
local_matrix_type::HostMirror getLocalMatrixHost() const
Access the underlying local Kokkos::CrsMatrix object.
void fillComplete(const RCP< ParameterList > ¶ms=null)
Signal that data entry is complete.
void resumeFill(const RCP< ParameterList > ¶ms=null)
size_t getGlobalMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on all nodes.
virtual bool isDiagonal() const
void getLocalDiagCopy(Vector &diag) const
Get a copy of the diagonal entries owned by this node, with local row indices.
bool isGloballyIndexed() const
If matrix indices are in the global range, this function returns true. Otherwise, this function retur...
global_size_t getGlobalNumRows() const
Returns the number of global rows.
RCP< const MapExtractor > getDomainMapExtractor() const
Returns map extractor for domain map.
virtual size_t Cols() const
number of column blocks
RCP< const Map > getDomainMap(size_t i, bool bThyraMode) const
Returns the Map associated with the i'th block domain of this operator.
RCP< const Map > getFullDomainMap() const
Returns the Map associated with the full domain of this operator.
global_size_t getGlobalNumEntries() const
Returns the global number of entries in this matrix.
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.
void removeEmptyProcessesInPlace(const Teuchos::RCP< const Map > &newMap)
void doExport(const Matrix &dest, const Import &importer, CombineMode CM)
Export.
std::string description() const
Return a simple one-line description of this object.
KokkosSparse::CrsMatrix< impl_scalar_type, LocalOrdinal, execution_space, void, typename local_graph_type::size_type > local_matrix_type
The specialization of Kokkos::CrsMatrix that represents the part of the sparse matrix on each MPI pro...
virtual Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const =0
The Map describing the parallel distribution of this object.
Exception indicating invalid cast attempted.
Exception throws to report incompatible objects (like maps).
Exception throws when you call an unimplemented method of Xpetra.
Exception throws to report errors in the internal logical of the program.
static Teuchos::RCP< Map< LocalOrdinal, GlobalOrdinal, Node > > Build(UnderlyingLib lib, global_size_t numGlobalElements, GlobalOrdinal indexBase, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, LocalGlobal lg=Xpetra::GloballyDistributed)
Map constructor with Xpetra-defined contiguous uniform distribution.
static Teuchos::RCP< Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > transformThyra2XpetraGIDs(const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > &input, const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > &nonOvlInput, const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > &nonOvlReferenceInput)
replace set of global ids by new global ids
static RCP< Matrix > Build(const RCP< const Map > &rowMap)
Xpetra-specific matrix class.
void CreateView(viewLabel_t viewLabel, const RCP< const Map > &rowMap, const RCP< const Map > &colMap)
viewLabel_t currentViewLabel_
virtual bool isFillComplete() const =0
Returns true if fillComplete() has been called and the matrix is in compute mode.
viewLabel_t defaultViewLabel_
virtual const RCP< const Map > & getRowMap() const
Returns the Map that describes the row distribution in this matrix.
const viewLabel_t & GetDefaultViewLabel() const
virtual void scale(const Scalar &alpha)=0
Scale the current values of a matrix, this = alpha*this.
virtual void insertGlobalValues(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &cols, const ArrayView< const Scalar > &vals)=0
Insert matrix entries, using global IDs.
static Teuchos::RCP< MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Build(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map, size_t NumVectors, bool zeroOut=true)
Constructor specifying the number of non-zeros for all rows.
virtual size_t getNumVectors() const =0
Number of columns in the multivector.
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.
static Teuchos::RCP< Xpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Build(const Teuchos::RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > &map, bool zeroOut=true)
Constructor specifying the number of non-zeros for all rows.
#define TEUCHOS_ASSERT(assertion_test)
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
bool is_null(const std::shared_ptr< T > &p)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
size_t global_size_t
Global size_t object.
CombineMode
Xpetra::Combine Mode enumerable type.
static magnitudeType magnitude(T a)