IFPACK  Development
 All Classes Namespaces Files Functions Variables Enumerations Friends Pages
Ifpack_SILU.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_SILU_H
44 #define IFPACK_SILU_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 
54 #ifdef HAVE_IFPACK_SUPERLU
55 #include "Ifpack_Preconditioner.h"
56 #include "Ifpack_Condest.h"
57 #include "Ifpack_ScalingType.h"
58 #include "Ifpack_IlukGraph.h"
59 #include "Epetra_CompObject.h"
60 #include "Epetra_MultiVector.h"
61 #include "Epetra_Vector.h"
62 #include "Epetra_CrsGraph.h"
63 #include "Epetra_CrsMatrix.h"
64 #include "Epetra_BlockMap.h"
65 #include "Epetra_Map.h"
66 #include "Epetra_Object.h"
67 #include "Epetra_Comm.h"
68 #include "Epetra_RowMatrix.h"
69 #include "Epetra_Time.h"
70 #include "Teuchos_RefCountPtr.hpp"
71 
72 namespace Teuchos {
73  class ParameterList;
74 }
75 
76 // SuperLU includes
77 #include "slu_ddefs.h"
78 
79 
90 
91 public:
93 
96 
99  {
100  Destroy();
101  }
102 
104 
106 
108  int Initialize();
109 
111  bool IsInitialized() const
112  {
113  return(IsInitialized_);
114  }
115 
117  int Compute();
118 
120  bool IsComputed() const
121  {
122  return(IsComputed_);
123  }
124 
126  /* This method is only available if the Teuchos package is enabled.
127  This method recognizes four parameter names: relax_value,
128  absolute_threshold, relative_threshold and overlap_mode. These names are
129  case insensitive, and in each case except overlap_mode, the ParameterEntry
130  must have type double. For overlap_mode, the ParameterEntry must have
131  type Epetra_CombineMode.
132  */
133  int SetParameters(Teuchos::ParameterList& parameterlist);
134 
136 
145  int SetUseTranspose(bool UseTranspose_in) {UseTranspose_ = UseTranspose_in; return(0);};
147 
149 
150  // Applies the matrix to X, returns the result in Y.
151  int Apply(const Epetra_MultiVector& X,
152  Epetra_MultiVector& Y) const
153  {
154  return(Multiply(false,X,Y));
155  }
156 
157  int Multiply(bool Trans, const Epetra_MultiVector& X,
158  Epetra_MultiVector& Y) const;
159 
161 
174  int ApplyInverse(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
175 
177  double Condest(const Ifpack_CondestType CT = Ifpack_Cheap,
178  const int MaxIters = 1550,
179  const double Tol = 1e-9,
180  Epetra_RowMatrix* Matrix_in = 0);
181 
183  double Condest() const
184  {
185  return(Condest_);
186  }
187 
189 
191 
192 
194  const char* Label() const {return(Label_);}
195 
197  int SetLabel(const char* Label_in)
198  {
199  strcpy(Label_,Label_in);
200  return(0);
201  }
202 
204  double NormInf() const {return(0.0);};
205 
207  bool HasNormInf() const {return(false);};
208 
210  bool UseTranspose() const {return(UseTranspose_);};
211 
213  const Epetra_Map & OperatorDomainMap() const {return(A_->OperatorDomainMap());};
214 
216  const Epetra_Map & OperatorRangeMap() const{return(A_->OperatorRangeMap());};
217 
219  const Epetra_Comm & Comm() const{return(Comm_);};
220 
222  const Epetra_RowMatrix& Matrix() const
223  {
224  return(*A_);
225  }
226 
228  virtual std::ostream& Print(std::ostream& os) const;
229 
231  virtual int NumInitialize() const
232  {
233  return(NumInitialize_);
234  }
235 
237  virtual int NumCompute() const
238  {
239  return(NumCompute_);
240  }
241 
243  virtual int NumApplyInverse() const
244  {
245  return(NumApplyInverse_);
246  }
247 
249  virtual double InitializeTime() const
250  {
251  return(InitializeTime_);
252  }
253 
255  virtual double ComputeTime() const
256  {
257  return(ComputeTime_);
258  }
259 
261  virtual double ApplyInverseTime() const
262  {
263  return(ApplyInverseTime_);
264  }
265 
266  virtual double InitializeFlops() const
267  {
268  return(0.0);
269  }
270 
271  virtual double ComputeFlops() const
272  {
273  return(0.0);
274  }
275 
276  virtual double ApplyInverseFlops() const
277  {
278  return(0.0);
279  }
280 
281 private:
282 
284 
286 
288  Ifpack_SILU(const Ifpack_SILU& RHS):
289  Comm_(RHS.Comm()),
290  Time_(RHS.Comm())
291  {}
292 
294  Ifpack_SILU& operator=(const Ifpack_SILU& RHS)
295  {
296  return(*this);
297  }
298 
300  void Destroy();
301 
303 
313  int Solve(bool Trans, const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
314 
315  int InitAllValues(const Epetra_RowMatrix & A, int MaxNumEntries);
316 
318  double DropTol() const {return DropTol_;}
319 
321  double FillTol() const{return FillTol_;}
322 
324  double FillFactor() const{return FillFactor_;}
325 
327  int DropRule() const{return DropRule_;}
328 
329 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
330  int NumGlobalRows() const {return(Graph().NumGlobalRows());};
332 
334  int NumGlobalCols() const {return(Graph().NumGlobalCols());};
335 
337  int NumGlobalNonzeros() const {return(Graph().NumGlobalNonzeros());};
338 
340  virtual int NumGlobalBlockDiagonals() const {return(Graph().NumGlobalBlockDiagonals());};
341 #endif
342 
344  long long NumGlobalRows64() const {return(Graph().NumGlobalRows64());};
345 
347  long long NumGlobalCols64() const {return(Graph().NumGlobalCols64());};
348 
350  long long NumGlobalNonzeros64() const {return(Graph().NumGlobalNonzeros64());};
351 
353  virtual long long NumGlobalBlockDiagonals64() const {return(Graph().NumGlobalBlockDiagonals64());};
354 
356  int NumMyRows() const {return(Graph().NumMyRows());};
357 
359  int NumMyCols() const {return(Graph().NumMyCols());};
360 
362  int NumMyNonzeros() const {return(Graph().NumMyNonzeros());};
363 
365  virtual int NumMyBlockDiagonals() const {return(Graph().NumMyBlockDiagonals());};
366 
368  virtual int NumMyDiagonals() const {return(NumMyDiagonals_);};
369 
370 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
371  int IndexBase() const {return(Graph().IndexBase());};
373 #endif
374  long long IndexBase64() const {return(Graph().IndexBase64());};
375 
377  const Epetra_CrsGraph & Graph() const {return(*Graph_);};
378 
381  {
382  return(*A_);
383  }
384 
386 
388 
389 
391  Teuchos::RefCountPtr<Epetra_RowMatrix> A_;
392  Teuchos::RefCountPtr<Epetra_CrsGraph> Graph_;
393  Teuchos::RefCountPtr<Epetra_Map> IlukRowMap_;
394  Teuchos::RefCountPtr<Epetra_Map> IlukDomainMap_;
395  Teuchos::RefCountPtr<Epetra_Map> IlukRangeMap_;
396  const Epetra_Comm & Comm_;
398  Teuchos::RefCountPtr<Epetra_CrsMatrix> Aover_;
399  bool UseTranspose_;
400 
401  int NumMyDiagonals_;
402  bool Allocated_;
403  bool ValuesInitialized_;
404  bool Factored_;
405 
407  double DropTol_;
409  double FillTol_;
411  double FillFactor_;
413  int DropRule_;
414 
416  double Condest_;
418  bool IsInitialized_;
420  bool IsComputed_;
422  char Label_[160];
424  int NumInitialize_;
426  int NumCompute_;
428  mutable int NumApplyInverse_;
430  double InitializeTime_;
432  double ComputeTime_;
434  mutable double ApplyInverseTime_;
436  mutable Epetra_Time Time_;
438 #ifdef HAVE_IFPACK_SUPERLU5_API
439  mutable GlobalLU_t lu_;
440 #endif
441  mutable SuperLUStat_t stat_;
444  mutable superlu_options_t options_;
446  mutable SuperMatrix SA_,SAc_,SL_,SU_,SY_;
448  int *etree_,*perm_r_,*perm_c_;
450 
451 
452  template<typename int_type>
453  int TInitialize();
454 };
455 
456 #endif /* HAVE_IFPACK_SUPERLU */
457 #endif /* IFPACK_ILU_H */
int SetLabel(const char *Label_in)
Sets label for this object.
Definition: Ifpack_SILU.h:197
virtual double ApplyInverseTime() const
Returns the time spent in ApplyInverse().
Definition: Ifpack_SILU.h:261
virtual double InitializeFlops() const
Returns the number of flops in the initialization phase.
Definition: Ifpack_SILU.h:266
const char * Label() const
Returns a character string describing the operator.
Definition: Ifpack_SILU.h:194
Ifpack_SILU(Epetra_RowMatrix *A)
Constructor.
Definition: Ifpack_SILU.cpp:70
virtual int NumInitialize() const
Returns the number of calls to Initialize().
Definition: Ifpack_SILU.h:231
bool UseTranspose() const
Returns the current UseTranspose setting.
Definition: Ifpack_SILU.h:210
const Epetra_RowMatrix & Matrix() const
Returns a reference to the matrix to be preconditioned.
Definition: Ifpack_SILU.h:222
int ApplyInverse(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Returns the result of a Epetra_Operator inverse applied to an Epetra_MultiVector X in Y...
A wrapper to SuperLU 4.0&#39;s supernodal ILUT w/ partial pivoting.
Definition: Ifpack_SILU.h:89
virtual double InitializeTime() const
Returns the time spent in Initialize().
Definition: Ifpack_SILU.h:249
~Ifpack_SILU()
Destructor.
Definition: Ifpack_SILU.h:98
bool IsInitialized() const
Returns true if the preconditioner has been successfully initialized.
Definition: Ifpack_SILU.h:111
bool HasNormInf() const
Returns false because this class cannot compute an Inf-norm.
Definition: Ifpack_SILU.h:207
virtual std::ostream & Print(std::ostream &os) const
Prints on stream basic information about this object.
Ifpack_ScalingType enumerable type.
Ifpack_Preconditioner: basic class for preconditioning in Ifpack.
int Compute()
Compute ILU factors L and U using the specified graph, diagonal perturbation thresholds and relaxatio...
int Initialize()
Initialize the preconditioner, does not touch matrix values.
int SetParameters(Teuchos::ParameterList &parameterlist)
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_SILU.h:213
int SetUseTranspose(bool UseTranspose_in)
If set true, transpose of this operator will be applied.
Definition: Ifpack_SILU.h:145
bool IsComputed() const
If factor is completed, this query returns true, otherwise it returns false.
Definition: Ifpack_SILU.h:120
virtual double ComputeTime() const
Returns the time spent in Compute().
Definition: Ifpack_SILU.h:255
virtual double ApplyInverseFlops() const
Returns the number of flops in the application of the preconditioner.
Definition: Ifpack_SILU.h:276
virtual int NumCompute() const
Returns the number of calls to Compute().
Definition: Ifpack_SILU.h:237
const Epetra_Map & OperatorRangeMap() const
Returns the Epetra_Map object associated with the range of this operator.
Definition: Ifpack_SILU.h:216
const Epetra_Comm & Comm() const
Returns the Epetra_BlockMap object associated with the range of this matrix operator.
Definition: Ifpack_SILU.h:219
virtual int NumApplyInverse() const
Returns the number of calls to ApplyInverse().
Definition: Ifpack_SILU.h:243
double NormInf() const
Returns 0.0 because this class cannot compute Inf-norm.
Definition: Ifpack_SILU.h:204
virtual double ComputeFlops() const
Returns the number of flops in the computation phase.
Definition: Ifpack_SILU.h:271
double Condest() const
Returns the computed estimated condition number, or -1.0 if not computed.
Definition: Ifpack_SILU.h:183