46 #ifndef XPETRA_TPETRABLOCKCRSMATRIX_DECL_HPP
47 #define XPETRA_TPETRABLOCKCRSMATRIX_DECL_HPP
53 #include "Tpetra_BlockCrsMatrix.hpp"
54 #include "Tpetra_CrsMatrix.hpp"
66 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node = KokkosClassic::DefaultNode::DefaultNodeType>
68 :
public CrsMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node>
83 size_t maxNumEntriesPerRow,
84 const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null);
89 const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc,
90 const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null);
96 size_t maxNumEntriesPerRow,
97 const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null);
103 const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc,
104 const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null);
109 const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null);
114 const LocalOrdinal blockSize);
118 TpetraBlockCrsMatrix(
const Teuchos::RCP<
const Tpetra::BlockCrsMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> >& sourceMatrix,
122 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
126 TpetraBlockCrsMatrix(
const Teuchos::RCP<
const Tpetra::BlockCrsMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> >& sourceMatrix,
130 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
134 TpetraBlockCrsMatrix(
const Teuchos::RCP<
const Tpetra::BlockCrsMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> >& sourceMatrix,
139 const Teuchos::RCP<Teuchos::ParameterList>& params);
143 TpetraBlockCrsMatrix(
const Teuchos::RCP<
const Tpetra::BlockCrsMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> >& sourceMatrix,
148 const Teuchos::RCP<Teuchos::ParameterList>& params);
161 const ArrayView< const GlobalOrdinal > &cols,
162 const ArrayView< const Scalar > &vals);
167 const ArrayView< const LocalOrdinal > &cols,
168 const ArrayView< const Scalar > &vals);
172 const ArrayView< const GlobalOrdinal > &cols,
173 const ArrayView< const Scalar > &vals);
178 const ArrayView<const LocalOrdinal> &cols,
179 const ArrayView<const Scalar> &vals);
185 void scale(
const Scalar &alpha);
190 ArrayRCP<LocalOrdinal> & colind,
191 ArrayRCP<Scalar> & values);
195 const ArrayRCP<LocalOrdinal> & colind,
196 const ArrayRCP<Scalar> & values);
200 ArrayRCP<const LocalOrdinal>& colind,
201 ArrayRCP<const Scalar>& values)
const;
207 void resumeFill(
const RCP< ParameterList > ¶ms=null);
214 void fillComplete(
const RCP< ParameterList > ¶ms=null);
226 const RCP<ParameterList> ¶ms=Teuchos::null);
232 const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > >
getRowMap()
const;
235 const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > >
getColMap()
const;
238 RCP< const CrsGraph< LocalOrdinal, GlobalOrdinal, Node> >
getCrsGraph()
const;
289 void getLocalRowCopy(LocalOrdinal LocalRow,
const ArrayView< LocalOrdinal > &Indices,
const ArrayView< Scalar > &Values,
size_t &NumEntries)
const;
292 void getGlobalRowView(GlobalOrdinal GlobalRow, ArrayView< const GlobalOrdinal > &indices, ArrayView< const Scalar > &values)
const;
295 void getGlobalRowCopy(GlobalOrdinal GlobalRow,
const ArrayView< GlobalOrdinal > &indices,
const ArrayView< Scalar > &values,
size_t &numEntries)
const;
298 void getLocalRowView(LocalOrdinal LocalRow, ArrayView< const LocalOrdinal > &indices, ArrayView< const Scalar > &values)
const;
308 void apply(
const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X,
MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Y, Teuchos::ETransp mode=Teuchos::NO_TRANS, Scalar alpha=ScalarTraits< Scalar >::one(), Scalar beta=ScalarTraits< Scalar >::zero())
const;
311 const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > >
getDomainMap()
const;
314 const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > >
getRangeMap()
const;
325 void describe(Teuchos::FancyOStream &out,
const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default)
const;
340 const Teuchos::ArrayView<const size_t> &offsets)
const;
358 Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > >
getMap()
const;
386 TpetraBlockCrsMatrix(
const Teuchos::RCP<Tpetra::BlockCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> > &mtx);
394 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
395 #ifdef HAVE_XPETRA_TPETRA
399 local_matrix_type getLocalMatrix ()
const;
401 void setAllValues (
const typename local_matrix_type::row_map_type& ptr,
402 const typename local_matrix_type::StaticCrsGraphType::entries_type::non_const_type& ind,
403 const typename local_matrix_type::values_type& val);
404 #endif // HAVE_XPETRA_TPETRA
405 #endif // HAVE_XPETRA_KOKKOS_REFACTOR
411 using STS = Teuchos::ScalarTraits<Scalar>;
412 R.
update(STS::one(),B,STS::zero());
413 this->
apply (X, R, Teuchos::NO_TRANS, -STS::one(), STS::one());
421 RCP< Tpetra::BlockCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
mtx_;
428 #endif // XPETRA_TPETRABLOCKCRSMATRIX_DECL_HPP
bool isGloballyIndexed() const
If matrix indices are in the global range, this function returns true. Otherwise, this function retur...
size_t getNodeNumEntries() const
Returns the local number of entries in this matrix.
void scale(const Scalar &alpha)
Scale the current values of a matrix, this = alpha*this (not implemented)
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...
void getGlobalRowCopy(GlobalOrdinal GlobalRow, const ArrayView< GlobalOrdinal > &indices, const ArrayView< Scalar > &values, size_t &numEntries) const
Extract a list of entries in a specified global row of this matrix. Put into pre-allocated storage...
void setAllToScalar(const Scalar &alpha)
Set all matrix entries equal to scalarThis.
void allocateAllValues(size_t numNonZeros, ArrayRCP< size_t > &rowptr, ArrayRCP< LocalOrdinal > &colind, ArrayRCP< Scalar > &values)
Allocates and returns ArrayRCPs of the Crs arrays — This is an Xpetra-only routine.
RCP< const CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > getCrsGraph() const
Returns the CrsGraph associated with this matrix.
void insertLocalValues(LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Insert matrix entries, using local IDs (not implemented)
void insertGlobalValues(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Insert matrix entries, using global IDs (not implemented)
RCP< Tpetra::BlockCrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getTpetra_BlockCrsMatrixNonConst() const
Get the underlying Tpetra matrix.
void replaceLocalValues(LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Replace matrix entries, using local IDs.
void rightScale(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &x)
Right scale operator with given vector values.
bool isLocallyIndexed() const
If matrix indices are in the local range, this function returns true. Otherwise, this function return...
global_size_t getGlobalNumCols() const
Number of global columns in the matrix.
bool hasMatrix() const
Does this have an underlying matrix.
TpetraBlockCrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > TpetraBlockCrsMatrixClass
global_size_t getGlobalNumRows() const
Number of global elements in the row map of this matrix.
size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const
Returns the current number of entries on this node in the specified local row.
void expertStaticFillComplete(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const RCP< const Import< LocalOrdinal, GlobalOrdinal, Node > > &importer=Teuchos::null, const RCP< const Export< LocalOrdinal, GlobalOrdinal, Node > > &exporter=Teuchos::null, const RCP< ParameterList > ¶ms=Teuchos::null)
Expert static fill complete.
void setObjectLabel(const std::string &objectLabel)
TpetraVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > TpetraVectorClass
const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getRangeMap() const
Returns the Map associated with the range of this operator, which must be compatible with Y...
void removeEmptyProcessesInPlace(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &newMap)
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.
global_size_t getGlobalNumEntries() const
Returns the global number of entries in this matrix.
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.
TpetraExport< LocalOrdinal, GlobalOrdinal, Node > TpetraExportClass
size_t getNodeNumCols() const
Returns the number of columns connected to the locally owned rows of this matrix. ...
virtual bool haveGlobalConstants() const
Returns true if globalConstants have been computed; false otherwise.
size_t getNodeMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on this node.
RCP< const Tpetra::BlockCrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getTpetra_BlockCrsMatrix() const
Get the underlying Tpetra matrix.
void apply(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Y, Teuchos::ETransp mode=Teuchos::NO_TRANS, Scalar alpha=ScalarTraits< Scalar >::one(), Scalar beta=ScalarTraits< Scalar >::zero()) const
Computes the sparse matrix-multivector multiplication.
void getLocalDiagCopy(Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag) const
Get a copy of the diagonal entries owned by this node, with local row idices.
std::string description() const
A simple one-line description of this object.
void setAllValues(const ArrayRCP< size_t > &rowptr, const ArrayRCP< LocalOrdinal > &colind, const ArrayRCP< Scalar > &values)
Sets the 1D pointer arrays of the graph (not impelmented)
RCP< Tpetra::BlockCrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > mtx_
bool isFillComplete() const
Returns true if the matrix is in compute mode, i.e. if fillComplete() has been called.
void fillComplete(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const RCP< ParameterList > ¶ms=null)
Signal that data entry is complete, specifying domain and range maps.
size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const
Returns the current number of entries in the (locally owned) global row.
void residual(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &B, MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &R) const
Compute a residual R = B - (*this) * X.
size_t global_size_t
Global size_t object.
ScalarTraits< Scalar >::magnitudeType getFrobeniusNorm() const
Returns the Frobenius norm of the matrix.
size_t getGlobalMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on all nodes.
void doImport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &source, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)
Import.
virtual ~TpetraBlockCrsMatrix()
Destructor.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const
Implements DistObject interface.
bool supportsRowViews() const
Returns true if getLocalRowView() and getGlobalRowView() are valid for this class.
size_t getNodeNumRows() const
Returns the number of matrix rows owned on the calling node.
TpetraBlockCrsMatrix(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, size_t maxNumEntriesPerRow, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
Constructor specifying fixed number of entries for each row (not implemented)
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.
void leftScale(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &x)
Left scale operator with given vector values.
void getAllValues(ArrayRCP< const size_t > &rowptr, ArrayRCP< const LocalOrdinal > &colind, ArrayRCP< const Scalar > &values) const
Gets the 1D pointer arrays of the graph (not implemented)
const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getDomainMap() const
Returns the Map associated with the domain of this operator. This will be null until fillComplete() i...
void replaceDiag(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag)
Replace the diagonal entries of the matrix.
CombineMode
Xpetra::Combine Mode enumerable type.
const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getColMap() const
Returns the Map that describes the column distribution in this matrix.
void replaceGlobalValues(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &cols, const ArrayView< const Scalar > &vals)
Replace matrix entries, using global IDs (not implemented)
TpetraImport< LocalOrdinal, GlobalOrdinal, Node > TpetraImportClass
void getLocalDiagOffsets(Teuchos::ArrayRCP< size_t > &offsets) const
Get offsets of the diagonal entries in the matrix.
void replaceDomainMapAndImporter(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &newDomainMap, Teuchos::RCP< const Import< LocalOrdinal, GlobalOrdinal, Node > > &newImporter)
Replaces the current domainMap and importer with the user-specified objects.
bool isFillActive() const
Returns true if the matrix is in edit mode.
void doExport(const DistObject< char, LocalOrdinal, GlobalOrdinal, Node > &dest, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)
Export.
const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getRowMap() const
Returns the Map that describes the row distribution in this matrix.
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.
void resumeFill(const RCP< ParameterList > ¶ms=null)