42 #ifndef TPETRA_EXPERIMENTAL_BLOCKCRSMATRIX_DECL_HPP 
   43 #define TPETRA_EXPERIMENTAL_BLOCKCRSMATRIX_DECL_HPP 
   48 #include "Tpetra_CrsGraph.hpp" 
   49 #include "Tpetra_RowMatrix.hpp" 
   50 #include "Tpetra_Experimental_BlockMultiVector_decl.hpp" 
   54 namespace Experimental {
 
  133 template<
class Scalar,
 
  144   using STS = Teuchos::ScalarTraits<Scalar>;
 
  185   typedef ::Tpetra::MultiVector<Scalar, LO, GO, node_type> 
mv_type;
 
  193                        Kokkos::MemoryTraits<Kokkos::Unmanaged> >
 
  199                        Kokkos::MemoryTraits<Kokkos::Unmanaged> >
 
  205                        Kokkos::MemoryTraits<Kokkos::Unmanaged> >
 
  211                        Kokkos::MemoryTraits<Kokkos::Unmanaged> >
 
  258   Teuchos::RCP<const map_type> 
getRowMap () 
const;
 
  261   Teuchos::RCP<const map_type> 
getColMap () 
const;
 
  283          Teuchos::ETransp mode = Teuchos::NO_TRANS,
 
  284          Scalar alpha = Teuchos::ScalarTraits<Scalar>::one (),
 
  285          Scalar beta = Teuchos::ScalarTraits<Scalar>::zero ()) 
const;
 
  329   describe (Teuchos::FancyOStream& out,
 
  330             const Teuchos::EVerbosityLevel verbLevel) 
const;
 
  340   virtual Teuchos::RCP<const ::Tpetra::RowGraph<LO,GO,Node> > 
getGraph () 
const;
 
  349   applyBlock (
const BlockMultiVector<Scalar, LO, GO, Node>& X,
 
  350               BlockMultiVector<Scalar, LO, GO, Node>& Y,
 
  351               Teuchos::ETransp mode = Teuchos::NO_TRANS,
 
  352               const Scalar alpha = Teuchos::ScalarTraits<Scalar>::one (),
 
  353               const Scalar beta = Teuchos::ScalarTraits<Scalar>::zero ());
 
  360                    const ::Tpetra::MultiVector<Scalar,LO,GO,Node> &B,
 
  361                    const ::Tpetra::MultiVector<Scalar,LO,GO,Node> &D,
 
  362                    const Scalar& dampingFactor,
 
  365                    const bool zeroInitialGuess) 
const;
 
  372                             const ::Tpetra::MultiVector<Scalar,LO,GO,Node>& B,
 
  373                             const ::Tpetra::MultiVector<Scalar,LO,GO,Node>& D,
 
  374                             const Teuchos::ArrayView<LO>& rowIndices,
 
  375                             const Scalar& dampingFactor,
 
  378                             const bool zeroInitialGuess) 
const;
 
  401                           BlockMultiVector<Scalar, LO, GO, Node>& Solution,
 
  403                           Kokkos::MemoryUnmanaged>& D_inv,
 
  437                       const LO numColInds) 
const;
 
  469                       const LO numColInds) 
const;
 
  509                    Teuchos::ArrayView<const LO> &indices,
 
  510                    Teuchos::ArrayView<const Scalar> &values) 
const;
 
  515                    const Teuchos::ArrayView<LO> &Indices,
 
  516                    const Teuchos::ArrayView<Scalar> &Values,
 
  517                    size_t &NumEntries) 
const;
 
  520   getLocalBlock (
const LO localRowInd, 
const LO localColInd) 
const;
 
  549                       const LO numColInds) 
const;
 
  558                                const ptrdiff_t offsets[],
 
  560                                const LO numOffsets) 
const;
 
  569                                const ptrdiff_t offsets[],
 
  571                                const LO numOffsets) 
const;
 
  616     return (*errs_).is_null () ? std::string (
"") : (*errs_)->str ();
 
  652                          Kokkos::MemoryUnmanaged>& offsets) 
const;
 
  654 #ifdef TPETRA_ENABLE_DEPRECATED_CODE 
  655   void TPETRA_DEPRECATED
 
  662 #endif // TPETRA_ENABLE_DEPRECATED_CODE 
  679                                        Kokkos::MemoryUnmanaged>& diag,
 
  681                                        Kokkos::MemoryUnmanaged>& offsets) 
const;
 
  698                                        Kokkos::MemoryUnmanaged>& diag,
 
  699                     const Teuchos::ArrayView<const size_t>& offsets) 
const;
 
  701 #ifdef TPETRA_ENABLE_DEPRECATED_CODE 
  702   void TPETRA_DEPRECATED
 
  717                     const Teuchos::ArrayView<const size_t>& offsets) 
const;
 
  718 #endif // TPETRA_ENABLE_DEPRECATED_CODE 
  726                      const LO numColInds) 
const;
 
  731                               const ptrdiff_t offsets[],
 
  733                               const LO numOffsets) 
const;
 
  749   virtual bool checkSizes (const ::Tpetra::SrcDistObject& source);
 
  752 #ifdef TPETRA_ENABLE_DEPRECATED_CODE 
  754 #else // TPETRA_ENABLE_DEPRECATED_CODE 
  756 #endif // TPETRA_ENABLE_DEPRECATED_CODE 
  758    const size_t numSameIDs,
 
  765 #ifdef TPETRA_ENABLE_DEPRECATED_CODE 
  767 #else // TPETRA_ENABLE_DEPRECATED_CODE 
  769 #endif // TPETRA_ENABLE_DEPRECATED_CODE 
  775    Kokkos::DualView<
size_t*,
 
  777    size_t& constantNumPackets,
 
  781 #ifdef TPETRA_ENABLE_DEPRECATED_CODE 
  783 #else // TPETRA_ENABLE_DEPRECATED_CODE 
  785 #endif // TPETRA_ENABLE_DEPRECATED_CODE 
  790    Kokkos::DualView<
size_t*,
 
  792    const size_t constantNumPackets,
 
  800   Teuchos::RCP<crs_graph_type> graphRCP_;
 
  840   typename crs_graph_type::local_graph_type::row_map_type::HostMirror ptrHost_;
 
  847   typename crs_graph_type::local_graph_type::entries_type::HostMirror indHost_;
 
  854   typename Kokkos::DualView<impl_scalar_type*, device_type> val_;
 
  877   Teuchos::RCP<Teuchos::RCP<BMV> > X_colMap_;
 
  881   Teuchos::RCP<Teuchos::RCP<BMV> > Y_rowMap_;
 
  890   Teuchos::RCP<Teuchos::RCP<typename crs_graph_type::import_type> > pointImporter_;
 
  906   Teuchos::RCP<bool> localError_;
 
  915   Teuchos::RCP<Teuchos::RCP<std::ostringstream> > errs_;
 
  918   std::ostream& markLocalErrorAndGetStream ();
 
  923   template<
class Device>
 
  925 #if defined(KOKKOS_ENABLE_CUDA) 
  931     static constexpr 
bool value =
 
  932       std::is_same<typename Device::execution_space, Kokkos::Cuda>::value;
 
  934     static constexpr 
bool value = 
false;
 
  935 #endif // defined(KOKKOS_ENABLE_CUDA) 
  951     val_.modify_device();
 
  955   template<
class MemorySpace>
 
  958     if (is_cuda<MemorySpace>::value) {
 
  969     return val_.need_sync_host();
 
  975     return val_.need_sync_device();
 
  979   template<
class MemorySpace>
 
  982     if (is_cuda<MemorySpace>::value) {
 
 1003   template<
class MemorySpace>
 
 1006     if (is_cuda<MemorySpace>::value) {
 
 1015   typename Kokkos::DualView<impl_scalar_type*, device_type>::t_host getValuesHost ()
 const {
 
 1016     return val_.view_host();
 
 1020   typename Kokkos::DualView<impl_scalar_type*, device_type>::t_dev getValuesDevice ()
 const {
 
 1021     return val_.view_device();
 
 1041   template<
class MemorySpace>
 
 1042   typename std::conditional<is_cuda<MemorySpace>::value,
 
 1043                             typename Kokkos::DualView<impl_scalar_type*, device_type>::t_dev,
 
 1044                             typename Kokkos::DualView<impl_scalar_type*, device_type>::t_host>::type
 
 1048     return Kokkos::Impl::if_c<
 
 1049         is_cuda<MemorySpace>::value,
 
 1050         typename Kokkos::DualView<impl_scalar_type*, device_type>::t_dev,
 
 1051         typename Kokkos::DualView<impl_scalar_type*, device_type>::t_host
 
 1052       >::select (this->getValuesDevice (), this->getValuesHost ());
 
 1071                    const Teuchos::ETransp mode,
 
 1141   findRelOffsetOfColumnIndex (
const LO localRowIndex,
 
 1142                               const LO colIndexToFind,
 
 1143                               const LO hint = 0) 
const;
 
 1147   LO offsetPerBlock () 
const;
 
 1150   getConstLocalBlockFromInput (
const impl_scalar_type* val, 
const size_t pointOffset) 
const;
 
 1153   getNonConstLocalBlockFromInput (
impl_scalar_type* val, 
const size_t pointOffset) 
const;
 
 1156   getConstLocalBlockFromAbsOffset (
const size_t absBlockOffset) 
const;
 
 1159   getNonConstLocalBlockFromAbsOffset (
const size_t absBlockOffset) 
const;
 
 1165   getConstLocalBlockFromRelOffset (
const LO lclMeshRow,
 
 1166                                    const size_t relMeshOffset) 
const;
 
 1170   virtual Teuchos::RCP<const Teuchos::Comm<int> > 
getComm() 
const;
 
 1172 #ifdef TPETRA_ENABLE_DEPRECATED_CODE 
 1173   virtual TPETRA_DEPRECATED Teuchos::RCP<Node> getNode() 
const;
 
 1175 #endif // TPETRA_ENABLE_DEPRECATED_CODE 
 1236 #ifdef TPETRA_ENABLE_DEPRECATED_CODE 
 1253   virtual size_t TPETRA_DEPRECATED getNodeNumDiags() 
const;
 
 1265   virtual bool TPETRA_DEPRECATED isLowerTriangular () 
const;
 
 1277   virtual bool TPETRA_DEPRECATED isUpperTriangular () 
const;
 
 1278 #endif // TPETRA_ENABLE_DEPRECATED_CODE 
 1306                     const Teuchos::ArrayView<GO> &Indices,
 
 1307                     const Teuchos::ArrayView<Scalar> &Values,
 
 1308                     size_t& NumEntries) 
const;
 
 1336                     Teuchos::ArrayView<const GO>& indices,
 
 1337                     Teuchos::ArrayView<const Scalar>& values) 
const;
 
 1361   virtual void leftScale (const ::Tpetra::Vector<Scalar, LO, GO, Node>& x);
 
 1368   virtual void rightScale (const ::Tpetra::Vector<Scalar, LO, GO, Node>& x);
 
 1378   virtual typename ::Tpetra::RowMatrix<Scalar, LO, GO, Node>::mag_type
 
 1386 #endif // TPETRA_EXPERIMENTAL_BLOCKCRSMATRIX_DECL_HPP 
LO absMaxLocalValuesByOffsets(const LO localRowInd, const ptrdiff_t offsets[], const Scalar vals[], const LO numOffsets) const 
Like sumIntoLocalValuesByOffsets, but for the ABSMAX combine mode. 
virtual void leftScale(const ::Tpetra::Vector< Scalar, LO, GO, Node > &x)
Scale the RowMatrix on the left with the given Vector x. 
virtual bool supportsRowViews() const 
Whether this object implements getLocalRowView() and getGlobalRowView(). 
Teuchos::RCP< const map_type > getColMap() const 
get the (mesh) map for the columns of this block matrix. 
LO getBlockSize() const 
The number of degrees of freedom per mesh point. 
Kokkos::View< impl_scalar_type *, Kokkos::LayoutRight, device_type, Kokkos::MemoryTraits< Kokkos::Unmanaged > > little_vec_type
The type used to access nonconst vector blocks. 
Teuchos::RCP< const map_type > getRowMap() const 
get the (mesh) map for the rows of this block matrix. 
LO replaceLocalValues(const LO localRowInd, const LO colInds[], const Scalar vals[], const LO numColInds) const 
Replace values at the given (mesh, i.e., block) column indices, in the given (mesh, i.e., block) row. 
LO replaceLocalValuesByOffsets(const LO localRowInd, const ptrdiff_t offsets[], const Scalar vals[], const LO numOffsets) const 
Like replaceLocalValues, but avoids computing row offsets. 
size_t getNodeNumRows() const 
get the local number of block rows 
Kokkos::View< impl_scalar_type **, Kokkos::LayoutRight, device_type, Kokkos::MemoryTraits< Kokkos::Unmanaged > > little_block_type
The type used to access nonconst matrix blocks. 
void applyBlock(const BlockMultiVector< Scalar, LO, GO, Node > &X, BlockMultiVector< Scalar, LO, GO, Node > &Y, Teuchos::ETransp mode=Teuchos::NO_TRANS, const Scalar alpha=Teuchos::ScalarTraits< Scalar >::one(), const Scalar beta=Teuchos::ScalarTraits< Scalar >::zero())
Version of apply() that takes BlockMultiVector input and output. 
Node::device_type device_type
The Kokkos::Device specialization that this class uses. 
virtual void rightScale(const ::Tpetra::Vector< Scalar, LO, GO, Node > &x)
Scale the RowMatrix on the right with the given Vector x. 
bool need_sync() const 
Whether the matrix's values need sync'ing to the given memory space. 
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const 
Print a description of this object to the given output stream. 
MultiVector for multiple degrees of freedom per mesh point. 
Declaration of the Tpetra::CrsMatrix class. 
GO global_ordinal_type
The type of global indices. 
LO getLocalRowOffsets(const LO localRowInd, ptrdiff_t offsets[], const LO colInds[], const LO numColInds) const 
Get relative offsets corresponding to the given rows, given by local row index. 
global_size_t getGlobalNumRows() const 
get the global number of block rows 
::Tpetra::MultiVector< Scalar, LO, GO, node_type > mv_type
The implementation of MultiVector that this class uses. 
void modify_device()
Mark the matrix's valueas as modified in device space. 
void modify_host()
Mark the matrix's valueas as modified in host space. 
LO absMaxLocalValues(const LO localRowInd, const LO colInds[], const Scalar vals[], const LO numColInds) const 
Like sumIntoLocalValues, but for the ABSMAX combine mode. 
Teuchos::RCP< const map_type > getRangeMap() const 
Get the (point) range Map of this matrix. 
bool need_sync_device() const 
Whether the matrix's values need sync'ing to device space. 
virtual bool hasColMap() const 
Whether this matrix has a well-defined column Map. 
Teuchos::RCP< const map_type > getDomainMap() const 
Get the (point) domain Map of this matrix. 
void setAllToScalar(const Scalar &alpha)
Set all matrix entries equal to alpha. 
virtual Teuchos::RCP< const ::Tpetra::RowGraph< LO, GO, Node > > getGraph() const 
Get the (mesh) graph. 
typename DistObject< Scalar, LO, GO, Node >::buffer_device_type buffer_device_type
Kokkos::Device specialization for communication buffers. 
::Tpetra::CrsGraph< LO, GO, node_type > crs_graph_type
The implementation of CrsGraph that this class uses. 
virtual GO getIndexBase() const 
The index base for global indices in this matrix. 
virtual bool isGloballyIndexed() const 
Whether matrix indices are globally indexed. 
::Tpetra::Map< LO, GO, node_type > map_type
The implementation of Map that this class uses. 
size_t global_size_t
Global size_t object. 
device_type::execution_space execution_space
The Kokkos execution space that this class uses. 
std::string description() const 
One-line description of this object. 
BlockCrsMatrix()
Default constructor: Makes an empty block matrix. 
virtual global_size_t getGlobalNumCols() const 
The global number of columns of this matrix. 
ESweepDirection
Sweep direction for Gauss-Seidel or Successive Over-Relaxation (SOR). 
virtual bool isFillComplete() const 
Whether fillComplete() has been called. 
Sets up and executes a communication plan for a Tpetra DistObject. 
CombineMode
Rule for combining data in an Import or Export. 
virtual size_t getNodeNumCols() const 
The number of columns needed to apply the forward operator on this node. 
virtual size_t getNodeNumEntries() const 
The local number of stored (structurally nonzero) entries. 
CrsGraphType::global_ordinal_type getGlobalNumDiags(const CrsGraphType &G)
Number of populated diagonal entries in the given sparse graph, over all processes in the graph's (MP...
virtual global_size_t getGlobalNumEntries() const 
The global number of stored (structurally nonzero) entries. 
virtual void getGlobalRowCopy(GO GlobalRow, const Teuchos::ArrayView< GO > &Indices, const Teuchos::ArrayView< Scalar > &Values, size_t &NumEntries) const 
Get a copy of the given global row's entries. 
void getLocalRowCopy(LO LocalRow, const Teuchos::ArrayView< LO > &Indices, const Teuchos::ArrayView< Scalar > &Values, size_t &NumEntries) const 
Not implemented. 
Abstract base class for objects that can be the source of an Import or Export operation. 
LO getLocalRowView(const LO localRowInd, const LO *&colInds, Scalar *&vals, LO &numInds) const 
Get a view of the (mesh, i.e., block) row, using local (mesh, i.e., block) indices. 
Scalar scalar_type
The type of entries in the matrix (that is, of each entry in each block). 
Kokkos::View< const impl_scalar_type **, Kokkos::LayoutRight, device_type, Kokkos::MemoryTraits< Kokkos::Unmanaged > > const_little_block_type
The type used to access const matrix blocks. 
std::string errorMessages() const 
The current stream of error messages. 
void localGaussSeidel(const BlockMultiVector< Scalar, LO, GO, Node > &Residual, BlockMultiVector< Scalar, LO, GO, Node > &Solution, const Kokkos::View< impl_scalar_type ***, device_type, Kokkos::MemoryUnmanaged > &D_inv, const Scalar &omega, const ESweepDirection direction) const 
Local Gauss-Seidel solve, given a factorized diagonal. 
void modify()
Mark the matrix's values as modified in the given memory space. 
Node node_type
The Node type. 
LO sumIntoLocalValues(const LO localRowInd, const LO colInds[], const Scalar vals[], const LO numColInds) const 
Sum into values at the given (mesh, i.e., block) column indices, in the given (mesh, i.e., block) row. 
virtual size_t getGlobalMaxNumRowEntries() const 
The maximum number of entries in any row over all processes in the matrix's communicator. 
void sync_device()
Sync the matrix's values to device space. 
LO local_ordinal_type
The type of local indices. 
typename BMV::impl_scalar_type impl_scalar_type
The implementation type of entries in the matrix. 
A read-only, row-oriented interface to a sparse matrix. 
void reorderedGaussSeidelCopy(::Tpetra::MultiVector< Scalar, LO, GO, Node > &X, const ::Tpetra::MultiVector< Scalar, LO, GO, Node > &B, const ::Tpetra::MultiVector< Scalar, LO, GO, Node > &D, const Teuchos::ArrayView< LO > &rowIndices, const Scalar &dampingFactor, const ESweepDirection direction, const int numSweeps, const bool zeroInitialGuess) const 
Version of reorderedGaussSeidel(), with fewer requirements on X. 
void sync_host()
Sync the matrix's values to host space. 
LO sumIntoLocalValuesByOffsets(const LO localRowInd, const ptrdiff_t offsets[], const Scalar vals[], const LO numOffsets) const 
Like sumIntoLocalValues, but avoids computing row offsets. 
A distributed dense vector. 
Sparse matrix whose entries are small dense square blocks, all of the same dimensions. 
virtual typename::Tpetra::RowMatrix< Scalar, LO, GO, Node >::mag_type getFrobeniusNorm() const 
The Frobenius norm of the matrix. 
void getLocalDiagOffsets(const Kokkos::View< size_t *, device_type, Kokkos::MemoryUnmanaged > &offsets) const 
Get offsets of the diagonal entries in the matrix. 
device_type::memory_space memory_space
The Kokkos memory space that this class uses. 
void apply(const mv_type &X, mv_type &Y, Teuchos::ETransp mode=Teuchos::NO_TRANS, Scalar alpha=Teuchos::ScalarTraits< Scalar >::one(), Scalar beta=Teuchos::ScalarTraits< Scalar >::zero()) const 
For this matrix A, compute Y := beta * Y + alpha * Op(A) * X. 
typename mv_type::impl_scalar_type impl_scalar_type
The implementation type of entries in the object. 
virtual Teuchos::RCP< const Teuchos::Comm< int > > getComm() const 
The communicator over which this matrix is distributed. 
void gaussSeidelCopy(MultiVector< Scalar, LO, GO, Node > &X, const ::Tpetra::MultiVector< Scalar, LO, GO, Node > &B, const ::Tpetra::MultiVector< Scalar, LO, GO, Node > &D, const Scalar &dampingFactor, const ESweepDirection direction, const int numSweeps, const bool zeroInitialGuess) const 
Version of gaussSeidel(), with fewer requirements on X. 
std::conditional< is_cuda< MemorySpace >::value, typename Kokkos::DualView< impl_scalar_type *, device_type >::t_dev, typename Kokkos::DualView< impl_scalar_type *, device_type >::t_host >::type getValues()
Get the host or device View of the matrix's values (val_). 
bool localError() const 
Whether this object had an error on the calling process. 
Kokkos::View< const impl_scalar_type *, Kokkos::LayoutRight, device_type, Kokkos::MemoryTraits< Kokkos::Unmanaged > > const_little_vec_type
The type used to access const vector blocks. 
virtual ~BlockCrsMatrix()
Destructor (declared virtual for memory safety). 
void sync()
Sync the matrix's values to the given memory space. 
Base class for distributed Tpetra objects that support data redistribution. 
size_t getNodeMaxNumRowEntries() const 
Maximum number of entries in any row of the matrix, on this process. 
bool hasTransposeApply() const 
Whether it is valid to apply the transpose or conjugate transpose of this matrix. ...
virtual size_t getNumEntriesInGlobalRow(GO globalRow) const 
The current number of entries on the calling process in the specified global row. ...
size_t getNumEntriesInLocalRow(const LO localRowInd) const 
Return the number of entries in the given row on the calling process. 
virtual void getGlobalRowView(GO GlobalRow, Teuchos::ArrayView< const GO > &indices, Teuchos::ArrayView< const Scalar > &values) const 
Get a constant, nonpersisting, globally indexed view of the given row of the matrix. 
char packet_type
Implementation detail; tells. 
void getLocalDiagCopy(const Kokkos::View< impl_scalar_type ***, device_type, Kokkos::MemoryUnmanaged > &diag, const Kokkos::View< const size_t *, device_type, Kokkos::MemoryUnmanaged > &offsets) const 
Variant of getLocalDiagCopy() that uses precomputed offsets and puts diagonal blocks in a 3-D Kokkos:...
virtual bool isLocallyIndexed() const 
Whether matrix indices are locally indexed. 
bool need_sync_host() const 
Whether the matrix's values need sync'ing to host space.