Ifpack2 Templated Preconditioning Package Version 1.0
Loading...
Searching...
No Matches
Ifpack2_Details_AdditiveSchwarzFilter_decl.hpp
1
2/*@HEADER
3// ***********************************************************************
4//
5// Ifpack2: Templated Object-Oriented Algebraic Preconditioner Package
6// Copyright (2009) Sandia Corporation
7//
8// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
9// license for use of this work by or on behalf of the U.S. Government.
10//
11// Redistribution and use in source and binary forms, with or without
12// modification, are permitted provided that the following conditions are
13// met:
14//
15// 1. Redistributions of source code must retain the above copyright
16// notice, this list of conditions and the following disclaimer.
17//
18// 2. Redistributions in binary form must reproduce the above copyright
19// notice, this list of conditions and the following disclaimer in the
20// documentation and/or other materials provided with the distribution.
21//
22// 3. Neither the name of the Corporation nor the names of the
23// contributors may be used to endorse or promote products derived from
24// this software without specific prior written permission.
25//
26// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37//
38// Questions? Contact Michael A. Heroux (maherou@sandia.gov)
39//
40// ***********************************************************************
41//@HEADER
42*/
43
44#ifndef IFPACK2_ADDITIVE_SCHWARZ_FILTER_DECL_HPP
45#define IFPACK2_ADDITIVE_SCHWARZ_FILTER_DECL_HPP
46
54#include "Ifpack2_ConfigDefs.hpp"
55#include "Ifpack2_Details_RowMatrix.hpp"
56#include "Ifpack2_OverlappingRowMatrix.hpp"
57
58namespace Ifpack2
59{
60namespace Details
61{
62 template<typename MatrixType>
64 public Ifpack2::Details::RowMatrix<MatrixType> {
65public:
66 typedef typename MatrixType::scalar_type scalar_type;
67 typedef typename Kokkos::ArithTraits<scalar_type>::val_type impl_scalar_type;
68 typedef typename MatrixType::local_ordinal_type local_ordinal_type;
69 typedef typename MatrixType::global_ordinal_type global_ordinal_type;
70 typedef typename MatrixType::node_type node_type;
71 typedef typename MatrixType::global_inds_host_view_type global_inds_host_view_type;
72 typedef typename MatrixType::local_inds_host_view_type local_inds_host_view_type;
73 typedef typename MatrixType::values_host_view_type values_host_view_type;
74
75 typedef typename MatrixType::nonconst_global_inds_host_view_type nonconst_global_inds_host_view_type;
76 typedef typename MatrixType::nonconst_local_inds_host_view_type nonconst_local_inds_host_view_type;
77 typedef typename MatrixType::nonconst_values_host_view_type nonconst_values_host_view_type;
78
79 typedef typename Teuchos::ScalarTraits<scalar_type>::magnitudeType magnitude_type;
80 typedef Tpetra::RowMatrix<scalar_type,
81 local_ordinal_type,
82 global_ordinal_type,
83 node_type> row_matrix_type;
84 typedef Tpetra::CrsMatrix<scalar_type,
85 local_ordinal_type,
86 global_ordinal_type,
87 node_type> crs_matrix_type;
88 typedef Tpetra::MultiVector<scalar_type,
89 local_ordinal_type,
90 global_ordinal_type,
91 node_type> mv_type;
92 typedef typename crs_matrix_type::device_type device_type;
93 typedef typename crs_matrix_type::execution_space execution_space;
94 typedef Kokkos::RangePolicy<execution_space> policy_type;
95 typedef Kokkos::MDRangePolicy<execution_space, Kokkos::Rank<2>> policy_2d_type;
96 typedef Ifpack2::OverlappingRowMatrix<row_matrix_type> overlapping_matrix_type;
97 typedef typename crs_matrix_type::local_matrix_device_type local_matrix_type;
98 typedef typename local_matrix_type::size_type size_type;
99 typedef typename local_matrix_type::row_map_type::non_const_type row_map_type;
100 typedef typename local_matrix_type::index_type entries_type;
101 typedef typename local_matrix_type::values_type values_type;
102 typedef typename row_map_type::HostMirror host_row_map_type;
103 typedef typename entries_type::HostMirror host_entries_type;
104 typedef typename values_type::HostMirror host_values_type;
105 typedef typename local_matrix_type::HostMirror host_local_matrix_type;
106
107 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.");
108
109 typedef Tpetra::Map<local_ordinal_type,
110 global_ordinal_type,
111 node_type> map_type;
112
113 typedef typename row_matrix_type::mag_type mag_type;
114
116
117
121 // Must be a Tpetra::CrsMatrix or an Ifpack2::OverlappingRowMatrix that wraps a Tpetra::CrsMatrix.
135 AdditiveSchwarzFilter(const Teuchos::RCP<const row_matrix_type>& A,
136 const Teuchos::ArrayRCP<local_ordinal_type>& perm,
137 const Teuchos::ArrayRCP<local_ordinal_type>& reverseperm,
138 bool filterSingletons);
139
141 void updateMatrixValues();
142
143 Teuchos::RCP<const crs_matrix_type> getFilteredMatrix() const;
144
146 virtual ~AdditiveSchwarzFilter ();
147
149
151
153 virtual Teuchos::RCP<const Teuchos::Comm<int> > getComm() const;
154
156 virtual Teuchos::RCP<const map_type> getRowMap() const;
157
159 virtual Teuchos::RCP<const map_type> getColMap() const;
160
162 virtual Teuchos::RCP<const map_type> getDomainMap() const;
163
165 virtual Teuchos::RCP<const map_type> getRangeMap() const;
166
168 virtual Teuchos::RCP<const Tpetra::RowGraph<local_ordinal_type,global_ordinal_type,node_type> > getGraph() const;
169
171 virtual global_size_t getGlobalNumRows() const;
172
174 virtual global_size_t getGlobalNumCols() const;
175
177 virtual size_t getLocalNumRows() const;
178
180 virtual size_t getLocalNumCols() const;
181
183 virtual global_ordinal_type getIndexBase() const;
184
186 virtual global_size_t getGlobalNumEntries() const;
187
189 virtual size_t getLocalNumEntries() const;
190
197 virtual size_t getNumEntriesInGlobalRow (global_ordinal_type globalRow) const;
198
205 virtual size_t getNumEntriesInLocalRow (local_ordinal_type localRow) const;
206
208 virtual size_t getGlobalMaxNumRowEntries() const;
209
211 virtual size_t getLocalMaxNumRowEntries() const;
212
214 virtual bool hasColMap() const;
215
217 virtual bool isLocallyIndexed() const;
218
220 virtual bool isGloballyIndexed() const;
221
223 virtual bool isFillComplete() const;
224
226 virtual bool supportsRowViews() const;
227
229
231
232
234
244 virtual void
245 getGlobalRowCopy (global_ordinal_type GlobalRow,
246 nonconst_global_inds_host_view_type &Indices,
247 nonconst_values_host_view_type &Values,
248 size_t& NumEntries) const;
250
260 virtual void
261 getLocalRowCopy (local_ordinal_type LocalRow,
262 nonconst_local_inds_host_view_type &Indices,
263 nonconst_values_host_view_type &Values,
264 size_t& NumEntries) const;
265
267
275 virtual void
276 getGlobalRowView (global_ordinal_type GlobalRow,
277 global_inds_host_view_type &indices,
278 values_host_view_type &values) const;
280
289 virtual void
290 getLocalRowView (local_ordinal_type LocalRow,
291 local_inds_host_view_type & indices,
292 values_host_view_type & values) const;
294
296 virtual void getLocalDiagCopy(Tpetra::Vector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &diag) const;
297
299
301
302
312 virtual void leftScale(const Tpetra::Vector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& x);
313
323 virtual void rightScale(const Tpetra::Vector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& x);
324
326
329 virtual mag_type getFrobeniusNorm() const;
330
352 virtual void
353 apply (const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &X,
354 Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &Y,
355 Teuchos::ETransp mode = Teuchos::NO_TRANS,
356 scalar_type alpha = Teuchos::ScalarTraits<scalar_type>::one(),
357 scalar_type beta = Teuchos::ScalarTraits<scalar_type>::zero()) const;
358
360 virtual bool hasTransposeApply() const;
361
363 void CreateReducedProblem(
364 const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& OverlappingB,
365 Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& OverlappingY,
366 Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& ReducedReorderedB) const;
367
369 void UpdateLHS(
370 const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& ReducedReorderedY,
371 Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& OverlappingY) const;
372
373 void setup(const Teuchos::RCP<const row_matrix_type>& A_unfiltered,
374 const Teuchos::ArrayRCP<local_ordinal_type>& perm,
375 const Teuchos::ArrayRCP<local_ordinal_type>& reverseperm,
376 bool filterSingletons);
377
382 void fillLocalMatrix(local_matrix_type localMatrix);
383
385
386private:
387
400 static bool
401 mapPairIsFitted (const map_type& map1, const map_type& map2);
402
406 // If both pairs of Maps of the original matrix A are fitted on this
407 // process, then this process can use a fast "view" implementation.
408 static bool
409 mapPairsAreFitted (const row_matrix_type& A);
410
412 Teuchos::RCP<const row_matrix_type> A_unfiltered_;
414 Teuchos::RCP<crs_matrix_type> A_;
416 Kokkos::DualView<local_ordinal_type*, device_type> perm_;
418 Kokkos::DualView<local_ordinal_type*, device_type> reverseperm_;
419 local_ordinal_type numSingletons_;
421 Kokkos::DualView<local_ordinal_type*, device_type> singletons_;
423 Kokkos::DualView<impl_scalar_type*, device_type> singletonDiagonals_;
424
426 // (apply and solve still process those rows separately)
427 bool FilterSingletons_;
428
430 Teuchos::RCP<const map_type> localMap_;
431};
432
433}} //namespace Ifpack2::Details
434
435#endif
436
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:67
Sparse matrix (Tpetra::RowMatrix subclass) with ghost rows.
Definition Ifpack2_OverlappingRowMatrix_decl.hpp:59
Ifpack2 implementation details.
Preconditioners and smoothers for Tpetra sparse matrices.
Definition Ifpack2_AdditiveSchwarz_decl.hpp:74