Ifpack2 Templated Preconditioning Package  Version 1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
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"
23 #include <type_traits>
24 
25 namespace Ifpack2 {
26 namespace Details {
27 
40 template<class MatrixType,
41  const bool stub = ! LapackSupportsScalar<typename MatrixType::scalar_type>::value>
42 class DenseSolver :
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 
54 template<class MatrixType>
55 class 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 {
65 public:
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 
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 
112 
114  virtual ~DenseSolver ();
115 
117 
119 
120 
126 
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,
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 
180 
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 =
215 private:
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
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 
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 
281 
284 
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 
318 template<class MatrixType>
319 class 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 {
329 public:
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 
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 
368 
370  virtual ~DenseSolver ();
371 
373 
375 
381 
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,
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 
435 
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 =
470 private:
472  typedef Tpetra::MultiVector<scalar_type, local_ordinal_type,
473  global_ordinal_type, node_type> MV;
474 };
475 
476 } // namespace Details
477 } // namespace Ifpack2
478 
479 #endif // IFPACK2_DETAILS_DENSESOLVER_DECL_HPP
virtual Teuchos::RCP< const Tpetra::Map< MatrixType::local_ordinal_type, MatrixType::global_ordinal_type, MatrixType::node_type > > getDomainMap() const =0
The domain Map of this operator.
Mix-in interface for preconditioners that can change their matrix after construction.
Definition: Ifpack2_Details_CanChangeMatrix.hpp:60
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
virtual Teuchos::RCP< const Tpetra::RowMatrix< MatrixType::scalar_type, MatrixType::local_ordinal_type, MatrixType::global_ordinal_type, MatrixType::node_type > > getMatrix() const =0
The input matrix given to the constructor.
Teuchos::ScalarTraits< MatrixType::scalar_type >::magnitudeType magnitude_type
The type of the magnitude (absolute value) of a matrix entry.
Definition: Ifpack2_Preconditioner.hpp:78
&quot;Preconditioner&quot; that uses LAPACK&#39;s dense LU.
Definition: Ifpack2_Details_DenseSolver_decl.hpp:42
virtual Teuchos::RCP< const Tpetra::Map< MatrixType::local_ordinal_type, MatrixType::global_ordinal_type, MatrixType::node_type > > getRangeMap() const =0
The range Map of this operator.
MatrixType::global_ordinal_type global_ordinal_type
The type of global indices in the input (global) matrix.
Definition: Ifpack2_Details_DenseSolver_decl.hpp:81
Interface for all Ifpack2 preconditioners.
Definition: Ifpack2_Preconditioner.hpp:74
MatrixType::node_type node_type
The Node type of the input (global) matrix.
Definition: Ifpack2_Details_DenseSolver_decl.hpp:84
MatrixType matrix_type
The first template parameter of this class.
Definition: Ifpack2_Details_DenseSolver_decl.hpp:72
Declaration of interface for preconditioners that can change their matrix after construction.
static const EVerbosityLevel verbLevel_default
virtual bool isComputed() const =0
True if the preconditioner has been successfully computed, else false.
MatrixType::local_ordinal_type local_ordinal_type
The type of local indices in the input (global) matrix.
Definition: Ifpack2_Details_DenseSolver_decl.hpp:78
virtual void setParameters(const Teuchos::ParameterList &List)=0
Set this preconditioner&#39;s parameters.
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
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_typealpha=Teuchos::ScalarTraits< MatrixType::scalar_type >::one(), MatrixType::scalar_typebeta=Teuchos::ScalarTraits< MatrixType::scalar_type >::zero()) const =0
Apply the preconditioner to X, putting the result in Y.
MatrixType::scalar_type scalar_type
The type of entries in the input (global) matrix.
Definition: Ifpack2_Details_DenseSolver_decl.hpp:75
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
virtual bool isInitialized() const =0
True if the preconditioner has been successfully initialized, else false.
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
Set the new matrix.