IFPACK  Development
 All Classes Files Functions Variables Enumerations Friends Pages
Ifpack_ICT.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_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 
94  Ifpack_ICT(const Epetra_RowMatrix* A);
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  int NumGlobalNonzeros() const {return(H().NumGlobalNonzeros());};
184 
186  int NumMyNonzeros() const {return(H().NumMyNonzeros());};
187 
189  const Epetra_CrsMatrix& H() const {return(*H_);};
190 
192 
194 
203  int SetUseTranspose(bool UseTranspose_in) {UseTranspose_ = UseTranspose_in; return(0);};
204 
206  double NormInf() const {return(0.0);};
207 
209  bool HasNormInf() const {return(false);};
210 
212  bool UseTranspose() const {return(UseTranspose_);};
213 
215  const Epetra_Map& OperatorDomainMap() const {return(A_.OperatorDomainMap());};
216 
218  const Epetra_Map& OperatorRangeMap() const{return(A_.OperatorRangeMap());};
219 
221  const Epetra_Comm& Comm() const{return(Comm_);};
223 
224  const char* Label() const
225  {
226  return(Label_.c_str());
227  }
228 
229  int SetLabel(const char* Label_in)
230  {
231  Label_ = Label_in;
232  return(0);
233  }
234 
236  virtual ostream& Print(std::ostream& os) const;
237 
239  virtual int NumInitialize() const
240  {
241  return(NumInitialize_);
242  }
243 
245  virtual int NumCompute() const
246  {
247  return(NumCompute_);
248  }
249 
251  virtual int NumApplyInverse() const
252  {
253  return(NumApplyInverse_);
254  }
255 
257  virtual double InitializeTime() const
258  {
259  return(InitializeTime_);
260  }
261 
263  virtual double ComputeTime() const
264  {
265  return(ComputeTime_);
266  }
267 
269  virtual double ApplyInverseTime() const
270  {
271  return(ApplyInverseTime_);
272  }
273 
275  virtual double InitializeFlops() const
276  {
277  return(0.0);
278  }
279 
281  virtual double ComputeFlops() const
282  {
283  return(ComputeFlops_);
284  }
285 
287  virtual double ApplyInverseFlops() const
288  {
289  return(ApplyInverseFlops_);
290  }
291 
293 
296  inline double LevelOfFill() const
297  {
298  return(LevelOfFill_);
299  }
300 
302  inline double AbsoluteThreshold() const
303  {
304  return(Athresh_);
305  }
306 
308  inline double RelativeThreshold() const
309  {
310  return(Rthresh_);
311  }
312 
314  inline double RelaxValue() const
315  {
316  return(Relax_);
317  }
318 
320  inline double DropTolerance() const
321  {
322  return(DropTolerance_);
323  }
324 
325 private:
326 
328  Ifpack_ICT(const Ifpack_ICT& rhs) :
329  A_(rhs.Matrix()),
330  Comm_(Comm()),
331  Time_(Comm())
332  {}
333 
335  Ifpack_ICT& operator=(const Ifpack_ICT& rhs)
336  {
337  return(*this);
338  }
339 
341  void Destroy();
342 
344  const Epetra_RowMatrix& A_;
346  const Epetra_Comm& Comm_;
348  Teuchos::RefCountPtr<Epetra_CrsMatrix> H_;
350  double Condest_;
352  double Athresh_;
354  double Rthresh_;
356  double LevelOfFill_;
358  double DropTolerance_;
360  double Relax_;
362  string Label_;
364  bool IsInitialized_;
366  bool IsComputed_;
368  bool UseTranspose_;
370  int NumMyRows_;
372  int NumInitialize_;
374  int NumCompute_;
376  mutable int NumApplyInverse_;
378  double InitializeTime_;
380  double ComputeTime_;
382  mutable double ApplyInverseTime_;
384  double ComputeFlops_;
386  mutable double ApplyInverseFlops_;
388  mutable Epetra_Time Time_;
390  int GlobalNonzeros_;
391  Teuchos::RefCountPtr<Epetra_SerialComm> SerialComm_;
392  Teuchos::RefCountPtr<Epetra_Map> SerialMap_;
393 };
394 
395 #endif /* IFPACK_ICT_H */
double RelaxValue() const
Returns the relaxation value.
Definition: Ifpack_ICT.h:314
const Epetra_Map & OperatorRangeMap() const
Returns the Epetra_Map object associated with the range of this operator.
Definition: Ifpack_ICT.h:218
virtual ostream & Print(std::ostream &os) const
Prints basic information on iostream. This function is used by operator&lt;&lt;.
Definition: Ifpack_ICT.cpp:486
const Epetra_CrsMatrix & H() const
Returns the address of the D factor associated with this factored matrix.
Definition: Ifpack_ICT.h:189
double LevelOfFill() const
Returns the level-of-fill.
Definition: Ifpack_ICT.h:296
double NormInf() const
Returns 0.0 because this class cannot compute Inf-norm.
Definition: Ifpack_ICT.h:206
int NumGlobalNonzeros() const
Returns the number of nonzero entries in the global graph.
Definition: Ifpack_ICT.h:183
const Epetra_Map & OperatorDomainMap() const
Returns the Epetra_Map object associated with the domain of this operator.
Definition: Ifpack_ICT.h:215
const Epetra_Comm & Comm() const
Returns the Epetra_BlockMap object associated with the range of this matrix operator.
Definition: Ifpack_ICT.h:221
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
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:423
bool HasNormInf() const
Returns false because this class cannot compute an Inf-norm.
Definition: Ifpack_ICT.h:209
int NumMyNonzeros() const
Returns the number of nonzero entries in the local graph.
Definition: Ifpack_ICT.h:186
int Initialize()
Initialize L and U with values from user matrix A.
Definition: Ifpack_ICT.cpp:136
double DropTolerance() const
Returns the drop threshold.
Definition: Ifpack_ICT.h:320
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:239
virtual int NumCompute() const
Returns the number of calls to Compute().
Definition: Ifpack_ICT.h:245
Ifpack_Preconditioner: basic class for preconditioning in Ifpack.
double Condest() const
Returns the computed condition number estimate, or -1.0 if not computed.
Definition: Ifpack_ICT.h:175
virtual double ComputeTime() const
Returns the time spent in Compute().
Definition: Ifpack_ICT.h:263
virtual double ApplyInverseTime() const
Returns the time spent in ApplyInverse().
Definition: Ifpack_ICT.h:269
virtual double ComputeFlops() const
Returns the number of flops in all applications of Compute().
Definition: Ifpack_ICT.h:281
bool IsComputed() const
If factor is completed, this query returns true, otherwise it returns false.
Definition: Ifpack_ICT.h:142
Ifpack_ICT: A class for constructing and using an incomplete Cholesky factorization of a given Epetra...
Definition: Ifpack_ICT.h:83
double RelativeThreshold() const
Returns the relative threshold.
Definition: Ifpack_ICT.h:308
bool UseTranspose() const
Returns the current UseTranspose setting.
Definition: Ifpack_ICT.h:212
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:203
virtual double ApplyInverseFlops() const
Returns the number of flops in all applications of ApplyInverse().
Definition: Ifpack_ICT.h:287
virtual double InitializeTime() const
Returns the time spent in Initialize().
Definition: Ifpack_ICT.h:257
int Compute()
Compute IC factor U using the specified graph, diagonal perturbation thresholds and relaxation parame...
Definition: Ifpack_ICT.cpp:158
virtual double InitializeFlops() const
Returns the number of flops in the initialization phase.
Definition: Ifpack_ICT.h:275
virtual int NumApplyInverse() const
Returns the number of calls to ApplyInverse().
Definition: Ifpack_ICT.h:251
double AbsoluteThreshold() const
Returns the absolute threshold.
Definition: Ifpack_ICT.h:302
virtual ~Ifpack_ICT()
Ifpack_ICT Destructor.
Definition: Ifpack_ICT.cpp:91