IFPACK Development
Loading...
Searching...
No Matches
Ifpack_IHSS.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_IHSS_H
44#define IFPACK_IHSS_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#include "Ifpack_Preconditioner.h"
54
55#ifdef HAVE_IFPACK_EPETRAEXT
56#include "Ifpack_Condest.h"
57#include "Ifpack_ScalingType.h"
58#include "Epetra_CompObject.h"
59#include "Epetra_MultiVector.h"
60#include "Epetra_Vector.h"
61#include "Epetra_CrsGraph.h"
62#include "Epetra_CrsMatrix.h"
63#include "Epetra_BlockMap.h"
64#include "Epetra_Map.h"
65#include "Epetra_Object.h"
66#include "Epetra_Comm.h"
67#include "Epetra_CrsMatrix.h"
68#include "Epetra_Time.h"
69#include "Teuchos_RefCountPtr.hpp"
70
71
72namespace Teuchos {
73 class ParameterList;
74}
75
77
85class Ifpack_IHSS: public Ifpack_Preconditioner {
86
87public:
88 // @{ Constructors and destructors.
90
92 Ifpack_IHSS(Epetra_RowMatrix* A);
93
95 ~Ifpack_IHSS()
96 {
97 Destroy();
98 }
99
100 // @}
101 // @{ Construction methods
102
104 int Initialize();
105
107 bool IsInitialized() const
108 {
109 return(IsInitialized_);
110 }
111
113
115 int Compute();
116
118 bool IsComputed() const
119 {
120 return(IsComputed_);
121 }
122
124 /* This method is only available if the Teuchos package is enabled.
125 This method recognizes four parameter names: relax_value,
126 absolute_threshold, relative_threshold and overlap_mode. These names are
127 case insensitive, and in each case except overlap_mode, the ParameterEntry
128 must have type double. For overlap_mode, the ParameterEntry must have
129 type Epetra_CombineMode.
130 */
131 int SetParameters(Teuchos::ParameterList& parameterlist);
132
134
143 int SetUseTranspose(bool UseTranspose_in) {UseTranspose_ = UseTranspose_in; return(0);};
144 // @}
145
146 // @{ Mathematical functions.
147 // Applies the matrix to X, returns the result in Y.
148 int Apply(const Epetra_MultiVector& X,
149 Epetra_MultiVector& Y) const
150 {
151 return(Multiply(false,X,Y));
152 }
153
154 int Multiply(bool Trans, const Epetra_MultiVector& X,
155 Epetra_MultiVector& Y) const{return A_->Multiply(Trans,X,Y);}
156
158
171 int ApplyInverse(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
172
174 double Condest(const Ifpack_CondestType CT = Ifpack_Cheap,
175 const int MaxIters = 1550,
176 const double Tol = 1e-9,
177 Epetra_RowMatrix* Matrix_in = 0);
178
180 double Condest() const
181 {
182 return(Condest_);
183 }
184
185 // @}
186 // @{ Query methods
187
189 const char* Label() const {return(Label_);}
190
192 int SetLabel(const char* Label_in)
193 {
194 strcpy(Label_,Label_in);
195 return(0);
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_IHSS(const Ifpack_IHSS& RHS) :
284 Time_(RHS.Comm())
285 {}
286
288 Ifpack_IHSS& operator=(const Ifpack_IHSS& /* 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
310#ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
312 int NumGlobalRows() const {return(A_->NumGlobalRows());};
313
315 int NumGlobalCols() const {return(A_->NumGlobalCols());};
316#endif
317 long long NumGlobalRows64() const {return(A_->NumGlobalRows64());};
318 long long NumGlobalCols64() const {return(A_->NumGlobalCols64());};
319
321 int NumMyRows() const {return(A_->NumMyRows());};
322
324 int NumMyCols() const {return(A_->NumMyCols());};
325
327 int PowerMethod(Epetra_Operator * Op,const int MaximumIterations, double& lambda_max);
328
330 /* Epetra_RowMatrix& Matrix()
331 {
332 return(*A_);
333 }*/
334
335 // @}
336 // @{ Internal data
337
339 Teuchos::RefCountPtr<Epetra_CrsMatrix> A_;
340 Teuchos::RefCountPtr<Epetra_RowMatrix> Aherm_;
341 Teuchos::RefCountPtr<Epetra_RowMatrix> Askew_;
342 Teuchos::RefCountPtr<Ifpack_Preconditioner> Pherm_;
343 Teuchos::RefCountPtr<Ifpack_Preconditioner> Pskew_;
344
345 Teuchos::ParameterList List_;
346
347 bool UseTranspose_;
348 double Condest_;
349
350
352 bool IsInitialized_;
354 bool IsComputed_;
356 char Label_[160];
358 int NumInitialize_;
360 int NumCompute_;
361
363 int EigMaxIters_;
365 double EigRatio_;
367 double LambdaMax_;
369 double Alpha_;
371 int NumSweeps_;
372
373
374
376 mutable int NumApplyInverse_;
378 double InitializeTime_;
380 double ComputeTime_;
382 mutable double ApplyInverseTime_;
384 double ComputeFlops_;
386 mutable double ApplyInverseFlops_;
388 mutable Epetra_Time Time_;
389
390};
391#else
392
393#ifdef _MSC_VER
394#pragma message("No EpetraEXT")
395#else
396#warning "No EpetraEXT"
397#endif
398
399#endif
400#endif /* IFPACK_IHSS_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.