Ifpack Package Browser (Single Doxygen Collection)  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Ifpack_SPARSKIT.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_SPARSKIT_H
44 #define IFPACK_SPARSKIT_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 #ifdef HAVE_IFPACK_SPARSKIT
54 #include "Ifpack_CondestType.h"
55 #include "Ifpack_ScalingType.h"
56 #include "Ifpack_Preconditioner.h"
57 #include "Epetra_Vector.h"
58 #include "Epetra_RowMatrix.h"
59 class Epetra_Comm;
60 class Epetra_Map;
61 class Epetra_MultiVector;
62 namespace Teuchos {
63  class ParameterList;
64 }
65 
67 
68 class Ifpack_SPARSKIT: public Ifpack_Preconditioner {
69 
70  public:
72  Ifpack_SPARSKIT(Epetra_RowMatrix* A);
73 
75  virtual ~Ifpack_SPARSKIT();
76 
78  /* This method is only available if the Teuchos package is enabled.
79  This method recognizes five parameter names: level_fill, drop_tolerance,
80  absolute_threshold, relative_threshold and overlap_mode. These names are
81  case insensitive. For level_fill the ParameterEntry must have type int, the
82  threshold entries must have type double and overlap_mode must have type
83  Epetra_CombineMode.
84  */
85  int SetParameters(Teuchos::ParameterList& parameterlis);
86 
87  int SetParameter(const std::string Name, const int Value)
88  {
89  IFPACK_CHK_ERR(-98);
90  }
91  int SetParameter(const std::string Name, const double Value)
92  {
93  IFPACK_CHK_ERR(-98);
94  }
95 
96  const Epetra_RowMatrix& Matrix() const
97  {
98  return(A_);
99  }
100 
102  {
103  return(A_);
104  }
105 
106  bool IsInitialized() const
107  {
108  return(IsInitialized_);
109  }
110 
112  int Initialize();
113 
115  int Compute();
116 
118  bool IsComputed() const
119  {
120  return(IsComputed_);
121  }
122 
123  // Mathematical functions.
124 
126 
136  int ApplyInverse(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
137 
138  int Apply(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const
139  {
140  IFPACK_CHK_ERR(-1);
141  }
142 
144 
152  double Condest(const Ifpack_CondestType CT = Ifpack_Cheap,
153  const int MaxIters = 1550,
154  const double Tol = 1e-9,
155  Epetra_RowMatrix* Matrix = 0);
156 
157  double Condest() const
158  {
159  return(Condest_);
160  }
161 
162  // Attribute access functions
163 
165 
167 
176  int SetUseTranspose(bool UseTranspose) {UseTranspose_ = UseTranspose; return(0);};
177 
179  double NormInf() const {return(0.0);};
180 
182  bool HasNormInf() const {return(false);};
183 
185  bool UseTranspose() const {return(UseTranspose_);};
186 
188  const Epetra_Map & OperatorDomainMap() const {return(A_.OperatorDomainMap());};
189 
191  const Epetra_Map & OperatorRangeMap() const{return(A_.OperatorRangeMap());};
192 
194  const Epetra_Comm & Comm() const{return(Comm_);};
196 
197  const char* Label() const
198  {
199  return(Label_.c_str());
200  }
201 
202  int SetLabel(const char* Label)
203  {
204  Label_ = Label;
205  return(0);
206  }
207 
209  virtual std::ostream& Print(std::ostream& os) const;
210 
212  virtual int NumInitialize() const
213  {
214  return(NumInitialize_);
215  }
216 
218  virtual int NumCompute() const
219  {
220  return(NumCompute_);
221  }
222 
224  virtual int NumApplyInverse() const
225  {
226  return(NumApplyInverse_);
227  }
228 
230  virtual double InitializeTime() const
231  {
232  return(InitializeTime_);
233  }
234 
236  virtual double ComputeTime() const
237  {
238  return(ComputeTime_);
239  }
240 
242  virtual double ApplyInverseTime() const
243  {
244  return(ApplyInverseTime_);
245  }
246 
248  virtual double InitializeFlops() const
249  {
250  return(0.0);
251  }
252 
253  virtual double ComputeFlops() const
254  {
255  return(0.0);
256  }
257 
258  virtual double ApplyInverseFlops() const
259  {
260  return(0.0);
261  }
262 
263 private:
264  Epetra_RowMatrix& A_;
265  const Epetra_Comm& Comm_;
266  bool UseTranspose_;
267  int lfil_;
268  double droptol_;
269  double tol_;
270  double permtol_;
271  double alph_;
272  int mbloc_;
273  std::string Type_;
274 
275  // Factorization in MSR format.
276  std::vector<double> alu_;
277  std::vector<int> jlu_;
278  std::vector<int> ju_;
279 
280  std::string Label_;
281  // Permutation vector if required by ILUTP and ILUDP.
282  std::vector<int> iperm_;
283 
284  double Condest_;
285 
286  bool IsInitialized_;
287  bool IsComputed_;
288 
290  int NumInitialize_;
292  int NumCompute_;
294  mutable int NumApplyInverse_;
295 
297  double InitializeTime_;
299  double ComputeTime_;
301  mutable double ApplyInverseTime_;
302 
304  double ComputeFlops_;
306  mutable double ApplyInverseFlops_;
307 
308 };
309 
310 #endif // HAVE_IFPACK_SPARSKIT
311 #endif /* IFPACK_SPARSKIT_H */
virtual int NumInitialize() const =0
Returns the number of calls to Initialize().
virtual int SetUseTranspose(bool UseTranspose)=0
virtual double ComputeTime() const =0
Returns the time spent in Compute().
virtual double ComputeFlops() const =0
Returns the number of flops in the computation phase.
virtual double ApplyInverseTime() const =0
Returns the time spent in ApplyInverse().
virtual double ApplyInverseFlops() const =0
Returns the number of flops in the application of the preconditioner.
virtual const Epetra_RowMatrix & Matrix() const =0
Returns a pointer to the matrix to be preconditioned.
virtual bool IsInitialized() const =0
Returns true if the preconditioner has been successfully initialized, false otherwise.
virtual std::ostream & Print(std::ostream &os) const =0
Prints basic information on iostream. This function is used by operator&lt;&lt;.
virtual const Epetra_Map & OperatorDomainMap() const =0
virtual const char * Label() const =0
virtual int Initialize()=0
Computes all it is necessary to initialize the preconditioner.
virtual double InitializeTime() const =0
Returns the time spent in Initialize().
Ifpack_CondestType
Ifpack_CondestType: enum to define the type of condition number estimate.
virtual int Apply(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const =0
virtual const Epetra_Map & OperatorRangeMap() const =0
virtual const Epetra_Comm & Comm() const =0
virtual int SetParameters(Teuchos::ParameterList &List)=0
Sets all parameters for the preconditioner.
virtual double Condest() const =0
Returns the computed condition number estimate, or -1.0 if not computed.
virtual bool UseTranspose() const =0
Ifpack_ScalingType enumerable type.
Ifpack_Preconditioner: basic class for preconditioning in Ifpack.
virtual int ApplyInverse(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const =0
Applies the preconditioner to vector X, returns the result in Y.
virtual double InitializeFlops() const =0
Returns the number of flops in the initialization phase.
cheap estimate
virtual bool HasNormInf() const =0
virtual int NumCompute() const =0
Returns the number of calls to Compute().
virtual double NormInf() const =0
virtual bool IsComputed() const =0
Returns true if the preconditioner has been successfully computed, false otherwise.
virtual int Compute()=0
Computes all it is necessary to apply the preconditioner.
#define IFPACK_CHK_ERR(ifpack_err)
virtual int NumApplyInverse() const =0
Returns the number of calls to ApplyInverse().