IFPACK  Development
 All Classes Namespaces 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 #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_CondestType.h"
54 #include "Ifpack_ScalingType.h"
55 #include "Ifpack_Preconditioner.h"
56 #include "Epetra_Vector.h"
57 #include "Epetra_CrsMatrix.h"
58 #include "Epetra_Time.h"
59 #include "Teuchos_RefCountPtr.hpp"
60 
61 class Epetra_RowMatrix;
62 class Epetra_SerialComm;
63 class Epetra_Comm;
64 class Epetra_Map;
65 class Epetra_MultiVector;
66 
67 namespace Teuchos {
68  class ParameterList;
69 }
70 
72 
90 
91  public:
93 
100  Ifpack_ICT(const Epetra_RowMatrix* A);
101 
103  virtual ~Ifpack_ICT();
104 
106  /* This method is only available if the Teuchos package is enabled.
107  This method recognizes five parameter names: level_fill, drop_tolerance,
108  absolute_threshold, relative_threshold and overlap_mode. These names are
109  case insensitive. For level_fill the ParameterEntry must have type int, the
110  threshold entries must have type double and overlap_mode must have type
111  Epetra_CombineMode.
112  */
113  int SetParameters(Teuchos::ParameterList& parameterlis);
114 
116  const Epetra_RowMatrix& Matrix() const
117  {
118  return(A_);
119  }
120 
122  bool IsInitialized() const
123  {
124  return(IsInitialized_);
125  }
126 
128 
134  int Initialize();
135 
137 
145  int Compute();
146 
148  bool IsComputed() const {return(IsComputed_);};
149 
150  // Mathematical functions.
151 
153 
163  int ApplyInverse(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
164 
165  int Apply(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
166 
168 
176  double Condest(const Ifpack_CondestType CT = Ifpack_Cheap,
177  const int MaxIters = 1550,
178  const double Tol = 1e-9,
179  Epetra_RowMatrix* Matrix_in = 0);
180 
181  double Condest() const
182  {
183  return(Condest_);
184  }
185 
186  // Attribute access functions
187 
189 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
190  int NumGlobalNonzeros() const {return(H().NumGlobalNonzeros());};
191 #endif
192  long long NumGlobalNonzeros64() const {return(H().NumGlobalNonzeros64());};
193 
195  int NumMyNonzeros() const {return(H().NumMyNonzeros());};
196 
198  const Epetra_CrsMatrix& H() const {return(*H_);};
199 
201 
203 
212  int SetUseTranspose(bool UseTranspose_in) {UseTranspose_ = UseTranspose_in; return(0);};
213 
215  double NormInf() const {return(0.0);};
216 
218  bool HasNormInf() const {return(false);};
219 
221  bool UseTranspose() const {return(UseTranspose_);};
222 
224  const Epetra_Map& OperatorDomainMap() const {return(A_.OperatorDomainMap());};
225 
227  const Epetra_Map& OperatorRangeMap() const{return(A_.OperatorRangeMap());};
228 
230  const Epetra_Comm& Comm() const{return(Comm_);};
232 
233  const char* Label() const
234  {
235  return(Label_.c_str());
236  }
237 
238  int SetLabel(const char* Label_in)
239  {
240  Label_ = Label_in;
241  return(0);
242  }
243 
245  virtual std::ostream& Print(std::ostream& os) const;
246 
248  virtual int NumInitialize() const
249  {
250  return(NumInitialize_);
251  }
252 
254  virtual int NumCompute() const
255  {
256  return(NumCompute_);
257  }
258 
260  virtual int NumApplyInverse() const
261  {
262  return(NumApplyInverse_);
263  }
264 
266  virtual double InitializeTime() const
267  {
268  return(InitializeTime_);
269  }
270 
272  virtual double ComputeTime() const
273  {
274  return(ComputeTime_);
275  }
276 
278  virtual double ApplyInverseTime() const
279  {
280  return(ApplyInverseTime_);
281  }
282 
284  virtual double InitializeFlops() const
285  {
286  return(0.0);
287  }
288 
290  virtual double ComputeFlops() const
291  {
292  return(ComputeFlops_);
293  }
294 
296  virtual double ApplyInverseFlops() const
297  {
298  return(ApplyInverseFlops_);
299  }
300 
302 
305  inline double LevelOfFill() const
306  {
307  return(LevelOfFill_);
308  }
309 
311  inline double AbsoluteThreshold() const
312  {
313  return(Athresh_);
314  }
315 
317  inline double RelativeThreshold() const
318  {
319  return(Rthresh_);
320  }
321 
323  inline double RelaxValue() const
324  {
325  return(Relax_);
326  }
327 
329  inline double DropTolerance() const
330  {
331  return(DropTolerance_);
332  }
333 
334 private:
335 
337  Ifpack_ICT(const Ifpack_ICT& rhs) :
338  A_(rhs.Matrix()),
339  Comm_(Comm()),
340  Time_(Comm())
341  {}
342 
344  Ifpack_ICT& operator=(const Ifpack_ICT& /* rhs */)
345  {
346  return(*this);
347  }
348 
350  void Destroy();
351 
353  const Epetra_RowMatrix& A_;
355  const Epetra_Comm& Comm_;
357  Teuchos::RefCountPtr<Epetra_CrsMatrix> H_;
359  double Condest_;
361  double Athresh_;
363  double Rthresh_;
365  double LevelOfFill_;
367  double DropTolerance_;
369  double Relax_;
371  std::string Label_;
373  bool IsInitialized_;
375  bool IsComputed_;
377  bool UseTranspose_;
379  int NumMyRows_;
381  int NumInitialize_;
383  int NumCompute_;
385  mutable int NumApplyInverse_;
387  double InitializeTime_;
389  double ComputeTime_;
391  mutable double ApplyInverseTime_;
393  double ComputeFlops_;
395  mutable double ApplyInverseFlops_;
397  mutable Epetra_Time Time_;
399  long long GlobalNonzeros_;
400  Teuchos::RefCountPtr<Epetra_SerialComm> SerialComm_;
401  Teuchos::RefCountPtr<Epetra_Map> SerialMap_;
402 
403  template<typename int_type>
404  int TCompute();
405 };
406 
407 #endif /* IFPACK_ICT_H */
double RelaxValue() const
Returns the relaxation value.
Definition: Ifpack_ICT.h:323
const Epetra_Map & OperatorRangeMap() const
Returns the Epetra_Map object associated with the range of this operator.
Definition: Ifpack_ICT.h:227
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:198
double LevelOfFill() const
Returns the level-of-fill.
Definition: Ifpack_ICT.h:305
double NormInf() const
Returns 0.0 because this class cannot compute Inf-norm.
Definition: Ifpack_ICT.h:215
int NumGlobalNonzeros() const
Returns the number of nonzero entries in the global graph.
Definition: Ifpack_ICT.h:190
const Epetra_Map & OperatorDomainMap() const
Returns the Epetra_Map object associated with the domain of this operator.
Definition: Ifpack_ICT.h:224
const Epetra_Comm & Comm() const
Returns the Epetra_BlockMap object associated with the range of this matrix operator.
Definition: Ifpack_ICT.h:230
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:122
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
bool HasNormInf() const
Returns false because this class cannot compute an Inf-norm.
Definition: Ifpack_ICT.h:218
int NumMyNonzeros() const
Returns the number of nonzero entries in the local graph.
Definition: Ifpack_ICT.h:195
int Initialize()
Initialize L and U with values from user matrix A.
Definition: Ifpack_ICT.cpp:138
virtual const Epetra_Map & OperatorRangeMap() const =0
double DropTolerance() const
Returns the drop threshold.
Definition: Ifpack_ICT.h:329
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:248
virtual int NumCompute() const
Returns the number of calls to Compute().
Definition: Ifpack_ICT.h:254
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:181
virtual double ComputeTime() const
Returns the time spent in Compute().
Definition: Ifpack_ICT.h:272
virtual double ApplyInverseTime() const
Returns the time spent in ApplyInverse().
Definition: Ifpack_ICT.h:278
virtual double ComputeFlops() const
Returns the number of flops in all applications of Compute().
Definition: Ifpack_ICT.h:290
bool IsComputed() const
If factor is completed, this query returns true, otherwise it returns false.
Definition: Ifpack_ICT.h:148
Ifpack_ICT: A class for constructing and using an incomplete Cholesky factorization of a given Epetra...
Definition: Ifpack_ICT.h:89
double RelativeThreshold() const
Returns the relative threshold.
Definition: Ifpack_ICT.h:317
bool UseTranspose() const
Returns the current UseTranspose setting.
Definition: Ifpack_ICT.h:221
const Epetra_RowMatrix & Matrix() const
Returns a reference to the matrix to be preconditioned.
Definition: Ifpack_ICT.h:116
int SetUseTranspose(bool UseTranspose_in)
If set true, transpose of this operator will be applied.
Definition: Ifpack_ICT.h:212
virtual double ApplyInverseFlops() const
Returns the number of flops in all applications of ApplyInverse().
Definition: Ifpack_ICT.h:296
virtual double InitializeTime() const
Returns the time spent in Initialize().
Definition: Ifpack_ICT.h:266
int Compute()
Compute IC factor U using the specified graph, diagonal perturbation thresholds and relaxation parame...
Definition: Ifpack_ICT.cpp:438
virtual double InitializeFlops() const
Returns the number of flops in the initialization phase.
Definition: Ifpack_ICT.h:284
virtual int NumApplyInverse() const
Returns the number of calls to ApplyInverse().
Definition: Ifpack_ICT.h:260
double AbsoluteThreshold() const
Returns the absolute threshold.
Definition: Ifpack_ICT.h:311
virtual ~Ifpack_ICT()
Ifpack_ICT Destructor.
Definition: Ifpack_ICT.cpp:91