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 #include "Ifpack_ConfigDefs.h"
47 #ifdef HAVE_IFPACK_SPARSKIT
48 #include "Ifpack_CondestType.h"
49 #include "Ifpack_ScalingType.h"
50 #include "Ifpack_Preconditioner.h"
51 #include "Epetra_Vector.h"
52 #include "Epetra_RowMatrix.h"
53 class Epetra_Comm;
54 class Epetra_Map;
55 class Epetra_MultiVector;
56 namespace Teuchos {
57  class ParameterList;
58 }
59 
61 
62 class Ifpack_SPARSKIT: public Ifpack_Preconditioner {
63 
64  public:
66  Ifpack_SPARSKIT(Epetra_RowMatrix* A);
67 
69  virtual ~Ifpack_SPARSKIT();
70 
72  /* This method is only available if the Teuchos package is enabled.
73  This method recognizes five parameter names: level_fill, drop_tolerance,
74  absolute_threshold, relative_threshold and overlap_mode. These names are
75  case insensitive. For level_fill the ParameterEntry must have type int, the
76  threshold entries must have type double and overlap_mode must have type
77  Epetra_CombineMode.
78  */
79  int SetParameters(Teuchos::ParameterList& parameterlis);
80 
81  int SetParameter(const std::string Name, const int Value)
82  {
83  IFPACK_CHK_ERR(-98);
84  }
85  int SetParameter(const std::string Name, const double Value)
86  {
87  IFPACK_CHK_ERR(-98);
88  }
89 
90  const Epetra_RowMatrix& Matrix() const
91  {
92  return(A_);
93  }
94 
96  {
97  return(A_);
98  }
99 
100  bool IsInitialized() const
101  {
102  return(IsInitialized_);
103  }
104 
106  int Initialize();
107 
109  int Compute();
110 
112  bool IsComputed() const
113  {
114  return(IsComputed_);
115  }
116 
117  // Mathematical functions.
118 
120 
130  int ApplyInverse(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
131 
132  int Apply(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const
133  {
134  IFPACK_CHK_ERR(-1);
135  }
136 
138 
146  double Condest(const Ifpack_CondestType CT = Ifpack_Cheap,
147  const int MaxIters = 1550,
148  const double Tol = 1e-9,
149  Epetra_RowMatrix* Matrix = 0);
150 
151  double Condest() const
152  {
153  return(Condest_);
154  }
155 
156  // Attribute access functions
157 
159 
161 
170  int SetUseTranspose(bool UseTranspose) {UseTranspose_ = UseTranspose; return(0);};
171 
173  double NormInf() const {return(0.0);};
174 
176  bool HasNormInf() const {return(false);};
177 
179  bool UseTranspose() const {return(UseTranspose_);};
180 
182  const Epetra_Map & OperatorDomainMap() const {return(A_.OperatorDomainMap());};
183 
185  const Epetra_Map & OperatorRangeMap() const{return(A_.OperatorRangeMap());};
186 
188  const Epetra_Comm & Comm() const{return(Comm_);};
190 
191  const char* Label() const
192  {
193  return(Label_.c_str());
194  }
195 
196  int SetLabel(const char* Label)
197  {
198  Label_ = Label;
199  return(0);
200  }
201 
203  virtual std::ostream& Print(std::ostream& os) const;
204 
206  virtual int NumInitialize() const
207  {
208  return(NumInitialize_);
209  }
210 
212  virtual int NumCompute() const
213  {
214  return(NumCompute_);
215  }
216 
218  virtual int NumApplyInverse() const
219  {
220  return(NumApplyInverse_);
221  }
222 
224  virtual double InitializeTime() const
225  {
226  return(InitializeTime_);
227  }
228 
230  virtual double ComputeTime() const
231  {
232  return(ComputeTime_);
233  }
234 
236  virtual double ApplyInverseTime() const
237  {
238  return(ApplyInverseTime_);
239  }
240 
242  virtual double InitializeFlops() const
243  {
244  return(0.0);
245  }
246 
247  virtual double ComputeFlops() const
248  {
249  return(0.0);
250  }
251 
252  virtual double ApplyInverseFlops() const
253  {
254  return(0.0);
255  }
256 
257 private:
258  Epetra_RowMatrix& A_;
259  const Epetra_Comm& Comm_;
260  bool UseTranspose_;
261  int lfil_;
262  double droptol_;
263  double tol_;
264  double permtol_;
265  double alph_;
266  int mbloc_;
267  std::string Type_;
268 
269  // Factorization in MSR format.
270  std::vector<double> alu_;
271  std::vector<int> jlu_;
272  std::vector<int> ju_;
273 
274  std::string Label_;
275  // Permutation vector if required by ILUTP and ILUDP.
276  std::vector<int> iperm_;
277 
278  double Condest_;
279 
280  bool IsInitialized_;
281  bool IsComputed_;
282 
284  int NumInitialize_;
286  int NumCompute_;
288  mutable int NumApplyInverse_;
289 
291  double InitializeTime_;
293  double ComputeTime_;
295  mutable double ApplyInverseTime_;
296 
298  double ComputeFlops_;
300  mutable double ApplyInverseFlops_;
301 
302 };
303 
304 #endif // HAVE_IFPACK_SPARSKIT
305 #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().