Ifpack2 Templated Preconditioning Package Version 1.0
Loading...
Searching...
No Matches
Ifpack2_Details_TriDiSolver_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_DETAILS_TRIDISOLVER_DECL_HPP
11#define IFPACK2_DETAILS_TRIDISOLVER_DECL_HPP
12
15
16#include "Ifpack2_ConfigDefs.hpp"
19#include "Ifpack2_Details_LapackSupportsScalar.hpp"
20#include "Tpetra_RowMatrix.hpp"
21#include "Tpetra_Import_fwd.hpp"
22#include "Tpetra_Export_fwd.hpp"
23#include "Teuchos_SerialTriDiMatrix.hpp"
24#include <type_traits>
25
26namespace Ifpack2 {
27namespace Details {
28
41template<class MatrixType,
42 const bool stub = ! LapackSupportsScalar<typename MatrixType::scalar_type>::value>
44 public Ifpack2::Preconditioner<typename MatrixType::scalar_type,
45 typename MatrixType::local_ordinal_type,
46 typename MatrixType::global_ordinal_type,
47 typename MatrixType::node_type>,
48 virtual public Ifpack2::Details::CanChangeMatrix<Tpetra::RowMatrix<typename MatrixType::scalar_type,
49 typename MatrixType::local_ordinal_type,
50 typename MatrixType::global_ordinal_type,
51 typename MatrixType::node_type> >
52{};
53
55template<class MatrixType>
56class TriDiSolver<MatrixType, false> :
57 public Ifpack2::Preconditioner<typename MatrixType::scalar_type,
58 typename MatrixType::local_ordinal_type,
59 typename MatrixType::global_ordinal_type,
60 typename MatrixType::node_type>,
61 virtual public Ifpack2::Details::CanChangeMatrix<Tpetra::RowMatrix<typename MatrixType::scalar_type,
62 typename MatrixType::local_ordinal_type,
63 typename MatrixType::global_ordinal_type,
64 typename MatrixType::node_type> >
65{
66public:
68
69
73 typedef MatrixType matrix_type;
74
76 typedef typename MatrixType::scalar_type scalar_type;
77
79 typedef typename MatrixType::local_ordinal_type local_ordinal_type;
80
82 typedef typename MatrixType::global_ordinal_type global_ordinal_type;
83
85 typedef typename MatrixType::node_type node_type;
86
88 typedef typename Teuchos::ScalarTraits<scalar_type>::magnitudeType magnitude_type;
89
91 typedef Tpetra::RowMatrix<scalar_type, local_ordinal_type, global_ordinal_type, node_type> row_matrix_type;
92
93 static_assert(std::is_same<MatrixType, row_matrix_type>::value, "Ifpack2::Details::TriDiSolver: 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.");
94
95 typedef typename row_matrix_type::nonconst_global_inds_host_view_type nonconst_global_inds_host_view_type;
96 typedef typename row_matrix_type::nonconst_local_inds_host_view_type nonconst_local_inds_host_view_type;
97 typedef typename row_matrix_type::nonconst_values_host_view_type nonconst_values_host_view_type;
98
100 typedef Tpetra::Map<local_ordinal_type, global_ordinal_type, node_type> map_type;
101
103
105
109 TriDiSolver (const Teuchos::RCP<const row_matrix_type>& matrix);
110
112 virtual ~TriDiSolver ();
113
115
117
118
123 Teuchos::RCP<const map_type> getDomainMap () const;
124
129 Teuchos::RCP<const map_type> getRangeMap () const;
130
136 void
137 apply (const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& X,
138 Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& Y,
139 Teuchos::ETransp mode = Teuchos::NO_TRANS,
140 scalar_type alpha = Teuchos::ScalarTraits<scalar_type>::one(),
141 scalar_type beta = Teuchos::ScalarTraits<scalar_type>::zero()) const;
142
144
146 void setParameters (const Teuchos::ParameterList& params);
147
157 void initialize ();
158
160 bool isInitialized () const;
161
171 void compute ();
172
174 bool isComputed () const;
175
177 Teuchos::RCP<const row_matrix_type> getMatrix () const;
178
180 void setMatrix (const Teuchos::RCP<const row_matrix_type>& A);
181
183 int getNumInitialize () const;
184
186 int getNumCompute () const;
187
189 int getNumApply() const;
190
192 double getInitializeTime() const;
193
195 double getComputeTime() const;
196
198 double getApplyTime() const;
199
201
203
205 std::string description () const;
206
208 void
209 describe (Teuchos::FancyOStream &out,
210 const Teuchos::EVerbosityLevel verbLevel =
211 Teuchos::Describable::verbLevel_default) const;
213private:
214
216 void
217 describeLocal (Teuchos::FancyOStream& out,
218 const Teuchos::EVerbosityLevel verbLevel) const;
219
221 void reset ();
222
230 static void
231 extract (Teuchos::SerialTriDiMatrix<int, scalar_type>& A_local_tridi,
232 const row_matrix_type& A_local);
233
243 static void
244 factor (Teuchos::SerialTriDiMatrix<int, scalar_type>& A,
245 const Teuchos::ArrayView<int>& ipiv);
246
248 typedef Tpetra::MultiVector<scalar_type, local_ordinal_type,
250
252 typedef Tpetra::Import<local_ordinal_type,
253 global_ordinal_type, node_type> import_type;
254
256 typedef Tpetra::Export<local_ordinal_type,
257 global_ordinal_type, node_type> export_type;
258
260 typedef Teuchos::ScalarTraits<scalar_type> STS;
261
270 void
271 applyImpl (const MV& X,
272 MV& Y,
273 const Teuchos::ETransp mode,
274 const scalar_type alpha,
275 const scalar_type beta) const;
276
278 Teuchos::RCP<const row_matrix_type> A_;
279
281 Teuchos::RCP<const row_matrix_type> A_local_;
282
284 Teuchos::SerialTriDiMatrix<int, scalar_type> A_local_tridi_;
285
287 Teuchos::Array<int> ipiv_;
288
290 double initializeTime_;
291
293 double computeTime_;
294
296 mutable double applyTime_;
297
299 int numInitialize_;
300
302 int numCompute_;
303
305 mutable int numApply_;
306
308 bool isInitialized_;
309
311 bool isComputed_;
312};
313
314
316template<class MatrixType>
317class TriDiSolver<MatrixType, true> :
318 public Ifpack2::Preconditioner<typename MatrixType::scalar_type,
319 typename MatrixType::local_ordinal_type,
320 typename MatrixType::global_ordinal_type,
321 typename MatrixType::node_type>,
322 virtual public Ifpack2::Details::CanChangeMatrix<Tpetra::RowMatrix<typename MatrixType::scalar_type,
323 typename MatrixType::local_ordinal_type,
324 typename MatrixType::global_ordinal_type,
325 typename MatrixType::node_type> >
326{
327public:
329
330
334 typedef MatrixType matrix_type;
335
337 typedef typename MatrixType::scalar_type scalar_type;
338
340 typedef typename MatrixType::local_ordinal_type local_ordinal_type;
341
343 typedef typename MatrixType::global_ordinal_type global_ordinal_type;
344
346 typedef typename MatrixType::node_type node_type;
347
349 typedef typename Teuchos::ScalarTraits<scalar_type>::magnitudeType magnitude_type;
350
352 typedef Tpetra::RowMatrix<scalar_type, local_ordinal_type, global_ordinal_type, node_type> row_matrix_type;
353
354 static_assert(std::is_same<MatrixType, row_matrix_type>::value, "Ifpack2::Details::TriDiSolver: 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.");
355
357 typedef Tpetra::Map<local_ordinal_type, global_ordinal_type, node_type> map_type;
358
360
362
366 TriDiSolver (const Teuchos::RCP<const row_matrix_type>& matrix);
367
369 virtual ~TriDiSolver ();
370
372
374
379 Teuchos::RCP<const map_type> getDomainMap () const;
380
385 Teuchos::RCP<const map_type> getRangeMap () const;
386
392 void
393 apply (const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& X,
394 Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& Y,
395 Teuchos::ETransp mode = Teuchos::NO_TRANS,
396 scalar_type alpha = Teuchos::ScalarTraits<scalar_type>::one(),
397 scalar_type beta = Teuchos::ScalarTraits<scalar_type>::zero()) const;
398
400
402 void setParameters (const Teuchos::ParameterList& params);
403
413 void initialize ();
414
416 bool isInitialized () const;
417
427 void compute ();
428
430 bool isComputed () const;
431
433 Teuchos::RCP<const row_matrix_type> getMatrix () const;
434
436 void setMatrix (const Teuchos::RCP<const row_matrix_type>& A);
437
439 int getNumInitialize () const;
440
442 int getNumCompute () const;
443
445 int getNumApply() const;
446
448 double getInitializeTime() const;
449
451 double getComputeTime() const;
452
454 double getApplyTime() const;
455
457
459
461 std::string description () const;
462
464 void
465 describe (Teuchos::FancyOStream &out,
466 const Teuchos::EVerbosityLevel verbLevel =
467 Teuchos::Describable::verbLevel_default) const;
468
469 void
470 describeLocal (Teuchos::FancyOStream& out,
471 const Teuchos::EVerbosityLevel verbLevel) const;
472
474private:
476 typedef Tpetra::MultiVector<scalar_type, local_ordinal_type,
478};
479
480} // namespace Details
481} // namespace Ifpack2
482
483#endif // IFPACK2_DETAILS_TRIDISOLVER_DECL_HPP
Declaration of interface for preconditioners that can change their matrix after construction.
Mix-in interface for preconditioners that can change their matrix after construction.
Definition Ifpack2_Details_CanChangeMatrix.hpp:60
virtual void setMatrix(const Teuchos::RCP< const Tpetra::RowMatrix< MatrixType::scalar_type, MatrixType::local_ordinal_type, MatrixType::global_ordinal_type, MatrixType::node_type > > &A)=0
Tpetra::RowMatrix< scalar_type, local_ordinal_type, global_ordinal_type, node_type > row_matrix_type
Specialization of Tpetra::RowMatrix used by this class.
Definition Ifpack2_Details_TriDiSolver_decl.hpp:91
TriDiSolver(const Teuchos::RCP< const row_matrix_type > &matrix)
Constructor.
Definition Ifpack2_Details_TriDiSolver_def.hpp:37
MatrixType::global_ordinal_type global_ordinal_type
The type of global indices in the input (global) matrix.
Definition Ifpack2_Details_TriDiSolver_decl.hpp:82
Teuchos::ScalarTraits< scalar_type >::magnitudeType magnitude_type
The type of the absolute value (magnitude) of a scalar_type.
Definition Ifpack2_Details_TriDiSolver_decl.hpp:88
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Print the object with some verbosity level to the given FancyOStream.
Definition Ifpack2_Details_TriDiSolver_def.hpp:532
MatrixType::node_type node_type
The Node type of the input (global) matrix.
Definition Ifpack2_Details_TriDiSolver_decl.hpp:85
MatrixType::local_ordinal_type local_ordinal_type
The type of local indices in the input (global) matrix.
Definition Ifpack2_Details_TriDiSolver_decl.hpp:79
std::string description() const
A one-line description of this object.
Definition Ifpack2_Details_TriDiSolver_def.hpp:468
MatrixType matrix_type
The first template parameter of this class.
Definition Ifpack2_Details_TriDiSolver_decl.hpp:73
MatrixType::scalar_type scalar_type
The type of entries in the input (global) matrix.
Definition Ifpack2_Details_TriDiSolver_decl.hpp:76
Tpetra::Map< local_ordinal_type, global_ordinal_type, node_type > map_type
Specialization of Tpetra::Map used by this class.
Definition Ifpack2_Details_TriDiSolver_decl.hpp:100
TriDiSolver(const Teuchos::RCP< const row_matrix_type > &matrix)
Constructor.
Definition Ifpack2_Details_TriDiSolver_def.hpp:638
MatrixType::scalar_type scalar_type
The type of entries in the input (global) matrix.
Definition Ifpack2_Details_TriDiSolver_decl.hpp:337
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Print the object with some verbosity level to the given FancyOStream.
Definition Ifpack2_Details_TriDiSolver_def.hpp:776
Tpetra::RowMatrix< scalar_type, local_ordinal_type, global_ordinal_type, node_type > row_matrix_type
Specialization of Tpetra::RowMatrix used by this class.
Definition Ifpack2_Details_TriDiSolver_decl.hpp:352
MatrixType matrix_type
The first template parameter of this class.
Definition Ifpack2_Details_TriDiSolver_decl.hpp:334
MatrixType::node_type node_type
The Node type of the input (global) matrix.
Definition Ifpack2_Details_TriDiSolver_decl.hpp:346
MatrixType::global_ordinal_type global_ordinal_type
The type of global indices in the input (global) matrix.
Definition Ifpack2_Details_TriDiSolver_decl.hpp:343
MatrixType::local_ordinal_type local_ordinal_type
The type of local indices in the input (global) matrix.
Definition Ifpack2_Details_TriDiSolver_decl.hpp:340
Teuchos::ScalarTraits< scalar_type >::magnitudeType magnitude_type
The type of the absolute value (magnitude) of a scalar_type.
Definition Ifpack2_Details_TriDiSolver_decl.hpp:349
std::string description() const
A one-line description of this object.
Definition Ifpack2_Details_TriDiSolver_def.hpp:769
Tpetra::Map< local_ordinal_type, global_ordinal_type, node_type > map_type
Specialization of Tpetra::Map used by this class.
Definition Ifpack2_Details_TriDiSolver_decl.hpp:357
"Preconditioner" that uses LAPACK's tridi LU.
Definition Ifpack2_Details_TriDiSolver_decl.hpp:52
Interface for all Ifpack2 preconditioners.
Definition Ifpack2_Preconditioner.hpp:75
virtual Teuchos::RCP< const Tpetra::RowMatrix< MatrixType::scalar_type, MatrixType::local_ordinal_type, MatrixType::global_ordinal_type, MatrixType::node_type > > getMatrix() const=0
virtual void apply(const Tpetra::MultiVector< MatrixType::scalar_type, MatrixType::local_ordinal_type, MatrixType::global_ordinal_type, MatrixType::node_type > &X, Tpetra::MultiVector< MatrixType::scalar_type, MatrixType::local_ordinal_type, MatrixType::global_ordinal_type, MatrixType::node_type > &Y, Teuchos::ETransp mode=Teuchos::NO_TRANS, MatrixType::scalar_type alpha=Teuchos::ScalarTraits< MatrixType::scalar_type >::one(), MatrixType::scalar_type beta=Teuchos::ScalarTraits< MatrixType::scalar_type >::zero()) const=0
virtual Teuchos::RCP< const Tpetra::Map< MatrixType::local_ordinal_type, MatrixType::global_ordinal_type, MatrixType::node_type > > getRangeMap() const=0
virtual Teuchos::RCP< const Tpetra::Map< MatrixType::local_ordinal_type, MatrixType::global_ordinal_type, MatrixType::node_type > > getDomainMap() const=0
Preconditioners and smoothers for Tpetra sparse matrices.
Definition Ifpack2_AdditiveSchwarz_decl.hpp:41