Ifpack2 Templated Preconditioning Package Version 1.0
Loading...
Searching...
No Matches
Ifpack2_Details_DenseSolver_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_DENSESOLVER_DECL_HPP
11#define IFPACK2_DETAILS_DENSESOLVER_DECL_HPP
12
15
16#include "Ifpack2_ConfigDefs.hpp"
19#include "Ifpack2_Details_LapackSupportsScalar.hpp"
20#include "Tpetra_Import_fwd.hpp"
21#include "Tpetra_Export_fwd.hpp"
22#include "Teuchos_SerialDenseMatrix.hpp"
23#include <type_traits>
24
25namespace Ifpack2 {
26namespace Details {
27
40template<class MatrixType,
41 const bool stub = ! LapackSupportsScalar<typename MatrixType::scalar_type>::value>
43 public Ifpack2::Preconditioner<typename MatrixType::scalar_type,
44 typename MatrixType::local_ordinal_type,
45 typename MatrixType::global_ordinal_type,
46 typename MatrixType::node_type>,
47 virtual public Ifpack2::Details::CanChangeMatrix<Tpetra::RowMatrix<typename MatrixType::scalar_type,
48 typename MatrixType::local_ordinal_type,
49 typename MatrixType::global_ordinal_type,
50 typename MatrixType::node_type> >
51{};
52
54template<class MatrixType>
55class DenseSolver<MatrixType, false> :
56 public Ifpack2::Preconditioner<typename MatrixType::scalar_type,
57 typename MatrixType::local_ordinal_type,
58 typename MatrixType::global_ordinal_type,
59 typename MatrixType::node_type>,
60 virtual public Ifpack2::Details::CanChangeMatrix<Tpetra::RowMatrix<typename MatrixType::scalar_type,
61 typename MatrixType::local_ordinal_type,
62 typename MatrixType::global_ordinal_type,
63 typename MatrixType::node_type> >
64{
65public:
67
68
72 typedef MatrixType matrix_type;
73
75 typedef typename MatrixType::scalar_type scalar_type;
76
78 typedef typename MatrixType::local_ordinal_type local_ordinal_type;
79
81 typedef typename MatrixType::global_ordinal_type global_ordinal_type;
82
84 typedef typename MatrixType::node_type node_type;
85
87 typedef typename Teuchos::ScalarTraits<scalar_type>::magnitudeType magnitude_type;
88
90 typedef Tpetra::RowMatrix<scalar_type, local_ordinal_type, global_ordinal_type, node_type> row_matrix_type;
91
92 static_assert(std::is_same<MatrixType, row_matrix_type>::value,
93 "Ifpack2::Details::DenseSolver: Please use MatrixType = Tpetra::RowMatrix.");
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
99
100
102 typedef Tpetra::Map<local_ordinal_type, global_ordinal_type, node_type> map_type;
103
105
107
111 DenseSolver (const Teuchos::RCP<const row_matrix_type>& matrix);
112
114 virtual ~DenseSolver ();
115
117
119
120
125 Teuchos::RCP<const map_type> getDomainMap () const;
126
131 Teuchos::RCP<const map_type> getRangeMap () const;
132
138 void
139 apply (const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& X,
140 Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& Y,
141 Teuchos::ETransp mode = Teuchos::NO_TRANS,
142 scalar_type alpha = Teuchos::ScalarTraits<scalar_type>::one(),
143 scalar_type beta = Teuchos::ScalarTraits<scalar_type>::zero()) const;
144
146
148 void setParameters (const Teuchos::ParameterList& params);
149
159 void initialize ();
160
162 bool isInitialized () const;
163
173 void compute ();
174
176 bool isComputed () const;
177
179 Teuchos::RCP<const row_matrix_type> getMatrix () const;
180
182 void setMatrix (const Teuchos::RCP<const row_matrix_type>& A);
183
185 int getNumInitialize () const;
186
188 int getNumCompute () const;
189
191 int getNumApply() const;
192
194 double getInitializeTime() const;
195
197 double getComputeTime() const;
198
200 double getApplyTime() const;
201
203
205
207 std::string description () const;
208
210 void
211 describe (Teuchos::FancyOStream &out,
212 const Teuchos::EVerbosityLevel verbLevel =
213 Teuchos::Describable::verbLevel_default) const;
215private:
216
218 void
219 describeLocal (Teuchos::FancyOStream& out,
220 const Teuchos::EVerbosityLevel verbLevel) const;
221
223 void reset ();
224
232 static void
233 extract (Teuchos::SerialDenseMatrix<int, scalar_type>& A_local_dense,
234 const row_matrix_type& A_local);
235
245 static void
246 factor (Teuchos::SerialDenseMatrix<int, scalar_type>& A,
247 const Teuchos::ArrayView<int>& ipiv);
248
250 typedef Tpetra::MultiVector<scalar_type, local_ordinal_type,
252
254 typedef Tpetra::Import<local_ordinal_type,
255 global_ordinal_type, node_type> import_type;
256
258 typedef Tpetra::Export<local_ordinal_type,
259 global_ordinal_type, node_type> export_type;
260
262 typedef Teuchos::ScalarTraits<scalar_type> STS;
263
272 void
273 applyImpl (const MV& X,
274 MV& Y,
275 const Teuchos::ETransp mode,
276 const scalar_type alpha,
277 const scalar_type beta) const;
278
280 Teuchos::RCP<const row_matrix_type> A_;
281
283 Teuchos::RCP<const row_matrix_type> A_local_;
284
286 Teuchos::SerialDenseMatrix<int, scalar_type> A_local_dense_;
287
289 Teuchos::Array<int> ipiv_;
290
292 double initializeTime_;
293
295 double computeTime_;
296
298 mutable double applyTime_;
299
301 int numInitialize_;
302
304 int numCompute_;
305
307 mutable int numApply_;
308
310 bool isInitialized_;
311
313 bool isComputed_;
314};
315
316
318template<class MatrixType>
319class DenseSolver<MatrixType, true> :
320 public Ifpack2::Preconditioner<typename MatrixType::scalar_type,
321 typename MatrixType::local_ordinal_type,
322 typename MatrixType::global_ordinal_type,
323 typename MatrixType::node_type>,
324 virtual public Ifpack2::Details::CanChangeMatrix<Tpetra::RowMatrix<typename MatrixType::scalar_type,
325 typename MatrixType::local_ordinal_type,
326 typename MatrixType::global_ordinal_type,
327 typename MatrixType::node_type> >
328{
329public:
331
332
337 typedef MatrixType matrix_type;
338
340 typedef typename MatrixType::scalar_type scalar_type;
341
343 typedef typename MatrixType::local_ordinal_type local_ordinal_type;
344
346 typedef typename MatrixType::global_ordinal_type global_ordinal_type;
347
349 typedef typename MatrixType::node_type node_type;
350
352 typedef typename Teuchos::ScalarTraits<scalar_type>::magnitudeType magnitude_type;
353
355 typedef Tpetra::RowMatrix<scalar_type, local_ordinal_type, global_ordinal_type, node_type> row_matrix_type;
356
358 typedef Tpetra::Map<local_ordinal_type, global_ordinal_type, node_type> map_type;
359
361
363
367 DenseSolver (const Teuchos::RCP<const row_matrix_type>& matrix);
368
370 virtual ~DenseSolver ();
371
373
375
380 Teuchos::RCP<const map_type> getDomainMap () const;
381
386 Teuchos::RCP<const map_type> getRangeMap () const;
387
393 void
394 apply (const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& X,
395 Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& Y,
396 Teuchos::ETransp mode = Teuchos::NO_TRANS,
397 scalar_type alpha = Teuchos::ScalarTraits<scalar_type>::one(),
398 scalar_type beta = Teuchos::ScalarTraits<scalar_type>::zero()) const;
399
401
403 void setParameters (const Teuchos::ParameterList& params);
404
414 void initialize ();
415
417 bool isInitialized () const;
418
428 void compute ();
429
431 bool isComputed () const;
432
434 Teuchos::RCP<const row_matrix_type> getMatrix () const;
435
437 void setMatrix (const Teuchos::RCP<const row_matrix_type>& A);
438
440 int getNumInitialize () const;
441
443 int getNumCompute () const;
444
446 int getNumApply() const;
447
449 double getInitializeTime() const;
450
452 double getComputeTime() const;
453
455 double getApplyTime() const;
456
458
460
462 std::string description () const;
463
465 void
466 describe (Teuchos::FancyOStream &out,
467 const Teuchos::EVerbosityLevel verbLevel =
468 Teuchos::Describable::verbLevel_default) const;
470private:
472 typedef Tpetra::MultiVector<scalar_type, local_ordinal_type,
474};
475
476} // namespace Details
477} // namespace Ifpack2
478
479#endif // IFPACK2_DETAILS_DENSESOLVER_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
MatrixType::node_type node_type
The Node type of the input (global) matrix.
Definition Ifpack2_Details_DenseSolver_decl.hpp:84
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_DenseSolver_def.hpp:543
MatrixType::local_ordinal_type local_ordinal_type
The type of local indices in the input (global) matrix.
Definition Ifpack2_Details_DenseSolver_decl.hpp:78
DenseSolver(const Teuchos::RCP< const row_matrix_type > &matrix)
Constructor.
Definition Ifpack2_Details_DenseSolver_def.hpp:35
MatrixType matrix_type
The first template parameter of this class.
Definition Ifpack2_Details_DenseSolver_decl.hpp:72
MatrixType::scalar_type scalar_type
The type of entries in the input (global) matrix.
Definition Ifpack2_Details_DenseSolver_decl.hpp:75
Tpetra::Map< local_ordinal_type, global_ordinal_type, node_type > map_type
Specialization of Tpetra::Map used by this class.
Definition Ifpack2_Details_DenseSolver_decl.hpp:102
MatrixType::global_ordinal_type global_ordinal_type
The type of global indices in the input (global) matrix.
Definition Ifpack2_Details_DenseSolver_decl.hpp:81
std::string description() const
A one-line description of this object.
Definition Ifpack2_Details_DenseSolver_def.hpp:460
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_DenseSolver_decl.hpp:90
Teuchos::ScalarTraits< scalar_type >::magnitudeType magnitude_type
The type of the absolute value (magnitude) of a scalar_type.
Definition Ifpack2_Details_DenseSolver_decl.hpp:87
MatrixType::node_type node_type
The Node type of the input (global) matrix.
Definition Ifpack2_Details_DenseSolver_decl.hpp:349
MatrixType matrix_type
The first template parameter of this class.
Definition Ifpack2_Details_DenseSolver_decl.hpp:337
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_DenseSolver_decl.hpp:355
Tpetra::Map< local_ordinal_type, global_ordinal_type, node_type > map_type
Specialization of Tpetra::Map used by this class.
Definition Ifpack2_Details_DenseSolver_decl.hpp:358
DenseSolver(const Teuchos::RCP< const row_matrix_type > &matrix)
Constructor.
Definition Ifpack2_Details_DenseSolver_def.hpp:650
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_DenseSolver_def.hpp:791
MatrixType::local_ordinal_type local_ordinal_type
The type of local indices in the input (global) matrix.
Definition Ifpack2_Details_DenseSolver_decl.hpp:343
Teuchos::ScalarTraits< scalar_type >::magnitudeType magnitude_type
The type of the absolute value (magnitude) of a scalar_type.
Definition Ifpack2_Details_DenseSolver_decl.hpp:352
std::string description() const
A one-line description of this object.
Definition Ifpack2_Details_DenseSolver_def.hpp:783
MatrixType::scalar_type scalar_type
The type of entries in the input (global) matrix.
Definition Ifpack2_Details_DenseSolver_decl.hpp:340
MatrixType::global_ordinal_type global_ordinal_type
The type of global indices in the input (global) matrix.
Definition Ifpack2_Details_DenseSolver_decl.hpp:346
"Preconditioner" that uses LAPACK's dense LU.
Definition Ifpack2_Details_DenseSolver_decl.hpp:51
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