Ifpack Package Browser (Single Doxygen Collection)  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Ifpack_Polynomial.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_POLYNOMIAL_H
44 #define IFPACK_POLYNOMIAL_H
45 
46 #include "Ifpack_ConfigDefs.h"
47 #include "Ifpack_Preconditioner.h"
48 #include "Teuchos_RefCountPtr.hpp"
49 #include "Teuchos_LAPACK.hpp"
50 #include "Teuchos_SerialDenseMatrix.hpp"
51 
52 namespace Teuchos {
53  class ParameterList;
54 }
55 
56 class Epetra_MultiVector;
57 class Epetra_Vector;
58 class Epetra_Map;
59 class Epetra_Comm;
60 class Epetra_Time;
61 class Epetra_Vector;
62 class Epetra_Operator;
63 class Epetra_RowMatrix;
64 
65 #ifdef HAVE_IFPACK_EPETRAEXT
67 #endif
68 
70 
100 
101 public:
102 
104 
111 
113 
118  Ifpack_Polynomial(const Epetra_RowMatrix* Matrix);
119 
121  virtual ~Ifpack_Polynomial() {};
122 
124 
131  virtual inline int SetUseTranspose(bool UseTranspose_in)
132  {
133  UseTranspose_ = UseTranspose_in;
134  return(0);
135  }
136 
138 
140 
142 
150  virtual int Apply(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
151 
153 
163  virtual int ApplyInverse(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
164 
166  virtual double NormInf() const
167  {
168  return(-1.0);
169  }
171 
173 
174  virtual const char * Label() const
175  {
176  return(Label_.c_str());
177  }
178 
180  virtual bool UseTranspose() const
181  {
182  return(UseTranspose_);
183  }
184 
186  virtual bool HasNormInf() const
187  {
188  return(false);
189  }
190 
192  virtual const Epetra_Comm & Comm() const;
193 
195  virtual const Epetra_Map & OperatorDomainMap() const;
196 
198  virtual const Epetra_Map & OperatorRangeMap() const;
199 
200  virtual int Initialize();
201 
202  virtual bool IsInitialized() const
203  {
204  return(IsInitialized_);
205  }
206 
208  virtual inline bool IsComputed() const
209  {
210  return(IsComputed_);
211  }
212 
214  virtual int Compute();
215 
217 
218  virtual const Epetra_RowMatrix& Matrix() const
219  {
220  return(*Matrix_);
221  }
222 
224  virtual double Condest(const Ifpack_CondestType CT = Ifpack_Cheap,
225  const int MaxIters = 1550,
226  const double Tol = 1e-9,
227  Epetra_RowMatrix* Matrix_in = 0);
228 
230  virtual double Condest() const
231  {
232  return(Condest_);
233  }
234 
236  virtual int SetParameters(Teuchos::ParameterList& List);
237 
239  virtual std::ostream& Print(std::ostream & os) const;
240 
242 
244 
246  virtual int NumInitialize() const
247  {
248  return(NumInitialize_);
249  }
250 
252  virtual int NumCompute() const
253  {
254  return(NumCompute_);
255  }
256 
258  virtual int NumApplyInverse() const
259  {
260  return(NumApplyInverse_);
261  }
262 
264  virtual double InitializeTime() const
265  {
266  return(InitializeTime_);
267  }
268 
270  virtual double ComputeTime() const
271  {
272  return(ComputeTime_);
273  }
274 
276  virtual double ApplyInverseTime() const
277  {
278  return(ApplyInverseTime_);
279  }
280 
282  virtual double InitializeFlops() const
283  {
284  return(0.0);
285  }
286 
288  virtual double ComputeFlops() const
289  {
290  return(ComputeFlops_);
291  }
292 
294  virtual double ApplyInverseFlops() const
295  {
296  return(ApplyInverseFlops_);
297  }
298 
299  // @}
300  // @{ \name Utility methods
301 
303  static int PowerMethod(const Epetra_Operator& Operator,
304  const Epetra_Vector& InvPointDiagonal,
305  const int MaximumIterations,
306  double& LambdaMax);
307 
309  static int CG(const Epetra_Operator& Operator,
310  const Epetra_Vector& InvPointDiagonal,
311  const int MaximumIterations,
312  double& lambda_min, double& lambda_max);
313 
314 #ifdef HAVE_IFPACK_EPETRAEXT
315  // WARNING: This only works in Block Mode.
317  int CG(const int MaximumIterations,
318  double& lambda_min, double& lambda_max);
320  // WARNING: This only works in Block Mode.
321  int PowerMethod(const int MaximumIterations,double& lambda_max);
322 #endif
323 
325  int GMRES(const Epetra_Operator& Operator,
326  const Epetra_Vector& InvPointDiagonal,
327  const int MaximumIterations,
328  double& lambda_real_min, double& lambda_real_max,
329  double& lambda_imag_min, double& lambda_imag_max);
330 
331 private:
332 
333  // @}
334  // @{ \name Private methods
335 
337  virtual void SetLabel();
338 
341  {}
342 
345  {
346  return(*this);
347  }
348 
349  // @{ Initializations, timing and flops
363  mutable int NumApplyInverse_;
367  double ComputeTime_;
369  mutable double ApplyInverseTime_;
373  mutable double ApplyInverseFlops_;
374  // @}
375 
376  // @{ Settings
384  double Condest_;
385 #if 0
386  // Unused; commented out to avoid build warnings
387 
389  bool ComputeCondest_;
390 #endif // 0
397  std::string Label_;
403  std::vector<double> coeff_;
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 
428 
431 
435  Teuchos::RefCountPtr<Epetra_Time> Time_;
438 
439  // @}
440 
441 };
442 
443 
444 #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.
bool IsInitialized_
If true, the preconditioner has been computed successfully.
Ifpack_Polynomial(const Ifpack_Polynomial &)
Copy constructor (PRIVATE, should not be used)
bool ZeroStartingSolution_
If true, the starting solution is always the zero vector.
Teuchos::RefCountPtr< Epetra_Vector > InvDiagonal_
Contains the inverse of diagonal elements of Matrix.
int NumCompute_
Contains the number of successful call to Compute().
virtual bool HasNormInf() const
Returns true if the this object can provide an approximate Inf-norm, false otherwise.
double ApplyInverseFlops_
Contain sthe number of flops for ApplyInverse().
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.
double Condest_
Contains the estimated condition number.
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.
double ApplyInverseTime_
Contains the time for all successful calls to ApplyInverse().
virtual int NumApplyInverse() const
Returns the number of calls to ApplyInverse().
long long NumGlobalNonzeros_
Number of global nonzeros.
int LSPointsReal_
Contains the number of discretization points of the least squares problem.
double RealEigRatio_
Contains the ratio such that the rectangular domain in the complex plane is [-LambdaRealMax_ / EigRat...
virtual int SetUseTranspose(bool UseTranspose_in)
virtual double NormInf() const
Returns the infinity norm of the global matrix (not implemented)
long long NumGlobalRows_
Number of global rows.
double ComputeFlops_
Contains the number of flops for Compute().
bool UseTranspose_
If true, use the tranpose of Matrix_.
Teuchos::RefCountPtr< const Epetra_RowMatrix > Matrix_
Pointers to the matrix to be preconditioned as an Epetra_RowMatrix.
std::string Label_
Contains the label of this object.
int NumApplyInverse_
Contains the number of successful call to ApplyInverse().
Teuchos::RefCountPtr< Epetra_Time > Time_
Time object to track timing.
Ifpack_CondestType
Ifpack_CondestType: enum to define the type of condition number estimate.
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.
Ifpack_Polynomial & operator=(const Ifpack_Polynomial &)
operator = (PRIVATE, should not be used)
virtual ~Ifpack_Polynomial()
Destructor.
virtual int Compute()
Computes the preconditioners.
std::vector< double > coeff_
coefficients of the polynomial
int PolyDegree_
Contains the degree of the least squares polynomial.
virtual bool IsInitialized() const
Returns true if the preconditioner has been successfully initialized, false otherwise.
Ifpack_Preconditioner: basic class for preconditioning in Ifpack.
Teuchos::RefCountPtr< const Epetra_Operator > Operator_
Pointers to the matrix to be preconditioned as an Epetra_Operator.
double InitializeTime_
Contains the time for all successful calls to Initialize().
double MinDiagonalValue_
Contains the minimum value on the diagonal.
Ifpack_Polynomial(const Epetra_Operator *Matrix)
Ifpack_Polynomial constructor with given Epetra_Operator/Epetra_RowMatrix.
int NumMyNonzeros_
Number of local nonzeros.
double ComputeTime_
Contains the time for all successful calls to Compute().
virtual int SetParameters(Teuchos::ParameterList &List)
Sets all the parameters for the preconditioner.
Ifpack_Polynomial: class for preconditioning with least squares polynomials in Ifpack.
bool IsComputed_
If true, the preconditioner has been computed successfully.
virtual const char * Label() const
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.
int NumMyRows_
Number of local rows.
cheap estimate
virtual double InitializeFlops() const
Returns the number of flops in the initialization phase.
bool IsIndefinite_
If true, have to compute polynomial for a spectrum with negative eigenvalues.
int EigMaxIters_
Max number of iterations to use in eigenvalue estimation (if automatic).
bool SolveNormalEquations_
Run on the normal equations.
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().
bool UseBlockMode_
Use Block Preconditioning.
bool IsRowMatrix_
If true, the Operator_ is an Epetra_RowMatrix.
double LambdaRealMin_
Bounds on the spectrum.
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.
int NumInitialize_
Contains the number of successful calls to Initialize().
bool IsComplex_
If true, have to compute polynomial for a spectrum with nonzero imaginary part.
virtual const Epetra_Comm & Comm() const
Returns a pointer to the Epetra_Comm communicator associated with this operator.
virtual void SetLabel()
Sets the label.
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.