Ifpack Package Browser (Single Doxygen Collection)  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Ifpack_Krylov.h
Go to the documentation of this file.
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 
58 namespace Teuchos {
59  class ParameterList;
60 }
61 
62 class Epetra_MultiVector;
63 class Epetra_Vector;
64 class Epetra_Map;
65 class Epetra_Comm;
66 class Epetra_Time;
67 class Epetra_Vector;
68 class Epetra_Operator;
69 class Epetra_RowMatrix;
70 #ifdef HAVE_IFPACK_AZTECOO
71 class AztecOO;
72 #endif
73 
74 
75 #ifdef HAVE_IFPACK_EPETRAEXT
77 #endif
78 
80 
82 
83  typedef double SC;
87 
88 public:
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 
273 private:
274 
275  // @}
276  // @{ \name Private methods
277 
279  virtual void SetLabel();
280 
282  Ifpack_Krylov(const Ifpack_Krylov& /* rhs */)
283  {}
284 
287  {
288  return(*this);
289  }
290 
291  // @{ Initializations, timing and flops
301  mutable int NumApplyInverse_;
305  double ComputeTime_;
307  mutable double ApplyInverseTime_;
311  mutable double ApplyInverseFlops_;
312  // @}
313 
314  // @{ Settings
318  double Tolerance_;
332  double Condest_;
333 #if 0
334  // Unused; commented out to avoid build warnings.
335 
337  bool ComputeCondest_;
338 #endif // 0
339  std::string Label_;
341 
342  // @{ Other data
348  long long NumGlobalRows_;
352  Teuchos::RefCountPtr<Epetra_Operator> Operator_;
354  Teuchos::RefCountPtr<Epetra_RowMatrix> Matrix_;
355 
359  Teuchos::RefCountPtr<Epetra_Time> Time_;
362 
363  // Aztec solver
364 #ifdef HAVE_IFPACK_AZTECOO
365  Teuchos::RCP<AztecOO> AztecSolver_;
366 #endif
367 
368  // Inner preconditioner
370 
371 };
372 
373 
374 #endif // IFPACK_KRYLOV_H
375 
376 #if defined(Ifpack_SHOW_DEPRECATED_WARNINGS)
377 #ifdef __GNUC__
378 #warning "The Ifpack package is deprecated"
379 #endif
380 #endif
381 
int NumApplyInverse_
Contains the number of successful call to ApplyInverse().
virtual int NumInitialize() const
Returns the number of calls to Initialize().
int PreconditionerType_
Preconditioner - 0 for none, 1 for Jacobi, 2 for GS, 3 for SGS.
double Tolerance_
Residual Tolerance.
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.
double ApplyInverseTime_
Contains the time for all successful calls to ApplyInverse().
double DampingParameter_
Damping parameter for inner preconditioner.
virtual double InitializeTime() const
Returns the time spent in Initialize().
virtual void SetLabel()
Sets the label.
virtual double ComputeTime() const
Returns the time spent in Compute().
virtual const char * Label() const
bool ZeroStartingSolution_
If true, the starting solution is always the zero vector.
int NumInitialize_
Contains the number of successful calls to Initialize().
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.
int NumSweeps_
Number of GS or Jacobi sweeps.
double ComputeFlops_
Contains the number of flops for Compute().
Ifpack_Krylov & operator=(const Ifpack_Krylov &)
operator = (PRIVATE, should not be used)
int BlockSize_
Block Size (for block relaxation)
std::string Label_
Contains the label of this object.
virtual double NormInf() const
Returns the infinity norm of the global matrix (not implemented)
long long NumGlobalRows_
Number of global rows.
virtual int Compute()
Computes the preconditioners.
Ifpack_CondestType
Ifpack_CondestType: enum to define the type of condition number estimate.
double ApplyInverseFlops_
Contain sthe number of flops for ApplyInverse().
Teuchos::RefCountPtr< Epetra_Operator > Operator_
Pointers to the matrix as an Epetra_Operator.
Epetra_Operator OP
Definition: Ifpack_Krylov.h:85
int Iterations_
Max number of iterations.
Epetra_MultiVector MV
Definition: Ifpack_Krylov.h:84
virtual int SetUseTranspose(bool UseTranspose_in)
Ifpack_Krylov(const Ifpack_Krylov &)
Copy constructor (PRIVATE, should not be used)
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.
bool IsInitialized_
If true, the preconditioner has been computed successfully.
int NumCompute_
Contains the number of successful call to Compute().
virtual bool IsComputed() const
Returns true if the preconditioner has been successfully computed.
long long NumGlobalNonzeros_
Number of global nonzeros.
bool IsRowMatrix_
If true, the Operator_ is an Epetra_RowMatrix.
double InitializeTime_
Contains the time for all successful calls to Initialize().
int NumMyRows_
Number of local rows.
virtual const Epetra_Map & OperatorRangeMap() const
Returns the Epetra_Map object associated with the range of this operator.
Ifpack_Krylov(Epetra_Operator *Matrix)
Ifpack_Krylov: class for smoothing with Krylov solvers in Ifpack.
Definition: Ifpack_Krylov.h:81
Teuchos::RefCountPtr< Epetra_Time > Time_
Time object to track timing.
double ComputeTime_
Contains the time for all successful calls to Compute().
virtual const Epetra_RowMatrix & Matrix() const
Returns a pointer to the matrix to be preconditioned.
Teuchos::RCP< Ifpack_Preconditioner > IfpackPrec_
cheap estimate
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().
Epetra_RowMatrix RM
Definition: Ifpack_Krylov.h:86
int NumMyNonzeros_
Number of local nonzeros.
virtual ~Ifpack_Krylov()
Destructor.
Definition: Ifpack_Krylov.h:97
Teuchos::RefCountPtr< Epetra_RowMatrix > Matrix_
Pointers to the matrix as an Epetra_RowMatrix.
bool UseTranspose_
If true, use the tranpose of Matrix_.
bool IsComputed_
If true, the preconditioner has been computed successfully.
virtual int ApplyInverse(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Applies the preconditioner to X, returns the result in Y.
double Condest_
Contains the estimated condition number.
int SolverType_
Solver - 0 for CG, 1 for GMRES.