IFPACK Development
Loading...
Searching...
No Matches
Ifpack_HIPS.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_HIPS_H
44#define IFPACK_HIPS_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_HIPS
54
55
56#include "Ifpack_Preconditioner.h"
57#include "Ifpack_Condest.h"
58#include "Ifpack_ScalingType.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_CrsMatrix.h"
69#include "Epetra_Time.h"
70#include "Teuchos_RefCountPtr.hpp"
71
72
73namespace Teuchos {
74 class ParameterList;
75}
76
78
86class Ifpack_HIPS: public Ifpack_Preconditioner {
87
88public:
89 // @{ Constructors and destructors.
91 Ifpack_HIPS(Epetra_RowMatrix* A);
92
94 ~Ifpack_HIPS()
95 {
96 Destroy();
97 }
98
99 // @}
100 // @{ Construction methods
101
103 int Initialize();
104
106 bool IsInitialized() const
107 {
108 return(IsInitialized_);
109 }
110
112
114 int Compute();
115
117 bool IsComputed() const
118 {
119 return(IsComputed_);
120 }
121
123 /* This method is only available if the Teuchos package is enabled.
124 This method recognizes four parameter names: relax_value,
125 absolute_threshold, relative_threshold and overlap_mode. These names are
126 case insensitive, and in each case except overlap_mode, the ParameterEntry
127 must have type double. For overlap_mode, the ParameterEntry must have
128 type Epetra_CombineMode.
129 */
130 int SetParameters(Teuchos::ParameterList& parameterlist);
131
133
142 int SetUseTranspose(bool UseTranspose_in) {UseTranspose_ = UseTranspose_in; return(0);};
143 // @}
144
145 // @{ Mathematical functions.
146 // Applies the matrix to X, returns the result in Y.
147 int Apply(const Epetra_MultiVector& X,
148 Epetra_MultiVector& Y) const
149 {
150 return(Multiply(false,X,Y));
151 }
152
153 int Multiply(bool Trans, const Epetra_MultiVector& X,
154 Epetra_MultiVector& Y) const{return A_->Multiply(Trans,X,Y);}
155
157
170 int ApplyInverse(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
171
173 double Condest(const Ifpack_CondestType CT = Ifpack_Cheap,
174 const int MaxIters = 1550,
175 const double Tol = 1e-9,
176 Epetra_RowMatrix* Matrix_in = 0);
177
179 double Condest() const
180 {
181 return(Condest_);
182 }
183
184 // @}
185 // @{ Query methods
186
188 const char* Label() const {return(Label_);}
189
191 int SetLabel(const char* Label_in)
192 {
193 strcpy(Label_,Label_in);
194 return(0);
195 }
196
197
199 double NormInf() const {return(0.0);};
200
202 bool HasNormInf() const {return(false);};
203
205 bool UseTranspose() const {return(UseTranspose_);};
206
208 const Epetra_Map & OperatorDomainMap() const {return(A_->OperatorDomainMap());};
209
211 const Epetra_Map & OperatorRangeMap() const{return(A_->OperatorRangeMap());};
212
214 const Epetra_Comm & Comm() const{return(A_->Comm());};
215
217 const Epetra_RowMatrix& Matrix() const
218 {
219 return(*A_);
220 }
221
223 virtual std::ostream& Print(std::ostream& os) const;
224
226 virtual int NumInitialize() const
227 {
228 return(NumInitialize_);
229 }
230
232 virtual int NumCompute() const
233 {
234 return(NumCompute_);
235 }
236
238 virtual int NumApplyInverse() const
239 {
240 return(NumApplyInverse_);
241 }
242
244 virtual double InitializeTime() const
245 {
246 return(InitializeTime_);
247 }
248
250 virtual double ComputeTime() const
251 {
252 return(ComputeTime_);
253 }
254
256 virtual double ApplyInverseTime() const
257 {
258 return(ApplyInverseTime_);
259 }
260
262 virtual double InitializeFlops() const
263 {
264 return(0.0);
265 }
266
267 virtual double ComputeFlops() const
268 {
269 return(ComputeFlops_);
270 }
271
272 virtual double ApplyInverseFlops() const
273 {
274 return(ApplyInverseFlops_);
275 }
276
277private:
278
279 // @}
280 // @{ Private methods
281
283 Ifpack_HIPS(const Ifpack_HIPS& RHS) :
284 Time_(RHS.Comm())
285 {}
286
288 Ifpack_HIPS& operator=(const Ifpack_HIPS& RHS)
289 {
290 return(*this);
291 }
292
294 void Destroy();
295
297
307 int Solve(bool Trans, const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
308
309
311 int NumGlobalRows() const {return(A_->NumGlobalRows());};
312
314 int NumGlobalCols() const {return(A_->NumGlobalCols());};
315
317 int NumMyRows() const {return(A_->NumMyRows());};
318
320 int NumMyCols() const {return(A_->NumMyCols());};
321
323 /* Epetra_RowMatrix& Matrix()
324 {
325 return(*A_);
326 }*/
327
328 // @}
329 // @{ Internal data
330
332 Teuchos::RefCountPtr<Epetra_RowMatrix> A_;
333 Teuchos::ParameterList List_;
334 Teuchos::RefCountPtr<Epetra_Map> RowMap0_;
335 Teuchos::RefCountPtr<Epetra_Map> ColMap0_;
336
337
338 int HIPS_id;
339
340 bool UseTranspose_;
341 bool Allocated_;
342 bool ValuesInitialized_;
343 bool Factored_;
344
345 double Condest_;
346
347 bool IsParallel_;
349 bool IsInitialized_;
351 bool IsComputed_;
353 char Label_[160];
355 int NumInitialize_;
357 int NumCompute_;
358
360 mutable int NumApplyInverse_;
362 double InitializeTime_;
364 double ComputeTime_;
366 mutable double ApplyInverseTime_;
368 double ComputeFlops_;
370 mutable double ApplyInverseFlops_;
372 mutable Epetra_Time Time_;
373
374};
375
376#endif
377#endif /* IFPACK_HIPS_H */
Ifpack_ScalingType enumerable type.
virtual int SetUseTranspose(bool UseTranspose)=0
virtual int Apply(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const=0
virtual const Epetra_Comm & Comm() const=0
virtual const char * Label() const=0
virtual const Epetra_Map & OperatorDomainMap() const=0
virtual bool HasNormInf() const=0
virtual const Epetra_Map & OperatorRangeMap() const=0
virtual bool UseTranspose() const=0
virtual double NormInf() const=0
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 bool IsInitialized() const =0
Returns true if the preconditioner has been successfully initialized, false otherwise.
virtual int Compute()=0
Computes all it is necessary to apply the preconditioner.
virtual double ApplyInverseFlops() const =0
Returns the number of flops in the application of the preconditioner.
virtual std::ostream & Print(std::ostream &os) const =0
Prints basic information on iostream. This function is used by operator<<.
virtual double ComputeTime() const =0
Returns the time spent in Compute().
virtual int NumCompute() const =0
Returns the number of calls to Compute().
virtual double ComputeFlops() const =0
Returns the number of flops in the computation phase.
virtual double InitializeTime() const =0
Returns the time spent in Initialize().
virtual bool IsComputed() const =0
Returns true if the preconditioner has been successfully computed, false otherwise.
virtual int NumApplyInverse() const =0
Returns the number of calls to ApplyInverse().
virtual int SetParameters(Teuchos::ParameterList &List)=0
Sets all parameters for the preconditioner.
virtual int NumInitialize() const =0
Returns the number of calls to Initialize().
virtual double Condest() const =0
Returns the computed condition number estimate, or -1.0 if not computed.
virtual const Epetra_RowMatrix & Matrix() const =0
Returns a pointer to the matrix to be preconditioned.
virtual double ApplyInverseTime() const =0
Returns the time spent in ApplyInverse().
virtual int Initialize()=0
Computes all it is necessary to initialize the preconditioner.
virtual double InitializeFlops() const =0
Returns the number of flops in the initialization phase.