Ifpack2 Templated Preconditioning Package Version 1.0
Loading...
Searching...
No Matches
Ifpack2_Details_AdditiveSchwarzFilter_decl.hpp
1
2// @HEADER
3// *****************************************************************************
4// Ifpack2: Templated Object-Oriented Algebraic Preconditioner Package
5//
6// Copyright 2009 NTESS and the Ifpack2 contributors.
7// SPDX-License-Identifier: BSD-3-Clause
8// *****************************************************************************
9// @HEADER
10
11#ifndef IFPACK2_ADDITIVE_SCHWARZ_FILTER_DECL_HPP
12#define IFPACK2_ADDITIVE_SCHWARZ_FILTER_DECL_HPP
13
20
21#include "Ifpack2_ConfigDefs.hpp"
22#include "Ifpack2_Details_RowMatrix.hpp"
23#include "Ifpack2_OverlappingRowMatrix.hpp"
24
25namespace Ifpack2
26{
27namespace Details
28{
29 template<typename MatrixType>
31 public Ifpack2::Details::RowMatrix<MatrixType> {
32public:
33 typedef typename MatrixType::scalar_type scalar_type;
34 typedef typename Kokkos::ArithTraits<scalar_type>::val_type impl_scalar_type;
35 typedef typename MatrixType::local_ordinal_type local_ordinal_type;
36 typedef typename MatrixType::global_ordinal_type global_ordinal_type;
37 typedef typename MatrixType::node_type node_type;
38 typedef typename MatrixType::global_inds_host_view_type global_inds_host_view_type;
39 typedef typename MatrixType::local_inds_host_view_type local_inds_host_view_type;
40 typedef typename MatrixType::values_host_view_type values_host_view_type;
41
42 typedef typename MatrixType::nonconst_global_inds_host_view_type nonconst_global_inds_host_view_type;
43 typedef typename MatrixType::nonconst_local_inds_host_view_type nonconst_local_inds_host_view_type;
44 typedef typename MatrixType::nonconst_values_host_view_type nonconst_values_host_view_type;
45
46 typedef typename Teuchos::ScalarTraits<scalar_type>::magnitudeType magnitude_type;
47 typedef Tpetra::RowMatrix<scalar_type,
48 local_ordinal_type,
49 global_ordinal_type,
50 node_type> row_matrix_type;
51 typedef Tpetra::CrsMatrix<scalar_type,
52 local_ordinal_type,
53 global_ordinal_type,
54 node_type> crs_matrix_type;
55 typedef Tpetra::MultiVector<scalar_type,
56 local_ordinal_type,
57 global_ordinal_type,
58 node_type> mv_type;
59 typedef typename crs_matrix_type::device_type device_type;
60 typedef typename crs_matrix_type::execution_space execution_space;
61 typedef Kokkos::RangePolicy<execution_space> policy_type;
62 typedef Kokkos::MDRangePolicy<execution_space, Kokkos::Rank<2>> policy_2d_type;
63 typedef Ifpack2::OverlappingRowMatrix<row_matrix_type> overlapping_matrix_type;
64 typedef typename crs_matrix_type::local_matrix_device_type local_matrix_type;
65 typedef typename local_matrix_type::size_type size_type;
66 typedef typename local_matrix_type::row_map_type::non_const_type row_map_type;
67 typedef typename local_matrix_type::index_type entries_type;
68 typedef typename local_matrix_type::values_type values_type;
69 typedef typename row_map_type::HostMirror host_row_map_type;
70 typedef typename entries_type::HostMirror host_entries_type;
71 typedef typename values_type::HostMirror host_values_type;
72 typedef typename local_matrix_type::HostMirror host_local_matrix_type;
73
74 static_assert(std::is_same<MatrixType, row_matrix_type>::value, "Ifpack2::AdditiveSchwarzFilter: 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.");
75
76 typedef Tpetra::Map<local_ordinal_type,
77 global_ordinal_type,
78 node_type> map_type;
79
80 typedef typename row_matrix_type::mag_type mag_type;
81
83
84
88 // Must be a Tpetra::CrsMatrix or an Ifpack2::OverlappingRowMatrix that wraps a Tpetra::CrsMatrix.
102 AdditiveSchwarzFilter(const Teuchos::RCP<const row_matrix_type>& A,
103 const Teuchos::ArrayRCP<local_ordinal_type>& perm,
104 const Teuchos::ArrayRCP<local_ordinal_type>& reverseperm,
105 bool filterSingletons);
106
108 void updateMatrixValues();
109
110 Teuchos::RCP<const crs_matrix_type> getFilteredMatrix() const;
111
113 virtual ~AdditiveSchwarzFilter ();
114
116
118
120 virtual Teuchos::RCP<const Teuchos::Comm<int> > getComm() const;
121
123 virtual Teuchos::RCP<const map_type> getRowMap() const;
124
126 virtual Teuchos::RCP<const map_type> getColMap() const;
127
129 virtual Teuchos::RCP<const map_type> getDomainMap() const;
130
132 virtual Teuchos::RCP<const map_type> getRangeMap() const;
133
135 virtual Teuchos::RCP<const Tpetra::RowGraph<local_ordinal_type,global_ordinal_type,node_type> > getGraph() const;
136
138 virtual local_ordinal_type getBlockSize() const;
139
141 virtual global_size_t getGlobalNumRows() const;
142
144 virtual global_size_t getGlobalNumCols() const;
145
147 virtual size_t getLocalNumRows() const;
148
150 virtual size_t getLocalNumCols() const;
151
153 virtual global_ordinal_type getIndexBase() const;
154
156 virtual global_size_t getGlobalNumEntries() const;
157
159 virtual size_t getLocalNumEntries() const;
160
167 virtual size_t getNumEntriesInGlobalRow (global_ordinal_type globalRow) const;
168
175 virtual size_t getNumEntriesInLocalRow (local_ordinal_type localRow) const;
176
178 virtual size_t getGlobalMaxNumRowEntries() const;
179
181 virtual size_t getLocalMaxNumRowEntries() const;
182
184 virtual bool hasColMap() const;
185
187 virtual bool isLocallyIndexed() const;
188
190 virtual bool isGloballyIndexed() const;
191
193 virtual bool isFillComplete() const;
194
196 virtual bool supportsRowViews() const;
197
199
201
202
204
214 virtual void
215 getGlobalRowCopy (global_ordinal_type GlobalRow,
216 nonconst_global_inds_host_view_type &Indices,
217 nonconst_values_host_view_type &Values,
218 size_t& NumEntries) const;
220
230 virtual void
231 getLocalRowCopy (local_ordinal_type LocalRow,
232 nonconst_local_inds_host_view_type &Indices,
233 nonconst_values_host_view_type &Values,
234 size_t& NumEntries) const;
235
237
245 virtual void
246 getGlobalRowView (global_ordinal_type GlobalRow,
247 global_inds_host_view_type &indices,
248 values_host_view_type &values) const;
250
259 virtual void
260 getLocalRowView (local_ordinal_type LocalRow,
261 local_inds_host_view_type & indices,
262 values_host_view_type & values) const;
264
266 virtual void getLocalDiagCopy(Tpetra::Vector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &diag) const;
267
269
271
272
282 virtual void leftScale(const Tpetra::Vector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& x);
283
293 virtual void rightScale(const Tpetra::Vector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& x);
294
296
299 virtual mag_type getFrobeniusNorm() const;
300
322 virtual void
323 apply (const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &X,
324 Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &Y,
325 Teuchos::ETransp mode = Teuchos::NO_TRANS,
326 scalar_type alpha = Teuchos::ScalarTraits<scalar_type>::one(),
327 scalar_type beta = Teuchos::ScalarTraits<scalar_type>::zero()) const;
328
330 virtual bool hasTransposeApply() const;
331
333 void CreateReducedProblem(
334 const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& OverlappingB,
335 Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& OverlappingY,
336 Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& ReducedReorderedB) const;
337
339 void UpdateLHS(
340 const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& ReducedReorderedY,
341 Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& OverlappingY) const;
342
343 void setup(const Teuchos::RCP<const row_matrix_type>& A_unfiltered,
344 const Teuchos::ArrayRCP<local_ordinal_type>& perm,
345 const Teuchos::ArrayRCP<local_ordinal_type>& reverseperm,
346 bool filterSingletons);
347
352 void fillLocalMatrix(local_matrix_type localMatrix);
353
355
356private:
357
370 static bool
371 mapPairIsFitted (const map_type& map1, const map_type& map2);
372
376 // If both pairs of Maps of the original matrix A are fitted on this
377 // process, then this process can use a fast "view" implementation.
378 static bool
379 mapPairsAreFitted (const row_matrix_type& A);
380
382 Teuchos::RCP<const row_matrix_type> A_unfiltered_;
384 Teuchos::RCP<crs_matrix_type> A_;
386 Kokkos::DualView<local_ordinal_type*, device_type> perm_;
388 Kokkos::DualView<local_ordinal_type*, device_type> reverseperm_;
389 local_ordinal_type numSingletons_;
391 Kokkos::DualView<local_ordinal_type*, device_type> singletons_;
393 Kokkos::DualView<impl_scalar_type*, device_type> singletonDiagonals_;
394
396 // (apply and solve still process those rows separately)
397 bool FilterSingletons_;
398
400 Teuchos::RCP<const map_type> localMap_;
401};
402
403}} //namespace Ifpack2::Details
404
405#endif
Wraps a Tpetra::CrsMatrix or Ifpack2::OverlappingRowMatrix in a filter that removes off-process edges...
All Ifpack2 implementations of Tpetra::RowMatrix must inherit from this class.
Definition Ifpack2_Details_RowMatrix.hpp:34
Sparse matrix (Tpetra::RowMatrix subclass) with ghost rows.
Definition Ifpack2_OverlappingRowMatrix_decl.hpp:26
Ifpack2 implementation details.
Preconditioners and smoothers for Tpetra sparse matrices.
Definition Ifpack2_AdditiveSchwarz_decl.hpp:41