IFPACK  Development
 All Classes Namespaces Files Functions Variables Enumerations Friends Pages
Ifpack_Polynomial.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_POLYNOMIAL_H
44 #define IFPACK_POLYNOMIAL_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 "Teuchos_LAPACK.hpp"
56 #include "Teuchos_SerialDenseMatrix.hpp"
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 
71 #ifdef HAVE_IFPACK_EPETRAEXT
72 class EpetraExt_PointToBlockDiagPermute;
73 #endif
74 
76 
106 
107 public:
108 
110 
117 
119 
124  Ifpack_Polynomial(const Epetra_RowMatrix* Matrix);
125 
127  virtual ~Ifpack_Polynomial() {};
128 
130 
137  virtual inline int SetUseTranspose(bool UseTranspose_in)
138  {
139  UseTranspose_ = UseTranspose_in;
140  return(0);
141  }
142 
144 
146 
148 
156  virtual int Apply(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
157 
159 
169  virtual int ApplyInverse(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
170 
172  virtual double NormInf() const
173  {
174  return(-1.0);
175  }
177 
179 
180  virtual const char * Label() const
181  {
182  return(Label_.c_str());
183  }
184 
186  virtual bool UseTranspose() const
187  {
188  return(UseTranspose_);
189  }
190 
192  virtual bool HasNormInf() const
193  {
194  return(false);
195  }
196 
198  virtual const Epetra_Comm & Comm() const;
199 
201  virtual const Epetra_Map & OperatorDomainMap() const;
202 
204  virtual const Epetra_Map & OperatorRangeMap() const;
205 
206  virtual int Initialize();
207 
208  virtual bool IsInitialized() const
209  {
210  return(IsInitialized_);
211  }
212 
214  virtual inline bool IsComputed() const
215  {
216  return(IsComputed_);
217  }
218 
220  virtual int Compute();
221 
223 
224  virtual const Epetra_RowMatrix& Matrix() const
225  {
226  return(*Matrix_);
227  }
228 
230  virtual double Condest(const Ifpack_CondestType CT = Ifpack_Cheap,
231  const int MaxIters = 1550,
232  const double Tol = 1e-9,
233  Epetra_RowMatrix* Matrix_in = 0);
234 
236  virtual double Condest() const
237  {
238  return(Condest_);
239  }
240 
242  virtual int SetParameters(Teuchos::ParameterList& List);
243 
245  virtual std::ostream& Print(std::ostream & os) const;
246 
248 
250 
252  virtual int NumInitialize() const
253  {
254  return(NumInitialize_);
255  }
256 
258  virtual int NumCompute() const
259  {
260  return(NumCompute_);
261  }
262 
264  virtual int NumApplyInverse() const
265  {
266  return(NumApplyInverse_);
267  }
268 
270  virtual double InitializeTime() const
271  {
272  return(InitializeTime_);
273  }
274 
276  virtual double ComputeTime() const
277  {
278  return(ComputeTime_);
279  }
280 
282  virtual double ApplyInverseTime() const
283  {
284  return(ApplyInverseTime_);
285  }
286 
288  virtual double InitializeFlops() const
289  {
290  return(0.0);
291  }
292 
294  virtual double ComputeFlops() const
295  {
296  return(ComputeFlops_);
297  }
298 
300  virtual double ApplyInverseFlops() const
301  {
302  return(ApplyInverseFlops_);
303  }
304 
305  // @}
306  // @{ \name Utility methods
307 
309  static int PowerMethod(const Epetra_Operator& Operator,
310  const Epetra_Vector& InvPointDiagonal,
311  const int MaximumIterations,
312  double& LambdaMax);
313 
315  static int CG(const Epetra_Operator& Operator,
316  const Epetra_Vector& InvPointDiagonal,
317  const int MaximumIterations,
318  double& lambda_min, double& lambda_max);
319 
320 #ifdef HAVE_IFPACK_EPETRAEXT
321  // WARNING: This only works in Block Mode.
323  int CG(const int MaximumIterations,
324  double& lambda_min, double& lambda_max);
326  // WARNING: This only works in Block Mode.
327  int PowerMethod(const int MaximumIterations,double& lambda_max);
328 #endif
329 
331  int GMRES(const Epetra_Operator& Operator,
332  const Epetra_Vector& InvPointDiagonal,
333  const int MaximumIterations,
334  double& lambda_real_min, double& lambda_real_max,
335  double& lambda_imag_min, double& lambda_imag_max);
336 
337 private:
338 
339  // @}
340  // @{ \name Private methods
341 
343  virtual void SetLabel();
344 
346  Ifpack_Polynomial(const Ifpack_Polynomial& /* rhs */)
347  {}
348 
350  Ifpack_Polynomial& operator=(const Ifpack_Polynomial& /* rhs */)
351  {
352  return(*this);
353  }
354 
355  // @{ Initializations, timing and flops
357  bool IsInitialized_;
359  bool IsComputed_;
361  bool IsIndefinite_;
363  bool IsComplex_;
365  int NumInitialize_;
367  int NumCompute_;
369  mutable int NumApplyInverse_;
371  double InitializeTime_;
373  double ComputeTime_;
375  mutable double ApplyInverseTime_;
377  double ComputeFlops_;
379  mutable double ApplyInverseFlops_;
380  // @}
381 
382  // @{ Settings
384  int PolyDegree_;
386  int LSPointsReal_, LSPointsImag_;
388  bool UseTranspose_;
390  double Condest_;
391 #if 0
392  // Unused; commented out to avoid build warnings
393 
395  bool ComputeCondest_;
396 #endif // 0
397  double RealEigRatio_, ImagEigRatio_;
401  int EigMaxIters_;
403  std::string Label_;
405  double LambdaRealMin_, LambdaRealMax_, LambdaImagMin_, LambdaImagMax_;
407  double MinDiagonalValue_;
409  std::vector<double> coeff_;
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 
434 
436  bool SolveNormalEquations_;
437 
439  bool IsRowMatrix_;
441  Teuchos::RefCountPtr<Epetra_Time> Time_;
443  bool ZeroStartingSolution_;
444 
445  // @}
446 
447 };
448 
449 
450 #endif // IFPACK_POLYNOMIAL_H
int GMRES(const Epetra_Operator &Operator, const Epetra_Vector &InvPointDiagonal, const int MaximumIterations, double &lambda_real_min, double &lambda_real_max, double &lambda_imag_min, double &lambda_imag_max)
Uses AztecOO&#39;s GMRES to estimate the height and width of the spectrum.
virtual bool HasNormInf() const
Returns true if the this object can provide an approximate Inf-norm, false otherwise.
virtual int NumInitialize() const
Returns the number of calls to Initialize().
virtual double ComputeTime() const
Returns the time spent in Compute().
virtual bool UseTranspose() const
Returns the current UseTranspose setting.
virtual const Epetra_Map & OperatorDomainMap() const
Returns the Epetra_Map object associated with the domain 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 int Initialize()
Computes all it is necessary to initialize the preconditioner.
virtual int NumApplyInverse() const
Returns the number of calls to ApplyInverse().
virtual int SetUseTranspose(bool UseTranspose_in)
virtual double NormInf() const
Returns the infinity norm of the global matrix (not implemented)
static int CG(const Epetra_Operator &Operator, const Epetra_Vector &InvPointDiagonal, const int MaximumIterations, double &lambda_min, double &lambda_max)
Uses AztecOO&#39;s CG to estimate lambda_min and lambda_max.
virtual ~Ifpack_Polynomial()
Destructor.
virtual int Compute()
Computes the preconditioners.
virtual bool IsInitialized() const
Returns true if the preconditioner has been successfully initialized, false otherwise.
Ifpack_Preconditioner: basic class for preconditioning in Ifpack.
Ifpack_Polynomial(const Epetra_Operator *Matrix)
Ifpack_Polynomial constructor with given Epetra_Operator/Epetra_RowMatrix.
virtual int SetParameters(Teuchos::ParameterList &List)
Sets all the parameters for the preconditioner.
Ifpack_Polynomial: class for preconditioning with least squares polynomials in Ifpack.
virtual bool IsComputed() const
Returns true if the preconditioner has been successfully computed.
virtual const Epetra_RowMatrix & Matrix() const
Returns a pointer to the matrix to be preconditioned.
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.
virtual double InitializeFlops() const
Returns the number of flops in the initialization phase.
virtual int NumCompute() const
Returns the number of calls to Compute().
static int PowerMethod(const Epetra_Operator &Operator, const Epetra_Vector &InvPointDiagonal, const int MaximumIterations, double &LambdaMax)
Simple power method to compute lambda_max.
virtual double InitializeTime() const
Returns the time spent in Initialize().
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 double ComputeFlops() const
Returns the number of flops in the computation phase.
virtual const Epetra_Comm & Comm() const
Returns a pointer to the Epetra_Comm communicator associated with this operator.
virtual const Epetra_Map & OperatorRangeMap() const
Returns the Epetra_Map object associated with the range of this operator.
virtual double Condest() const
Returns the condition number estimate, or -1.0 if not computed.