Ifpack Package Browser (Single Doxygen Collection)  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Ifpack_IC.h
Go to the documentation of this file.
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 
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 std::string /* Name */, const int /* Value */)
113  {
114  IFPACK_CHK_ERR(-98);
115  }
116  int SetParameter(const std::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 
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 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
206  int NumGlobalNonzeros() const {return(U().NumGlobalNonzeros()+D().GlobalLength());};
207 #endif
208  long long NumGlobalNonzeros64() const {return(U().NumGlobalNonzeros64()+D().GlobalLength64());};
209 
211  int NumMyNonzeros() const {return(U().NumMyNonzeros()+D().MyLength());};
213  const Epetra_Vector & D() const {return(*D_);};
214 
216  const Epetra_CrsMatrix & U() const {return(*U_);};
217 
219 
221 
230  int SetUseTranspose(bool UseTranspose_in) {UseTranspose_ = UseTranspose_in; return(0);};
231 
233  double NormInf() const {return(0.0);};
234 
236  bool HasNormInf() const {return(false);};
237 
239  bool UseTranspose() const {return(UseTranspose_);};
240 
242  const Epetra_Map & OperatorDomainMap() const {return(A_->OperatorDomainMap());};
243 
245  const Epetra_Map & OperatorRangeMap() const{return(A_->OperatorRangeMap());};
246 
248  const Epetra_Comm & Comm() const{return(Comm_);};
250 
251  const char* Label() const
252  {
253  return(Label_);
254  }
255 
256  int SetLabel(const char* Label_in)
257  {
258  strcpy(Label_,Label_in);
259  return(0);
260  }
261 
263  virtual std::ostream& Print(std::ostream& os) const;
264 
266  virtual int NumInitialize() const
267  {
268  return(NumInitialize_);
269  }
270 
272  virtual int NumCompute() const
273  {
274  return(NumCompute_);
275  }
276 
278  virtual int NumApplyInverse() const
279  {
280  return(NumApplyInverse_);
281  }
282 
284  virtual double InitializeTime() const
285  {
286  return(InitializeTime_);
287  }
288 
290  virtual double ComputeTime() const
291  {
292  return(ComputeTime_);
293  }
294 
296  virtual double ApplyInverseTime() const
297  {
298  return(ApplyInverseTime_);
299  }
300 
302  virtual double InitializeFlops() const
303  {
304  return(0.0);
305  }
306 
307  virtual double ComputeFlops() const
308  {
309  return(ComputeFlops_);
310  }
311 
312  virtual double ApplyInverseFlops() const
313  {
314  return(ApplyInverseFlops_);
315  }
316 
317 
318  private:
319 
320  double LevelOfFill() const
321  {
322  return(Lfil_);
323  }
324 
325  double AbsoluteThreshold() const
326  {
327  return(Athresh_);
328  }
329 
330  double RelativeThreshold() const
331  {
332  return(Rthresh_);
333  }
334 
335  double DropTolerance() const
336  {
337  return(Droptol_);
338  }
339 
340  Teuchos::RefCountPtr<Epetra_RowMatrix> A_;
342  Teuchos::RefCountPtr<Epetra_CrsMatrix> U_;
343  Teuchos::RefCountPtr<Epetra_Vector> D_;
345 
346  double Condest_;
347  double Athresh_;
348  double Rthresh_;
349  double Droptol_;
350  double Lfil_;
351 
352  void * Aict_;
353  void * Lict_;
354  double * Ldiag_;
355  char Label_[160];
356 
359 
365  mutable int NumApplyInverse_;
366 
370  double ComputeTime_;
372  mutable double ApplyInverseTime_;
375 
379  mutable double ApplyInverseFlops_;
380 
381 };
382 
383 #endif /* IFPACK_IC_H */
double InitializeTime_
Contains the time for all successful calls to Initialize().
Definition: Ifpack_IC.h:368
const Epetra_Vector & D() const
Returns the address of the D factor associated with this factored matrix.
Definition: Ifpack_IC.h:213
double ComputeTime_
Contains the time for all successful calls to Compute().
Definition: Ifpack_IC.h:370
virtual int NumInitialize() const
Returns the number of calls to Initialize().
Definition: Ifpack_IC.h:266
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:239
const Epetra_Map & OperatorDomainMap() const
Returns the Epetra_Map object associated with the domain of this operator.
Definition: Ifpack_IC.h:242
bool HasNormInf() const
Returns false because this class cannot compute an Inf-norm.
Definition: Ifpack_IC.h:236
double Condest_
Definition: Ifpack_IC.h:346
char Label_[160]
Definition: Ifpack_IC.h:355
int SetParameters(Teuchos::ParameterList &parameterlis)
Set parameters using a Teuchos::ParameterList object.
Definition: Ifpack_IC.cpp:110
virtual double ApplyInverseTime() const
Returns the time spent in ApplyInverse().
Definition: Ifpack_IC.h:296
double RelativeThreshold() const
Definition: Ifpack_IC.h:330
Epetra_Time Time_
Used for timing purposes.
Definition: Ifpack_IC.h:374
Teuchos::RefCountPtr< Epetra_RowMatrix > A_
Definition: Ifpack_IC.h:340
bool UseTranspose_
Definition: Ifpack_IC.h:344
double AbsoluteThreshold() const
Definition: Ifpack_IC.h:325
Ifpack_IC(Epetra_RowMatrix *A)
Ifpack_IC constuctor with variable number of indices per row.
Definition: Ifpack_IC.cpp:61
virtual ~Ifpack_IC()
Ifpack_IC Destructor.
Definition: Ifpack_IC.cpp:90
const Epetra_RowMatrix & Matrix() const
Returns a pointer to the matrix to be preconditioned.
Definition: Ifpack_IC.h:121
double ApplyInverseTime_
Contains the time for all successful calls to ApplyInverse().
Definition: Ifpack_IC.h:372
int SetParameter(const std::string, const double)
Definition: Ifpack_IC.h:116
Teuchos::RefCountPtr< Epetra_Vector > D_
Definition: Ifpack_IC.h:343
virtual double ComputeTime() const
Returns the time spent in Compute().
Definition: Ifpack_IC.h:290
const Epetra_Map & OperatorRangeMap() const
Returns the Epetra_Map object associated with the range of this operator.
Definition: Ifpack_IC.h:245
double Athresh_
Definition: Ifpack_IC.h:347
bool IsComputed_
Definition: Ifpack_IC.h:358
Teuchos::RefCountPtr< Epetra_CrsMatrix > U_
Definition: Ifpack_IC.h:342
Ifpack_CondestType
Ifpack_CondestType: enum to define the type of condition number estimate.
int Initialize()
Initialize L and U with values from user matrix A.
Definition: Ifpack_IC.cpp:126
void SetAbsoluteThreshold(double Athresh)
Set absolute threshold value.
Definition: Ifpack_IC.h:97
double GetAbsoluteThreshold()
Get absolute threshold value.
Definition: Ifpack_IC.h:199
double ApplyInverseFlops_
Contain sthe number of flops for ApplyInverse().
Definition: Ifpack_IC.h:379
int ApplyInverse(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Returns the result of a Ifpack_IC forward/back solve on a Epetra_MultiVector X in Y...
Definition: Ifpack_IC.cpp:309
Epetra_RowMatrix & Matrix()
Definition: Ifpack_IC.h:126
Ifpack_ScalingType enumerable type.
double Droptol_
Definition: Ifpack_IC.h:349
const Epetra_Comm & Comm_
Definition: Ifpack_IC.h:341
double LevelOfFill() const
Definition: Ifpack_IC.h:320
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:216
double ComputeFlops_
Contains the number of flops for Compute().
Definition: Ifpack_IC.h:377
double * Ldiag_
Definition: Ifpack_IC.h:354
int ComputeSetup()
Definition: Ifpack_IC.cpp:139
long long NumGlobalNonzeros64() const
Definition: Ifpack_IC.h:208
virtual double ApplyInverseFlops() const
Returns the number of flops in the application of the preconditioner.
Definition: Ifpack_IC.h:312
virtual std::ostream & Print(std::ostream &os) const
Prints basic information on iostream. This function is used by operator&lt;&lt;.
Definition: Ifpack_IC.cpp:385
int SetLabel(const char *Label_in)
Definition: Ifpack_IC.h:256
const char * Label() const
Definition: Ifpack_IC.h:251
int SetParameter(const std::string, const int)
Definition: Ifpack_IC.h:112
int NumCompute_
Contains the number of successful call to Compute().
Definition: Ifpack_IC.h:363
double GetRelativeThreshold()
Get relative threshold value.
Definition: Ifpack_IC.h:202
void * Aict_
Definition: Ifpack_IC.h:352
int Apply(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Definition: Ifpack_IC.cpp:350
bool IsInitialized() const
Returns true if the preconditioner has been successfully initialized, false otherwise.
Definition: Ifpack_IC.h:131
cheap estimate
int SetUseTranspose(bool UseTranspose_in)
If set true, transpose of this operator will be applied.
Definition: Ifpack_IC.h:230
double Rthresh_
Definition: Ifpack_IC.h:348
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
void * Lict_
Definition: Ifpack_IC.h:353
double Condest() const
Returns the computed condition number estimate, or -1.0 if not computed.
Definition: Ifpack_IC.h:191
double DropTolerance() const
Definition: Ifpack_IC.h:335
virtual double InitializeTime() const
Returns the time spent in Initialize().
Definition: Ifpack_IC.h:284
bool IsInitialized_
Definition: Ifpack_IC.h:357
virtual int NumApplyInverse() const
Returns the number of calls to ApplyInverse().
Definition: Ifpack_IC.h:278
virtual int NumCompute() const
Returns the number of calls to Compute().
Definition: Ifpack_IC.h:272
virtual double ComputeFlops() const
Returns the number of flops in the computation phase.
Definition: Ifpack_IC.h:307
double Lfil_
Definition: Ifpack_IC.h:350
#define IFPACK_CHK_ERR(ifpack_err)
virtual double InitializeFlops() const
Returns the number of flops in the initialization phase.
Definition: Ifpack_IC.h:302
int Compute()
Compute IC factor U using the specified graph, diagonal perturbation thresholds and relaxation parame...
Definition: Ifpack_IC.cpp:214
int NumMyNonzeros() const
Returns the number of nonzero entries in the local graph.
Definition: Ifpack_IC.h:211
const Epetra_Comm & Comm() const
Returns the Epetra_BlockMap object associated with the range of this matrix operator.
Definition: Ifpack_IC.h:248
int NumGlobalNonzeros() const
Returns the number of nonzero entries in the global graph.
Definition: Ifpack_IC.h:206
double NormInf() const
Returns 0.0 because this class cannot compute Inf-norm.
Definition: Ifpack_IC.h:233
int NumInitialize_
Contains the number of successful calls to Initialize().
Definition: Ifpack_IC.h:361
int NumApplyInverse_
Contains the number of successful call to ApplyInverse().
Definition: Ifpack_IC.h:365