IFPACK Development
Loading...
Searching...
No Matches
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#include "Ifpack_ConfigDefs.h"
47#include "Ifpack_Preconditioner.h"
48#include "Teuchos_RefCountPtr.hpp"
49
50namespace Teuchos {
51 class ParameterList;
52}
53
55class Epetra_Vector;
56class Epetra_Map;
57class Epetra_Comm;
58class Epetra_Time;
59class Epetra_Vector;
60class Epetra_Operator;
62
63#ifdef HAVE_IFPACK_EPETRAEXT
64class EpetraExt_PointToBlockDiagPermute;
65#endif
66
68
105
106public:
107
109
116
118
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 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
329 // 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
336private:
337
338 // @}
339 // @{ \name Private methods
340
342 virtual void SetLabel();
343
345 Ifpack_Chebyshev(const Ifpack_Chebyshev& /* rhs */)
346 {}
347
349 Ifpack_Chebyshev& operator=(const Ifpack_Chebyshev& /* rhs */)
350 {
351 return(*this);
352 }
353
354 // @{ Initializations, timing and flops
356 bool IsInitialized_;
358 bool IsComputed_;
360 int NumInitialize_;
362 int NumCompute_;
364 mutable int NumApplyInverse_;
366 double InitializeTime_;
368 double ComputeTime_;
370 mutable double ApplyInverseTime_;
372 double ComputeFlops_;
374 mutable double ApplyInverseFlops_;
375 // @}
376
377 // @{ Settings
379 int PolyDegree_;
381 bool UseTranspose_;
383 double Condest_;
384#if 0
385 // Unused; commented out to avoid build warnings
386
388 bool ComputeCondest_;
389#endif // 0
392 double EigRatio_;
394 int EigMaxIters_;
396 std::string Label_;
398 double LambdaMin_;
400 double LambdaMax_;
402 double MinDiagonalValue_;
403 // @}
404
405 // @{ Other data
407 int NumMyRows_;
409 int NumMyNonzeros_;
411 long long NumGlobalRows_;
413 long long NumGlobalNonzeros_;
415 Teuchos::RefCountPtr<const Epetra_Operator> Operator_;
417 Teuchos::RefCountPtr<const Epetra_RowMatrix> Matrix_;
419 mutable Teuchos::RefCountPtr<Epetra_Vector> InvDiagonal_;
421 bool UseBlockMode_;
422#ifdef HAVE_IFPACK_EPETRAEXT
424 Teuchos::ParameterList BlockList_;
425 Teuchos::RefCountPtr<EpetraExt_PointToBlockDiagPermute> InvBlockDiagonal_;
426#endif
427
429 bool SolveNormalEquations_;
430
432 bool IsRowMatrix_;
434 Teuchos::RefCountPtr<Epetra_Time> Time_;
436 bool ZeroStartingSolution_;
437
438 // @}
439
440};
441
442
443#endif // IFPACK_CHEBYSHEV_H
Ifpack_Chebyshev: class for preconditioning with Chebyshev polynomials in Ifpack.
virtual int NumInitialize() const
Returns the number of calls to Initialize().
virtual double InitializeFlops() const
Returns the number of flops in the initialization phase.
virtual const Epetra_RowMatrix & Matrix() const
Returns a pointer to the matrix to be preconditioned.
virtual bool UseTranspose() const
Returns the current UseTranspose setting.
virtual double ComputeFlops() const
Returns the number of flops in the computation phase.
virtual bool HasNormInf() const
Returns true if the this object can provide an approximate Inf-norm, false otherwise.
virtual double ComputeTime() const
Returns the time spent in Compute().
virtual int SetParameters(Teuchos::ParameterList &List)
Sets all the parameters for the preconditioner.
virtual int NumApplyInverse() const
Returns the number of calls to ApplyInverse().
virtual double ApplyInverseTime() const
Returns the time spent in ApplyInverse().
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 SetUseTranspose(bool UseTranspose_in)
virtual int ApplyInverse(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Applies the preconditioner to X, returns the result in Y.
virtual double GetLambdaMax()
Returns an approximation to the largest eigenvalue.
virtual double GetLambdaMin()
Contains an approximation to the smallest eigenvalue.
virtual const Epetra_Map & OperatorDomainMap() const
Returns the Epetra_Map object associated with the domain of this operator.
virtual bool IsComputed() const
Returns true if the preconditioner has been successfully computed.
virtual int Compute()
Computes the preconditioners.
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's CG to estimate lambda_min and lambda_max.
virtual double InitializeTime() const
Returns the time spent in Initialize().
virtual std::ostream & Print(std::ostream &os) const
Prints object to an output stream.
virtual int Initialize()
Computes all it is necessary to initialize the preconditioner.
virtual double ApplyInverseFlops() const
Returns the number of flops for the application of the preconditioner.
virtual int Apply(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Applies the matrix to an Epetra_MultiVector.
virtual double NormInf() const
Returns the infinity norm of the global matrix (not implemented)
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 ~Ifpack_Chebyshev()
Destructor.
virtual bool IsInitialized() const
Returns true if the preconditioner has been successfully initialized, false otherwise.
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.
Ifpack_Preconditioner: basic class for preconditioning in Ifpack.