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 {
125 class GO = Details::DefaultTypes::global_ordinal_type,
134 typedef Teuchos::ScalarTraits<Scalar> STS;
137 typedef char packet_type;
168 typedef ::Tpetra::Map<LO, GO, node_type>
map_type;
203 const map_type& domainPointMap,
204 const map_type& rangePointMap,
221 Teuchos::RCP<const map_type>
getRowMap ()
const;
224 Teuchos::RCP<const map_type>
getColMap ()
const;
244 apply (
const mv_type& X,
246 Teuchos::ETransp mode = Teuchos::NO_TRANS,
247 Scalar alpha = Teuchos::ScalarTraits<Scalar>::one (),
248 Scalar beta = Teuchos::ScalarTraits<Scalar>::zero ())
const;
292 describe (Teuchos::FancyOStream& out,
293 const Teuchos::EVerbosityLevel verbLevel)
const;
303 virtual Teuchos::RCP<const Tpetra::RowGraph<LO,GO,Node> >
getGraph ()
const;
305 const crs_graph_type & getCrsGraph ()
const {
return graph_; }
314 Teuchos::ETransp mode = Teuchos::NO_TRANS,
315 const Scalar alpha = Teuchos::ScalarTraits<Scalar>::one (),
316 const Scalar beta = Teuchos::ScalarTraits<Scalar>::zero ());
325 const Scalar& dampingFactor,
328 const bool zeroInitialGuess)
const;
337 const ArrayView<LO>& rowIndices,
338 const Scalar& dampingFactor,
341 const bool zeroInitialGuess)
const;
367 const Kokkos::View<impl_scalar_type***, device_type,
368 Kokkos::MemoryUnmanaged>& factoredDiagonal,
369 const Kokkos::View<
int**, device_type,
370 Kokkos::MemoryUnmanaged>& factorizationPivots,
404 const LO numColInds)
const;
436 const LO numColInds)
const;
476 Teuchos::ArrayView<const LO> &indices,
477 Teuchos::ArrayView<const Scalar> &values)
const;
482 const Teuchos::ArrayView<LO> &Indices,
483 const Teuchos::ArrayView<Scalar> &Values,
484 size_t &NumEntries)
const;
487 getLocalBlock (
const LO localRowInd,
const LO localColInd)
const;
516 const LO numColInds)
const;
525 const ptrdiff_t offsets[],
527 const LO numOffsets)
const;
536 const ptrdiff_t offsets[],
538 const LO numOffsets)
const;
583 return (*errs_).is_null () ? std::string (
"") : (*errs_)->str ();
630 const Teuchos::ArrayView<const size_t>& offsets)
const;
647 Kokkos::MemoryUnmanaged>& diag,
648 const Teuchos::ArrayView<const size_t>& offsets)
const;
656 const LO numColInds)
const;
661 const ptrdiff_t offsets[],
663 const LO numOffsets)
const;
678 const Teuchos::ArrayView<const LO>& permuteToLIDs,
679 const Teuchos::ArrayView<const LO>& permuteFromLIDs);
683 const Teuchos::ArrayView<const LO>& exportLIDs,
684 Teuchos::Array<packet_type>& exports,
685 const Teuchos::ArrayView<size_t>& numPacketsPerLID,
686 size_t& constantNumPackets,
690 unpackAndCombine (
const Teuchos::ArrayView<const LO> &importLIDs,
691 const Teuchos::ArrayView<const packet_type> &imports,
692 const Teuchos::ArrayView<size_t> &numPacketsPerLID,
693 size_t constantNumPackets,
700 crs_graph_type graph_;
701 Teuchos::RCP<crs_graph_type> graphRCP_;
710 map_type rowMeshMap_;
717 map_type domainPointMap_;
724 map_type rangePointMap_;
732 typename crs_graph_type::local_graph_type::row_map_type::HostMirror ptr_;
741 Kokkos::View<impl_scalar_type*, device_type> valView_;
746 impl_scalar_type* val_;
769 Teuchos::RCP<Teuchos::RCP<BMV> > X_colMap_;
773 Teuchos::RCP<Teuchos::RCP<BMV> > Y_rowMap_;
789 Teuchos::RCP<bool> localError_;
798 Teuchos::RCP<Teuchos::RCP<std::ostringstream> > errs_;
801 std::ostream& markLocalErrorAndGetStream ();
818 const Teuchos::ETransp mode,
888 findRelOffsetOfColumnIndex (
const LO localRowIndex,
889 const LO colIndexToFind,
890 const LO hint = 0)
const;
894 LO offsetPerBlock ()
const;
896 const_little_block_type
897 getConstLocalBlockFromInput (
const impl_scalar_type* val,
const size_t pointOffset)
const;
900 getNonConstLocalBlockFromInput (impl_scalar_type* val,
const size_t pointOffset)
const;
902 const_little_block_type
903 getConstLocalBlockFromAbsOffset (
const size_t absBlockOffset)
const;
906 getNonConstLocalBlockFromAbsOffset (
const size_t absBlockOffset)
const;
911 const_little_block_type
912 getConstLocalBlockFromRelOffset (
const LO lclMeshRow,
913 const size_t relMeshOffset)
const;
917 virtual Teuchos::RCP<const Teuchos::Comm<int> >
getComm()
const;
920 virtual Teuchos::RCP<Node>
getNode()
const;
1018 const Teuchos::ArrayView<GO> &Indices,
1019 const Teuchos::ArrayView<Scalar> &Values,
1020 size_t& NumEntries)
const;
1048 Teuchos::ArrayView<const GO>& indices,
1049 Teuchos::ArrayView<const Scalar>& values)
const;
1098 #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.
Namespace Tpetra contains the class and methods constituting the Tpetra library.
virtual bool supportsRowViews() const
Whether this object implements getLocalRowView() and getGlobalRowView().
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.
virtual bool isLowerTriangular() const
Whether this matrix is lower triangular.
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.
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.
Scalar scalar_type
The type of entries in the matrix.
LO replaceLocalValuesByOffsets(const LO localRowInd, const ptrdiff_t offsets[], const Scalar vals[], const LO numOffsets) const
Like replaceLocalValues, but avoids computing row offsets.
KokkosClassic::DefaultNode::DefaultNodeType node_type
Default value of Node template parameter.
size_t getNodeNumRows() const
get the local number of block rows
void getLocalDiagOffsets(Teuchos::ArrayRCP< size_t > &offsets) const
Get offsets of the diagonal entries in the matrix.
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.
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
Nonowning view of a square dense block in a block matrix.
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.
virtual bool isUpperTriangular() const
Whether this matrix is upper triangular.
int local_ordinal_type
Default value of LocalOrdinal template parameter.
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.
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 size_t getNodeNumDiags() const
The number of local diagonal entries, based on global row/column index comparisons.
virtual GO getIndexBase() const
The index base for global indices in this matrix.
virtual bool isGloballyIndexed() const
Whether matrix indices are globally indexed.
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.
Nonowning view of a set of degrees of freedom corresponding to a mesh point in a block vector or mult...
Sets up and executes a communication plan for a Tpetra DistObject.
CombineMode
Rule for combining data in an Import or Export.
void reorderedGaussSeidelCopy(MultiVector< Scalar, LO, GO, Node > &X, const MultiVector< Scalar, LO, GO, Node > &B, const MultiVector< Scalar, LO, GO, Node > &D, const ArrayView< LO > &rowIndices, const Scalar &dampingFactor, const ESweepDirection direction, const int numSweeps, const bool zeroInitialGuess) const
Version of reorderedGaussSeidel(), with fewer requirements on X.
Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::mag_type mag_type
Type of a norm result.
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.
virtual void leftScale(const Vector< Scalar, LO, GO, Node > &x)
Scale the RowMatrix on the left with the given Vector x.
void getLocalDiagCopy(BlockCrsMatrix< Scalar, LO, GO, Node > &diag, const Teuchos::ArrayView< const size_t > &offsets) const
Variant of getLocalDiagCopy() that uses precomputed offsets.
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.
double scalar_type
Default value of Scalar template parameter.
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.
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.
std::string errorMessages() const
The current stream of error messages.
Node node_type
The Kokkos 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 across all rows/columns on all nodes.
LO local_ordinal_type
The type of local indices.
virtual void rightScale(const Vector< Scalar, LO, GO, Node > &x)
Scale the RowMatrix on the right with the given Vector x.
virtual Tpetra::RowMatrix< Scalar, LO, GO, Node >::mag_type getFrobeniusNorm() const
The Frobenius norm of the matrix.
A read-only, row-oriented interface to a sparse matrix.
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.
Constant block CRS matrix class.
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.
virtual Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
The communicator over which this matrix is distributed.
virtual global_size_t getGlobalNumDiags() const
The number of global diagonal entries, based on global row/column index comparisons.
bool localError() const
Whether this object had an error on the calling process.
BlockMultiVector< Scalar, LO, GO, Node >::impl_scalar_type impl_scalar_type
The implementation type of entries in the matrix.
virtual Teuchos::RCP< Node > getNode() const
The Kokkos Node instance.
virtual ~BlockCrsMatrix()
Destructor (declared virtual for memory safety).
Base class for distributed Tpetra objects that support data redistribution.
size_t getNodeMaxNumRowEntries() const
The maximum number of entries across all rows/columns on this node.
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. ...
virtual Teuchos::RCP< const Tpetra::RowGraph< LO, GO, Node > > getGraph() const
Get the (mesh) graph.
size_t getNumEntriesInLocalRow(const LO localRowInd) const
Return the number of entries in the given row on the calling process.
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 > &factoredDiagonal, const Kokkos::View< int **, device_type, Kokkos::MemoryUnmanaged > &factorizationPivots, const Scalar &omega, const ESweepDirection direction) const
Local Gauss-Seidel solve, given a factorized diagonal.
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 bool isLocallyIndexed() const
Whether matrix indices are locally indexed.