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.hpp" 54 namespace Experimental {
135 class GO = ::Tpetra::Details::DefaultTypes::global_ordinal_type,
144 typedef Teuchos::ScalarTraits<Scalar> STS;
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 ());
362 const Scalar& dampingFactor,
365 const bool zeroInitialGuess)
const;
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;
659 void TPETRA_DEPRECATED
677 Kokkos::MemoryUnmanaged>& diag,
679 Kokkos::MemoryUnmanaged>& offsets)
const;
696 Kokkos::MemoryUnmanaged>& diag,
697 const Teuchos::ArrayView<const size_t>& offsets)
const;
712 void TPETRA_DEPRECATED
714 const Teuchos::ArrayView<const size_t>& offsets)
const;
722 const LO numColInds)
const;
727 const ptrdiff_t offsets[],
729 const LO numOffsets)
const;
743 const Teuchos::ArrayView<const LO>& permuteToLIDs,
744 const Teuchos::ArrayView<const LO>& permuteFromLIDs);
748 const Teuchos::ArrayView<const LO>& exportLIDs,
749 Teuchos::Array<packet_type>& exports,
750 const Teuchos::ArrayView<size_t>& numPacketsPerLID,
751 size_t& constantNumPackets,
755 unpackAndCombine (
const Teuchos::ArrayView<const LO> &importLIDs,
756 const Teuchos::ArrayView<const packet_type> &imports,
757 const Teuchos::ArrayView<size_t> &numPacketsPerLID,
758 size_t constantNumPackets,
766 Teuchos::RCP<crs_graph_type> graphRCP_;
806 typename crs_graph_type::local_graph_type::row_map_type::HostMirror ptrHost_;
813 typename crs_graph_type::local_graph_type::entries_type::HostMirror indHost_;
820 typename Kokkos::DualView<impl_scalar_type*, device_type> val_;
843 Teuchos::RCP<Teuchos::RCP<BMV> > X_colMap_;
847 Teuchos::RCP<Teuchos::RCP<BMV> > Y_rowMap_;
856 Teuchos::RCP<Teuchos::RCP<typename crs_graph_type::import_type> > pointImporter_;
872 Teuchos::RCP<bool> localError_;
881 Teuchos::RCP<Teuchos::RCP<std::ostringstream> > errs_;
884 std::ostream& markLocalErrorAndGetStream ();
894 template<
class MemorySpace>
903 val_.template modify<typename MemorySpace::memory_space> ();
907 template<
class MemorySpace>
916 return val_.template need_sync<typename MemorySpace::memory_space> ();
920 template<
class MemorySpace>
929 val_.template sync<typename MemorySpace::memory_space> ();
946 template<
class MemorySpace>
947 auto getValues () -> decltype (val_.template view<typename MemorySpace::memory_space> ())
949 return val_.template view<typename MemorySpace::memory_space> ();
968 const Teuchos::ETransp mode,
1038 findRelOffsetOfColumnIndex (
const LO localRowIndex,
1039 const LO colIndexToFind,
1040 const LO hint = 0)
const;
1044 LO offsetPerBlock ()
const;
1047 getConstLocalBlockFromInput (
const impl_scalar_type* val,
const size_t pointOffset)
const;
1050 getNonConstLocalBlockFromInput (
impl_scalar_type* val,
const size_t pointOffset)
const;
1053 getConstLocalBlockFromAbsOffset (
const size_t absBlockOffset)
const;
1056 getNonConstLocalBlockFromAbsOffset (
const size_t absBlockOffset)
const;
1062 getConstLocalBlockFromRelOffset (
const LO lclMeshRow,
1063 const size_t relMeshOffset)
const;
1067 virtual Teuchos::RCP<const Teuchos::Comm<int> >
getComm()
const;
1070 virtual Teuchos::RCP<Node>
getNode()
const;
1168 const Teuchos::ArrayView<GO> &Indices,
1169 const Teuchos::ArrayView<Scalar> &Values,
1170 size_t& NumEntries)
const;
1198 Teuchos::ArrayView<const GO>& indices,
1199 Teuchos::ArrayView<const Scalar>& values)
const;
1248 #endif // TPETRA_EXPERIMENTAL_BLOCKCRSMATRIX_DECL_HPP virtual Tpetra::RowMatrix< Scalar, LO, GO, Node >::mag_type getFrobeniusNorm() const
The Frobenius norm of the matrix.
LO absMaxLocalValues(const LO localRowInd, const LO colInds[], const Scalar vals[], const LO numColInds) const
Like sumIntoLocalValues, but for the ABSMAX combine mode.
Namespace Tpetra contains the class and methods constituting the Tpetra library.
LO replaceLocalValuesByOffsets(const LO localRowInd, const ptrdiff_t offsets[], const Scalar vals[], const LO numOffsets) const
Like replaceLocalValues, but avoids computing row offsets.
virtual void copyAndPermute(const Tpetra::SrcDistObject &source, size_t numSameIDs, const Teuchos::ArrayView< const LO > &permuteToLIDs, const Teuchos::ArrayView< const LO > &permuteFromLIDs)
Perform copies and permutations that are local to this process.
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.
bool hasTransposeApply() const
Whether it is valid to apply the transpose or conjugate transpose of this matrix. ...
virtual size_t getNodeNumEntries() const
The local number of stored (structurally nonzero) entries.
Kokkos::View< impl_scalar_type *, Kokkos::LayoutRight, device_type, Kokkos::MemoryTraits< Kokkos::Unmanaged > > little_vec_type
The type used to access nonconst vector blocks.
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.
Scalar scalar_type
The type of entries in the matrix (that is, of each entry in each block).
virtual size_t getNumEntriesInGlobalRow(GO globalRow) const
The current number of entries on the calling process in the specified global row. ...
global_size_t getGlobalNumRows() const
get the global number of block rows
KokkosClassic::DefaultNode::DefaultNodeType node_type
Default value of Node template parameter.
Kokkos::View< impl_scalar_type **, Kokkos::LayoutRight, device_type, Kokkos::MemoryTraits< Kokkos::Unmanaged > > little_block_type
The type used to access nonconst matrix blocks.
std::string errorMessages() const
The current stream of error messages.
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.
One or more distributed dense vectors.
Node::device_type device_type
The Kokkos::Device specialization that this class uses.
MultiVector for multiple degrees of freedom per mesh point.
Declaration of the Tpetra::CrsMatrix class.
GO global_ordinal_type
The type of global indices.
size_t getNumEntriesInLocalRow(const LO localRowInd) const
Return the number of entries in the given row on the calling process.
virtual Teuchos::RCP< const Tpetra::RowGraph< LO, GO, Node > > getGraph() const
Get the (mesh) graph.
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.
virtual global_size_t getGlobalNumCols() const
The global number of columns of this matrix.
std::string description() const
One-line description of this object.
LO sumIntoLocalValuesByOffsets(const LO localRowInd, const ptrdiff_t offsets[], const Scalar vals[], const LO numOffsets) const
Like sumIntoLocalValues, but avoids computing row offsets.
virtual size_t getNodeNumDiags() const
The number of local diagonal entries, based on global row/column index comparisons.
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.
virtual bool isGloballyIndexed() const
Whether matrix indices are globally indexed.
int local_ordinal_type
Default value of LocalOrdinal template parameter.
virtual bool isLowerTriangular() const
Whether this matrix is lower triangular.
Tpetra::MultiVector< Scalar, LO, GO, node_type > mv_type
The implementation of MultiVector that this class uses.
virtual global_size_t getGlobalNumDiags() const
The number of global diagonal entries, based on global row/column index comparisons.
mv_type::impl_scalar_type impl_scalar_type
The implementation type of entries in the matrix.
virtual bool checkSizes(const Tpetra::SrcDistObject &source)
Compare the source and target (this) objects for compatibility.
void setAllToScalar(const Scalar &alpha)
Set all matrix entries equal to alpha.
::Tpetra::Map< LO, GO, node_type > map_type
The implementation of Map that this class uses.
virtual size_t getNodeNumCols() const
The number of columns needed to apply the forward operator on this node.
size_t global_size_t
Global size_t object.
device_type::execution_space execution_space
The Kokkos execution space that this class uses.
BlockCrsMatrix()
Default constructor: Makes an empty block matrix.
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.
void reorderedGaussSeidelCopy(MultiVector< Scalar, LO, GO, Node > &X, const MultiVector< Scalar, LO, GO, Node > &B, const 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.
ESweepDirection
Sweep direction for Gauss-Seidel or Successive Over-Relaxation (SOR).
LO absMaxLocalValuesByOffsets(const LO localRowInd, const ptrdiff_t offsets[], const Scalar vals[], const LO numOffsets) const
Like sumIntoLocalValuesByOffsets, but for the ABSMAX combine mode.
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.
bool need_sync() const
Whether the matrix's values need sync'ing to the given memory space.
virtual Teuchos::RCP< Node > getNode() const
The Kokkos Node instance.
Sets up and executes a communication plan for a Tpetra DistObject.
void gaussSeidelCopy(MultiVector< Scalar, LO, GO, Node > &X, const MultiVector< Scalar, LO, GO, Node > &B, const 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.
CombineMode
Rule for combining data in an Import or Export.
size_t getNodeMaxNumRowEntries() const
The maximum number of entries across all rows/columns on this node.
Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::mag_type mag_type
Type of a norm result.
virtual void leftScale(const Vector< Scalar, LO, GO, Node > &x)
Scale the RowMatrix on the left with the given Vector x.
auto getValues() -> decltype(val_.template view< typename MemorySpace::memory_space >())
Get the host or device View of the matrix's values (val_).
Abstract base class for objects that can be the source of an Import or Export operation.
virtual size_t getGlobalMaxNumRowEntries() const
The maximum number of entries across all rows/columns on all nodes.
double scalar_type
Default value of Scalar template parameter.
virtual bool supportsRowViews() const
Whether this object implements getLocalRowView() and getGlobalRowView().
void getLocalRowCopy(LO LocalRow, const Teuchos::ArrayView< LO > &Indices, const Teuchos::ArrayView< Scalar > &Values, size_t &NumEntries) const
Not implemented.
Teuchos::RCP< const map_type > getRowMap() const
get the (mesh) map for the rows of this block matrix.
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.
bool localError() const
Whether this object had an error on the calling process.
virtual bool hasColMap() const
Whether this matrix has a well-defined column map.
void modify()
Mark the matrix's values as modified in the given memory space.
Node node_type
The Node type.
virtual bool isUpperTriangular() const
Whether this matrix is upper triangular.
LO local_ordinal_type
The type of local indices.
void getLocalDiagOffsets(const Kokkos::View< size_t *, device_type, Kokkos::MemoryUnmanaged > &offsets) const
Get offsets of the diagonal entries in the matrix.
virtual global_size_t getGlobalNumEntries() const
The global number of stored (structurally nonzero) entries.
virtual void rightScale(const Vector< Scalar, LO, GO, Node > &x)
Scale the RowMatrix on the right with the given Vector x.
virtual Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
The communicator over which this matrix is distributed.
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.
virtual GO getIndexBase() const
The index base for global indices in this matrix.
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.
A read-only, row-oriented interface to a sparse matrix.
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:...
A distributed dense vector.
Sparse matrix whose entries are small dense square blocks, all of the same dimensions.
device_type::memory_space memory_space
The Kokkos memory space that this class uses.
Teuchos::RCP< const map_type > getDomainMap() const
Get the (point) domain Map of this matrix.
virtual bool isFillComplete() const
Whether fillComplete() has been called.
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.
BlockMultiVector< Scalar, LO, GO, Node >::impl_scalar_type impl_scalar_type
The implementation type of entries in the matrix.
LO getBlockSize() const
The number of degrees of freedom per mesh point.
virtual ~BlockCrsMatrix()
Destructor (declared virtual for memory safety).
Teuchos::RCP< const map_type > getColMap() const
get the (mesh) map for the columns of this block matrix.
void sync()
Sync the matrix's values to the given memory space.
Base class for distributed Tpetra objects that support data redistribution.
Teuchos::RCP< const map_type > getRangeMap() const
Get the (point) range Map of this matrix.
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
Print a description of this object to the given output stream.
size_t getNodeNumRows() const
get the local number of block rows
virtual bool isLocallyIndexed() const
Whether matrix indices are locally indexed.
char packet_type
Implementation detail; tells.
Tpetra::CrsGraph< LO, GO, node_type > crs_graph_type
The implementation of CrsGraph that this class uses.