Ifpack2 Templated Preconditioning Package  Version 1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Ifpack2_Krylov_decl.hpp
Go to the documentation of this file.
1 /*@HEADER
2 // ***********************************************************************
3 //
4 // Ifpack2: Templated Object-Oriented Algebraic Preconditioner Package
5 // Copyright (2009) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38 //
39 // ***********************************************************************
40 //@HEADER
41 */
42 
49 
50 #ifndef IFPACK2_KRYLOV_DECL_HPP
51 #define IFPACK2_KRYLOV_DECL_HPP
52 
53 #include "Ifpack2_ConfigDefs.hpp"
54 #ifdef HAVE_IFPACK2_DEPRECATED_CODE
55 
58 
59 #include "BelosSolverManager.hpp"
60 #include "BelosTpetraAdapter.hpp"
61 #include "Teuchos_ScalarTraits.hpp"
62 #include <type_traits>
63 
64 namespace Teuchos {
65  class ParameterList; // forward declaration
66 }
67 
68 namespace Ifpack2 {
69 namespace DeprecatedAndMayDisappearAtAnyTime {
70 
81  template <typename ScalarType>
82  struct BelosScalarType {
83  typedef ScalarType type;
84  };
85 
100  template<class MatrixType>
101  class IFPACK2_DEPRECATED Krylov :
102  virtual public Ifpack2::Preconditioner<typename MatrixType::scalar_type,
103  typename MatrixType::local_ordinal_type,
104  typename MatrixType::global_ordinal_type,
105  typename MatrixType::node_type>,
106  virtual public Ifpack2::Details::CanChangeMatrix<Tpetra::RowMatrix<typename MatrixType::scalar_type,
107  typename MatrixType::local_ordinal_type,
108  typename MatrixType::global_ordinal_type,
109  typename MatrixType::node_type> >
110  {
111  public:
112  // \name Public typedefs
114 
116  typedef typename MatrixType::scalar_type scalar_type;
117 
119  typedef typename BelosScalarType<scalar_type>::type belos_scalar_type;
120 
122  typedef typename MatrixType::local_ordinal_type local_ordinal_type;
123 
125  typedef typename MatrixType::global_ordinal_type global_ordinal_type;
126 
128  typedef typename MatrixType::node_type node_type;
129 
131  typedef typename Teuchos::ScalarTraits<scalar_type>::magnitudeType magnitude_type;
132 
134  typedef Tpetra::RowMatrix<scalar_type,
135  local_ordinal_type,
136  global_ordinal_type,
137  node_type> row_matrix_type;
138 
139  static_assert(std::is_same<MatrixType, row_matrix_type>::value, "Ifpack2::Krylov: 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.");
140 
142  typedef Ifpack2::Preconditioner<scalar_type,
143  local_ordinal_type,
144  global_ordinal_type,
145  node_type> prec_type;
146 
148  // \name Constructors and Destructors
150 
152  explicit Krylov (const Teuchos::RCP<const row_matrix_type>& A);
153 
155  virtual ~Krylov ();
156 
158 
160 
175  void setParameters (const Teuchos::ParameterList& params);
176 
178  void initialize ();
179 
181  inline bool isInitialized () const {
182  return IsInitialized_;
183  }
184 
186  void compute ();
187 
189  inline bool isComputed() const {
190  return IsComputed_;
191  }
192 
194 
196 
219  virtual void setMatrix (const Teuchos::RCP<const row_matrix_type>& A);
220 
222 
224 
226  void
227  apply (const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& X,
228  Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& Y,
230  scalar_type alpha = Teuchos::ScalarTraits<scalar_type>::one(),
231  scalar_type beta = Teuchos::ScalarTraits<scalar_type>::zero()) const;
232 
235 
238 
240  bool hasTransposeApply() const;
241 
243 
245 
247  Teuchos::RCP<const Teuchos::Comm<int> > getComm() const;
248 
251 
253  int getNumInitialize() const;
254 
256  int getNumCompute() const;
257 
259  int getNumApply() const;
260 
262  double getInitializeTime() const;
263 
265  double getComputeTime() const;
266 
268  double getApplyTime() const;
269 
271 
272 
274  std::string description() const;
275 
278 
280 
281  private:
284 
286  Krylov (const Krylov<MatrixType>& RHS);
287 
289  Krylov<MatrixType>& operator= (const Krylov<MatrixType>& RHS);
290 
296 
298 
302  std::string iterationType_;
303 
305  int numIters_;
306 
308  magnitude_type resTol_;
309 
311  int BlockSize_;
312 
314  bool ZeroStartingSolution_;
315 
317  // 1 for relaxation
318  // 2 for ILUT
319  // 3 for RILUK
320  // 4 for Chebyshev
321  int PreconditionerType_;
322 
327  Teuchos::ParameterList precParams_;
328 
330  bool IsInitialized_;
332  bool IsComputed_;
334  int NumInitialize_;
336  int NumCompute_;
338  mutable int NumApply_;
340  double InitializeTime_;
342  double ComputeTime_;
344  mutable double ApplyTime_;
345 
347  Teuchos::RCP<Belos::LinearProblem<belos_scalar_type,
348  Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>,
349  Tpetra::Operator<scalar_type,local_ordinal_type,global_ordinal_type,node_type> > > belosProblem_;
350 
352  Teuchos::RCP<Belos::SolverManager<belos_scalar_type,
353  Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>,
354  Tpetra::Operator<scalar_type,local_ordinal_type,global_ordinal_type,node_type> > > belosSolver_;
355 
357  Teuchos::RCP<prec_type> ifpack2_prec_;
358  };
359 
360 } // namespace DeprecatedAndMayDisappearAtAnyTime
361 } // namespace Ifpack2
362 
363 #endif // HAVE_IFPACK2_DEPRECATED_CODE
364 #endif // IFPACK2_KRYLOV_DECL_HPP
Mix-in interface for preconditioners that can change their matrix after construction.
Definition: Ifpack2_Details_CanChangeMatrix.hpp:93
Interface for all Ifpack2 preconditioners.
Definition: Ifpack2_Preconditioner.hpp:107
Declaration of interface for preconditioners that can change their matrix after construction.
static const EVerbosityLevel verbLevel_default