Ifpack Package Browser (Single Doxygen Collection)  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Ifpack_Chebyshev.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_CHEBYSHEV_H
44 #define IFPACK_CHEBYSHEV_H
45 
46 #include "Ifpack_ConfigDefs.h"
47 #include "Ifpack_Preconditioner.h"
48 #include "Teuchos_RefCountPtr.hpp"
49 
50 namespace Teuchos {
51  class ParameterList;
52 }
53 
54 class Epetra_MultiVector;
55 class Epetra_Vector;
56 class Epetra_Map;
57 class Epetra_Comm;
58 class Epetra_Time;
59 class Epetra_Vector;
60 class Epetra_Operator;
61 class Epetra_RowMatrix;
62 
63 #ifdef HAVE_IFPACK_EPETRAEXT
65 #endif
66 
68 
105 
106 public:
107 
109 
116 
118 
123  Ifpack_Chebyshev(const Epetra_RowMatrix* Matrix);
124 
126  virtual ~Ifpack_Chebyshev() {};
127 
129 
136  virtual inline int SetUseTranspose(bool UseTranspose_in)
137  {
138  UseTranspose_ = UseTranspose_in;
139  return(0);
140  }
141 
143 
145 
147 
155  virtual inline int Apply(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
156 
158 
168  virtual int ApplyInverse(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
169 
171  virtual double NormInf() const
172  {
173  return(-1.0);
174  }
176 
178 
179  virtual const char * Label() const
180  {
181  return(Label_.c_str());
182  }
183 
185  virtual bool UseTranspose() const
186  {
187  return(UseTranspose_);
188  }
189 
191  virtual bool HasNormInf() const
192  {
193  return(false);
194  }
195 
197  virtual const Epetra_Comm & Comm() const;
198 
200  virtual const Epetra_Map & OperatorDomainMap() const;
201 
203  virtual const Epetra_Map & OperatorRangeMap() const;
204 
205  virtual int Initialize();
206 
207  virtual bool IsInitialized() const
208  {
209  return(IsInitialized_);
210  }
211 
213  virtual inline bool IsComputed() const
214  {
215  return(IsComputed_);
216  }
217 
219  virtual int Compute();
220 
222  virtual double GetLambdaMax(){return LambdaMax_;}
223 
225  virtual double GetLambdaMin(){return LambdaMin_;}
226 
228 
230 
231  virtual const Epetra_RowMatrix& Matrix() const
232  {
233  return(*Matrix_);
234  }
235 
237  virtual double Condest(const Ifpack_CondestType CT = Ifpack_Cheap,
238  const int MaxIters = 1550,
239  const double Tol = 1e-9,
240  Epetra_RowMatrix* Matrix_in = 0);
241 
243  virtual double Condest() const
244  {
245  return(Condest_);
246  }
247 
249  virtual int SetParameters(Teuchos::ParameterList& List);
250 
252  virtual std::ostream& Print(std::ostream & os) const;
253 
255 
257 
259  virtual int NumInitialize() const
260  {
261  return(NumInitialize_);
262  }
263 
265  virtual int NumCompute() const
266  {
267  return(NumCompute_);
268  }
269 
271  virtual int NumApplyInverse() const
272  {
273  return(NumApplyInverse_);
274  }
275 
277  virtual double InitializeTime() const
278  {
279  return(InitializeTime_);
280  }
281 
283  virtual double ComputeTime() const
284  {
285  return(ComputeTime_);
286  }
287 
289  virtual double ApplyInverseTime() const
290  {
291  return(ApplyInverseTime_);
292  }
293 
295  virtual double InitializeFlops() const
296  {
297  return(0.0);
298  }
299 
301  virtual double ComputeFlops() const
302  {
303  return(ComputeFlops_);
304  }
305 
307  virtual double ApplyInverseFlops() const
308  {
309  return(ApplyInverseFlops_);
310  }
311 
312  // @}
313  // @{ \name Utility methods
314 
316  static int PowerMethod(const Epetra_Operator& Operator,
317  const Epetra_Vector& InvPointDiagonal,
318  const int MaximumIterations,
319  double& LambdaMax,const unsigned int * RngSeed=0);
320 
322  static int CG(const Epetra_Operator& Operator,
323  const Epetra_Vector& InvPointDiagonal,
324  const int MaximumIterations,
325  double& lambda_min, double& lambda_max,const unsigned int * RngSeed=0);
326 
327 #ifdef HAVE_IFPACK_EPETRAEXT
328  // WARNING: This only works in Block Mode.
330  int CG(const int MaximumIterations,
331  double& lambda_min, double& lambda_max,const unsigned int * RngSeed=0);
333  // WARNING: This only works in Block Mode.
334  int PowerMethod(const int MaximumIterations,double& lambda_max,const unsigned int * RngSeed=0);
335 #endif
336 private:
337 
338  // @}
339  // @{ \name Private methods
340 
342  virtual void SetLabel();
343 
346  {}
347 
350  {
351  return(*this);
352  }
353 
354  // @{ Initializations, timing and flops
364  mutable int NumApplyInverse_;
368  double ComputeTime_;
370  mutable double ApplyInverseTime_;
374  mutable double ApplyInverseFlops_;
375  // @}
376 
377  // @{ Settings
383  double Condest_;
384 #if 0
385  // Unused; commented out to avoid build warnings
386 
388  bool ComputeCondest_;
389 #endif // 0
390  double EigRatio_;
396  std::string Label_;
398  double LambdaMin_;
400  double LambdaMax_;
403  // @}
404 
405  // @{ Other data
411  long long NumGlobalRows_;
415  Teuchos::RefCountPtr<const Epetra_Operator> Operator_;
417  Teuchos::RefCountPtr<const Epetra_RowMatrix> Matrix_;
419  mutable Teuchos::RefCountPtr<Epetra_Vector> InvDiagonal_;
422 #ifdef HAVE_IFPACK_EPETRAEXT
423  Teuchos::ParameterList BlockList_;
425  Teuchos::RefCountPtr<EpetraExt_PointToBlockDiagPermute> InvBlockDiagonal_;
426 #endif
427 
430 
434  Teuchos::RefCountPtr<Epetra_Time> Time_;
437 
438  // @}
439 
440 };
441 
442 
443 #endif // IFPACK_CHEBYSHEV_H
virtual double NormInf() const
Returns the infinity norm of the global matrix (not implemented)
double ApplyInverseFlops_
Contain sthe number of flops for ApplyInverse().
bool UseBlockMode_
Use Block Preconditioning.
virtual int Compute()
Computes the preconditioners.
int NumMyNonzeros_
Number of local nonzeros.
int NumCompute_
Contains the number of successful call to Compute().
double EigRatio_
Contains the ratio such that [LambdaMax_ / EigRatio_, LambdaMax_] is the interval of interest for the...
bool ZeroStartingSolution_
If true, the starting solution is always the zero vector.
virtual ~Ifpack_Chebyshev()
Destructor.
std::string Label_
Contains the label of this object.
virtual double ApplyInverseTime() const
Returns the time spent in ApplyInverse().
int EigMaxIters_
Max number of iterations to use in eigenvalue estimation (if automatic).
long long NumGlobalNonzeros_
Number of global nonzeros.
virtual double ComputeTime() const
Returns the time spent in Compute().
long long NumGlobalRows_
Number of global rows.
double LambdaMin_
Contains an approximation to the smallest eigenvalue.
virtual int SetParameters(Teuchos::ParameterList &List)
Sets all the parameters for the preconditioner.
virtual bool IsInitialized() const
Returns true if the preconditioner has been successfully initialized, false otherwise.
double ComputeFlops_
Contains the number of flops for Compute().
double ApplyInverseTime_
Contains the time for all successful calls to ApplyInverse().
virtual double GetLambdaMin()
Contains an approximation to the smallest eigenvalue.
virtual int NumApplyInverse() const
Returns the number of calls to ApplyInverse().
int PolyDegree_
Contains the degree of Chebyshev polynomial.
virtual bool IsComputed() const
Returns true if the preconditioner has been successfully computed.
bool IsRowMatrix_
If true, the Operator_ is an Epetra_RowMatrix.
Ifpack_CondestType
Ifpack_CondestType: enum to define the type of condition number estimate.
Teuchos::RefCountPtr< const Epetra_Operator > Operator_
Pointers to the matrix to be preconditioned as an Epetra_Operator.
virtual const char * Label() const
virtual std::ostream & Print(std::ostream &os) const
Prints object to an output stream.
Ifpack_Chebyshev(const Ifpack_Chebyshev &)
Copy constructor (PRIVATE, should not be used)
virtual int Apply(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Applies the matrix to an Epetra_MultiVector.
Ifpack_Chebyshev: class for preconditioning with Chebyshev polynomials in Ifpack. ...
Ifpack_Preconditioner: basic class for preconditioning in Ifpack.
virtual double InitializeTime() const
Returns the time spent in Initialize().
double InitializeTime_
Contains the time for all successful calls to Initialize().
double Condest_
Contains the estimated condition number.
bool SolveNormalEquations_
Run on the normal equations.
virtual const Epetra_Map & OperatorDomainMap() const
Returns the Epetra_Map object associated with the domain of this operator.
virtual double GetLambdaMax()
Returns an approximation to the largest eigenvalue.
virtual double Condest() const
Returns the condition number estimate, or -1.0 if not computed.
int NumMyRows_
Number of local rows.
static int CG(const Epetra_Operator &Operator, const Epetra_Vector &InvPointDiagonal, const int MaximumIterations, double &lambda_min, double &lambda_max, const unsigned int *RngSeed=0)
Uses AztecOO&#39;s CG to estimate lambda_min and lambda_max.
virtual bool UseTranspose() const
Returns the current UseTranspose setting.
virtual const Epetra_RowMatrix & Matrix() const
Returns a pointer to the matrix to be preconditioned.
int NumInitialize_
Contains the number of successful calls to Initialize().
virtual void SetLabel()
Sets the label.
bool IsInitialized_
If true, the preconditioner has been computed successfully.
virtual double ComputeFlops() const
Returns the number of flops in the computation phase.
cheap estimate
Teuchos::RefCountPtr< Epetra_Time > Time_
Time object to track timing.
virtual int SetUseTranspose(bool UseTranspose_in)
Ifpack_Chebyshev & operator=(const Ifpack_Chebyshev &)
operator = (PRIVATE, should not be used)
double LambdaMax_
Contains an approximation to the largest eigenvalue.
Ifpack_Chebyshev(const Epetra_Operator *Matrix)
Ifpack_Chebyshev constructor with given Epetra_Operator/Epetra_RowMatrix.
Teuchos::RefCountPtr< Epetra_Vector > InvDiagonal_
Contains the inverse of diagonal elements of Matrix.
virtual double InitializeFlops() const
Returns the number of flops in the initialization phase.
virtual int Initialize()
Computes all it is necessary to initialize the preconditioner.
double ComputeTime_
Contains the time for all successful calls to Compute().
virtual const Epetra_Comm & Comm() const
Returns a pointer to the Epetra_Comm communicator associated with this operator.
bool UseTranspose_
If true, use the tranpose of Matrix_.
virtual int NumCompute() const
Returns the number of calls to Compute().
virtual double ApplyInverseFlops() const
Returns the number of flops for the application of the preconditioner.
virtual const Epetra_Map & OperatorRangeMap() const
Returns the Epetra_Map object associated with the range of this operator.
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.
virtual bool HasNormInf() const
Returns true if the this object can provide an approximate Inf-norm, false otherwise.
static int PowerMethod(const Epetra_Operator &Operator, const Epetra_Vector &InvPointDiagonal, const int MaximumIterations, double &LambdaMax, const unsigned int *RngSeed=0)
Simple power method to compute lambda_max.
virtual int NumInitialize() const
Returns the number of calls to Initialize().
Teuchos::RefCountPtr< const Epetra_RowMatrix > Matrix_
Pointers to the matrix to be preconditioned as an Epetra_RowMatrix.
int NumApplyInverse_
Contains the number of successful call to ApplyInverse().
double MinDiagonalValue_
Contains the minimum value on the diagonal.