IFPACK  Development
 All Classes Namespaces Files Functions Variables Enumerations Friends Pages
Ifpack_Euclid.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_EUCLID_H
44 #define IFPACK_EUCLID_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_EUCLID
54 
55 #include "Ifpack_Condest.h"
56 #include "Ifpack_ScalingType.h"
57 #include "Epetra_CompObject.h"
58 #include "Epetra_MultiVector.h"
59 #include "Epetra_Vector.h"
60 #include "Epetra_CrsGraph.h"
61 #include "Epetra_CrsMatrix.h"
62 #include "Epetra_BlockMap.h"
63 #include "Epetra_Map.h"
64 #include "Epetra_Object.h"
65 #include "Epetra_Comm.h"
66 #include "Epetra_CrsMatrix.h"
67 #include "Epetra_Time.h"
68 #include "Teuchos_RefCountPtr.hpp"
69 #include "Teuchos_ParameterList.hpp"
70 #include "Epetra_MpiComm.h"
71 
72 #include "Mem_dh.h"
73 #include "io_dh.h"
74 #include "TimeLog_dh.h"
75 #include "Parser_dh.h"
76 #include "Euclid_dh.h"
77 
78 namespace Teuchos {
79  class ParameterList;
80 }
81 
83 
88  //The other files that were modified for Trilinos are getRow.c, call_epetra.{cpp,h}.
89 
90 class Ifpack_Euclid: public Epetra_Object, public Epetra_CompObject, public virtual Epetra_Operator {
91 
92  friend std::ostream& operator << (std::ostream& os, const Ifpack_Euclid& A);
93 
94 public:
95  // @{ Constructors and destructors.
97  Ifpack_Euclid(Epetra_CrsMatrix* A);
98 
100  ~Ifpack_Euclid(){ Destroy();}
101 
102  // @}
103  // @{ Construction methods
104 
106  int Initialize();
107 
109  bool IsInitialized() const{ return(IsInitialized_);}
110 
112 
114  int Compute();
115 
117  bool IsComputed() const{ return(IsComputed_);}
118 
119 
121 
133  int SetParameters(Teuchos::ParameterList& parameterlist);
134 
136 
142  int SetParameter(std::string name, int Value);
143 
145 
151  int SetParameter(std::string name, double Value);
152 
154  int SetUseTranspose(bool UseTranspose_in) {UseTranspose_ = UseTranspose_in; return(0);};
155  // @}
156 
157  // @{ Mathematical functions.
158  // Applies the matrix to X, returns the result in Y.
159  int Apply(const Epetra_MultiVector& X,
160  Epetra_MultiVector& Y) const{ return(Multiply(false,X,Y));}
161 
163 
173  int Multiply(bool Trans, const Epetra_MultiVector& X, Epetra_MultiVector& Y) const{ return A_->Multiply(Trans, X, Y); }
174 
176 
189  int ApplyInverse(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
190 
192  double Condest(const Ifpack_CondestType CT = Ifpack_Cheap, const int MaxIters = 1550,
193  const double Tol = 1e-9, Epetra_RowMatrix* Matrix_in = 0);
194 
196  double Condest() const{ return(Condest_);}
197 
198  // @}
199  // @{ Query methods
200 
202  const char* Label() const {return(Label_);}
203 
205  void SetLabel(const char* Label_in){ strcpy(Label_,Label_in);}
206 
208  const Epetra_Map &OperatorDomainMap() const{return A_->DomainMap();}
209 
211  const Epetra_Map &OperatorRangeMap() const{return A_->RangeMap();}
212 
214  double NormInf() const {return(0.0);};
215 
217  bool HasNormInf() const {return(false);};
218 
220  bool UseTranspose() const {return(UseTranspose_);};
221 
223  const Epetra_Comm & Comm() const{return(A_->Comm());};
224 
226  const Epetra_CrsMatrix& Matrix() const{ return(*A_);}
227 
229  virtual int NumInitialize() const{ return(NumInitialize_);}
230 
232  virtual int NumCompute() const{ return(NumCompute_);}
233 
235  virtual int NumApplyInverse() const{ return(NumApplyInverse_);}
236 
238  virtual double InitializeTime() const{ return(InitializeTime_);}
239 
241  virtual double ComputeTime() const{ return(ComputeTime_);}
242 
244  virtual double ApplyInverseTime() const{ return(ApplyInverseTime_);}
245 
247  virtual double InitializeFlops() const{ return(0.0);}
248 
250  virtual double ComputeFlops() const{ return(ComputeFlops_);}
251 
253  virtual double ApplyInverseFlops() const{ return(ApplyInverseFlops_);}
254 
255 private:
256 
257  // @}
258  // @{ Private methods
259 
261  Ifpack_Euclid(const Ifpack_Euclid& RHS) : Time_(RHS.Comm()){}
262 
264  Ifpack_Euclid& operator=(const Ifpack_Euclid& RHS){ return(*this);}
265 
267  void Destroy();
268 
270  MPI_Comm GetMpiComm() const{ return (dynamic_cast<const Epetra_MpiComm*>(&A_->Comm()))->GetMpiComm();}
271 
273  int CallEuclid(double *x, double *y) const;
274 
276 
286  int Solve(bool Trans, const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
287 
289  int NumGlobalRows() const {return(A_->NumGlobalRows());};
290 
292  int NumGlobalCols() const {return(A_->NumGlobalCols());};
293 
295  int NumMyRows() const {return(A_->NumMyRows());};
296 
298  int NumMyCols() const {return(A_->NumMyCols());};
299 
300  // @}
301  // @{ Internal data
302 
304  Teuchos::RefCountPtr<Epetra_CrsMatrix> A_;
306  Teuchos::ParameterList List_;
308  bool UseTranspose_;
310  double Condest_;
312  bool IsInitialized_;
314  bool IsComputed_;
316  char Label_[160];
318  int NumInitialize_;
320  int NumCompute_;
322  mutable int NumApplyInverse_;
324  double InitializeTime_;
326  double ComputeTime_;
328  mutable double ApplyInverseTime_;
330  double ComputeFlops_;
332  mutable double ApplyInverseFlops_;
334  mutable Epetra_Time Time_;
336  Euclid_dh eu;
338  int SetLevel_;
340  int SetBJ_;
342  int SetStats_;
344  int SetMem_;
346  double SetSparse_;
348  int SetRowScale_;
350  double SetILUT_;
351 };
352 
354 std::ostream& operator << (std::ostream& os, const Ifpack_Euclid& A);
355 
356 #endif // HAVE_EUCLID
357 #endif /* IFPACK_EUCLID_H */
virtual int SetUseTranspose(bool UseTranspose)=0
virtual int ApplyInverse(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const =0
virtual const Epetra_Map & OperatorDomainMap() const =0
virtual const char * Label() const =0
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 bool UseTranspose() const =0
Ifpack_ScalingType enumerable type.
virtual bool HasNormInf() const =0
virtual double NormInf() const =0