IFPACK Development
Loading...
Searching...
No Matches
Ifpack_Krylov.h
1/*@HEADER
2// ***********************************************************************
3//
4// Ifpack: Object-Oriented Algebraic Preconditioner Package
5// Copyright (2002) 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
43#ifndef IFPACK_KRYLOV_H
44#define IFPACK_KRYLOV_H
45
46#include "Ifpack_ConfigDefs.h"
47#include "Ifpack_Preconditioner.h"
48#include "Teuchos_RefCountPtr.hpp"
49#include "Ifpack_PointRelaxation.h"
50#include "Ifpack_BlockRelaxation.h"
51#include "Ifpack_SparseContainer.h"
52#include "Ifpack_DenseContainer.h"
53#include "Ifpack_Amesos.h"
54#ifdef HAVE_IFPACK_AZTECOO
55#include "AztecOO.h"
56#endif
57
58namespace Teuchos {
59 class ParameterList;
60}
61
63class Epetra_Vector;
64class Epetra_Map;
65class Epetra_Comm;
66class Epetra_Time;
67class Epetra_Vector;
68class Epetra_Operator;
70#ifdef HAVE_IFPACK_AZTECOO
71class AztecOO;
72#endif
73
74
75#ifdef HAVE_IFPACK_EPETRAEXT
76class EpetraExt_PointToBlockDiagPermute;
77#endif
78
80
82
83 typedef double SC;
84 typedef Epetra_MultiVector MV;
85 typedef Epetra_Operator OP;
86 typedef Epetra_RowMatrix RM;
87
88public:
89
92
95
97 virtual ~Ifpack_Krylov() {};
98
100
107 virtual inline int SetUseTranspose(bool UseTranspose_in)
108 {
109 UseTranspose_ = UseTranspose_in;
110 return(0);
111 }
112
114
116
118
126 virtual int Apply(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
127
129
139 virtual int ApplyInverse(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
140
142 virtual double NormInf() const
143 {
144 return(-1.0);
145 }
147
149
150 virtual const char * Label() const
151 {
152 return(Label_.c_str());
153 }
154
156 virtual bool UseTranspose() const
157 {
158 return(UseTranspose_);
159 }
160
162 virtual bool HasNormInf() const
163 {
164 return(false);
165 }
166
168 virtual const Epetra_Comm & Comm() const;
169
171 virtual const Epetra_Map & OperatorDomainMap() const;
172
174 virtual const Epetra_Map & OperatorRangeMap() const;
175
176 virtual int Initialize();
177
178 virtual bool IsInitialized() const
179 {
180 return(IsInitialized_);
181 }
182
184 virtual inline bool IsComputed() const
185 {
186 return(IsComputed_);
187 }
188
190 virtual int Compute();
191
192 virtual const Epetra_RowMatrix& Matrix() const
193 {
194 return(*Matrix_);
195 }
196
198 virtual double Condest(const Ifpack_CondestType CT = Ifpack_Cheap,
199 const int MaxIters = 1550,
200 const double Tol = 1e-9,
201 Epetra_RowMatrix* Matrix_in = 0);
202
204 virtual double Condest() const
205 {
206 return(Condest_);
207 }
208
210 virtual int SetParameters(Teuchos::ParameterList& List);
211
213 virtual std::ostream& Print(std::ostream & os) const;
214
216
218
220 virtual int NumInitialize() const
221 {
222 return(NumInitialize_);
223 }
224
226 virtual int NumCompute() const
227 {
228 return(NumCompute_);
229 }
230
232 virtual int NumApplyInverse() const
233 {
234 return(NumApplyInverse_);
235 }
236
238 virtual double InitializeTime() const
239 {
240 return(InitializeTime_);
241 }
242
244 virtual double ComputeTime() const
245 {
246 return(ComputeTime_);
247 }
248
250 virtual double ApplyInverseTime() const
251 {
252 return(ApplyInverseTime_);
253 }
254
256 virtual double InitializeFlops() const
257 {
258 return(0.0);
259 }
260
262 virtual double ComputeFlops() const
263 {
264 return(ComputeFlops_);
265 }
266
268 virtual double ApplyInverseFlops() const
269 {
270 return(ApplyInverseFlops_);
271 }
272
273private:
274
275 // @}
276 // @{ \name Private methods
277
279 virtual void SetLabel();
280
282 Ifpack_Krylov(const Ifpack_Krylov& /* rhs */)
283 {}
284
286 Ifpack_Krylov& operator=(const Ifpack_Krylov& /* rhs */)
287 {
288 return(*this);
289 }
290
291 // @{ Initializations, timing and flops
293 bool IsInitialized_;
295 bool IsComputed_;
297 int NumInitialize_;
299 int NumCompute_;
301 mutable int NumApplyInverse_;
303 double InitializeTime_;
305 double ComputeTime_;
307 mutable double ApplyInverseTime_;
309 double ComputeFlops_;
311 mutable double ApplyInverseFlops_;
312 // @}
313
314 // @{ Settings
316 int Iterations_;
318 double Tolerance_;
320 int SolverType_;
322 int PreconditionerType_;
324 int NumSweeps_;
326 int BlockSize_;
328 double DampingParameter_;
330 bool UseTranspose_;
332 double Condest_;
333#if 0
334 // Unused; commented out to avoid build warnings.
335
337 bool ComputeCondest_;
338#endif // 0
340 std::string Label_;
341
342 // @{ Other data
344 int NumMyRows_;
346 int NumMyNonzeros_;
348 long long NumGlobalRows_;
350 long long NumGlobalNonzeros_;
352 Teuchos::RefCountPtr<Epetra_Operator> Operator_;
354 Teuchos::RefCountPtr<Epetra_RowMatrix> Matrix_;
355
357 bool IsRowMatrix_;
359 Teuchos::RefCountPtr<Epetra_Time> Time_;
361 bool ZeroStartingSolution_;
362
363 // Aztec solver
364#ifdef HAVE_IFPACK_AZTECOO
365 Teuchos::RCP<AztecOO> AztecSolver_;
366#endif
367
368 // Inner preconditioner
369 Teuchos::RCP<Ifpack_Preconditioner> IfpackPrec_;
370
371};
372
373
374#endif // IFPACK_KRYLOV_H
Ifpack_Krylov: class for smoothing with Krylov solvers in Ifpack.
Definition: Ifpack_Krylov.h:81
virtual double NormInf() const
Returns the infinity norm of the global matrix (not implemented)
virtual const Epetra_Map & OperatorRangeMap() const
Returns the Epetra_Map object associated with the range of this operator.
virtual int Compute()
Computes the preconditioners.
virtual bool IsComputed() const
Returns true if the preconditioner has been successfully computed.
virtual double ApplyInverseTime() const
Returns the time spent in ApplyInverse().
virtual double Condest() const
Returns the condition number estimate, or -1.0 if not computed.
virtual double InitializeFlops() const
Returns the number of flops in the initialization phase.
virtual int SetParameters(Teuchos::ParameterList &List)
Sets all the parameters for the preconditioner.
virtual ~Ifpack_Krylov()
Destructor.
Definition: Ifpack_Krylov.h:97
virtual bool HasNormInf() const
Returns true if the this object can provide an approximate Inf-norm, false otherwise.
virtual bool UseTranspose() const
Returns the current UseTranspose setting.
virtual std::ostream & Print(std::ostream &os) const
Prints object to an output stream.
virtual int ApplyInverse(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Applies the preconditioner to X, returns the result in Y.
virtual int Apply(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Applies the matrix to an Epetra_MultiVector.
virtual int SetUseTranspose(bool UseTranspose_in)
virtual double ComputeTime() const
Returns the time spent in Compute().
virtual int NumInitialize() const
Returns the number of calls to Initialize().
virtual bool IsInitialized() const
Returns true if the preconditioner has been successfully initialized, false otherwise.
virtual int Initialize()
Computes all it is necessary to initialize the preconditioner.
virtual int NumApplyInverse() const
Returns the number of calls to ApplyInverse().
virtual const Epetra_RowMatrix & Matrix() const
Returns a pointer to the matrix to be preconditioned.
virtual const Epetra_Comm & Comm() const
Returns a pointer to the Epetra_Comm communicator associated with this operator.
virtual double ApplyInverseFlops() const
Returns the number of flops for the application of the preconditioner.
virtual int NumCompute() const
Returns the number of calls to Compute().
virtual double InitializeTime() const
Returns the time spent in Initialize().
virtual const Epetra_Map & OperatorDomainMap() const
Returns the Epetra_Map object associated with the domain of this operator.
virtual double ComputeFlops() const
Returns the number of flops in the computation phase.
Ifpack_Preconditioner: basic class for preconditioning in Ifpack.