IFPACK  Development
 All Classes Namespaces Files Functions Variables Enumerations Friends Pages
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 #if defined(Ifpack_SHOW_DEPRECATED_WARNINGS)
47 #ifdef __GNUC__
48 #warning "The Ifpack package is deprecated"
49 #endif
50 #endif
51 
52 #include "Ifpack_ConfigDefs.h"
53 #include "Ifpack_Preconditioner.h"
54 #include "Teuchos_RefCountPtr.hpp"
55 #include "Ifpack_PointRelaxation.h"
56 #include "Ifpack_BlockRelaxation.h"
57 #include "Ifpack_SparseContainer.h"
58 #include "Ifpack_DenseContainer.h"
59 #include "Ifpack_Amesos.h"
60 #ifdef HAVE_IFPACK_AZTECOO
61 #include "AztecOO.h"
62 #endif
63 
64 namespace Teuchos {
65  class ParameterList;
66 }
67 
68 class Epetra_MultiVector;
69 class Epetra_Vector;
70 class Epetra_Map;
71 class Epetra_Comm;
72 class Epetra_Time;
73 class Epetra_Vector;
74 class Epetra_Operator;
75 class Epetra_RowMatrix;
76 #ifdef HAVE_IFPACK_AZTECOO
77 class AztecOO;
78 #endif
79 
80 
81 #ifdef HAVE_IFPACK_EPETRAEXT
82 class EpetraExt_PointToBlockDiagPermute;
83 #endif
84 
86 
88 
89  typedef double SC;
90  typedef Epetra_MultiVector MV;
91  typedef Epetra_Operator OP;
92  typedef Epetra_RowMatrix RM;
93 
94 public:
95 
98 
101 
103  virtual ~Ifpack_Krylov() {};
104 
106 
113  virtual inline int SetUseTranspose(bool UseTranspose_in)
114  {
115  UseTranspose_ = UseTranspose_in;
116  return(0);
117  }
118 
120 
122 
124 
132  virtual int Apply(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
133 
135 
145  virtual int ApplyInverse(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
146 
148  virtual double NormInf() const
149  {
150  return(-1.0);
151  }
153 
155 
156  virtual const char * Label() const
157  {
158  return(Label_.c_str());
159  }
160 
162  virtual bool UseTranspose() const
163  {
164  return(UseTranspose_);
165  }
166 
168  virtual bool HasNormInf() const
169  {
170  return(false);
171  }
172 
174  virtual const Epetra_Comm & Comm() const;
175 
177  virtual const Epetra_Map & OperatorDomainMap() const;
178 
180  virtual const Epetra_Map & OperatorRangeMap() const;
181 
182  virtual int Initialize();
183 
184  virtual bool IsInitialized() const
185  {
186  return(IsInitialized_);
187  }
188 
190  virtual inline bool IsComputed() const
191  {
192  return(IsComputed_);
193  }
194 
196  virtual int Compute();
197 
198  virtual const Epetra_RowMatrix& Matrix() const
199  {
200  return(*Matrix_);
201  }
202 
204  virtual double Condest(const Ifpack_CondestType CT = Ifpack_Cheap,
205  const int MaxIters = 1550,
206  const double Tol = 1e-9,
207  Epetra_RowMatrix* Matrix_in = 0);
208 
210  virtual double Condest() const
211  {
212  return(Condest_);
213  }
214 
216  virtual int SetParameters(Teuchos::ParameterList& List);
217 
219  virtual std::ostream& Print(std::ostream & os) const;
220 
222 
224 
226  virtual int NumInitialize() const
227  {
228  return(NumInitialize_);
229  }
230 
232  virtual int NumCompute() const
233  {
234  return(NumCompute_);
235  }
236 
238  virtual int NumApplyInverse() const
239  {
240  return(NumApplyInverse_);
241  }
242 
244  virtual double InitializeTime() const
245  {
246  return(InitializeTime_);
247  }
248 
250  virtual double ComputeTime() const
251  {
252  return(ComputeTime_);
253  }
254 
256  virtual double ApplyInverseTime() const
257  {
258  return(ApplyInverseTime_);
259  }
260 
262  virtual double InitializeFlops() const
263  {
264  return(0.0);
265  }
266 
268  virtual double ComputeFlops() const
269  {
270  return(ComputeFlops_);
271  }
272 
274  virtual double ApplyInverseFlops() const
275  {
276  return(ApplyInverseFlops_);
277  }
278 
279 private:
280 
281  // @}
282  // @{ \name Private methods
283 
285  virtual void SetLabel();
286 
288  Ifpack_Krylov(const Ifpack_Krylov& /* rhs */)
289  {}
290 
292  Ifpack_Krylov& operator=(const Ifpack_Krylov& /* rhs */)
293  {
294  return(*this);
295  }
296 
297  // @{ Initializations, timing and flops
299  bool IsInitialized_;
301  bool IsComputed_;
303  int NumInitialize_;
305  int NumCompute_;
307  mutable int NumApplyInverse_;
309  double InitializeTime_;
311  double ComputeTime_;
313  mutable double ApplyInverseTime_;
315  double ComputeFlops_;
317  mutable double ApplyInverseFlops_;
318  // @}
319 
320  // @{ Settings
322  int Iterations_;
324  double Tolerance_;
326  int SolverType_;
328  int PreconditionerType_;
330  int NumSweeps_;
332  int BlockSize_;
334  double DampingParameter_;
336  bool UseTranspose_;
338  double Condest_;
339 #if 0
340  // Unused; commented out to avoid build warnings.
341 
343  bool ComputeCondest_;
344 #endif // 0
345  std::string Label_;
347 
348  // @{ Other data
350  int NumMyRows_;
352  int NumMyNonzeros_;
354  long long NumGlobalRows_;
356  long long NumGlobalNonzeros_;
358  Teuchos::RefCountPtr<Epetra_Operator> Operator_;
360  Teuchos::RefCountPtr<Epetra_RowMatrix> Matrix_;
361 
363  bool IsRowMatrix_;
365  Teuchos::RefCountPtr<Epetra_Time> Time_;
367  bool ZeroStartingSolution_;
368 
369  // Aztec solver
370 #ifdef HAVE_IFPACK_AZTECOO
371  Teuchos::RCP<AztecOO> AztecSolver_;
372 #endif
373 
374  // Inner preconditioner
375  Teuchos::RCP<Ifpack_Preconditioner> IfpackPrec_;
376 
377 };
378 
379 
380 #endif // IFPACK_KRYLOV_H
virtual int NumInitialize() const
Returns the number of calls to Initialize().
virtual double ComputeFlops() const
Returns the number of flops in the computation phase.
virtual int Initialize()
Computes all it is necessary to initialize the preconditioner.
virtual int Apply(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Applies the matrix to an Epetra_MultiVector.
virtual int NumCompute() const
Returns the number of calls to Compute().
virtual double Condest() const
Returns the condition number estimate, or -1.0 if not computed.
virtual double InitializeTime() const
Returns the time spent in Initialize().
virtual double ComputeTime() const
Returns the time spent in Compute().
virtual bool HasNormInf() const
Returns true if the this object can provide an approximate Inf-norm, false otherwise.
virtual int NumApplyInverse() const
Returns the number of calls to ApplyInverse().
virtual double InitializeFlops() const
Returns the number of flops in the initialization phase.
virtual double NormInf() const
Returns the infinity norm of the global matrix (not implemented)
virtual int Compute()
Computes the preconditioners.
virtual int SetUseTranspose(bool UseTranspose_in)
Ifpack_Preconditioner: basic class for preconditioning in Ifpack.
virtual int SetParameters(Teuchos::ParameterList &List)
Sets all the parameters for the preconditioner.
virtual std::ostream & Print(std::ostream &os) const
Prints object to an output stream.
virtual const Epetra_Map & OperatorDomainMap() const
Returns the Epetra_Map object associated with the domain of this operator.
virtual bool IsInitialized() const
Returns true if the preconditioner has been successfully initialized, false otherwise.
virtual bool IsComputed() const
Returns true if the preconditioner has been successfully computed.
virtual const Epetra_Map & OperatorRangeMap() const
Returns the Epetra_Map object associated with the range of this operator.
Ifpack_Krylov: class for smoothing with Krylov solvers in Ifpack.
Definition: Ifpack_Krylov.h:87
virtual const Epetra_RowMatrix & Matrix() const
Returns a pointer to the matrix to be preconditioned.
virtual bool UseTranspose() const
Returns the current UseTranspose setting.
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 double ApplyInverseTime() const
Returns the time spent in ApplyInverse().
virtual ~Ifpack_Krylov()
Destructor.
virtual int ApplyInverse(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Applies the preconditioner to X, returns the result in Y.