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 #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
83 #endif
84 
86 
88 
89  typedef double SC;
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 
293  {
294  return(*this);
295  }
296 
297  // @{ Initializations, timing and flops
307  mutable int NumApplyInverse_;
311  double ComputeTime_;
313  mutable double ApplyInverseTime_;
317  mutable double ApplyInverseFlops_;
318  // @}
319 
320  // @{ Settings
324  double Tolerance_;
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
354  long long NumGlobalRows_;
358  Teuchos::RefCountPtr<Epetra_Operator> Operator_;
360  Teuchos::RefCountPtr<Epetra_RowMatrix> Matrix_;
361 
365  Teuchos::RefCountPtr<Epetra_Time> Time_;
368 
369  // Aztec solver
370 #ifdef HAVE_IFPACK_AZTECOO
371  Teuchos::RCP<AztecOO> AztecSolver_;
372 #endif
373 
374  // Inner preconditioner
376 
377 };
378 
379 
380 #endif // IFPACK_KRYLOV_H
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:91
int Iterations_
Max number of iterations.
Epetra_MultiVector MV
Definition: Ifpack_Krylov.h:90
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:87
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:92
int NumMyNonzeros_
Number of local nonzeros.
virtual ~Ifpack_Krylov()
Destructor.
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.