Ifpack Package Browser (Single Doxygen Collection)  Development
Ifpack_Krylov.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_KRYLOV_H
44 #define IFPACK_KRYLOV_H
45 
46 #include "Ifpack_ConfigDefs.h"
47 #include "Ifpack_Preconditioner.h"
48 #include "Teuchos_RefCountPtr.hpp"
49 #include "Ifpack_PointRelaxation.h"
50 #include "Ifpack_BlockRelaxation.h"
51 #include "Ifpack_SparseContainer.h"
52 #include "Ifpack_DenseContainer.h"
53 #include "Ifpack_Amesos.h"
54 #ifdef HAVE_IFPACK_AZTECOO
55 #include "AztecOO.h"
56 #endif
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 #ifdef HAVE_IFPACK_AZTECOO
71 class AztecOO;
72 #endif
73 
74 
75 #ifdef HAVE_IFPACK_EPETRAEXT
76 class EpetraExt_PointToBlockDiagPermute;
77 #endif
78 
80 
82 
83  typedef double SC;
87 
88 public:
89 
92 
95 
97  virtual ~Ifpack_Krylov() {};
98 
100 
107  virtual inline int SetUseTranspose(bool UseTranspose_in)
108  {
109  UseTranspose_ = UseTranspose_in;
110  return(0);
111  }
112 
114 
116 
118 
126  virtual inline int Apply(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
127 
129 
139  virtual int ApplyInverse(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
140 
142  virtual double NormInf() const
143  {
144  return(-1.0);
145  }
147 
149 
150  virtual const char * Label() const
151  {
152  return(Label_.c_str());
153  }
154 
156  virtual bool UseTranspose() const
157  {
158  return(UseTranspose_);
159  }
160 
162  virtual bool HasNormInf() const
163  {
164  return(false);
165  }
166 
168  virtual const Epetra_Comm & Comm() const;
169 
171  virtual const Epetra_Map & OperatorDomainMap() const;
172 
174  virtual const Epetra_Map & OperatorRangeMap() const;
175 
176  virtual int Initialize();
177 
178  virtual bool IsInitialized() const
179  {
180  return(IsInitialized_);
181  }
182 
184  virtual inline bool IsComputed() const
185  {
186  return(IsComputed_);
187  }
188 
190  virtual int Compute();
191 
192  virtual const Epetra_RowMatrix& Matrix() const
193  {
194  return(*Matrix_);
195  }
196 
198  virtual double Condest(const Ifpack_CondestType CT = Ifpack_Cheap,
199  const int MaxIters = 1550,
200  const double Tol = 1e-9,
201  Epetra_RowMatrix* Matrix_in = 0);
202 
204  virtual double Condest() const
205  {
206  return(Condest_);
207  }
208 
210  virtual int SetParameters(Teuchos::ParameterList& List);
211 
213  virtual std::ostream& Print(std::ostream & os) const;
214 
216 
218 
220  virtual int NumInitialize() const
221  {
222  return(NumInitialize_);
223  }
224 
226  virtual int NumCompute() const
227  {
228  return(NumCompute_);
229  }
230 
232  virtual int NumApplyInverse() const
233  {
234  return(NumApplyInverse_);
235  }
236 
238  virtual double InitializeTime() const
239  {
240  return(InitializeTime_);
241  }
242 
244  virtual double ComputeTime() const
245  {
246  return(ComputeTime_);
247  }
248 
250  virtual double ApplyInverseTime() const
251  {
252  return(ApplyInverseTime_);
253  }
254 
256  virtual double InitializeFlops() const
257  {
258  return(0.0);
259  }
260 
262  virtual double ComputeFlops() const
263  {
264  return(ComputeFlops_);
265  }
266 
268  virtual double ApplyInverseFlops() const
269  {
270  return(ApplyInverseFlops_);
271  }
272 
273 private:
274 
275  // @}
276  // @{ \name Private methods
277 
279  virtual void SetLabel();
280 
283  {}
284 
287  {
288  return(*this);
289  }
290 
291  // @{ Initializations, timing and flops
301  mutable int NumApplyInverse_;
305  double ComputeTime_;
307  mutable double ApplyInverseTime_;
311  mutable double ApplyInverseFlops_;
312  // @}
313 
314  // @{ Settings
318  double Tolerance_;
332  double Condest_;
333 #if 0
334  // Unused; commented out to avoid build warnings.
335 
337  bool ComputeCondest_;
338 #endif // 0
339  std::string Label_;
341 
342  // @{ Other data
348  long long NumGlobalRows_;
352  Teuchos::RefCountPtr<Epetra_Operator> Operator_;
354  Teuchos::RefCountPtr<Epetra_RowMatrix> Matrix_;
355 
359  Teuchos::RefCountPtr<Epetra_Time> Time_;
362 
363  // Aztec solver
364 #ifdef HAVE_IFPACK_AZTECOO
365  Teuchos::RCP<AztecOO> AztecSolver_;
366 #endif
367 
368  // Inner preconditioner
370 
371 };
372 
373 
374 #endif // IFPACK_KRYLOV_H
Ifpack_Preconditioner.h
Ifpack_Krylov::NumCompute
virtual int NumCompute() const
Returns the number of calls to Compute().
Definition: Ifpack_Krylov.h:226
Ifpack_Krylov::NumInitialize_
int NumInitialize_
Contains the number of successful calls to Initialize().
Definition: Ifpack_Krylov.h:297
Ifpack_Krylov::ApplyInverseTime_
double ApplyInverseTime_
Contains the time for all successful calls to ApplyInverse().
Definition: Ifpack_Krylov.h:307
Ifpack_Krylov::DampingParameter_
double DampingParameter_
Damping parameter for inner preconditioner.
Definition: Ifpack_Krylov.h:328
Ifpack_Krylov::IsComputed
virtual bool IsComputed() const
Returns true if the preconditioner has been successfully computed.
Definition: Ifpack_Krylov.h:184
Ifpack_Krylov::HasNormInf
virtual bool HasNormInf() const
Returns true if the this object can provide an approximate Inf-norm, false otherwise.
Definition: Ifpack_Krylov.h:162
Ifpack_Krylov::IsComputed_
bool IsComputed_
If true, the preconditioner has been computed successfully.
Definition: Ifpack_Krylov.h:295
Ifpack_Krylov::ComputeTime_
double ComputeTime_
Contains the time for all successful calls to Compute().
Definition: Ifpack_Krylov.h:305
Ifpack_Krylov::BlockSize_
int BlockSize_
Block Size (for block relaxation)
Definition: Ifpack_Krylov.h:326
Ifpack_Krylov::ZeroStartingSolution_
bool ZeroStartingSolution_
If true, the starting solution is always the zero vector.
Definition: Ifpack_Krylov.h:361
Ifpack_Krylov::NumMyNonzeros_
int NumMyNonzeros_
Number of local nonzeros.
Definition: Ifpack_Krylov.h:346
Ifpack_Krylov::~Ifpack_Krylov
virtual ~Ifpack_Krylov()
Destructor.
Definition: Ifpack_Krylov.h:97
Ifpack_Krylov::NumGlobalRows_
long long NumGlobalRows_
Number of global rows.
Definition: Ifpack_Krylov.h:348
Ifpack_SparseContainer.h
Ifpack_Krylov::MV
Epetra_MultiVector MV
Definition: Ifpack_Krylov.h:84
Ifpack_Krylov::Print
virtual std::ostream & Print(std::ostream &os) const
Prints object to an output stream.
Definition: Ifpack_Krylov.cpp:310
Ifpack_Krylov::InitializeTime
virtual double InitializeTime() const
Returns the time spent in Initialize().
Definition: Ifpack_Krylov.h:238
Ifpack_Krylov::Condest_
double Condest_
Contains the estimated condition number.
Definition: Ifpack_Krylov.h:332
Ifpack_Krylov::RM
Epetra_RowMatrix RM
Definition: Ifpack_Krylov.h:86
Ifpack_Krylov::Apply
virtual int Apply(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Applies the matrix to an Epetra_MultiVector.
Definition: Ifpack_Krylov.cpp:178
Ifpack_Krylov::UseTranspose
virtual bool UseTranspose() const
Returns the current UseTranspose setting.
Definition: Ifpack_Krylov.h:156
Ifpack_Krylov::Condest
virtual double Condest() const
Returns the condition number estimate, or -1.0 if not computed.
Definition: Ifpack_Krylov.h:204
Ifpack_Krylov::ApplyInverseFlops_
double ApplyInverseFlops_
Contain sthe number of flops for ApplyInverse().
Definition: Ifpack_Krylov.h:311
Ifpack_Krylov::Matrix_
Teuchos::RefCountPtr< Epetra_RowMatrix > Matrix_
Pointers to the matrix as an Epetra_RowMatrix.
Definition: Ifpack_Krylov.h:354
Ifpack_Krylov::IsInitialized_
bool IsInitialized_
If true, the preconditioner has been computed successfully.
Definition: Ifpack_Krylov.h:293
Ifpack_Krylov::Ifpack_Krylov
Ifpack_Krylov(const Ifpack_Krylov &rhs)
Copy constructor (PRIVATE, should not be used)
Definition: Ifpack_Krylov.h:282
Ifpack_Krylov::Time_
Teuchos::RefCountPtr< Epetra_Time > Time_
Time object to track timing.
Definition: Ifpack_Krylov.h:359
Ifpack_Krylov::NumInitialize
virtual int NumInitialize() const
Returns the number of calls to Initialize().
Definition: Ifpack_Krylov.h:220
Ifpack_Krylov::IsRowMatrix_
bool IsRowMatrix_
If true, the Operator_ is an Epetra_RowMatrix.
Definition: Ifpack_Krylov.h:357
Ifpack_Krylov
Ifpack_Krylov: class for smoothing with Krylov solvers in Ifpack.
Definition: Ifpack_Krylov.h:81
Ifpack_Krylov::IfpackPrec_
Teuchos::RCP< Ifpack_Preconditioner > IfpackPrec_
Definition: Ifpack_Krylov.h:369
Ifpack_Krylov::InitializeTime_
double InitializeTime_
Contains the time for all successful calls to Initialize().
Definition: Ifpack_Krylov.h:303
Epetra_Comm
Ifpack_CondestType
Ifpack_CondestType
Ifpack_CondestType: enum to define the type of condition number estimate.
Definition: Ifpack_CondestType.h:48
Ifpack_Krylov::SC
double SC
Definition: Ifpack_Krylov.h:83
Ifpack_Krylov::Initialize
virtual int Initialize()
Computes all it is necessary to initialize the preconditioner.
Definition: Ifpack_Krylov.cpp:199
Ifpack_PointRelaxation.h
Ifpack_Cheap
cheap estimate
Definition: Ifpack_CondestType.h:49
Ifpack_Krylov::SolverType_
int SolverType_
Solver - 0 for CG, 1 for GMRES.
Definition: Ifpack_Krylov.h:320
Teuchos::RCP
Ifpack_Krylov::Matrix
virtual const Epetra_RowMatrix & Matrix() const
Returns a pointer to the matrix to be preconditioned.
Definition: Ifpack_Krylov.h:192
Ifpack_Krylov::PreconditionerType_
int PreconditionerType_
Preconditioner - 0 for none, 1 for Jacobi, 2 for GS, 3 for SGS.
Definition: Ifpack_Krylov.h:322
Ifpack_Krylov::OperatorRangeMap
virtual const Epetra_Map & OperatorRangeMap() const
Returns the Epetra_Map object associated with the range of this operator.
Definition: Ifpack_Krylov.cpp:171
Ifpack_ConfigDefs.h
Ifpack_Krylov::NumApplyInverse
virtual int NumApplyInverse() const
Returns the number of calls to ApplyInverse().
Definition: Ifpack_Krylov.h:232
Epetra_RowMatrix
Ifpack_Krylov::operator=
Ifpack_Krylov & operator=(const Ifpack_Krylov &rhs)
operator = (PRIVATE, should not be used)
Definition: Ifpack_Krylov.h:286
Ifpack_Krylov::NumSweeps_
int NumSweeps_
Number of GS or Jacobi sweeps.
Definition: Ifpack_Krylov.h:324
Epetra_Vector
Ifpack_Krylov::InitializeFlops
virtual double InitializeFlops() const
Returns the number of flops in the initialization phase.
Definition: Ifpack_Krylov.h:256
Ifpack_Krylov::UseTranspose_
bool UseTranspose_
If true, use the tranpose of Matrix_.
Definition: Ifpack_Krylov.h:330
Ifpack_Krylov::Label_
std::string Label_
Contains the label of this object.
Definition: Ifpack_Krylov.h:340
Ifpack_Krylov::SetParameters
virtual int SetParameters(Teuchos::ParameterList &List)
Sets all the parameters for the preconditioner.
Definition: Ifpack_Krylov.cpp:144
Ifpack_Amesos.h
Ifpack_Krylov::ComputeFlops
virtual double ComputeFlops() const
Returns the number of flops in the computation phase.
Definition: Ifpack_Krylov.h:262
Ifpack_Krylov::NormInf
virtual double NormInf() const
Returns the infinity norm of the global matrix (not implemented)
Definition: Ifpack_Krylov.h:142
Ifpack_Krylov::OP
Epetra_Operator OP
Definition: Ifpack_Krylov.h:85
Ifpack_Krylov::Compute
virtual int Compute()
Computes the preconditioners.
Definition: Ifpack_Krylov.cpp:233
Ifpack_Krylov::Iterations_
int Iterations_
Max number of iterations.
Definition: Ifpack_Krylov.h:316
Ifpack_Krylov::OperatorDomainMap
virtual const Epetra_Map & OperatorDomainMap() const
Returns the Epetra_Map object associated with the domain of this operator.
Definition: Ifpack_Krylov.cpp:165
Epetra_Time
Ifpack_BlockRelaxation.h
Ifpack_Krylov::SetUseTranspose
virtual int SetUseTranspose(bool UseTranspose_in)
Definition: Ifpack_Krylov.h:107
Epetra_MultiVector
Ifpack_Preconditioner
Ifpack_Preconditioner: basic class for preconditioning in Ifpack.
Definition: Ifpack_Preconditioner.h:136
Ifpack_DenseContainer.h
Ifpack_Krylov::NumMyRows_
int NumMyRows_
Number of local rows.
Definition: Ifpack_Krylov.h:344
Ifpack_Krylov::Tolerance_
double Tolerance_
Residual Tolerance.
Definition: Ifpack_Krylov.h:318
Ifpack_Krylov::Ifpack_Krylov
Ifpack_Krylov(Epetra_Operator *Matrix)
Definition: Ifpack_Krylov.cpp:68
Ifpack_Krylov::ComputeTime
virtual double ComputeTime() const
Returns the time spent in Compute().
Definition: Ifpack_Krylov.h:244
Ifpack_Krylov::ApplyInverseFlops
virtual double ApplyInverseFlops() const
Returns the number of flops for the application of the preconditioner.
Definition: Ifpack_Krylov.h:268
Ifpack_Krylov::Operator_
Teuchos::RefCountPtr< Epetra_Operator > Operator_
Pointers to the matrix as an Epetra_Operator.
Definition: Ifpack_Krylov.h:352
Teuchos::ParameterList
Ifpack_Krylov::NumApplyInverse_
int NumApplyInverse_
Contains the number of successful call to ApplyInverse().
Definition: Ifpack_Krylov.h:301
Teuchos
Ifpack_Krylov::Label
virtual const char * Label() const
Definition: Ifpack_Krylov.h:150
Ifpack_Krylov::ApplyInverse
virtual int ApplyInverse(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Applies the preconditioner to X, returns the result in Y.
Definition: Ifpack_Krylov.cpp:380
Epetra_Operator
Ifpack_Krylov::ApplyInverseTime
virtual double ApplyInverseTime() const
Returns the time spent in ApplyInverse().
Definition: Ifpack_Krylov.h:250
Ifpack_Krylov::Comm
virtual const Epetra_Comm & Comm() const
Returns a pointer to the Epetra_Comm communicator associated with this operator.
Definition: Ifpack_Krylov.cpp:159
Epetra_Map
Ifpack_Krylov::ComputeFlops_
double ComputeFlops_
Contains the number of flops for Compute().
Definition: Ifpack_Krylov.h:309
Ifpack_Krylov::IsInitialized
virtual bool IsInitialized() const
Returns true if the preconditioner has been successfully initialized, false otherwise.
Definition: Ifpack_Krylov.h:178
Ifpack_Krylov::NumCompute_
int NumCompute_
Contains the number of successful call to Compute().
Definition: Ifpack_Krylov.h:299
Ifpack_Krylov::NumGlobalNonzeros_
long long NumGlobalNonzeros_
Number of global nonzeros.
Definition: Ifpack_Krylov.h:350
Ifpack_Krylov::SetLabel
virtual void SetLabel()
Sets the label.
Definition: Ifpack_Krylov.cpp:373