Ifpack Package Browser (Single Doxygen Collection)  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Ifpack_PointRelaxation.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_POINTRELAXATION_H
44 #define IFPACK_POINTRELAXATION_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 
55 #include "Epetra_Vector.h"
56 #include "Epetra_Time.h"
57 #include "Epetra_RowMatrix.h"
58 #include "Epetra_Import.h"
59 
60 #include "Teuchos_RefCountPtr.hpp"
61 
62 namespace Teuchos {
63  class ParameterList;
64 }
65 class Epetra_MultiVector;
66 class Epetra_Vector;
67 class Epetra_Map;
68 class Epetra_Comm;
69 class Epetra_CrsMatrix;
70 
72 
137 
138 public:
139 
141 
147 
150 
152 
159  virtual inline int SetUseTranspose(bool UseTranspose_in)
160  {
161  UseTranspose_ = UseTranspose_in;
162  return(0);
163  }
164 
166 
168 
170 
178  virtual inline int Apply(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const
179  {
180  if (IsComputed() == false)
181  IFPACK_CHK_ERR(-3);
182 
183  if (X.NumVectors() != Y.NumVectors())
184  IFPACK_CHK_ERR(-2);
185 
186  IFPACK_CHK_ERR(Matrix_->Multiply(UseTranspose(),X,Y));
187  return(0);
188  }
189 
191 
201  virtual int ApplyInverse(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
202 
204  virtual double NormInf() const
205  {
206  return(-1.0);
207  }
209 
211 
212  virtual const char * Label() const
213  {
214  return(Label_.c_str());
215  }
216 
218  virtual bool UseTranspose() const
219  {
220  return(UseTranspose_);
221  }
222 
224  virtual bool HasNormInf() const
225  {
226  return(false);
227  }
228 
230  virtual const Epetra_Comm & Comm() const;
231 
233  virtual const Epetra_Map & OperatorDomainMap() const;
234 
236  virtual const Epetra_Map & OperatorRangeMap() const;
237 
238  virtual int Initialize();
239 
240  virtual bool IsInitialized() const
241  {
242  return(IsInitialized_);
243  }
244 
246  virtual inline bool IsComputed() const
247  {
248  return(IsComputed_);
249  }
250 
252  virtual int Compute();
253 
255 
257 
258  virtual const Epetra_RowMatrix& Matrix() const
259  {
260  return(*Matrix_);
261  }
262 
264  virtual double Condest(const Ifpack_CondestType CT = Ifpack_Cheap,
265  const int MaxIters = 1550,
266  const double Tol = 1e-9,
267  Epetra_RowMatrix* Matrix = 0);
268 
270  virtual double Condest() const
271  {
272  return(Condest_);
273  }
274 
276  virtual int SetParameters(Teuchos::ParameterList& List);
277 
279  virtual std::ostream& Print(std::ostream & os) const;
280 
282 
284 
286  virtual int NumInitialize() const
287  {
288  return(NumInitialize_);
289  }
290 
292  virtual int NumCompute() const
293  {
294  return(NumCompute_);
295  }
296 
298  virtual int NumApplyInverse() const
299  {
300  return(NumApplyInverse_);
301  }
302 
304  virtual double InitializeTime() const
305  {
306  return(InitializeTime_);
307  }
308 
310  virtual double ComputeTime() const
311  {
312  return(ComputeTime_);
313  }
314 
316  virtual double ApplyInverseTime() const
317  {
318  return(ApplyInverseTime_);
319  }
320 
322  virtual double InitializeFlops() const
323  {
324  return(0.0);
325  }
326 
328  virtual double ComputeFlops() const
329  {
330  return(ComputeFlops_);
331  }
332 
334  virtual double ApplyInverseFlops() const
335  {
336  return(ApplyInverseFlops_);
337  }
338 
339  // @}
340 
341 private:
342 
343  // @{ Application of the preconditioner
344 
346  virtual int ApplyInverseJacobi(const Epetra_MultiVector& X,
347  Epetra_MultiVector& Y) const;
348 
350  virtual int ApplyInverseGS(const Epetra_MultiVector& X,
351  Epetra_MultiVector& Y) const;
352 
353  virtual int ApplyInverseGS_RowMatrix(const Epetra_MultiVector& X,
354  Epetra_MultiVector& Y) const;
355 
356  virtual int ApplyInverseGS_CrsMatrix(const Epetra_CrsMatrix* A,
357  const Epetra_MultiVector& X,
358  Epetra_MultiVector& Y) const;
359 
361  const Epetra_MultiVector& X,
362  Epetra_MultiVector& Y) const;
364  const Epetra_MultiVector& X,
365  Epetra_MultiVector& Y) const;
366 
368  virtual int ApplyInverseSGS(const Epetra_MultiVector& X,
369  Epetra_MultiVector& Y) const;
370 
371  virtual int ApplyInverseSGS_RowMatrix(const Epetra_MultiVector& X,
372  Epetra_MultiVector& Y) const;
373 
374  virtual int ApplyInverseSGS_CrsMatrix(const Epetra_CrsMatrix* A,
375  const Epetra_MultiVector& X,
376  Epetra_MultiVector& Y) const;
377 
379  const Epetra_MultiVector& X,
380  Epetra_MultiVector& Y) const;
381 
383  const Epetra_MultiVector& X,
384  Epetra_MultiVector& Y) const;
385 
386 
388 
389 private:
390 
392  virtual void SetLabel();
393 
396  {}
397 
400  {
401  return(*this);
402  }
403 
404  // @{ Initializations, timing and flops
414  mutable int NumApplyInverse_;
418  double ComputeTime_;
420  mutable double ApplyInverseTime_;
424  mutable double ApplyInverseFlops_;
425  // @}
426 
427  // @{ Settings
435  double Condest_;
436 #if 0
437  // Unused; commented out to avoid build warnings
438 
440  bool ComputeCondest_;
441 #endif // 0
442  std::string Label_;
446  // @}
447 
448  // @{ Other data
454  long long NumGlobalRows_;
458  Teuchos::RefCountPtr<const Epetra_RowMatrix> Matrix_;
460  Teuchos::RefCountPtr<Epetra_Import> Importer_;
462  mutable Teuchos::RefCountPtr<Epetra_Vector> Diagonal_;
464  Teuchos::RefCountPtr<Epetra_Time> Time_;
474  double L1Eta_;
475 
480 
481  // @}
482 
483 
484 
485 };
486 
487 #endif // IFPACK_POINTRELAXATION_H
bool UseTranspose_
If true, use the tranpose of Matrix_.
int NumCompute_
Contains the number of successful call to Compute().
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.
std::string Label_
Contains the label of this object.
virtual const Epetra_Comm & Comm() const
Returns a pointer to the Epetra_Comm communicator associated with this operator.
Ifpack_PointRelaxation & operator=(const Ifpack_PointRelaxation &)
operator = (PRIVATE, should not be used)
virtual int ApplyInverseJacobi(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Applies the Jacobi preconditioner to X, returns the result in Y.
virtual const char * Label() const
virtual int NumApplyInverse() const
Returns the number of calls to ApplyInverse().
bool IsInitialized_
If true, the preconditioner has been computed successfully.
Ifpack_PointRelaxation(const Ifpack_PointRelaxation &)
Copy constructor (PRIVATE, should not be used)
virtual const Epetra_Map & OperatorDomainMap() const
Returns the Epetra_Map object associated with the domain of this operator.
virtual int ApplyInverseGS_CrsMatrix(const Epetra_CrsMatrix *A, const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
virtual double ComputeFlops() const
Returns the number of flops in the computation phase.
double ComputeFlops_
Contains the number of flops for Compute().
virtual int SetUseTranspose(bool UseTranspose_in)
double InitializeTime_
Contains the time for all successful calls to Initialize().
virtual int ApplyInverseGS_LocalFastCrsMatrix(const Epetra_CrsMatrix *A, const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
virtual double ApplyInverseFlops() const
Returns the number of flops for the application of the preconditioner.
Ifpack_PointRelaxation(const Epetra_RowMatrix *Matrix)
Ifpack_PointRelaxation constructor with given Epetra_RowMatrix.
virtual int NumCompute() const
Returns the number of calls to Compute().
virtual double Condest() const
Returns the condition number estimate, or -1.0 if not computed.
virtual int SetParameters(Teuchos::ParameterList &List)
Sets all the parameters for the preconditioner.
virtual double ComputeTime() const
Returns the time spent in Compute().
long long NumGlobalNonzeros_
Number of global nonzeros.
Ifpack_CondestType
Ifpack_CondestType: enum to define the type of condition number estimate.
Teuchos::RefCountPtr< Epetra_Vector > Diagonal_
Contains the diagonal elements of Matrix.
int NumLocalSmoothingIndices_
Number of (local) unknowns for local smoothing.
long long NumGlobalRows_
Number of global rows.
virtual double NormInf() const
Returns the infinity norm of the global matrix (not implemented)
virtual int ApplyInverseSGS_RowMatrix(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
double ComputeTime_
Contains the time for all successful calls to Compute().
Teuchos::RefCountPtr< const Epetra_RowMatrix > Matrix_
Pointers to the matrix to be preconditioned.
virtual int ApplyInverseGS_RowMatrix(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
virtual bool UseTranspose() const
Returns the current UseTranspose setting.
Ifpack_Preconditioner: basic class for preconditioning in Ifpack.
virtual bool IsInitialized() const
Returns true if the preconditioner has been successfully initialized, false otherwise.
Ifpack_PointRelaxation: a class to define point relaxation preconditioners of for Epetra_RowMatrix&#39;s...
double L1Eta_
Eta parameter for modified L1 method.
virtual int Compute()
Computes the preconditioners.
virtual int ApplyInverseSGS(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Applies the symmetric Gauss-Seidel preconditioner to X, returns the result in Y.
int NumInitialize_
Contains the number of successful calls to Initialize().
bool IsComputed_
If true, the preconditioner has been computed successfully.
virtual int Initialize()
Computes all it is necessary to initialize the preconditioner.
virtual const Epetra_RowMatrix & Matrix() const
Returns a pointer to the matrix to be preconditioned.
bool ZeroStartingSolution_
If true, the starting solution is always the zero vector.
double ApplyInverseFlops_
Contain sthe number of flops for ApplyInverse().
virtual bool IsComputed() const
Returns true if the preconditioner has been successfully computed.
int NumMyRows_
Number of local rows.
bool IsParallel_
If true, more than 1 processor is currently used.
virtual int ApplyInverseGS(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Applies the Gauss-Seidel preconditioner to X, returns the result in Y.
double DampingFactor_
Damping factor.
cheap estimate
double ApplyInverseTime_
Contains the time for all successful calls to ApplyInverse().
virtual int NumInitialize() const
Returns the number of calls to Initialize().
virtual int ApplyInverseSGS_LocalFastCrsMatrix(const Epetra_CrsMatrix *A, const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
virtual int ApplyInverseSGS_CrsMatrix(const Epetra_CrsMatrix *A, const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
virtual int ApplyInverseGS_FastCrsMatrix(const Epetra_CrsMatrix *A, const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
bool DoBackwardGS_
Backward-Mode Gauss Seidel.
int NumSweeps_
Number of application of the preconditioner (should be greater than 0).
int NumApplyInverse_
Contains the number of successful call to ApplyInverse().
virtual double InitializeFlops() const
Returns the number of flops in the initialization phase.
int * LocalSmoothingIndices_
List of (local) unknowns for local smoothing (if any)
virtual bool HasNormInf() const
Returns true if the this object can provide an approximate Inf-norm, false otherwise.
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 InitializeTime() const
Returns the time spent in Initialize().
#define IFPACK_CHK_ERR(ifpack_err)
virtual double ApplyInverseTime() const
Returns the time spent in ApplyInverse().
Teuchos::RefCountPtr< Epetra_Time > Time_
Time object to track timing.
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.
int NumMyNonzeros_
Number of local nonzeros.
Teuchos::RefCountPtr< Epetra_Import > Importer_
Importer for parallel GS and SGS.
virtual int ApplyInverseSGS_FastCrsMatrix(const Epetra_CrsMatrix *A, const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
bool DoL1Method_
Do L1 Jacobi/GS/SGS.
virtual ~Ifpack_PointRelaxation()
Destructor.