Ifpack2 Templated Preconditioning Package Version 1.0
Loading...
Searching...
No Matches
Ifpack2_LocalFilter_decl.hpp
1// @HEADER
2// *****************************************************************************
3// Ifpack2: Templated Object-Oriented Algebraic Preconditioner Package
4//
5// Copyright 2009 NTESS and the Ifpack2 contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
10#ifndef IFPACK2_LOCALFILTER_DECL_HPP
11#define IFPACK2_LOCALFILTER_DECL_HPP
12
13#include "Ifpack2_ConfigDefs.hpp"
14#include "Ifpack2_Details_RowMatrix.hpp"
15#include "Tpetra_CrsGraph.hpp"
16#include <type_traits>
17#include <vector>
18
19
20namespace Ifpack2 {
21
127template<class MatrixType>
129 virtual public Ifpack2::Details::RowMatrix<MatrixType>,
130 virtual public Teuchos::Describable
131{
132private:
133 // Tpetra needs C++11 now because Kokkos needs C++11 now.
134 // Thus, Ifpack2 needs C++11.
135 static_assert (std::is_same<
136 MatrixType,
137 Tpetra::RowMatrix<
138 typename MatrixType::scalar_type,
139 typename MatrixType::local_ordinal_type,
140 typename MatrixType::global_ordinal_type,
141 typename MatrixType::node_type> >::value,
142 "Ifpack2::LocalFilter: MatrixType must be a Tpetra::RowMatrix specialization.");
143
144public:
146
147
149 typedef typename MatrixType::scalar_type scalar_type;
150
152 typedef typename MatrixType::local_ordinal_type local_ordinal_type;
153
155 typedef typename MatrixType::global_ordinal_type global_ordinal_type;
156
158 typedef typename MatrixType::node_type node_type;
159
160
161 typedef typename MatrixType::global_inds_host_view_type global_inds_host_view_type;
162 typedef typename MatrixType::local_inds_host_view_type local_inds_host_view_type;
163 typedef typename MatrixType::values_host_view_type values_host_view_type;
164
165 typedef typename MatrixType::nonconst_global_inds_host_view_type nonconst_global_inds_host_view_type;
166 typedef typename MatrixType::nonconst_local_inds_host_view_type nonconst_local_inds_host_view_type;
167 typedef typename MatrixType::nonconst_values_host_view_type nonconst_values_host_view_type;
168
169
171 typedef typename Teuchos::ScalarTraits<scalar_type>::magnitudeType magnitude_type;
172
173
174
176 typedef Tpetra::RowMatrix<scalar_type,
180
182 typedef Tpetra::RowGraph<local_ordinal_type,
185
187 typedef Tpetra::Map<local_ordinal_type,
190
191 typedef typename row_matrix_type::mag_type mag_type;
192
194
196
198 virtual std::string description () const;
199
201 virtual void
202 describe (Teuchos::FancyOStream &out,
203 const Teuchos::EVerbosityLevel verbLevel =
204 Teuchos::Describable::verbLevel_default) const;
205
207
209
215 explicit LocalFilter (const Teuchos::RCP<const row_matrix_type>& A);
216
218 virtual ~LocalFilter();
219
221
223
225 virtual Teuchos::RCP<const Teuchos::Comm<int> > getComm() const;
226
227
229 virtual Teuchos::RCP<const map_type> getRowMap() const;
230
232 virtual Teuchos::RCP<const map_type> getColMap() const;
233
235 virtual Teuchos::RCP<const map_type> getDomainMap() const;
236
238 virtual Teuchos::RCP<const map_type> getRangeMap() const;
239
241 virtual Teuchos::RCP<const Tpetra::RowGraph<local_ordinal_type,global_ordinal_type,node_type> >
242 getGraph () const;
243
245 virtual global_size_t getGlobalNumRows() const;
246
248 virtual global_size_t getGlobalNumCols() const;
249
251 virtual size_t getLocalNumRows() const;
252
254 virtual size_t getLocalNumCols() const;
255
258
260 virtual global_size_t getGlobalNumEntries() const;
261
263 virtual size_t getLocalNumEntries() const;
264
267
273 virtual size_t getNumEntriesInGlobalRow (global_ordinal_type globalRow) const;
274
280 virtual size_t getNumEntriesInLocalRow (local_ordinal_type localRow) const;
281
283 virtual size_t getGlobalMaxNumRowEntries() const;
284
286 virtual size_t getLocalMaxNumRowEntries() const;
287
289 virtual bool hasColMap() const;
290
292 virtual bool isLocallyIndexed() const;
293
295 virtual bool isGloballyIndexed() const;
296
298 virtual bool isFillComplete() const;
299
301 virtual bool supportsRowViews() const;
302
304
306
320 virtual void
322 nonconst_global_inds_host_view_type &Indices,
323 nonconst_values_host_view_type &Values,
324 size_t& NumEntries) const;
325
339 virtual void
341 nonconst_local_inds_host_view_type &Indices,
342 nonconst_values_host_view_type &Values,
343 size_t& NumEntries) const;
344
346
356 virtual void
358 global_inds_host_view_type &indices,
359 values_host_view_type &values) const;
360
362
372 virtual void
374 local_inds_host_view_type & indices,
375 values_host_view_type & values) const;
376
383 virtual void
384 getLocalDiagCopy (Tpetra::Vector<scalar_type, local_ordinal_type, global_ordinal_type, node_type> &diag) const;
385
387
389
399 virtual void leftScale(const Tpetra::Vector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& x);
400
410 virtual void rightScale(const Tpetra::Vector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& x);
411
420 virtual mag_type getFrobeniusNorm() const;
421
428 virtual void
429 apply (const Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type> &X,
430 Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type> &Y,
431 Teuchos::ETransp mode = Teuchos::NO_TRANS,
432 scalar_type alpha = Teuchos::ScalarTraits<scalar_type>::one(),
433 scalar_type beta = Teuchos::ScalarTraits<scalar_type>::zero()) const;
434
436 virtual bool hasTransposeApply() const;
437
439 virtual Teuchos::RCP<const row_matrix_type> getUnderlyingMatrix() const;
440
442private:
444 typedef Tpetra::CrsGraph<local_ordinal_type,
446 node_type> crs_graph_type;
447
449 void
450 applyNonAliased (const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &X,
451 Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &Y,
452 Teuchos::ETransp mode,
453 scalar_type alpha,
454 scalar_type beta) const;
455
468 static bool
469 mapPairIsFitted (const map_type& map1, const map_type& map2);
470
474 // If both pairs of Maps of the original matrix A are fitted on this
475 // process, then this process can use a fast "view" implementation.
476 static bool
477 mapPairsAreFitted (const row_matrix_type& A);
478
480 Teuchos::RCP<const row_matrix_type> A_;
481
483 Teuchos::RCP<const map_type> localRowMap_;
484
486 Teuchos::RCP<const map_type> localDomainMap_;
487
489 Teuchos::RCP<const map_type> localRangeMap_;
490
492 mutable Teuchos::RCP<const row_graph_type> local_graph_;
493
495 size_t NumNonzeros_;
497 size_t MaxNumEntries_;
499 size_t MaxNumEntriesA_;
501 std::vector<size_t> NumEntries_;
502
504 mutable nonconst_local_inds_host_view_type localIndices_;
505 mutable nonconst_local_inds_host_view_type localIndicesForGlobalCopy_;
507 mutable nonconst_values_host_view_type Values_;
508
509};// class LocalFilter
510
511}// namespace Ifpack2
512
513#endif /* IFPACK2_LOCALFILTER_DECL_HPP */
All Ifpack2 implementations of Tpetra::RowMatrix must inherit from this class.
Definition Ifpack2_Details_RowMatrix.hpp:34
virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Print the object to the given output stream.
Definition Ifpack2_LocalFilter_def.hpp:886
virtual Teuchos::RCP< const Tpetra::RowGraph< local_ordinal_type, global_ordinal_type, node_type > > getGraph() const
The (locally filtered) matrix's graph.
Definition Ifpack2_LocalFilter_def.hpp:259
virtual Teuchos::RCP< const map_type > getDomainMap() const
Returns the Map that describes the domain distribution in this matrix.
Definition Ifpack2_LocalFilter_def.hpp:239
virtual size_t getGlobalMaxNumRowEntries() const
The maximum number of entries across all rows/columns on all processes.
Definition Ifpack2_LocalFilter_def.hpp:384
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_LocalFilter_def.hpp:621
virtual void getGlobalRowCopy(global_ordinal_type GlobalRow, nonconst_global_inds_host_view_type &Indices, nonconst_values_host_view_type &Values, size_t &NumEntries) const
Get the entries in the given row, using global indices.
Definition Ifpack2_LocalFilter_def.hpp:428
Tpetra::RowMatrix< scalar_type, local_ordinal_type, global_ordinal_type, node_type > row_matrix_type
Definition Ifpack2_LocalFilter_decl.hpp:179
Teuchos::ScalarTraits< scalar_type >::magnitudeType magnitude_type
Definition Ifpack2_LocalFilter_decl.hpp:171
virtual bool isGloballyIndexed() const
Whether the underlying sparse matrix is globally (opposite of locally) indexed.
Definition Ifpack2_LocalFilter_def.hpp:412
virtual Teuchos::RCP< const row_matrix_type > getUnderlyingMatrix() const
Return matrix that LocalFilter was built on.
Definition Ifpack2_LocalFilter_def.hpp:926
TRowMatrix::scalar_type scalar_type
Definition Ifpack2_LocalFilter_decl.hpp:149
virtual Teuchos::RCP< const map_type > getRangeMap() const
Returns the Map that describes the range distribution in this matrix.
Definition Ifpack2_LocalFilter_def.hpp:249
virtual mag_type getFrobeniusNorm() const
The Frobenius norm of the (locally filtered) matrix.
Definition Ifpack2_LocalFilter_def.hpp:839
virtual size_t getNumEntriesInGlobalRow(global_ordinal_type globalRow) const
The current number of entries on this node in the specified global row.
Definition Ifpack2_LocalFilter_def.hpp:344
TRowMatrix::node_type node_type
Definition Ifpack2_LocalFilter_decl.hpp:158
virtual global_size_t getGlobalNumCols() const
The number of global columns in this matrix.
Definition Ifpack2_LocalFilter_def.hpp:294
virtual bool hasColMap() const
Whether this matrix has a well-defined column Map.
Definition Ifpack2_LocalFilter_def.hpp:398
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_LocalFilter_def.hpp:582
TRowMatrix::global_ordinal_type global_ordinal_type
Definition Ifpack2_LocalFilter_decl.hpp:155
virtual bool isFillComplete() const
Returns true if fillComplete() has been called.
Definition Ifpack2_LocalFilter_def.hpp:419
virtual bool isLocallyIndexed() const
Whether the underlying sparse matrix is locally (opposite of globally) indexed.
Definition Ifpack2_LocalFilter_def.hpp:405
virtual size_t getLocalNumCols() const
The number of columns in the (locally filtered) matrix.
Definition Ifpack2_LocalFilter_def.hpp:308
virtual Teuchos::RCP< const map_type > getColMap() const
Returns the Map that describes the column distribution in this matrix.
Definition Ifpack2_LocalFilter_def.hpp:229
virtual bool hasTransposeApply() const
Whether this operator supports applying the transpose or conjugate transpose.
Definition Ifpack2_LocalFilter_def.hpp:823
virtual void getLocalDiagCopy(Tpetra::Vector< scalar_type, local_ordinal_type, global_ordinal_type, node_type > &diag) const
Get the diagonal entries of the (locally filtered) matrix.
Definition Ifpack2_LocalFilter_def.hpp:606
virtual size_t getLocalMaxNumRowEntries() const
The maximum number of entries across all rows/columns on this process.
Definition Ifpack2_LocalFilter_def.hpp:391
LocalFilter(const Teuchos::RCP< const row_matrix_type > &A)
Constructor.
Definition Ifpack2_LocalFilter_def.hpp:65
virtual global_ordinal_type getIndexBase() const
Returns the index base for global indices for this matrix.
Definition Ifpack2_LocalFilter_def.hpp:316
virtual bool supportsRowViews() const
Returns true if RowViews are supported.
Definition Ifpack2_LocalFilter_def.hpp:830
virtual std::string description() const
A one-line description of this object.
Definition Ifpack2_LocalFilter_def.hpp:866
virtual global_size_t getGlobalNumEntries() const
Returns the global number of entries in this matrix.
Definition Ifpack2_LocalFilter_def.hpp:323
virtual local_ordinal_type getBlockSize() const
The number of degrees of freedom per mesh point.
Definition Ifpack2_LocalFilter_def.hpp:336
virtual ~LocalFilter()
Destructor.
Definition Ifpack2_LocalFilter_def.hpp:201
virtual size_t getLocalNumRows() const
The number of rows owned on the calling process.
Definition Ifpack2_LocalFilter_def.hpp:301
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
Compute Y = beta*Y + alpha*A_local*X.
Definition Ifpack2_LocalFilter_def.hpp:641
TRowMatrix::local_ordinal_type local_ordinal_type
Definition Ifpack2_LocalFilter_decl.hpp:152
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_LocalFilter_def.hpp:631
virtual void getLocalRowCopy(local_ordinal_type LocalRow, nonconst_local_inds_host_view_type &Indices, nonconst_values_host_view_type &Values, size_t &NumEntries) const
Get the entries in the given row, using local indices.
Definition Ifpack2_LocalFilter_def.hpp:473
virtual size_t getNumEntriesInLocalRow(local_ordinal_type localRow) const
The current number of entries on this node in the specified local row.
Definition Ifpack2_LocalFilter_def.hpp:363
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_LocalFilter_def.hpp:594
virtual global_size_t getGlobalNumRows() const
The number of global rows in this matrix.
Definition Ifpack2_LocalFilter_def.hpp:287
Tpetra::Map< local_ordinal_type, global_ordinal_type, node_type > map_type
Definition Ifpack2_LocalFilter_decl.hpp:189
virtual size_t getLocalNumEntries() const
Returns the local number of entries in this matrix.
Definition Ifpack2_LocalFilter_def.hpp:330
Tpetra::RowGraph< local_ordinal_type, global_ordinal_type, node_type > row_graph_type
Definition Ifpack2_LocalFilter_decl.hpp:184
virtual Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
Returns the communicator.
Definition Ifpack2_LocalFilter_def.hpp:207
virtual Teuchos::RCP< const map_type > getRowMap() const
Returns the Map that describes the row distribution in this matrix.
Definition Ifpack2_LocalFilter_def.hpp:219
Preconditioners and smoothers for Tpetra sparse matrices.
Definition Ifpack2_AdditiveSchwarz_decl.hpp:41