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 #include "Ifpack_ConfigDefs.h"
47 #ifdef HAVE_EUCLID
48 
49 #include "Ifpack_Condest.h"
50 #include "Ifpack_ScalingType.h"
51 #include "Epetra_CompObject.h"
52 #include "Epetra_MultiVector.h"
53 #include "Epetra_Vector.h"
54 #include "Epetra_CrsGraph.h"
55 #include "Epetra_CrsMatrix.h"
56 #include "Epetra_BlockMap.h"
57 #include "Epetra_Map.h"
58 #include "Epetra_Object.h"
59 #include "Epetra_Comm.h"
60 #include "Epetra_CrsMatrix.h"
61 #include "Epetra_Time.h"
62 #include "Teuchos_RefCountPtr.hpp"
63 #include "Teuchos_ParameterList.hpp"
64 #include "Epetra_MpiComm.h"
65 
66 #include "Mem_dh.h"
67 #include "io_dh.h"
68 #include "TimeLog_dh.h"
69 #include "Parser_dh.h"
70 #include "Euclid_dh.h"
71 
72 namespace Teuchos {
73  class ParameterList;
74 }
75 
77 
82  //The other files that were modified for Trilinos are getRow.c, call_epetra.{cpp,h}.
83 
84 class Ifpack_Euclid: public Epetra_Object, public Epetra_CompObject, public virtual Epetra_Operator {
85 
86  friend std::ostream& operator << (std::ostream& os, const Ifpack_Euclid& A);
87 
88 public:
89  // @{ Constructors and destructors.
91  Ifpack_Euclid(Epetra_CrsMatrix* A);
92 
94  ~Ifpack_Euclid(){ Destroy();}
95 
96  // @}
97  // @{ Construction methods
98 
100  int Initialize();
101 
103  bool IsInitialized() const{ return(IsInitialized_);}
104 
106 
108  int Compute();
109 
111  bool IsComputed() const{ return(IsComputed_);}
112 
113 
115 
127  int SetParameters(Teuchos::ParameterList& parameterlist);
128 
130 
136  int SetParameter(std::string name, int Value);
137 
139 
145  int SetParameter(std::string name, double Value);
146 
148  int SetUseTranspose(bool UseTranspose_in) {UseTranspose_ = UseTranspose_in; return(0);};
149  // @}
150 
151  // @{ Mathematical functions.
152  // Applies the matrix to X, returns the result in Y.
153  int Apply(const Epetra_MultiVector& X,
154  Epetra_MultiVector& Y) const{ return(Multiply(false,X,Y));}
155 
157 
167  int Multiply(bool Trans, const Epetra_MultiVector& X, Epetra_MultiVector& Y) const{ return A_->Multiply(Trans, X, Y); }
168 
170 
183  int ApplyInverse(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
184 
186  double Condest(const Ifpack_CondestType CT = Ifpack_Cheap, const int MaxIters = 1550,
187  const double Tol = 1e-9, Epetra_RowMatrix* Matrix_in = 0);
188 
190  double Condest() const{ return(Condest_);}
191 
192  // @}
193  // @{ Query methods
194 
196  const char* Label() const {return(Label_);}
197 
199  void SetLabel(const char* Label_in){ strcpy(Label_,Label_in);}
200 
202  const Epetra_Map &OperatorDomainMap() const{return A_->DomainMap();}
203 
205  const Epetra_Map &OperatorRangeMap() const{return A_->RangeMap();}
206 
208  double NormInf() const {return(0.0);};
209 
211  bool HasNormInf() const {return(false);};
212 
214  bool UseTranspose() const {return(UseTranspose_);};
215 
217  const Epetra_Comm & Comm() const{return(A_->Comm());};
218 
220  const Epetra_CrsMatrix& Matrix() const{ return(*A_);}
221 
223  virtual int NumInitialize() const{ return(NumInitialize_);}
224 
226  virtual int NumCompute() const{ return(NumCompute_);}
227 
229  virtual int NumApplyInverse() const{ return(NumApplyInverse_);}
230 
232  virtual double InitializeTime() const{ return(InitializeTime_);}
233 
235  virtual double ComputeTime() const{ return(ComputeTime_);}
236 
238  virtual double ApplyInverseTime() const{ return(ApplyInverseTime_);}
239 
241  virtual double InitializeFlops() const{ return(0.0);}
242 
244  virtual double ComputeFlops() const{ return(ComputeFlops_);}
245 
247  virtual double ApplyInverseFlops() const{ return(ApplyInverseFlops_);}
248 
249 private:
250 
251  // @}
252  // @{ Private methods
253 
255  Ifpack_Euclid(const Ifpack_Euclid& RHS) : Time_(RHS.Comm()){}
256 
258  Ifpack_Euclid& operator=(const Ifpack_Euclid& RHS){ return(*this);}
259 
261  void Destroy();
262 
264  MPI_Comm GetMpiComm() const{ return (dynamic_cast<const Epetra_MpiComm*>(&A_->Comm()))->GetMpiComm();}
265 
267  int CallEuclid(double *x, double *y) const;
268 
270 
280  int Solve(bool Trans, const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
281 
283  int NumGlobalRows() const {return(A_->NumGlobalRows());};
284 
286  int NumGlobalCols() const {return(A_->NumGlobalCols());};
287 
289  int NumMyRows() const {return(A_->NumMyRows());};
290 
292  int NumMyCols() const {return(A_->NumMyCols());};
293 
294  // @}
295  // @{ Internal data
296 
298  Teuchos::RefCountPtr<Epetra_CrsMatrix> A_;
300  Teuchos::ParameterList List_;
302  bool UseTranspose_;
304  double Condest_;
306  bool IsInitialized_;
308  bool IsComputed_;
310  char Label_[160];
312  int NumInitialize_;
314  int NumCompute_;
316  mutable int NumApplyInverse_;
318  double InitializeTime_;
320  double ComputeTime_;
322  mutable double ApplyInverseTime_;
324  double ComputeFlops_;
326  mutable double ApplyInverseFlops_;
328  mutable Epetra_Time Time_;
330  Euclid_dh eu;
332  int SetLevel_;
334  int SetBJ_;
336  int SetStats_;
338  int SetMem_;
340  double SetSparse_;
342  int SetRowScale_;
344  double SetILUT_;
345 };
346 
348 std::ostream& operator << (std::ostream& os, const Ifpack_Euclid& A);
349 
350 #endif // HAVE_EUCLID
351 #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