Tpetra parallel linear algebra Version of the Day
Loading...
Searching...
No Matches
Tpetra_RowMatrix_decl.hpp
1// @HEADER
2// *****************************************************************************
3// Tpetra: Templated Linear Algebra Services Package
4//
5// Copyright 2008 NTESS and the Tpetra contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
10#ifndef TPETRA_ROWMATRIX_DECL_HPP
11#define TPETRA_ROWMATRIX_DECL_HPP
12
13#include "Tpetra_ConfigDefs.hpp"
15#include "Tpetra_Vector_fwd.hpp"
16#include "Tpetra_Operator.hpp"
18#include "Tpetra_Packable.hpp"
20#include "Teuchos_Describable.hpp"
21#include "KokkosKernels_ArithTraits.hpp"
22
23namespace Tpetra {
49template <class Scalar,
50 class LocalOrdinal,
51 class GlobalOrdinal,
52 class Node>
53class RowMatrix : virtual public Operator<Scalar, LocalOrdinal, GlobalOrdinal, Node>,
54 virtual public SrcDistObject,
55 public Packable<char, LocalOrdinal> {
56 public:
58
59
67 typedef Node node_type;
68
78 using impl_scalar_type = typename KokkosKernels::ArithTraits<Scalar>::val_type;
84 using mag_type = typename KokkosKernels::ArithTraits<Scalar>::mag_type;
85
86 typedef typename Kokkos::View<impl_scalar_type*, typename Node::device_type>::const_type
87 values_device_view_type;
88 typedef typename values_device_view_type::host_mirror_type::const_type
89 values_host_view_type;
90 typedef typename values_device_view_type::host_mirror_type
91 nonconst_values_host_view_type;
92
93 typedef typename Kokkos::View<LocalOrdinal*, typename Node::device_type>::const_type
94 local_inds_device_view_type;
95 typedef typename local_inds_device_view_type::host_mirror_type::const_type
96 local_inds_host_view_type;
97 typedef typename local_inds_device_view_type::host_mirror_type
98 nonconst_local_inds_host_view_type;
99
100 typedef typename Kokkos::View<GlobalOrdinal*, typename Node::device_type>::const_type
101 global_inds_device_view_type;
102 typedef typename global_inds_device_view_type::host_mirror_type::const_type
103 global_inds_host_view_type;
104 typedef typename global_inds_device_view_type::host_mirror_type
105 nonconst_global_inds_host_view_type;
106
107 typedef typename Kokkos::View<const size_t*, typename Node::device_type>::const_type
108 row_ptrs_device_view_type;
109 typedef typename row_ptrs_device_view_type::host_mirror_type::const_type
110 row_ptrs_host_view_type;
111
113
115
117 virtual ~RowMatrix();
118
120
122
124 virtual Teuchos::RCP<const Teuchos::Comm<int> > getComm() const = 0;
125
127 virtual Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > getRowMap() const = 0;
128
130 virtual Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > getColMap() const = 0;
131
133 virtual Teuchos::RCP<const RowGraph<LocalOrdinal, GlobalOrdinal, Node> > getGraph() const = 0;
134
136 virtual global_size_t getGlobalNumRows() const = 0;
137
139 virtual global_size_t getGlobalNumCols() const = 0;
140
142 virtual size_t getLocalNumRows() const = 0;
143
149 virtual size_t getLocalNumCols() const = 0;
150
152 virtual GlobalOrdinal getIndexBase() const = 0;
153
156
158 virtual size_t getLocalNumEntries() const = 0;
159
170
180 virtual size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const = 0;
181
190 virtual size_t getGlobalMaxNumRowEntries() const = 0;
191
193 virtual local_ordinal_type getBlockSize() const = 0;
194
203 virtual size_t getLocalMaxNumRowEntries() const = 0;
204
206 virtual bool hasColMap() const = 0;
207
217 virtual bool isLocallyIndexed() const = 0;
218
228 virtual bool isGloballyIndexed() const = 0;
229
231 virtual bool isFillComplete() const = 0;
232
234 virtual bool supportsRowViews() const = 0;
235
237
239
260 virtual void
262 nonconst_global_inds_host_view_type& Indices,
263 nonconst_values_host_view_type& Values,
264 size_t& NumEntries) const = 0;
265
286 virtual void
288 nonconst_local_inds_host_view_type& Indices,
289 nonconst_values_host_view_type& Values,
290 size_t& NumEntries) const = 0;
291
316 virtual void
318 global_inds_host_view_type& indices,
319 values_host_view_type& values) const = 0;
320
345 virtual void
347 local_inds_host_view_type& indices,
348 values_host_view_type& values) const = 0;
349
362
364
366
372
378
387 virtual mag_type getFrobeniusNorm() const = 0;
388
440 virtual Teuchos::RCP<RowMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
441 add(const Scalar& alpha,
443 const Scalar& beta,
444 const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >& domainMap = Teuchos::null,
445 const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >& rangeMap = Teuchos::null,
446 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null) const;
448
450 private:
451 bool
452 packRow(char* const numEntOut,
453 char* const valOut,
454 char* const indOut,
455 const size_t numEnt,
456 const LocalOrdinal lclRow) const;
457
458 // TODO (mfh 25 Jan 2015) Could just make this "protected" and let
459 // CrsMatrix use it, since it's exactly the same there.
460 void
461 allocatePackSpace(Teuchos::Array<char>& exports,
462 size_t& totalNumEntries,
463 const Teuchos::ArrayView<const LocalOrdinal>& exportLIDs) const;
464
469 void
470 packImpl(const Teuchos::ArrayView<const LocalOrdinal>& exportLIDs,
471 Teuchos::Array<char>& exports,
472 const Teuchos::ArrayView<size_t>& numPacketsPerLID,
473 size_t& constantNumPackets) const;
474
475 public:
484 virtual void
485 pack(const Teuchos::ArrayView<const LocalOrdinal>& exportLIDs,
486 Teuchos::Array<char>& exports,
487 const Teuchos::ArrayView<size_t>& numPacketsPerLID,
488 size_t& constantNumPackets) const;
490}; // class RowMatrix
491} // namespace Tpetra
492
493#endif // TPETRA_ROWMATRIX_DECL_HPP
Declaration of Tpetra::Packable.
Forward declaration of Tpetra::RowGraph.
Forward declaration of Tpetra::RowMatrix.
Abstract base class for sources of an Import or Export.
Forward declaration of Tpetra::Vector.
Struct that holds views of the contents of a CrsMatrix.
Abstract interface for operators (e.g., matrices and preconditioners).
Abstract base class for objects that can be the source of an Import or Export operation,...
A read-only, row-oriented interface to a sparse matrix.
virtual void getLocalRowCopy(LocalOrdinal LocalRow, nonconst_local_inds_host_view_type &Indices, nonconst_values_host_view_type &Values, size_t &NumEntries) const =0
Get a copy of the given local row's entries.
virtual void getLocalDiagCopy(Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag) const =0
Get a copy of the diagonal entries, distributed by the row Map.
virtual bool isLocallyIndexed() const =0
Whether matrix indices are locally indexed.
virtual Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getColMap() const =0
The Map that describes the distribution of columns over processes.
virtual mag_type getFrobeniusNorm() const =0
The Frobenius norm of the matrix.
virtual global_size_t getGlobalNumRows() const =0
The global number of rows of this matrix.
virtual size_t getLocalMaxNumRowEntries() const =0
Maximum number of entries in any row of the matrix, on this process.
virtual Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getRowMap() const =0
The Map that describes the distribution of rows over processes.
Node node_type
The Kokkos Node type.
virtual Teuchos::RCP< const RowGraph< LocalOrdinal, GlobalOrdinal, Node > > getGraph() const =0
The RowGraph associated with this matrix.
virtual void getLocalRowView(LocalOrdinal LocalRow, local_inds_host_view_type &indices, values_host_view_type &values) const =0
Get a constant, nonpersisting, locally indexed view of the given row of the matrix.
virtual size_t getLocalNumCols() const =0
The number of columns needed to apply the forward operator on this node.
typename KokkosKernels::ArithTraits< Scalar >::mag_type mag_type
Type of a norm result.
virtual GlobalOrdinal getIndexBase() const =0
The index base for global indices in this matrix.
virtual bool supportsRowViews() const =0
Whether this object implements getLocalRowView() and getGlobalRowView().
virtual global_size_t getGlobalNumCols() const =0
The global number of columns of this matrix.
virtual void getGlobalRowCopy(GlobalOrdinal GlobalRow, nonconst_global_inds_host_view_type &Indices, nonconst_values_host_view_type &Values, size_t &NumEntries) const =0
Get a copy of the given global row's entries.
Scalar scalar_type
The type of the entries in the sparse matrix.
virtual size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const =0
The current number of entries on the calling process in the specified local row.
virtual void pack(const Teuchos::ArrayView< const LocalOrdinal > &exportLIDs, Teuchos::Array< char > &exports, const Teuchos::ArrayView< size_t > &numPacketsPerLID, size_t &constantNumPackets) const
Pack this object's data for an Import or Export.
virtual ~RowMatrix()
Destructor (virtual for memory safety of derived classes).
virtual global_size_t getGlobalNumEntries() const =0
The global number of stored (structurally nonzero) entries.
virtual void getGlobalRowView(GlobalOrdinal GlobalRow, global_inds_host_view_type &indices, values_host_view_type &values) const =0
Get a constant, nonpersisting, globally indexed view of the given row of the matrix.
virtual bool hasColMap() const =0
Whether this matrix has a well-defined column Map.
virtual bool isGloballyIndexed() const =0
Whether matrix indices are globally indexed.
virtual local_ordinal_type getBlockSize() const =0
The number of degrees of freedom per mesh point.
virtual Teuchos::RCP< RowMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > add(const Scalar &alpha, const RowMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Scalar &beta, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap=Teuchos::null, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null) const
Return a new RowMatrix which is the result of beta*this + alpha*A.
virtual size_t getLocalNumEntries() const =0
The local number of stored (structurally nonzero) entries.
virtual Teuchos::RCP< const Teuchos::Comm< int > > getComm() const =0
The communicator over which this matrix is distributed.
virtual size_t getGlobalMaxNumRowEntries() const =0
Maximum number of entries in any row of the matrix, over all processes.
virtual bool isFillComplete() const =0
Whether fillComplete() has been called.
typename KokkosKernels::ArithTraits< Scalar >::val_type impl_scalar_type
The type used internally in place of Scalar.
virtual void leftScale(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &x)=0
Scale the matrix on the left with the given Vector.
virtual size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const =0
The current number of entries on the calling process in the specified global row.
GlobalOrdinal global_ordinal_type
The type of global indices.
virtual void rightScale(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &x)=0
Scale the matrix on the right with the given Vector.
LocalOrdinal local_ordinal_type
The type of local indices.
virtual size_t getLocalNumRows() const =0
The number of rows owned by the calling process.
Abstract base class for objects that can be the source of an Import or Export operation.
Namespace Tpetra contains the class and methods constituting the Tpetra library.