Ifpack2 Templated Preconditioning Package Version 1.0
Loading...
Searching...
No Matches
Ifpack2_OverlappingRowMatrix_decl.hpp
1/*@HEADER
2// ***********************************************************************
3//
4// Ifpack2: Templated Object-Oriented Algebraic Preconditioner Package
5// Copyright (2009) Sandia Corporation
6//
7// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8// license for use of this work by or on behalf of the U.S. Government.
9//
10// Redistribution and use in source and binary forms, with or without
11// modification, are permitted provided that the following conditions are
12// met:
13//
14// 1. Redistributions of source code must retain the above copyright
15// notice, this list of conditions and the following disclaimer.
16//
17// 2. Redistributions in binary form must reproduce the above copyright
18// notice, this list of conditions and the following disclaimer in the
19// documentation and/or other materials provided with the distribution.
20//
21// 3. Neither the name of the Corporation nor the names of the
22// contributors may be used to endorse or promote products derived from
23// this software without specific prior written permission.
24//
25// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36//
37// Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38//
39// ***********************************************************************
40//@HEADER
41*/
42
43#ifndef IFPACK2_OVERLAPPINGROWMATRIX_DECL_HPP
44#define IFPACK2_OVERLAPPINGROWMATRIX_DECL_HPP
45
46#include "Ifpack2_Details_RowMatrix.hpp"
47#include "Tpetra_CrsMatrix_decl.hpp" // only need the declaration here
48#include "Tpetra_Import_decl.hpp"
49#include "Tpetra_Map_decl.hpp"
50#include <type_traits>
51
52namespace Ifpack2 {
53
57template<class MatrixType>
59 virtual public Ifpack2::Details::RowMatrix<MatrixType> {
60public:
62
63 typedef typename MatrixType::scalar_type scalar_type;
64 typedef typename MatrixType::local_ordinal_type local_ordinal_type;
65 typedef typename MatrixType::global_ordinal_type global_ordinal_type;
66 typedef typename MatrixType::node_type node_type;
67 typedef typename Teuchos::ScalarTraits<scalar_type>::magnitudeType magnitude_type;
68 typedef typename MatrixType::global_inds_host_view_type global_inds_host_view_type;
69 typedef typename MatrixType::local_inds_host_view_type local_inds_host_view_type;
70 typedef typename MatrixType::values_host_view_type values_host_view_type;
71
72 typedef typename MatrixType::nonconst_global_inds_host_view_type nonconst_global_inds_host_view_type;
73 typedef typename MatrixType::nonconst_local_inds_host_view_type nonconst_local_inds_host_view_type;
74 typedef typename MatrixType::nonconst_values_host_view_type nonconst_values_host_view_type;
75
76 using row_matrix_type = Tpetra::RowMatrix<scalar_type, local_ordinal_type,
77 global_ordinal_type, node_type>;
78 using crs_matrix_type = Tpetra::CrsMatrix<scalar_type, local_ordinal_type,
79 global_ordinal_type, node_type>;
80
81 // device typedefs
82 typedef typename MatrixType::node_type::device_type device_type;
83 typedef typename device_type::execution_space execution_space;
84 typedef typename MatrixType::local_inds_device_view_type local_inds_device_view_type;
85 typedef typename MatrixType::global_inds_device_view_type global_inds_device_view_type;
86 typedef typename MatrixType::values_device_view_type values_device_view_type;
87
88 static_assert(std::is_same<MatrixType, row_matrix_type>::value, "Ifpack2::OverlappingRowMatrix: The template parameter MatrixType must be a Tpetra::RowMatrix specialization. Please don't use Tpetra::CrsMatrix (a subclass of Tpetra::RowMatrix) here anymore. The constructor can take either a RowMatrix or a CrsMatrix just fine.");
89
90 typedef typename row_matrix_type::mag_type mag_type;
91
93
95
106 OverlappingRowMatrix (const Teuchos::RCP<const row_matrix_type>& A,
107 const int overlapLevel);
108
111
113
115
117 virtual Teuchos::RCP<const Teuchos::Comm<int> > getComm() const;
118
119
121 virtual Teuchos::RCP<const Tpetra::Map<local_ordinal_type, global_ordinal_type, node_type> >
122 getRowMap () const;
123
125 virtual Teuchos::RCP<const Tpetra::Map<local_ordinal_type, global_ordinal_type, node_type> >
126 getColMap () const;
127
131 virtual Teuchos::RCP<const Tpetra::Map<local_ordinal_type, global_ordinal_type, node_type> >
132 getDomainMap () const;
133
137 virtual Teuchos::RCP<const Tpetra::Map<local_ordinal_type, global_ordinal_type, node_type> >
138 getRangeMap () const;
139
141 virtual Teuchos::RCP<const Tpetra::RowGraph<local_ordinal_type, global_ordinal_type, node_type> >
142 getGraph () const;
143
145 virtual global_size_t getGlobalNumRows () const;
146
148 virtual global_size_t getGlobalNumCols () const;
149
151 virtual size_t getLocalNumRows () const;
152
158 virtual size_t getLocalNumCols () const;
159
161 virtual global_ordinal_type getIndexBase () const;
162
164 virtual global_size_t getGlobalNumEntries () const;
165
167 virtual size_t getLocalNumEntries () const;
168
178 virtual size_t getNumEntriesInGlobalRow (global_ordinal_type globalRow) const;
179
189 virtual size_t getNumEntriesInLocalRow (local_ordinal_type localRow) const;
190
192 virtual size_t getGlobalMaxNumRowEntries () const;
193
195 virtual size_t getLocalMaxNumRowEntries() const;
196
198 virtual bool hasColMap() const;
199
201 virtual bool isLocallyIndexed () const;
202
204 virtual bool isGloballyIndexed () const;
205
207 virtual bool isFillComplete() const;
208
210 virtual bool supportsRowViews() const;
211
213
215
217
227 virtual void
228 getGlobalRowCopy (global_ordinal_type GlobalRow,
229 nonconst_global_inds_host_view_type &Indices,
230 nonconst_values_host_view_type &Values,
231 size_t& NumEntries) const;
232
234
244 virtual void
245 getLocalRowCopy (local_ordinal_type LocalRow,
246 nonconst_local_inds_host_view_type &Indices,
247 nonconst_values_host_view_type &Values,
248 size_t& NumEntries) const;
249
251
260 virtual void
261 getGlobalRowView (global_ordinal_type GlobalRow,
262 global_inds_host_view_type &indices,
263 values_host_view_type &values) const;
264
266
275 virtual void
276 getLocalRowView (local_ordinal_type LocalRow,
277 local_inds_host_view_type & indices,
278 values_host_view_type & values) const;
279
281
283 virtual
284 void getLocalDiagCopy (Tpetra::Vector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &diag) const;
285
287
289
299 virtual void
300 leftScale (const Tpetra::Vector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& x);
301
311 virtual void
312 rightScale (const Tpetra::Vector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& x);
313
315
318 virtual mag_type
319 getFrobeniusNorm () const;
320
322
329 virtual void
330 apply (const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &X,
331 Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &Y,
332 Teuchos::ETransp mode = Teuchos::NO_TRANS,
333 scalar_type alpha = Teuchos::ScalarTraits<scalar_type>::one(),
334 scalar_type beta = Teuchos::ScalarTraits<scalar_type>::zero()) const;
335
337 virtual bool hasTransposeApply() const;
338
339 virtual void
340 importMultiVector (const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &X,
341 Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &OvX,
342 Tpetra::CombineMode CM = Tpetra::INSERT);
343
344 virtual void
345 exportMultiVector (const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &OvX,
346 Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &X,
347 Tpetra::CombineMode CM = Tpetra::ADD);
348
349 std::string description() const;
350
351 void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const;
352
353 Teuchos::RCP<const crs_matrix_type> getUnderlyingMatrix() const;
354
355 Teuchos::RCP<const crs_matrix_type> getExtMatrix() const;
356
357 Kokkos::View<size_t*, typename OverlappingRowMatrix<MatrixType>::device_type> getExtHaloStarts() const;
358 typename Kokkos::View<size_t*, typename OverlappingRowMatrix<MatrixType>::device_type>::HostMirror getExtHaloStartsHost() const;
359
360 void doExtImport();
361
362private:
363 typedef Tpetra::Map<local_ordinal_type, global_ordinal_type, node_type> map_type;
364 typedef Tpetra::Import<local_ordinal_type, global_ordinal_type, node_type> import_type;
365 typedef Tpetra::Export<local_ordinal_type, global_ordinal_type, node_type> export_type;
366 typedef Tpetra::RowGraph<local_ordinal_type, global_ordinal_type, node_type> row_graph_type;
367 typedef Tpetra::Vector<scalar_type, local_ordinal_type, global_ordinal_type, node_type> vector_type;
368
370 Teuchos::RCP<const crs_matrix_type> A_;
371
372 Tpetra::global_size_t NumGlobalRows_;
373 Tpetra::global_size_t NumGlobalNonzeros_;
374 size_t MaxNumEntries_;
375 int OverlapLevel_;
376
377 // Wrapper matrix objects
378 Teuchos::RCP<const map_type> RowMap_;
379 Teuchos::RCP<const map_type> ColMap_;
380 Teuchos::RCP<const import_type> Importer_;
381
383 Teuchos::RCP<crs_matrix_type> ExtMatrix_;
384 Teuchos::RCP<const map_type> ExtMap_;
385 Teuchos::RCP<const import_type> ExtImporter_;
386 Kokkos::View<size_t*, device_type> ExtHaloStarts_;
387 typename Kokkos::View<size_t*, device_type>::HostMirror ExtHaloStarts_h;
388
390 Teuchos::RCP<const row_graph_type> graph_;
392 mutable nonconst_local_inds_host_view_type Indices_;
394 mutable nonconst_values_host_view_type Values_;
395
396
397}; // class OverlappingRowMatrix
398
399} // namespace Ifpack2
400
401#endif // IFPACK2_OVERLAPPINGROWMATRIX_DECL_HPP
All Ifpack2 implementations of Tpetra::RowMatrix must inherit from this class.
Definition Ifpack2_Details_RowMatrix.hpp:67
Sparse matrix (Tpetra::RowMatrix subclass) with ghost rows.
Definition Ifpack2_OverlappingRowMatrix_decl.hpp:59
virtual void apply(const Tpetra::MultiVector< scalar_type, local_ordinal_type, global_ordinal_type, node_type > &X, Tpetra::MultiVector< scalar_type, local_ordinal_type, global_ordinal_type, node_type > &Y, Teuchos::ETransp mode=Teuchos::NO_TRANS, scalar_type alpha=Teuchos::ScalarTraits< scalar_type >::one(), scalar_type beta=Teuchos::ScalarTraits< scalar_type >::zero()) const
Computes the operator-multivector application.
Definition Ifpack2_OverlappingRowMatrix_def.hpp:541
virtual bool hasTransposeApply() const
Whether this operator's apply() method can apply the adjoint (transpose).
Definition Ifpack2_OverlappingRowMatrix_def.hpp:599
virtual Teuchos::RCP< const Tpetra::Map< local_ordinal_type, global_ordinal_type, node_type > > getRangeMap() const
The Map that describes the range of this matrix.
Definition Ifpack2_OverlappingRowMatrix_def.hpp:279
virtual void getLocalRowCopy(local_ordinal_type LocalRow, nonconst_local_inds_host_view_type &Indices, nonconst_values_host_view_type &Values, size_t &NumEntries) const
Extract a list of entries in a specified local row of the graph. Put into storage allocated by callin...
Definition Ifpack2_OverlappingRowMatrix_def.hpp:428
virtual bool isLocallyIndexed() const
Whether this matrix is locally indexed.
Definition Ifpack2_OverlappingRowMatrix_def.hpp:394
virtual size_t getNumEntriesInGlobalRow(global_ordinal_type globalRow) const
The number of entries in the given global row that are owned by the calling process.
Definition Ifpack2_OverlappingRowMatrix_def.hpp:346
virtual void getLocalRowView(local_ordinal_type LocalRow, local_inds_host_view_type &indices, values_host_view_type &values) const
Extract a const, non-persisting view of local indices in a specified row of the matrix.
Definition Ifpack2_OverlappingRowMatrix_def.hpp:465
virtual void getGlobalRowCopy(global_ordinal_type GlobalRow, nonconst_global_inds_host_view_type &Indices, nonconst_values_host_view_type &Values, size_t &NumEntries) const
Extract a list of entries in a specified global row of this matrix. Put into pre-allocated storage.
Definition Ifpack2_OverlappingRowMatrix_def.hpp:417
virtual Teuchos::RCP< const Tpetra::Map< local_ordinal_type, global_ordinal_type, node_type > > getColMap() const
The Map that describes the distribution of columns over processes.
Definition Ifpack2_OverlappingRowMatrix_def.hpp:254
~OverlappingRowMatrix()=default
Destructor.
virtual size_t getGlobalMaxNumRowEntries() const
The maximum number of entries in any row on any process.
Definition Ifpack2_OverlappingRowMatrix_def.hpp:373
virtual global_size_t getGlobalNumCols() const
The global number of columns in this matrix.
Definition Ifpack2_OverlappingRowMatrix_def.hpp:301
virtual bool isGloballyIndexed() const
Whether this matrix is globally indexed.
Definition Ifpack2_OverlappingRowMatrix_def.hpp:401
virtual global_ordinal_type getIndexBase() const
The index base for global indices for this matrix.
Definition Ifpack2_OverlappingRowMatrix_def.hpp:323
virtual size_t getLocalNumEntries() const
The number of entries in this matrix owned by the calling process.
Definition Ifpack2_OverlappingRowMatrix_def.hpp:337
virtual Teuchos::RCP< const Tpetra::RowGraph< local_ordinal_type, global_ordinal_type, node_type > > getGraph() const
This matrix's graph.
Definition Ifpack2_OverlappingRowMatrix_def.hpp:287
virtual size_t getLocalNumCols() const
The number of columns owned by the calling process.
Definition Ifpack2_OverlappingRowMatrix_def.hpp:315
virtual size_t getLocalNumRows() const
The number of rows owned by the calling process.
Definition Ifpack2_OverlappingRowMatrix_def.hpp:308
virtual void getGlobalRowView(global_ordinal_type GlobalRow, global_inds_host_view_type &indices, values_host_view_type &values) const
Extract a const, non-persisting view of global indices in a specified row of the matrix.
Definition Ifpack2_OverlappingRowMatrix_def.hpp:446
virtual size_t getNumEntriesInLocalRow(local_ordinal_type localRow) const
The number of entries in the given local row that are owned by the calling process.
Definition Ifpack2_OverlappingRowMatrix_def.hpp:360
virtual void rightScale(const Tpetra::Vector< scalar_type, local_ordinal_type, global_ordinal_type, node_type > &x)
Scales the RowMatrix on the right with the Vector x.
Definition Ifpack2_OverlappingRowMatrix_def.hpp:524
virtual bool hasColMap() const
Whether this matrix has a column Map.
Definition Ifpack2_OverlappingRowMatrix_def.hpp:387
virtual Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
The communicator over which the matrix is distributed.
Definition Ifpack2_OverlappingRowMatrix_def.hpp:235
virtual global_size_t getGlobalNumRows() const
The global number of rows in this matrix.
Definition Ifpack2_OverlappingRowMatrix_def.hpp:294
virtual bool supportsRowViews() const
true if row views are supported, else false.
Definition Ifpack2_OverlappingRowMatrix_def.hpp:606
virtual global_size_t getGlobalNumEntries() const
The global number of entries in this matrix.
Definition Ifpack2_OverlappingRowMatrix_def.hpp:330
virtual Teuchos::RCP< const Tpetra::Map< local_ordinal_type, global_ordinal_type, node_type > > getRowMap() const
The Map that describes the distribution of rows over processes.
Definition Ifpack2_OverlappingRowMatrix_def.hpp:245
virtual void leftScale(const Tpetra::Vector< scalar_type, local_ordinal_type, global_ordinal_type, node_type > &x)
Scales the RowMatrix on the left with the Vector x.
Definition Ifpack2_OverlappingRowMatrix_def.hpp:515
OverlappingRowMatrix(const Teuchos::RCP< const row_matrix_type > &A, const int overlapLevel)
Definition Ifpack2_OverlappingRowMatrix_def.hpp:59
virtual size_t getLocalMaxNumRowEntries() const
The maximum number of entries in any row on the calling process.
Definition Ifpack2_OverlappingRowMatrix_def.hpp:380
virtual bool isFillComplete() const
true if fillComplete() has been called, else false.
Definition Ifpack2_OverlappingRowMatrix_def.hpp:408
virtual mag_type getFrobeniusNorm() const
Returns the Frobenius norm of the matrix.
Definition Ifpack2_OverlappingRowMatrix_def.hpp:532
virtual void getLocalDiagCopy(Tpetra::Vector< scalar_type, local_ordinal_type, global_ordinal_type, node_type > &diag) const
Get a copy of the diagonal entries owned by this node, with local row indices.
Definition Ifpack2_OverlappingRowMatrix_def.hpp:482
virtual Teuchos::RCP< const Tpetra::Map< local_ordinal_type, global_ordinal_type, node_type > > getDomainMap() const
The Map that describes the domain of this matrix.
Definition Ifpack2_OverlappingRowMatrix_def.hpp:263
Preconditioners and smoothers for Tpetra sparse matrices.
Definition Ifpack2_AdditiveSchwarz_decl.hpp:74