IFPACK  Development
 All Classes Namespaces Files Functions Variables Enumerations Friends Pages
Ifpack_ILUT.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_ILUT_H
44 #define IFPACK_ILUT_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 
82 
83 public:
84  // @{ Constructors and Destructors
86  Ifpack_ILUT(const Epetra_RowMatrix* A);
87 
89  virtual ~Ifpack_ILUT();
90 
91  // @}
92  // @{ Construction methods
94  /* This method is only available if the Teuchos package is enabled.
95  This method recognizes five parameter names: level_fill, drop_tolerance,
96  absolute_threshold, relative_threshold and overlap_mode. These names are
97  case insensitive. For level_fill the ParameterEntry must have type int, the
98  threshold entries must have type double and overlap_mode must have type
99  Epetra_CombineMode.
100  */
101  int SetParameters(Teuchos::ParameterList& parameterlis);
102 
104 
110  int Initialize();
111 
113  bool IsInitialized() const
114  {
115  return(IsInitialized_);
116  }
117 
119 
127  int Compute();
128 
130  bool IsComputed() const {return(IsComputed_);};
131 
132  // Mathematical functions.
133 
135 
143  int ApplyInverse(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
144 
145  int Apply(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
146 
148  double Condest(const Ifpack_CondestType CT = Ifpack_Cheap,
149  const int MaxIters = 1550,
150  const double Tol = 1e-9,
151  Epetra_RowMatrix* Matrix_in = 0);
152 
154  double Condest() const
155  {
156  return(Condest_);
157  }
158 
160 
168  int SetUseTranspose(bool UseTranspose_in) {UseTranspose_ = UseTranspose_in; return(0);};
169 
171  double NormInf() const {return(0.0);};
172 
174  bool HasNormInf() const {return(false);};
175 
177  bool UseTranspose() const {return(UseTranspose_);};
178 
180  const Epetra_Map & OperatorDomainMap() const {return(A_.OperatorDomainMap());};
181 
183  const Epetra_Map & OperatorRangeMap() const{return(A_.OperatorRangeMap());};
184 
186  const Epetra_Comm & Comm() const{return(Comm_);};
187 
189  const Epetra_RowMatrix& Matrix() const
190  {
191  return(A_);
192  }
193 
195  const Epetra_CrsMatrix & L() const {return(*L_);};
196 
198  const Epetra_CrsMatrix & U() const {return(*U_);};
199 
201  const char* Label() const
202  {
203  return(Label_.c_str());
204  }
205 
207  int SetLabel(const char* Label_in)
208  {
209  Label_ = Label_in;
210  return(0);
211  }
212 
214  virtual std::ostream& Print(std::ostream& os) const;
215 
217  virtual int NumInitialize() const
218  {
219  return(NumInitialize_);
220  }
221 
223  virtual int NumCompute() const
224  {
225  return(NumCompute_);
226  }
227 
229  virtual int NumApplyInverse() const
230  {
231  return(NumApplyInverse_);
232  }
233 
235  virtual double InitializeTime() const
236  {
237  return(InitializeTime_);
238  }
239 
241  virtual double ComputeTime() const
242  {
243  return(ComputeTime_);
244  }
245 
247  virtual double ApplyInverseTime() const
248  {
249  return(ApplyInverseTime_);
250  }
251 
253  virtual double InitializeFlops() const
254  {
255  return(0.0);
256  }
257 
258  virtual double ComputeFlops() const
259  {
260  return(ComputeFlops_);
261  }
262 
263  virtual double ApplyInverseFlops() const
264  {
265  return(ApplyInverseFlops_);
266  }
267 
268  inline double LevelOfFill() const {
269  return(LevelOfFill_);
270  }
271 
273  inline double RelaxValue() const {
274  return(Relax_);
275  }
276 
278  inline double AbsoluteThreshold() const
279  {
280  return(Athresh_);
281  }
282 
284  inline double RelativeThreshold() const
285  {
286  return(Rthresh_);
287  }
288 
290  inline double DropTolerance() const
291  {
292  return(DropTolerance_);
293  }
294 
296 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
297  int NumGlobalNonzeros() const {
298  // FIXME: diagonal of L_ should not be stored
299  return(L().NumGlobalNonzeros() + U().NumGlobalNonzeros() - L().NumGlobalRows());
300  }
301 #endif
302  long long NumGlobalNonzeros64() const {
303  // FIXME: diagonal of L_ should not be stored
304  return(L().NumGlobalNonzeros64() + U().NumGlobalNonzeros64() - L().NumGlobalRows64());
305  }
306 
308  int NumMyNonzeros() const {
309  return(L().NumMyNonzeros() + U().NumMyNonzeros());
310  }
311 
312 private:
313 
314  // @}
315  // @{ Internal methods
316 
318  Ifpack_ILUT(const Ifpack_ILUT& RHS) :
319  A_(RHS.Matrix()),
320  Comm_(RHS.Comm()),
321  Time_(Comm())
322  {};
323 
325  Ifpack_ILUT& operator=(const Ifpack_ILUT& /* RHS */)
326  {
327  return(*this);
328  }
329 
330  template<typename int_type>
331  int TCompute();
332 
334  void Destroy();
335 
336  // @}
337  // @{ Internal data
338 
340  const Epetra_RowMatrix& A_;
342  const Epetra_Comm& Comm_;
344  Teuchos::RefCountPtr<Epetra_CrsMatrix> L_;
346  Teuchos::RefCountPtr<Epetra_CrsMatrix> U_;
348  double Condest_;
350  double Relax_;
352  double Athresh_;
354  double Rthresh_;
356  double LevelOfFill_;
358  double DropTolerance_;
360  std::string Label_;
362  bool IsInitialized_;
364  bool IsComputed_;
366  bool UseTranspose_;
368  int NumMyRows_;
370  int NumInitialize_;
372  int NumCompute_;
374  mutable int NumApplyInverse_;
376  double InitializeTime_;
378  double ComputeTime_;
380  mutable double ApplyInverseTime_;
382  double ComputeFlops_;
384  mutable double ApplyInverseFlops_;
386  mutable Epetra_Time Time_;
388  long long GlobalNonzeros_;
389  Teuchos::RefCountPtr<Epetra_SerialComm> SerialComm_;
390  Teuchos::RefCountPtr<Epetra_Map> SerialMap_;
391 }; // Ifpack_ILUT
392 
393 #endif /* IFPACK_ILUT_H */
double NormInf() const
Returns 0.0 because this class cannot compute Inf-norm.
Definition: Ifpack_ILUT.h:171
virtual std::ostream & Print(std::ostream &os) const
Prints basic information on iostream. This function is used by operator&lt;&lt;.
const Epetra_Map & OperatorRangeMap() const
Returns the Epetra_Map object associated with the range of this operator.
Definition: Ifpack_ILUT.h:183
const Epetra_RowMatrix & Matrix() const
Returns a reference to the matrix to be preconditioned.
Definition: Ifpack_ILUT.h:189
double Condest() const
Returns the computed estimated condition number, or -1.0 if no computed.
Definition: Ifpack_ILUT.h:154
bool IsComputed() const
If factor is completed, this query returns true, otherwise it returns false.
Definition: Ifpack_ILUT.h:130
virtual int NumApplyInverse() const
Returns the number of calls to ApplyInverse().
Definition: Ifpack_ILUT.h:229
Ifpack_ILUT(const Epetra_RowMatrix *A)
Ifpack_ILUT constuctor with variable number of indices per row.
Definition: Ifpack_ILUT.cpp:66
virtual const Epetra_Map & OperatorDomainMap() const =0
int SetParameters(Teuchos::ParameterList &parameterlis)
Set parameters using a Teuchos::ParameterList object.
const Epetra_Map & OperatorDomainMap() const
Returns the Epetra_Map object associated with the domain of this operator.
Definition: Ifpack_ILUT.h:180
virtual int NumInitialize() const
Returns the number of calls to Initialize().
Definition: Ifpack_ILUT.h:217
const Epetra_CrsMatrix & U() const
Returns a reference to the U factor.
Definition: Ifpack_ILUT.h:198
int Initialize()
Initialize L and U with values from user matrix A.
const Epetra_CrsMatrix & L() const
Returns a reference to the L factor.
Definition: Ifpack_ILUT.h:195
virtual ~Ifpack_ILUT()
Ifpack_ILUT Destructor.
Definition: Ifpack_ILUT.cpp:94
int NumMyNonzeros() const
Returns the number of nonzero entries in the local graph.
Definition: Ifpack_ILUT.h:308
virtual const Epetra_Map & OperatorRangeMap() const =0
bool HasNormInf() const
Returns false because this class cannot compute an Inf-norm.
Definition: Ifpack_ILUT.h:174
double RelativeThreshold() const
Get relative threshold value.
Definition: Ifpack_ILUT.h:284
const Epetra_Comm & Comm() const
Returns the Epetra_BlockMap object associated with the range of this matrix operator.
Definition: Ifpack_ILUT.h:186
Ifpack_ScalingType enumerable type.
virtual int NumCompute() const
Returns the number of calls to Compute().
Definition: Ifpack_ILUT.h:223
Ifpack_Preconditioner: basic class for preconditioning in Ifpack.
int Compute()
Compute IC factor U using the specified graph, diagonal perturbation thresholds and relaxation parame...
bool UseTranspose() const
Returns the current UseTranspose setting.
Definition: Ifpack_ILUT.h:177
virtual double ComputeFlops() const
Returns the number of flops in the computation phase.
Definition: Ifpack_ILUT.h:258
virtual double ApplyInverseTime() const
Returns the time spent in ApplyInverse().
Definition: Ifpack_ILUT.h:247
int SetUseTranspose(bool UseTranspose_in)
If set true, transpose of this operator will be applied.
Definition: Ifpack_ILUT.h:168
bool IsInitialized() const
Returns true if the preconditioner has been successfully initialized.
Definition: Ifpack_ILUT.h:113
virtual double ApplyInverseFlops() const
Returns the number of flops in the application of the preconditioner.
Definition: Ifpack_ILUT.h:263
int ApplyInverse(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Returns the result of a Ifpack_ILUT forward/back solve on a Epetra_MultiVector X in Y...
virtual double InitializeFlops() const
Returns the number of flops in the initialization phase.
Definition: Ifpack_ILUT.h:253
double DropTolerance() const
Gets the dropping tolerance.
Definition: Ifpack_ILUT.h:290
virtual double ComputeTime() const
Returns the time spent in Compute().
Definition: Ifpack_ILUT.h:241
double AbsoluteThreshold() const
Get absolute threshold value.
Definition: Ifpack_ILUT.h:278
int NumGlobalNonzeros() const
Returns the number of nonzero entries in the global graph.
Definition: Ifpack_ILUT.h:297
const char * Label() const
Returns the label of this object.
Definition: Ifpack_ILUT.h:201
Ifpack_ILUT: A class for constructing and using an incomplete LU factorization of a given Epetra_RowM...
Definition: Ifpack_ILUT.h:81
virtual double InitializeTime() const
Returns the time spent in Initialize().
Definition: Ifpack_ILUT.h:235
int SetLabel(const char *Label_in)
Sets the label for this object.
Definition: Ifpack_ILUT.h:207
double RelaxValue() const
Set relative threshold value.
Definition: Ifpack_ILUT.h:273