Ifpack Package Browser (Single Doxygen Collection)  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Ifpack_ICT.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_ICT_H
44 #define IFPACK_ICT_H
45 
46 #include "Ifpack_ConfigDefs.h"
47 #include "Ifpack_CondestType.h"
48 #include "Ifpack_ScalingType.h"
49 #include "Ifpack_Preconditioner.h"
50 #include "Epetra_Vector.h"
51 #include "Epetra_CrsMatrix.h"
52 #include "Epetra_Time.h"
53 #include "Teuchos_RefCountPtr.hpp"
54 
55 class Epetra_RowMatrix;
56 class Epetra_SerialComm;
57 class Epetra_Comm;
58 class Epetra_Map;
59 class Epetra_MultiVector;
60 
61 namespace Teuchos {
62  class ParameterList;
63 }
64 
66 
84 
85  public:
87 
95 
97  virtual ~Ifpack_ICT();
98 
100  /* This method is only available if the Teuchos package is enabled.
101  This method recognizes five parameter names: level_fill, drop_tolerance,
102  absolute_threshold, relative_threshold and overlap_mode. These names are
103  case insensitive. For level_fill the ParameterEntry must have type int, the
104  threshold entries must have type double and overlap_mode must have type
105  Epetra_CombineMode.
106  */
107  int SetParameters(Teuchos::ParameterList& parameterlis);
108 
110  const Epetra_RowMatrix& Matrix() const
111  {
112  return(A_);
113  }
114 
116  bool IsInitialized() const
117  {
118  return(IsInitialized_);
119  }
120 
122 
128  int Initialize();
129 
131 
139  int Compute();
140 
142  bool IsComputed() const {return(IsComputed_);};
143 
144  // Mathematical functions.
145 
147 
157  int ApplyInverse(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
158 
159  int Apply(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
160 
162 
170  double Condest(const Ifpack_CondestType CT = Ifpack_Cheap,
171  const int MaxIters = 1550,
172  const double Tol = 1e-9,
173  Epetra_RowMatrix* Matrix_in = 0);
174 
175  double Condest() const
176  {
177  return(Condest_);
178  }
179 
180  // Attribute access functions
181 
183 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
184  int NumGlobalNonzeros() const {return(H().NumGlobalNonzeros());};
185 #endif
186  long long NumGlobalNonzeros64() const {return(H().NumGlobalNonzeros64());};
187 
189  int NumMyNonzeros() const {return(H().NumMyNonzeros());};
190 
192  const Epetra_CrsMatrix& H() const {return(*H_);};
193 
195 
197 
206  int SetUseTranspose(bool UseTranspose_in) {UseTranspose_ = UseTranspose_in; return(0);};
207 
209  double NormInf() const {return(0.0);};
210 
212  bool HasNormInf() const {return(false);};
213 
215  bool UseTranspose() const {return(UseTranspose_);};
216 
218  const Epetra_Map& OperatorDomainMap() const {return(A_.OperatorDomainMap());};
219 
221  const Epetra_Map& OperatorRangeMap() const{return(A_.OperatorRangeMap());};
222 
224  const Epetra_Comm& Comm() const{return(Comm_);};
226 
227  const char* Label() const
228  {
229  return(Label_.c_str());
230  }
231 
232  int SetLabel(const char* Label_in)
233  {
234  Label_ = Label_in;
235  return(0);
236  }
237 
239  virtual std::ostream& Print(std::ostream& os) const;
240 
242  virtual int NumInitialize() const
243  {
244  return(NumInitialize_);
245  }
246 
248  virtual int NumCompute() const
249  {
250  return(NumCompute_);
251  }
252 
254  virtual int NumApplyInverse() const
255  {
256  return(NumApplyInverse_);
257  }
258 
260  virtual double InitializeTime() const
261  {
262  return(InitializeTime_);
263  }
264 
266  virtual double ComputeTime() const
267  {
268  return(ComputeTime_);
269  }
270 
272  virtual double ApplyInverseTime() const
273  {
274  return(ApplyInverseTime_);
275  }
276 
278  virtual double InitializeFlops() const
279  {
280  return(0.0);
281  }
282 
284  virtual double ComputeFlops() const
285  {
286  return(ComputeFlops_);
287  }
288 
290  virtual double ApplyInverseFlops() const
291  {
292  return(ApplyInverseFlops_);
293  }
294 
296 
299  inline double LevelOfFill() const
300  {
301  return(LevelOfFill_);
302  }
303 
305  inline double AbsoluteThreshold() const
306  {
307  return(Athresh_);
308  }
309 
311  inline double RelativeThreshold() const
312  {
313  return(Rthresh_);
314  }
315 
317  inline double RelaxValue() const
318  {
319  return(Relax_);
320  }
321 
323  inline double DropTolerance() const
324  {
325  return(DropTolerance_);
326  }
327 
328 private:
329 
331  Ifpack_ICT(const Ifpack_ICT& rhs) :
332  A_(rhs.Matrix()),
333  Comm_(Comm()),
334  Time_(Comm())
335  {}
336 
338  Ifpack_ICT& operator=(const Ifpack_ICT& /* rhs */)
339  {
340  return(*this);
341  }
342 
344  void Destroy();
345 
351  Teuchos::RefCountPtr<Epetra_CrsMatrix> H_;
353  double Condest_;
355  double Athresh_;
357  double Rthresh_;
359  double LevelOfFill_;
363  double Relax_;
365  std::string Label_;
379  mutable int NumApplyInverse_;
383  double ComputeTime_;
385  mutable double ApplyInverseTime_;
389  mutable double ApplyInverseFlops_;
393  long long GlobalNonzeros_;
394  Teuchos::RefCountPtr<Epetra_SerialComm> SerialComm_;
395  Teuchos::RefCountPtr<Epetra_Map> SerialMap_;
396 
397  template<typename int_type>
398  int TCompute();
399 };
400 
401 #endif /* IFPACK_ICT_H */
double RelaxValue() const
Returns the relaxation value.
Definition: Ifpack_ICT.h:317
int NumApplyInverse_
Contains the number of successful call to ApplyInverse().
Definition: Ifpack_ICT.h:379
bool UseTranspose_
If true, use the transpose of the matrix.
Definition: Ifpack_ICT.h:371
int NumCompute_
Contains the number of successful call to Compute().
Definition: Ifpack_ICT.h:377
const Epetra_Map & OperatorRangeMap() const
Returns the Epetra_Map object associated with the range of this operator.
Definition: Ifpack_ICT.h:221
virtual std::ostream & Print(std::ostream &os) const
Prints basic information on iostream. This function is used by operator&lt;&lt;.
Definition: Ifpack_ICT.cpp:518
const Epetra_CrsMatrix & H() const
Returns the address of the D factor associated with this factored matrix.
Definition: Ifpack_ICT.h:192
double LevelOfFill() const
Returns the level-of-fill.
Definition: Ifpack_ICT.h:299
long long NumGlobalNonzeros64() const
Definition: Ifpack_ICT.h:186
double ComputeTime_
Contains the time for all successful calls to Compute().
Definition: Ifpack_ICT.h:383
double NormInf() const
Returns 0.0 because this class cannot compute Inf-norm.
Definition: Ifpack_ICT.h:209
int NumGlobalNonzeros() const
Returns the number of nonzero entries in the global graph.
Definition: Ifpack_ICT.h:184
const Epetra_Map & OperatorDomainMap() const
Returns the Epetra_Map object associated with the domain of this operator.
Definition: Ifpack_ICT.h:218
Ifpack_ICT & operator=(const Ifpack_ICT &)
Should not be used.
Definition: Ifpack_ICT.h:338
const Epetra_Comm & Comm() const
Returns the Epetra_BlockMap object associated with the range of this matrix operator.
Definition: Ifpack_ICT.h:224
double LevelOfFill_
Level of fill.
Definition: Ifpack_ICT.h:359
Epetra_Time Time_
Used for timing purposes.
Definition: Ifpack_ICT.h:391
double ApplyInverseTime_
Contains the time for all successful calls to ApplyInverse().
Definition: Ifpack_ICT.h:385
int SetParameters(Teuchos::ParameterList &parameterlis)
Set parameters using a Teuchos::ParameterList object.
Definition: Ifpack_ICT.cpp:104
bool IsInitialized() const
Returns true is the preconditioner has been successfully initialized.
Definition: Ifpack_ICT.h:116
virtual const Epetra_Map & OperatorDomainMap() const =0
int ApplyInverse(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Returns the result of a Ifpack_ICT forward/back solve on a Epetra_MultiVector X in Y...
Definition: Ifpack_ICT.cpp:455
double ComputeFlops_
Contains the number of flops for Compute().
Definition: Ifpack_ICT.h:387
bool HasNormInf() const
Returns false because this class cannot compute an Inf-norm.
Definition: Ifpack_ICT.h:212
int NumMyNonzeros() const
Returns the number of nonzero entries in the local graph.
Definition: Ifpack_ICT.h:189
Teuchos::RefCountPtr< Epetra_CrsMatrix > H_
Contains the Cholesky factorization.
Definition: Ifpack_ICT.h:351
double ApplyInverseFlops_
Contain sthe number of flops for ApplyInverse().
Definition: Ifpack_ICT.h:389
int SetLabel(const char *Label_in)
Definition: Ifpack_ICT.h:232
int Initialize()
Initialize L and U with values from user matrix A.
Definition: Ifpack_ICT.cpp:138
double DropTolerance_
During factorization, drop all values below this.
Definition: Ifpack_ICT.h:361
Teuchos::RefCountPtr< Epetra_Map > SerialMap_
Definition: Ifpack_ICT.h:395
bool IsInitialized_
If true, the preconditioner has been successfully initialized.
Definition: Ifpack_ICT.h:367
int Apply(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Definition: Ifpack_ICT.cpp:494
Ifpack_CondestType
Ifpack_CondestType: enum to define the type of condition number estimate.
virtual const Epetra_Map & OperatorRangeMap() const =0
long long GlobalNonzeros_
Global number of nonzeros in L and U factors.
Definition: Ifpack_ICT.h:393
std::string Label_
Label of this object.
Definition: Ifpack_ICT.h:365
double DropTolerance() const
Returns the drop threshold.
Definition: Ifpack_ICT.h:323
Ifpack_ICT(const Epetra_RowMatrix *A)
Ifpack_ICT constuctor with variable number of indices per row.
Definition: Ifpack_ICT.cpp:63
Ifpack_ScalingType enumerable type.
virtual int NumInitialize() const
Returns the number of calls to Initialize().
Definition: Ifpack_ICT.h:242
double Rthresh_
Relative threshold.
Definition: Ifpack_ICT.h:357
double InitializeTime_
Contains the time for all successful calls to Initialize().
Definition: Ifpack_ICT.h:381
virtual int NumCompute() const
Returns the number of calls to Compute().
Definition: Ifpack_ICT.h:248
const char * Label() const
Definition: Ifpack_ICT.h:227
Ifpack_Preconditioner: basic class for preconditioning in Ifpack.
int NumInitialize_
Contains the number of successful calls to Initialize().
Definition: Ifpack_ICT.h:375
double Condest() const
Returns the computed condition number estimate, or -1.0 if not computed.
Definition: Ifpack_ICT.h:175
int TCompute()
Definition: Ifpack_ICT.cpp:161
virtual double ComputeTime() const
Returns the time spent in Compute().
Definition: Ifpack_ICT.h:266
void Destroy()
Destroys all data associated to the preconditioner.
Definition: Ifpack_ICT.cpp:97
double Relax_
Relaxation value.
Definition: Ifpack_ICT.h:363
virtual double ApplyInverseTime() const
Returns the time spent in ApplyInverse().
Definition: Ifpack_ICT.h:272
virtual double ComputeFlops() const
Returns the number of flops in all applications of Compute().
Definition: Ifpack_ICT.h:284
bool IsComputed() const
If factor is completed, this query returns true, otherwise it returns false.
Definition: Ifpack_ICT.h:142
cheap estimate
Ifpack_ICT: A class for constructing and using an incomplete Cholesky factorization of a given Epetra...
Definition: Ifpack_ICT.h:83
const Epetra_Comm & Comm_
Reference to the communicator.
Definition: Ifpack_ICT.h:349
double RelativeThreshold() const
Returns the relative threshold.
Definition: Ifpack_ICT.h:311
Teuchos::RefCountPtr< Epetra_SerialComm > SerialComm_
Definition: Ifpack_ICT.h:394
bool UseTranspose() const
Returns the current UseTranspose setting.
Definition: Ifpack_ICT.h:215
const Epetra_RowMatrix & Matrix() const
Returns a reference to the matrix to be preconditioned.
Definition: Ifpack_ICT.h:110
int SetUseTranspose(bool UseTranspose_in)
If set true, transpose of this operator will be applied.
Definition: Ifpack_ICT.h:206
virtual double ApplyInverseFlops() const
Returns the number of flops in all applications of ApplyInverse().
Definition: Ifpack_ICT.h:290
Ifpack_ICT(const Ifpack_ICT &rhs)
Should not be used.
Definition: Ifpack_ICT.h:331
double Condest_
Contains the estimate of the condition number, if -1.0 if not computed.
Definition: Ifpack_ICT.h:353
bool IsComputed_
If true, the preconditioner has been successfully computed.
Definition: Ifpack_ICT.h:369
virtual double InitializeTime() const
Returns the time spent in Initialize().
Definition: Ifpack_ICT.h:260
int Compute()
Compute IC factor U using the specified graph, diagonal perturbation thresholds and relaxation parame...
Definition: Ifpack_ICT.cpp:438
int NumMyRows_
Number of local rows in the matrix.
Definition: Ifpack_ICT.h:373
virtual double InitializeFlops() const
Returns the number of flops in the initialization phase.
Definition: Ifpack_ICT.h:278
virtual int NumApplyInverse() const
Returns the number of calls to ApplyInverse().
Definition: Ifpack_ICT.h:254
const Epetra_RowMatrix & A_
Reference to the matrix to be preconditioned, supposed symmetric.
Definition: Ifpack_ICT.h:347
double AbsoluteThreshold() const
Returns the absolute threshold.
Definition: Ifpack_ICT.h:305
virtual ~Ifpack_ICT()
Ifpack_ICT Destructor.
Definition: Ifpack_ICT.cpp:91
double Athresh_
Absolute threshold.
Definition: Ifpack_ICT.h:355