IFPACK  Development
Ifpack_IC.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_IC_H
44 #define IFPACK_IC_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_RowMatrix.h"
53 #include "Epetra_Time.h"
54 #include "Teuchos_RefCountPtr.hpp"
55 
56 class Epetra_Comm;
57 class Epetra_Map;
58 class Epetra_MultiVector;
59 namespace Teuchos {
60  class ParameterList;
61 }
62 
64 
81 
82  public:
84 
91  Ifpack_IC(Epetra_RowMatrix* A);
92 
94  virtual ~Ifpack_IC();
95 
97  void SetAbsoluteThreshold( double Athresh) {Athresh_ = Athresh; return;}
98 
100  void SetRelativeThreshold( double Rthresh) {Rthresh_ = Rthresh; return;}
101 
103  /* This method is only available if the Teuchos package is enabled.
104  This method recognizes five parameter names: level_fill, drop_tolerance,
105  absolute_threshold, relative_threshold and overlap_mode. These names are
106  case insensitive. For level_fill the ParameterEntry must have type int, the
107  threshold entries must have type double and overlap_mode must have type
108  Epetra_CombineMode.
109  */
110  int SetParameters(Teuchos::ParameterList& parameterlis);
111 
112  int SetParameter(const string Name, const int Value)
113  {
114  IFPACK_CHK_ERR(-98);
115  }
116  int SetParameter(const string Name, const double Value)
117  {
118  IFPACK_CHK_ERR(-98);
119  }
120 
121  const Epetra_RowMatrix& Matrix() const
122  {
123  return(*A_);
124  }
125 
126  Epetra_RowMatrix& Matrix()
127  {
128  return(*A_);
129  }
130 
131  bool IsInitialized() const
132  {
133  return(IsInitialized_);
134  }
135 
137 
143  int Initialize();
144 
146 
154  int Compute();
155  int ComputeSetup();
156 
158  bool IsComputed() const {return(IsComputed_);};
159 
160  // Mathematical functions.
161 
163 
173  int ApplyInverse(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
174 
175  int Apply(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
176 
178 
186  double Condest(const Ifpack_CondestType CT = Ifpack_Cheap,
187  const int MaxIters = 1550,
188  const double Tol = 1e-9,
189  Epetra_RowMatrix* Matrix_in = 0);
190 
191  double Condest() const
192  {
193  return(Condest_);
194  }
195 
196  // Attribute access functions
197 
199  double GetAbsoluteThreshold() {return Athresh_;}
200 
202  double GetRelativeThreshold() {return Rthresh_;}
203 
205  int NumGlobalNonzeros() const {return(U().NumGlobalNonzeros()+D().GlobalLength());};
206 
208  int NumMyNonzeros() const {return(U().NumMyNonzeros()+D().MyLength());};
210  const Epetra_Vector & D() const {return(*D_);};
211 
213  const Epetra_CrsMatrix & U() const {return(*U_);};
214 
216 
218 
227  int SetUseTranspose(bool UseTranspose_in) {UseTranspose_ = UseTranspose_in; return(0);};
228 
230  double NormInf() const {return(0.0);};
231 
233  bool HasNormInf() const {return(false);};
234 
236  bool UseTranspose() const {return(UseTranspose_);};
237 
239  const Epetra_Map & OperatorDomainMap() const {return(A_->OperatorDomainMap());};
240 
242  const Epetra_Map & OperatorRangeMap() const{return(A_->OperatorRangeMap());};
243 
245  const Epetra_Comm & Comm() const{return(Comm_);};
247 
248  const char* Label() const
249  {
250  return(Label_);
251  }
252 
253  int SetLabel(const char* Label_in)
254  {
255  strcpy(Label_,Label_in);
256  return(0);
257  }
258 
260  virtual ostream& Print(std::ostream& os) const;
261 
263  virtual int NumInitialize() const
264  {
265  return(NumInitialize_);
266  }
267 
269  virtual int NumCompute() const
270  {
271  return(NumCompute_);
272  }
273 
275  virtual int NumApplyInverse() const
276  {
277  return(NumApplyInverse_);
278  }
279 
281  virtual double InitializeTime() const
282  {
283  return(InitializeTime_);
284  }
285 
287  virtual double ComputeTime() const
288  {
289  return(ComputeTime_);
290  }
291 
293  virtual double ApplyInverseTime() const
294  {
295  return(ApplyInverseTime_);
296  }
297 
299  virtual double InitializeFlops() const
300  {
301  return(0.0);
302  }
303 
304  virtual double ComputeFlops() const
305  {
306  return(ComputeFlops_);
307  }
308 
309  virtual double ApplyInverseFlops() const
310  {
311  return(ApplyInverseFlops_);
312  }
313 
314 
315  private:
316 
317  double LevelOfFill() const
318  {
319  return(Lfil_);
320  }
321 
322  double AbsoluteThreshold() const
323  {
324  return(Athresh_);
325  }
326 
327  double RelativeThreshold() const
328  {
329  return(Rthresh_);
330  }
331 
332  double DropTolerance() const
333  {
334  return(Droptol_);
335  }
336 
337  Teuchos::RefCountPtr<Epetra_RowMatrix> A_;
338  const Epetra_Comm & Comm_;
339  Teuchos::RefCountPtr<Epetra_CrsMatrix> U_;
340  Teuchos::RefCountPtr<Epetra_Vector> D_;
341  bool UseTranspose_;
342 
343  double Condest_;
344  double Athresh_;
345  double Rthresh_;
346  double Droptol_;
347  double Lfil_;
348 
349  void * Aict_;
350  void * Lict_;
351  double * Ldiag_;
352  char Label_[160];
353 
354  bool IsInitialized_;
355  bool IsComputed_;
356 
358  int NumInitialize_;
360  int NumCompute_;
362  mutable int NumApplyInverse_;
363 
365  double InitializeTime_;
367  double ComputeTime_;
369  mutable double ApplyInverseTime_;
371  mutable Epetra_Time Time_;
372 
374  double ComputeFlops_;
376  mutable double ApplyInverseFlops_;
377 
378 };
379 
380 #endif /* IFPACK_IC_H */
const Epetra_Vector & D() const
Returns the address of the D factor associated with this factored matrix.
Definition: Ifpack_IC.h:210
virtual int NumInitialize() const
Returns the number of calls to Initialize().
Definition: Ifpack_IC.h:263
bool IsComputed() const
If factor is completed, this query returns true, otherwise it returns false.
Definition: Ifpack_IC.h:158
bool UseTranspose() const
Returns the current UseTranspose setting.
Definition: Ifpack_IC.h:236
const Epetra_Map & OperatorDomainMap() const
Returns the Epetra_Map object associated with the domain of this operator.
Definition: Ifpack_IC.h:239
bool HasNormInf() const
Returns false because this class cannot compute an Inf-norm.
Definition: Ifpack_IC.h:233
virtual double ApplyInverseTime() const
Returns the time spent in ApplyInverse().
Definition: Ifpack_IC.h:293
const Epetra_RowMatrix & Matrix() const
Returns a pointer to the matrix to be preconditioned.
Definition: Ifpack_IC.h:121
virtual double ComputeTime() const
Returns the time spent in Compute().
Definition: Ifpack_IC.h:287
const Epetra_Map & OperatorRangeMap() const
Returns the Epetra_Map object associated with the range of this operator.
Definition: Ifpack_IC.h:242
void SetAbsoluteThreshold(double Athresh)
Set absolute threshold value.
Definition: Ifpack_IC.h:97
double GetAbsoluteThreshold()
Get absolute threshold value.
Definition: Ifpack_IC.h:199
Ifpack_ScalingType enumerable type.
Ifpack_Preconditioner: basic class for preconditioning in Ifpack.
const Epetra_CrsMatrix & U() const
Returns the address of the U factor associated with this factored matrix.
Definition: Ifpack_IC.h:213
virtual double ApplyInverseFlops() const
Returns the number of flops in the application of the preconditioner.
Definition: Ifpack_IC.h:309
double GetRelativeThreshold()
Get relative threshold value.
Definition: Ifpack_IC.h:202
bool IsInitialized() const
Returns true if the preconditioner has been successfully initialized, false otherwise.
Definition: Ifpack_IC.h:131
int SetUseTranspose(bool UseTranspose_in)
If set true, transpose of this operator will be applied.
Definition: Ifpack_IC.h:227
void SetRelativeThreshold(double Rthresh)
Set relative threshold value.
Definition: Ifpack_IC.h:100
Ifpack_IC: A class for constructing and using an incomplete Cholesky factorization of a given Epetra_...
Definition: Ifpack_IC.h:80
double Condest() const
Returns the computed condition number estimate, or -1.0 if not computed.
Definition: Ifpack_IC.h:191
virtual double InitializeTime() const
Returns the time spent in Initialize().
Definition: Ifpack_IC.h:281
virtual int NumApplyInverse() const
Returns the number of calls to ApplyInverse().
Definition: Ifpack_IC.h:275
virtual int NumCompute() const
Returns the number of calls to Compute().
Definition: Ifpack_IC.h:269
virtual double ComputeFlops() const
Returns the number of flops in the computation phase.
Definition: Ifpack_IC.h:304
virtual double InitializeFlops() const
Returns the number of flops in the initialization phase.
Definition: Ifpack_IC.h:299
int NumMyNonzeros() const
Returns the number of nonzero entries in the local graph.
Definition: Ifpack_IC.h:208
const Epetra_Comm & Comm() const
Returns the Epetra_BlockMap object associated with the range of this matrix operator.
Definition: Ifpack_IC.h:245
int NumGlobalNonzeros() const
Returns the number of nonzero entries in the global graph.
Definition: Ifpack_IC.h:205
double NormInf() const
Returns 0.0 because this class cannot compute Inf-norm.
Definition: Ifpack_IC.h:230