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
21#include "Ifpack2_ConfigDefs.hpp"
22#include "Ifpack2_Details_RowMatrix.hpp"
23#include "Ifpack2_OverlappingRowMatrix.hpp"
24
25namespace Ifpack2 {
26namespace Details {
27template <typename MatrixType>
28class AdditiveSchwarzFilter : public Ifpack2::Details::RowMatrix<MatrixType> {
29 public:
30 typedef typename MatrixType::scalar_type scalar_type;
31#if KOKKOS_VERSION >= 40799
32 typedef typename KokkosKernels::ArithTraits<scalar_type>::val_type impl_scalar_type;
33#else
34 typedef typename Kokkos::ArithTraits<scalar_type>::val_type impl_scalar_type;
35#endif
36 typedef typename MatrixType::local_ordinal_type local_ordinal_type;
37 typedef typename MatrixType::global_ordinal_type global_ordinal_type;
38 typedef typename MatrixType::node_type node_type;
39 typedef typename MatrixType::global_inds_host_view_type global_inds_host_view_type;
40 typedef typename MatrixType::local_inds_host_view_type local_inds_host_view_type;
41 typedef typename MatrixType::values_host_view_type values_host_view_type;
42
43 typedef typename MatrixType::nonconst_global_inds_host_view_type nonconst_global_inds_host_view_type;
44 typedef typename MatrixType::nonconst_local_inds_host_view_type nonconst_local_inds_host_view_type;
45 typedef typename MatrixType::nonconst_values_host_view_type nonconst_values_host_view_type;
46
47 typedef typename Teuchos::ScalarTraits<scalar_type>::magnitudeType magnitude_type;
48 typedef Tpetra::RowMatrix<scalar_type,
49 local_ordinal_type,
50 global_ordinal_type,
51 node_type>
52 row_matrix_type;
53 typedef Tpetra::CrsMatrix<scalar_type,
54 local_ordinal_type,
55 global_ordinal_type,
56 node_type>
57 crs_matrix_type;
58 typedef Tpetra::MultiVector<scalar_type,
59 local_ordinal_type,
60 global_ordinal_type,
61 node_type>
62 mv_type;
63 typedef typename crs_matrix_type::device_type device_type;
64 typedef typename crs_matrix_type::execution_space execution_space;
65 typedef Kokkos::RangePolicy<execution_space> policy_type;
66 typedef Kokkos::MDRangePolicy<execution_space, Kokkos::Rank<2>> policy_2d_type;
67 typedef Ifpack2::OverlappingRowMatrix<row_matrix_type> overlapping_matrix_type;
68 typedef typename crs_matrix_type::local_matrix_device_type local_matrix_type;
69 typedef typename local_matrix_type::size_type size_type;
70 typedef typename local_matrix_type::row_map_type::non_const_type row_map_type;
71 typedef typename local_matrix_type::index_type entries_type;
72 typedef typename local_matrix_type::values_type values_type;
73 typedef typename row_map_type::host_mirror_type host_row_map_type;
74 typedef typename entries_type::host_mirror_type host_entries_type;
75 typedef typename values_type::host_mirror_type host_values_type;
76#if KOKKOS_VERSION >= 40799
77 typedef typename local_matrix_type::host_mirror_type host_local_matrix_type;
78#else
79 typedef typename local_matrix_type::HostMirror host_local_matrix_type;
80#endif
81
82 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.");
83
84 typedef Tpetra::Map<local_ordinal_type,
85 global_ordinal_type,
86 node_type>
87 map_type;
88
89 typedef typename row_matrix_type::mag_type mag_type;
90
92
93
97 // Must be a Tpetra::CrsMatrix or an Ifpack2::OverlappingRowMatrix that wraps a Tpetra::CrsMatrix.
111 AdditiveSchwarzFilter(const Teuchos::RCP<const row_matrix_type>& A,
112 const Teuchos::ArrayRCP<local_ordinal_type>& perm,
113 const Teuchos::ArrayRCP<local_ordinal_type>& reverseperm,
114 bool filterSingletons);
115
117 void updateMatrixValues();
118
119 Teuchos::RCP<const crs_matrix_type> getFilteredMatrix() const;
120
122 virtual ~AdditiveSchwarzFilter();
123
125
127
129 virtual Teuchos::RCP<const Teuchos::Comm<int>> getComm() const;
130
132 virtual Teuchos::RCP<const map_type> getRowMap() const;
133
135 virtual Teuchos::RCP<const map_type> getColMap() const;
136
138 virtual Teuchos::RCP<const map_type> getDomainMap() const;
139
141 virtual Teuchos::RCP<const map_type> getRangeMap() const;
142
144 virtual Teuchos::RCP<const Tpetra::RowGraph<local_ordinal_type, global_ordinal_type, node_type>> getGraph() const;
145
147 virtual local_ordinal_type getBlockSize() const;
148
150 virtual global_size_t getGlobalNumRows() const;
151
153 virtual global_size_t getGlobalNumCols() const;
154
156 virtual size_t getLocalNumRows() const;
157
159 virtual size_t getLocalNumCols() const;
160
162 virtual global_ordinal_type getIndexBase() const;
163
165 virtual global_size_t getGlobalNumEntries() const;
166
168 virtual size_t getLocalNumEntries() const;
169
176 virtual size_t getNumEntriesInGlobalRow(global_ordinal_type globalRow) const;
177
184 virtual size_t getNumEntriesInLocalRow(local_ordinal_type localRow) const;
185
187 virtual size_t getGlobalMaxNumRowEntries() const;
188
190 virtual size_t getLocalMaxNumRowEntries() const;
191
193 virtual bool hasColMap() const;
194
196 virtual bool isLocallyIndexed() const;
197
199 virtual bool isGloballyIndexed() const;
200
202 virtual bool isFillComplete() const;
203
205 virtual bool supportsRowViews() const;
206
208
210
211
213
223 virtual void
224 getGlobalRowCopy(global_ordinal_type GlobalRow,
225 nonconst_global_inds_host_view_type& Indices,
226 nonconst_values_host_view_type& Values,
227 size_t& NumEntries) const;
229
239 virtual void
240 getLocalRowCopy(local_ordinal_type LocalRow,
241 nonconst_local_inds_host_view_type& Indices,
242 nonconst_values_host_view_type& Values,
243 size_t& NumEntries) const;
244
246
254 virtual void
255 getGlobalRowView(global_ordinal_type GlobalRow,
256 global_inds_host_view_type& indices,
257 values_host_view_type& values) const;
259
268 virtual void
269 getLocalRowView(local_ordinal_type LocalRow,
270 local_inds_host_view_type& indices,
271 values_host_view_type& values) const;
273
275 virtual void getLocalDiagCopy(Tpetra::Vector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& diag) const;
276
278
280
281
291 virtual void leftScale(const Tpetra::Vector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& x);
292
302 virtual void rightScale(const Tpetra::Vector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& x);
303
305
308 virtual mag_type getFrobeniusNorm() const;
309
331 virtual void
332 apply(const Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& X,
333 Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& Y,
334 Teuchos::ETransp mode = Teuchos::NO_TRANS,
335 scalar_type alpha = Teuchos::ScalarTraits<scalar_type>::one(),
336 scalar_type beta = Teuchos::ScalarTraits<scalar_type>::zero()) const;
337
339 virtual bool hasTransposeApply() const;
340
342 void CreateReducedProblem(
343 const Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& OverlappingB,
344 Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& OverlappingY,
345 Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& ReducedReorderedB) const;
346
348 void UpdateLHS(
349 const Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& ReducedReorderedY,
350 Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& OverlappingY) const;
351
352 void setup(const Teuchos::RCP<const row_matrix_type>& A_unfiltered,
353 const Teuchos::ArrayRCP<local_ordinal_type>& perm,
354 const Teuchos::ArrayRCP<local_ordinal_type>& reverseperm,
355 bool filterSingletons);
356
361 void fillLocalMatrix(local_matrix_type localMatrix);
362
364
365 private:
378 static bool
379 mapPairIsFitted(const map_type& map1, const map_type& map2);
380
384 // If both pairs of Maps of the original matrix A are fitted on this
385 // process, then this process can use a fast "view" implementation.
386 static bool
387 mapPairsAreFitted(const row_matrix_type& A);
388
390 Teuchos::RCP<const row_matrix_type> A_unfiltered_;
392 Teuchos::RCP<crs_matrix_type> A_;
394 Kokkos::DualView<local_ordinal_type*, device_type> perm_;
396 Kokkos::DualView<local_ordinal_type*, device_type> reverseperm_;
397 local_ordinal_type numSingletons_;
399 Kokkos::DualView<local_ordinal_type*, device_type> singletons_;
401 Kokkos::DualView<impl_scalar_type*, device_type> singletonDiagonals_;
402
404 // (apply and solve still process those rows separately)
405 bool FilterSingletons_;
406
408 Teuchos::RCP<const map_type> localMap_;
409};
410
411} // namespace Details
412} // namespace Ifpack2
413
414#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:33
Sparse matrix (Tpetra::RowMatrix subclass) with ghost rows.
Definition Ifpack2_OverlappingRowMatrix_decl.hpp:25
Ifpack2 implementation details.
Preconditioners and smoothers for Tpetra sparse matrices.
Definition Ifpack2_AdditiveSchwarz_decl.hpp:40