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 
169  int SetUseTranspose(bool UseTranspose_in) {UseTranspose_ = UseTranspose_in; return(0);};
170 
172  double NormInf() const {return(0.0);};
173 
175  bool HasNormInf() const {return(false);};
176 
178  bool UseTranspose() const {return(UseTranspose_);};
179 
181  const Epetra_Map & OperatorDomainMap() const {return(A_.OperatorDomainMap());};
182 
184  const Epetra_Map & OperatorRangeMap() const{return(A_.OperatorRangeMap());};
185 
187  const Epetra_Comm & Comm() const{return(Comm_);};
188 
190  const Epetra_RowMatrix& Matrix() const
191  {
192  return(A_);
193  }
194 
196  const Epetra_CrsMatrix & L() const {return(*L_);};
197 
199  const Epetra_CrsMatrix & U() const {return(*U_);};
200 
202  const char* Label() const
203  {
204  return(Label_.c_str());
205  }
206 
208  int SetLabel(const char* Label_in)
209  {
210  Label_ = Label_in;
211  return(0);
212  }
213 
215  virtual std::ostream& Print(std::ostream& os) const;
216 
218  virtual int NumInitialize() const
219  {
220  return(NumInitialize_);
221  }
222 
224  virtual int NumCompute() const
225  {
226  return(NumCompute_);
227  }
228 
230  virtual int NumApplyInverse() const
231  {
232  return(NumApplyInverse_);
233  }
234 
236  virtual double InitializeTime() const
237  {
238  return(InitializeTime_);
239  }
240 
242  virtual double ComputeTime() const
243  {
244  return(ComputeTime_);
245  }
246 
248  virtual double ApplyInverseTime() const
249  {
250  return(ApplyInverseTime_);
251  }
252 
254  virtual double InitializeFlops() const
255  {
256  return(0.0);
257  }
258 
259  virtual double ComputeFlops() const
260  {
261  return(ComputeFlops_);
262  }
263 
264  virtual double ApplyInverseFlops() const
265  {
266  return(ApplyInverseFlops_);
267  }
268 
269  inline double LevelOfFill() const {
270  return(LevelOfFill_);
271  }
272 
274  inline double RelaxValue() const {
275  return(Relax_);
276  }
277 
279  inline double AbsoluteThreshold() const
280  {
281  return(Athresh_);
282  }
283 
285  inline double RelativeThreshold() const
286  {
287  return(Rthresh_);
288  }
289 
291  inline double DropTolerance() const
292  {
293  return(DropTolerance_);
294  }
295 
297 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
298  int NumGlobalNonzeros() const {
299  // FIXME: diagonal of L_ should not be stored
300  return(L().NumGlobalNonzeros() + U().NumGlobalNonzeros() - L().NumGlobalRows());
301  }
302 #endif
303  long long NumGlobalNonzeros64() const {
304  // FIXME: diagonal of L_ should not be stored
305  return(L().NumGlobalNonzeros64() + U().NumGlobalNonzeros64() - L().NumGlobalRows64());
306  }
307 
309  int NumMyNonzeros() const {
310  return(L().NumMyNonzeros() + U().NumMyNonzeros());
311  }
312 
313 private:
314 
315  // @}
316  // @{ Internal methods
317 
319  Ifpack_ILUT(const Ifpack_ILUT& RHS) :
320  A_(RHS.Matrix()),
321  Comm_(RHS.Comm()),
322  Time_(Comm())
323  {};
324 
326  Ifpack_ILUT& operator=(const Ifpack_ILUT& /* RHS */)
327  {
328  return(*this);
329  }
330 
331  template<typename int_type>
332  int TCompute();
333 
335  void Destroy();
336 
337  // @}
338  // @{ Internal data
339 
341  const Epetra_RowMatrix& A_;
343  const Epetra_Comm& Comm_;
345  Teuchos::RefCountPtr<Epetra_CrsMatrix> L_;
347  Teuchos::RefCountPtr<Epetra_CrsMatrix> U_;
349  double Condest_;
351  double Relax_;
353  double Athresh_;
355  double Rthresh_;
357  double LevelOfFill_;
359  double DropTolerance_;
361  std::string Label_;
363  bool IsInitialized_;
365  bool IsComputed_;
367  bool UseTranspose_;
369  int NumMyRows_;
371  int NumInitialize_;
373  int NumCompute_;
375  mutable int NumApplyInverse_;
377  double InitializeTime_;
379  double ComputeTime_;
381  mutable double ApplyInverseTime_;
383  double ComputeFlops_;
385  mutable double ApplyInverseFlops_;
387  mutable Epetra_Time Time_;
389  long long GlobalNonzeros_;
390  Teuchos::RefCountPtr<Epetra_SerialComm> SerialComm_;
391  Teuchos::RefCountPtr<Epetra_Map> SerialMap_;
392 }; // Ifpack_ILUT
393 
394 #endif /* IFPACK_ILUT_H */
double NormInf() const
Returns 0.0 because this class cannot compute Inf-norm.
Definition: Ifpack_ILUT.h:172
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:184
const Epetra_RowMatrix & Matrix() const
Returns a reference to the matrix to be preconditioned.
Definition: Ifpack_ILUT.h:190
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:230
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:181
virtual int NumInitialize() const
Returns the number of calls to Initialize().
Definition: Ifpack_ILUT.h:218
const Epetra_CrsMatrix & U() const
Returns a reference to the U factor.
Definition: Ifpack_ILUT.h:199
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:196
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:309
virtual const Epetra_Map & OperatorRangeMap() const =0
bool HasNormInf() const
Returns false because this class cannot compute an Inf-norm.
Definition: Ifpack_ILUT.h:175
double RelativeThreshold() const
Get relative threshold value.
Definition: Ifpack_ILUT.h:285
const Epetra_Comm & Comm() const
Returns the Epetra_BlockMap object associated with the range of this matrix operator.
Definition: Ifpack_ILUT.h:187
Ifpack_ScalingType enumerable type.
virtual int NumCompute() const
Returns the number of calls to Compute().
Definition: Ifpack_ILUT.h:224
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:178
virtual double ComputeFlops() const
Returns the number of flops in the computation phase.
Definition: Ifpack_ILUT.h:259
virtual double ApplyInverseTime() const
Returns the time spent in ApplyInverse().
Definition: Ifpack_ILUT.h:248
int SetUseTranspose(bool UseTranspose_in)
If set true, transpose of this operator will be applied.
Definition: Ifpack_ILUT.h:169
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:264
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:254
double DropTolerance() const
Gets the dropping tolerance.
Definition: Ifpack_ILUT.h:291
virtual double ComputeTime() const
Returns the time spent in Compute().
Definition: Ifpack_ILUT.h:242
double AbsoluteThreshold() const
Get absolute threshold value.
Definition: Ifpack_ILUT.h:279
int NumGlobalNonzeros() const
Returns the number of nonzero entries in the global graph.
Definition: Ifpack_ILUT.h:298
const char * Label() const
Returns the label of this object.
Definition: Ifpack_ILUT.h:202
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:236
int SetLabel(const char *Label_in)
Sets the label for this object.
Definition: Ifpack_ILUT.h:208
double RelaxValue() const
Set relative threshold value.
Definition: Ifpack_ILUT.h:274