10 #ifndef XPETRA_BLOCKEDCRSMATRIX_DECL_HPP
11 #define XPETRA_BLOCKEDCRSMATRIX_DECL_HPP
13 #include <Tpetra_KokkosCompat_DefaultNode.hpp>
15 #include <Teuchos_SerialDenseMatrix.hpp>
16 #include <Teuchos_Hashtable.hpp>
21 #include "Xpetra_MapFactory.hpp"
22 #include "Xpetra_MultiVector.hpp"
23 #include "Xpetra_BlockedMultiVector.hpp"
24 #include "Xpetra_MultiVectorFactory.hpp"
25 #include "Xpetra_BlockedVector.hpp"
30 #include "Xpetra_MapExtractor.hpp"
33 #include "Xpetra_Matrix.hpp"
34 #include "Xpetra_MatrixFactory.hpp"
35 #include "Xpetra_CrsMatrixWrap.hpp"
37 #ifdef HAVE_XPETRA_THYRA
38 #include <Thyra_ProductVectorSpaceBase.hpp>
39 #include <Thyra_VectorSpaceBase.hpp>
40 #include <Thyra_LinearOpBase.hpp>
41 #include <Thyra_BlockedLinearOpBase.hpp>
42 #include <Thyra_PhysicallyBlockedLinearOpBase.hpp>
43 #include "Xpetra_ThyraUtils.hpp"
46 #include "Xpetra_VectorFactory.hpp"
54 #ifdef HAVE_XPETRA_THYRA
55 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
61 template <
class Scalar,
64 class Node = Tpetra::KokkosClassic::DefaultNode::DefaultNodeType>
73 #undef XPETRA_BLOCKEDCRSMATRIX_SHORT
87 const Teuchos::RCP<const BlockedMap>& domainMaps,
88 size_t numEntriesPerRow);
99 Teuchos::RCP<const MapExtractor>& domainMapExtractor,
100 size_t numEntriesPerRow);
102 #ifdef HAVE_XPETRA_THYRA
109 BlockedCrsMatrix(
const Teuchos::RCP<
const Thyra::BlockedLinearOpBase<Scalar> >& thyraOp,
const Teuchos::RCP<
const Teuchos::Comm<int> >& );
159 void insertGlobalValues(GlobalOrdinal globalRow,
const ArrayView<const GlobalOrdinal>& cols,
const ArrayView<const Scalar>& vals);
172 void insertLocalValues(LocalOrdinal localRow,
const ArrayView<const LocalOrdinal>& cols,
const ArrayView<const Scalar>& vals);
186 const ArrayView<const GlobalOrdinal>& cols,
187 const ArrayView<const Scalar>& vals);
195 const ArrayView<const LocalOrdinal>& cols,
196 const ArrayView<const Scalar>& vals);
202 void scale(
const Scalar& alpha);
216 void resumeFill(
const RCP<ParameterList>& params = null);
223 void fillComplete(
const RCP<const Map>& domainMap,
const RCP<const Map>& rangeMap,
const RCP<ParameterList>& params = null);
239 void fillComplete(
const RCP<ParameterList>& params = null);
311 const ArrayView<LocalOrdinal>& Indices,
312 const ArrayView<Scalar>& Values,
313 size_t& NumEntries)
const;
325 void getGlobalRowView(GlobalOrdinal GlobalRow, ArrayView<const GlobalOrdinal>& indices, ArrayView<const Scalar>& values)
const;
337 void getLocalRowView(LocalOrdinal LocalRow, ArrayView<const LocalOrdinal>& indices, ArrayView<const Scalar>& values)
const;
352 virtual typename ScalarTraits<Scalar>::magnitudeType
getFrobeniusNorm()
const;
388 virtual void apply(
const MultiVector& X,
MultiVector& Y, Teuchos::ETransp mode, Scalar alpha, Scalar beta,
bool sumInterfaceValues,
390 const Teuchos::ArrayRCP<LocalOrdinal>& regionInterfaceLIDs)
const;
397 Teuchos::ETransp mode = Teuchos::NO_TRANS,
398 Scalar alpha = ScalarTraits<Scalar>::one(),
399 Scalar beta = ScalarTraits<Scalar>::zero())
const;
414 RCP<const Map>
getDomainMap(
size_t i,
bool bThyraMode)
const;
429 RCP<const Map>
getRangeMap(
size_t i,
bool bThyraMode)
const;
454 Teuchos::ETransp mode = Teuchos::NO_TRANS,
455 Scalar alpha = ScalarTraits<Scalar>::one(),
456 Scalar beta = ScalarTraits<Scalar>::zero()
465 const Teuchos::RCP<const Map>
getMap()
const;
488 void describe(Teuchos::FancyOStream& out,
const Teuchos::EVerbosityLevel verbLevel = Teuchos::Describable::verbLevel_default)
const;
509 virtual size_t Rows()
const;
512 virtual size_t Cols()
const;
521 Teuchos::RCP<Matrix>
getMatrix(
size_t r,
size_t c)
const;
525 void setMatrix(
size_t r,
size_t c, Teuchos::RCP<Matrix> mat);
530 Teuchos::RCP<Matrix>
Merge()
const;
539 #ifdef HAVE_XPETRA_THYRA
540 Teuchos::RCP<Thyra::BlockedLinearOpBase<Scalar> > getThyraOperator();
565 void Add(
const Matrix& A,
const Scalar scalarA,
Matrix& B,
const Scalar scalarB)
const;
579 #ifdef HAVE_XPETRA_THYRA
580 Teuchos::RCP<const Thyra::BlockedLinearOpBase<Scalar> > thyraOp_;
588 #define XPETRA_BLOCKEDCRSMATRIX_SHORT
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
CrsMatrix::local_matrix_type local_matrix_type
local_matrix_type::HostMirror getLocalMatrixHost() const
Access the underlying local Kokkos::CrsMatrix object.
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 MapExtractor > getDomainMapExtractor() const
Returns map extractor for domain map.
bool isFillComplete() const
Returns true if fillComplete() has been called and the matrix is in compute mode. ...
void replaceGlobalValues(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Replace matrix entries, using global IDs.
void fillComplete(const RCP< const Map > &domainMap, const RCP< const Map > &rangeMap, const RCP< ParameterList > ¶ms=null)
Signal that data entry is complete.
LocalOrdinal GetStorageBlockSize() const
Returns the block size of the storage mechanism.
RCP< const Map > getFullDomainMap() const
Returns the Map associated with the full domain of this operator.
Teuchos::RCP< const MapExtractor > rangemaps_
full range map together with all partial domain maps
void doImport(const Matrix &source, const Import &importer, CombineMode CM)
Import.
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.
virtual void setAllToScalar(const Scalar &alpha)
Set all matrix entries equal to scalar.
void doExport(const Matrix &dest, const Import &importer, CombineMode CM)
Export.
LocalOrdinal local_ordinal_type
virtual size_t Cols() const
number of column blocks
size_t getGlobalMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on all nodes.
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.
void resumeFill(const RCP< ParameterList > ¶ms=null)
global_size_t getGlobalNumCols() const
Returns the number of global columns in the matrix.
const RCP< const Map > getDomainMap() const
Returns the Map associated with the domain of this operator.
void rightScale(const Vector &x)
Right scale matrix using the given vector entries.
size_t getLocalMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on this node.
global_size_t getGlobalNumEntries() const
Returns the global number of entries in this matrix.
size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const
Returns the current number of entries on this node in the specified local row.
const Teuchos::RCP< const Map > getMap() const
Implements DistObject interface.
virtual bool haveGlobalConstants() const
Returns true if globalConstants have been computed; false otherwise.
void insertGlobalValues(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Insert matrix entries, using global IDs.
void getLocalDiagCopy(Vector &diag) const
Get a copy of the diagonal entries owned by this node, with local row indices.
GlobalOrdinal global_ordinal_type
bool is_diagonal_
If we're diagonal, a bunch of the extraction stuff should work.
RCP< const CrsGraph > getCrsGraph() const
Returns the CrsGraph associated with this matrix.
void leftScale(const Vector &x)
Left scale matrix using the given vector entries.
virtual ~BlockedCrsMatrix()
Destructor.
void setObjectLabel(const std::string &objectLabel)
void insertLocalValues(LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Insert matrix entries, using local IDs.
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...
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 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 ScalarTraits< Scalar >::magnitudeType getFrobeniusNorm() const
Get Frobenius norm of the matrix.
void scale(const Scalar &alpha)
Scale the current values of a matrix, this = alpha*this.
void residual(const MultiVector &X, const MultiVector &B, MultiVector &R) const
Compute a residual R = B - (*this) * X.
virtual size_t Rows() const
number of row blocks
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.
const RCP< const Map > getRangeMap() const
Returns the Map associated with the range of this operator.
bool hasCrsGraph() const
Supports the getCrsGraph() call.
size_t global_size_t
Global size_t object.
std::vector< Teuchos::RCP< Matrix > > blocks_
row major matrix block storage
RCP< const MapExtractor > getRangeMapExtractor() const
Returns map extractor class for range map.
virtual bool isDiagonal() const
Teuchos::RCP< Matrix > getMatrix(size_t r, size_t c) const
return block (r,c)
BlockedCrsMatrix(const Teuchos::RCP< const BlockedMap > &rangeMaps, const Teuchos::RCP< const BlockedMap > &domainMaps, size_t numEntriesPerRow)
Constructor.
global_size_t getGlobalNumRows() const
Returns the number of global rows.
RCP< const BlockedMap > getBlockedDomainMap() const
Returns the BlockedMap associated with the domain of this operator.
size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const
Returns the current number of entries in the specified (locally owned) global row.
size_t getLocalNumEntries() const
Returns the local number of entries in this matrix.
void setMatrix(size_t r, size_t c, Teuchos::RCP< Matrix > mat)
set matrix block
std::string description() const
Return a simple one-line description of this object.
bool bDomainThyraMode_
boolean flag, which is true, if BlockedCrsMatrix has been created using Thyra-style numbering for sub...
bool isGloballyIndexed() const
If matrix indices are in the global range, this function returns true. Otherwise, this function retur...
RCP< const Map > getFullRangeMap() const
Returns the Map associated with the full range of this operator.
CombineMode
Xpetra::Combine Mode enumerable type.
local_matrix_type getLocalMatrixDevice() const
Access the underlying local Kokkos::CrsMatrix 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...
Teuchos::RCP< Matrix > getCrsMatrix() const
return unwrap 1x1 blocked operators
void removeEmptyProcessesInPlace(const Teuchos::RCP< const Map > &newMap)
Teuchos::RCP< Matrix > getInnermostCrsMatrix()
helper routine recursively returns the first inner-most non-null matrix block from a (nested) blocked...
RCP< const BlockedMap > getBlockedRangeMap() const
Returns the BlockedMap associated with the range of this operator.
bool isLocallyIndexed() const
If matrix indices of all matrix blocks are in the local range, this function returns true...
void replaceLocalValues(LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Replace matrix entries, using local IDs.
Xpetra-specific matrix class.
Teuchos::RCP< const MapExtractor > domainmaps_
full domain map together with all partial domain maps
bool bRangeThyraMode_
boolean flag, which is true, if BlockedCrsMatrix has been created using Thyra-style numbering for sub...