IFPACK  Development
 All Classes Namespaces Files Functions Variables Enumerations Friends Pages
Ifpack_Chebyshev.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_CHEBYSHEV_H
44 #define IFPACK_CHEBYSHEV_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 
56 namespace Teuchos {
57  class ParameterList;
58 }
59 
60 class Epetra_MultiVector;
61 class Epetra_Vector;
62 class Epetra_Map;
63 class Epetra_Comm;
64 class Epetra_Time;
65 class Epetra_Vector;
66 class Epetra_Operator;
67 class Epetra_RowMatrix;
68 
69 #ifdef HAVE_IFPACK_EPETRAEXT
70 class EpetraExt_PointToBlockDiagPermute;
71 #endif
72 
74 
111 
112 public:
113 
115 
122 
124 
129  Ifpack_Chebyshev(const Epetra_RowMatrix* Matrix);
130 
132  virtual ~Ifpack_Chebyshev() {};
133 
135 
142  virtual inline int SetUseTranspose(bool UseTranspose_in)
143  {
144  UseTranspose_ = UseTranspose_in;
145  return(0);
146  }
147 
149 
151 
153 
161  virtual int Apply(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
162 
164 
174  virtual int ApplyInverse(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
175 
177  virtual double NormInf() const
178  {
179  return(-1.0);
180  }
182 
184 
185  virtual const char * Label() const
186  {
187  return(Label_.c_str());
188  }
189 
191  virtual bool UseTranspose() const
192  {
193  return(UseTranspose_);
194  }
195 
197  virtual bool HasNormInf() const
198  {
199  return(false);
200  }
201 
203  virtual const Epetra_Comm & Comm() const;
204 
206  virtual const Epetra_Map & OperatorDomainMap() const;
207 
209  virtual const Epetra_Map & OperatorRangeMap() const;
210 
211  virtual int Initialize();
212 
213  virtual bool IsInitialized() const
214  {
215  return(IsInitialized_);
216  }
217 
219  virtual inline bool IsComputed() const
220  {
221  return(IsComputed_);
222  }
223 
225  virtual int Compute();
226 
228  virtual double GetLambdaMax(){return LambdaMax_;}
229 
231  virtual double GetLambdaMin(){return LambdaMin_;}
232 
234 
236 
237  virtual const Epetra_RowMatrix& Matrix() const
238  {
239  return(*Matrix_);
240  }
241 
243  virtual double Condest(const Ifpack_CondestType CT = Ifpack_Cheap,
244  const int MaxIters = 1550,
245  const double Tol = 1e-9,
246  Epetra_RowMatrix* Matrix_in = 0);
247 
249  virtual double Condest() const
250  {
251  return(Condest_);
252  }
253 
255  virtual int SetParameters(Teuchos::ParameterList& List);
256 
258  virtual std::ostream& Print(std::ostream & os) const;
259 
261 
263 
265  virtual int NumInitialize() const
266  {
267  return(NumInitialize_);
268  }
269 
271  virtual int NumCompute() const
272  {
273  return(NumCompute_);
274  }
275 
277  virtual int NumApplyInverse() const
278  {
279  return(NumApplyInverse_);
280  }
281 
283  virtual double InitializeTime() const
284  {
285  return(InitializeTime_);
286  }
287 
289  virtual double ComputeTime() const
290  {
291  return(ComputeTime_);
292  }
293 
295  virtual double ApplyInverseTime() const
296  {
297  return(ApplyInverseTime_);
298  }
299 
301  virtual double InitializeFlops() const
302  {
303  return(0.0);
304  }
305 
307  virtual double ComputeFlops() const
308  {
309  return(ComputeFlops_);
310  }
311 
313  virtual double ApplyInverseFlops() const
314  {
315  return(ApplyInverseFlops_);
316  }
317 
318  // @}
319  // @{ \name Utility methods
320 
322  static int PowerMethod(const Epetra_Operator& Operator,
323  const Epetra_Vector& InvPointDiagonal,
324  const int MaximumIterations,
325  double& LambdaMax,const unsigned int * RngSeed=0);
326 
328  static int CG(const Epetra_Operator& Operator,
329  const Epetra_Vector& InvPointDiagonal,
330  const int MaximumIterations,
331  double& lambda_min, double& lambda_max,const unsigned int * RngSeed=0);
332 
333 #ifdef HAVE_IFPACK_EPETRAEXT
334  // WARNING: This only works in Block Mode.
336  int CG(const int MaximumIterations,
337  double& lambda_min, double& lambda_max,const unsigned int * RngSeed=0);
339  // WARNING: This only works in Block Mode.
340  int PowerMethod(const int MaximumIterations,double& lambda_max,const unsigned int * RngSeed=0);
341 #endif
342 private:
343 
344  // @}
345  // @{ \name Private methods
346 
348  virtual void SetLabel();
349 
351  Ifpack_Chebyshev(const Ifpack_Chebyshev& /* rhs */)
352  {}
353 
355  Ifpack_Chebyshev& operator=(const Ifpack_Chebyshev& /* rhs */)
356  {
357  return(*this);
358  }
359 
360  // @{ Initializations, timing and flops
362  bool IsInitialized_;
364  bool IsComputed_;
366  int NumInitialize_;
368  int NumCompute_;
370  mutable int NumApplyInverse_;
372  double InitializeTime_;
374  double ComputeTime_;
376  mutable double ApplyInverseTime_;
378  double ComputeFlops_;
380  mutable double ApplyInverseFlops_;
381  // @}
382 
383  // @{ Settings
385  int PolyDegree_;
387  bool UseTranspose_;
389  double Condest_;
390 #if 0
391  // Unused; commented out to avoid build warnings
392 
394  bool ComputeCondest_;
395 #endif // 0
396  double EigRatio_;
400  int EigMaxIters_;
402  std::string Label_;
404  double LambdaMin_;
406  double LambdaMax_;
408  double MinDiagonalValue_;
409  // @}
410 
411  // @{ Other data
413  int NumMyRows_;
415  int NumMyNonzeros_;
417  long long NumGlobalRows_;
419  long long NumGlobalNonzeros_;
421  Teuchos::RefCountPtr<const Epetra_Operator> Operator_;
423  Teuchos::RefCountPtr<const Epetra_RowMatrix> Matrix_;
425  mutable Teuchos::RefCountPtr<Epetra_Vector> InvDiagonal_;
427  bool UseBlockMode_;
428 #ifdef HAVE_IFPACK_EPETRAEXT
429  Teuchos::ParameterList BlockList_;
431  Teuchos::RefCountPtr<EpetraExt_PointToBlockDiagPermute> InvBlockDiagonal_;
432 #endif
433 
435  bool SolveNormalEquations_;
436 
438  bool IsRowMatrix_;
440  Teuchos::RefCountPtr<Epetra_Time> Time_;
442  bool ZeroStartingSolution_;
443 
444  // @}
445 
446 };
447 
448 
449 #endif // IFPACK_CHEBYSHEV_H
virtual double NormInf() const
Returns the infinity norm of the global matrix (not implemented)
virtual int Compute()
Computes the preconditioners.
virtual ~Ifpack_Chebyshev()
Destructor.
virtual double ApplyInverseTime() const
Returns the time spent in ApplyInverse().
virtual double ComputeTime() const
Returns the time spent in Compute().
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.
virtual double GetLambdaMin()
Contains an approximation to the smallest eigenvalue.
virtual int NumApplyInverse() const
Returns the number of calls to ApplyInverse().
virtual bool IsComputed() const
Returns true if the preconditioner has been successfully computed.
virtual std::ostream & Print(std::ostream &os) const
Prints object to an output stream.
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().
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.
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.
virtual double ComputeFlops() const
Returns the number of flops in the computation phase.
virtual int SetUseTranspose(bool UseTranspose_in)
Ifpack_Chebyshev(const Epetra_Operator *Matrix)
Ifpack_Chebyshev constructor with given Epetra_Operator/Epetra_RowMatrix.
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.
virtual const Epetra_Comm & Comm() const
Returns a pointer to the Epetra_Comm communicator associated with this operator.
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.
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().