IFPACK Development
Loading...
Searching...
No Matches
Ifpack_Amesos.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_AMESOS_H
44#define IFPACK_AMESOS_H
45
46#include "Ifpack_ConfigDefs.h"
47#include "Ifpack_Preconditioner.h"
48#include "Epetra_Operator.h"
49#include "Teuchos_ParameterList.hpp"
50#include "Teuchos_RefCountPtr.hpp"
51
52class Epetra_Map;
53class Epetra_Time;
54class Epetra_Comm;
55class Amesos_BaseSolver;
58
60
82
83public:
84
86
89
91 Ifpack_Amesos(const Ifpack_Amesos& rhs);
92
95
97
98 virtual ~Ifpack_Amesos() {};
99
101
103
105
114 virtual int SetUseTranspose(bool UseTranspose_in);
116
118
120
128 virtual int Apply(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
129
131
142 virtual int ApplyInverse(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
143
145 virtual double NormInf() const;
147
149
151 virtual const char * Label() const;
152
154 virtual bool UseTranspose() const;
155
157 virtual bool HasNormInf() const;
158
160 virtual const Epetra_Comm & Comm() const;
161
163 virtual const Epetra_Map & OperatorDomainMap() const;
164
166 virtual const Epetra_Map & OperatorRangeMap() const;
167
169
171
173 virtual bool IsInitialized() const
174 {
175 return(IsInitialized_);
176 }
177
179
182 virtual int Initialize();
183
185 virtual bool IsComputed() const
186 {
187 return(IsComputed_);
188 }
189
191
194 virtual int Compute();
195
197
204 virtual int SetParameters(Teuchos::ParameterList& List);
205
207
209
211 virtual const Epetra_RowMatrix& Matrix() const
212 {
213 return(*Matrix_);
214 }
215
217 virtual double Condest(const Ifpack_CondestType CT = Ifpack_Cheap,
218 const int MaxIters = 1550,
219 const double Tol = 1e-9,
220 Epetra_RowMatrix* Matrix_in= 0);
221
223 virtual double Condest() const
224 {
225 return(Condest_);
226 }
227
229 virtual int NumInitialize() const
230 {
231 return(NumInitialize_);
232 }
233
235 virtual int NumCompute() const
236 {
237 return(NumCompute_);
238 }
239
241 virtual int NumApplyInverse() const
242 {
243 return(NumApplyInverse_);
244 }
245
247 virtual double InitializeTime() const
248 {
249 return(InitializeTime_);
250 }
251
253 virtual double ComputeTime() const
254 {
255 return(ComputeTime_);
256 }
257
259 virtual double ApplyInverseTime() const
260 {
261 return(ApplyInverseTime_);
262 }
263
265 virtual double InitializeFlops() const
266 {
267 return(0.0);
268 }
269
271 virtual double ComputeFlops() const
272 {
273 return(ComputeFlops_);
274 }
275
277 virtual double ApplyInverseFlops() const
278 {
279 return(ApplyInverseFlops_);
280 }
281
282 // Returns a constant reference to the internally stored
283 virtual const Teuchos::ParameterList& List() const
284 {
285 return(List_);
286 }
287
289 virtual std::ostream& Print(std::ostream& os) const;
290
292
293protected:
294
296
298 inline void SetLabel(const char* Label_in)
299 {
300 Label_ = Label_in;
301 }
302
304 inline void SetIsInitialized(const bool IsInitialized_in)
305 {
306 IsInitialized_ = IsInitialized_in;
307 }
308
310 inline void SetIsComputed(const int IsComputed_in)
311 {
312 IsComputed_ = IsComputed_in;
313 }
314
316 inline void SetNumInitialize(const int NumInitialize_in)
317 {
318 NumInitialize_ = NumInitialize_in;
319 }
320
322 inline void SetNumCompute(const int NumCompute_in)
323 {
324 NumCompute_ = NumCompute_in;
325 }
326
328 inline void SetNumApplyInverse(const int NumApplyInverse_in)
329 {
330 NumApplyInverse_ = NumApplyInverse_in;
331 }
332
334 inline void SetInitializeTime(const double InitializeTime_in)
335 {
336 InitializeTime_ = InitializeTime_in;
337 }
338
340 inline void SetComputeTime(const double ComputeTime_in)
341 {
342 ComputeTime_ = ComputeTime_in;
343 }
344
346 inline void SetApplyInverseTime(const double ApplyInverseTime_in)
347 {
348 ApplyInverseTime_ = ApplyInverseTime_in;
349 }
350
352 inline void SetComputeFlops(const double ComputeFlops_in)
353 {
354 ComputeFlops_ = ComputeFlops_in;
355 }
356
358 inline void SetApplyInverseFlops(const double ApplyInverseFlops_in)
359 {
360 ApplyInverseFlops_ = ApplyInverseFlops_in;
361 }
362
364 inline void SetList(const Teuchos::ParameterList& List_in)
365 {
366 List_ = List_in;
367 }
369
370private:
371
373 Teuchos::RefCountPtr<const Epetra_RowMatrix> Matrix_;
374
376 Teuchos::RefCountPtr<Epetra_LinearProblem> Problem_;
378 Teuchos::RefCountPtr<Amesos_BaseSolver> Solver_;
380 Teuchos::ParameterList List_;
381
383 std::string Label_;
385 bool IsEmpty_;
387 bool IsInitialized_;
389 bool IsComputed_;
391 bool UseTranspose_;
392
394 int NumInitialize_;
396 int NumCompute_;
398 mutable int NumApplyInverse_;
399
401 double InitializeTime_;
403 double ComputeTime_;
405 mutable double ApplyInverseTime_;
407 Teuchos::RefCountPtr<Epetra_Time> Time_;
408
410 double ComputeFlops_;
412 double ApplyInverseFlops_;
413
415 double Condest_;
416};
417
418#endif // IFPACK_AMESOS_H
Ifpack_Amesos: a class to use Amesos' factorizations as preconditioners.
void SetIsInitialized(const bool IsInitialized_in)
Sets IsInitialized_.
Ifpack_Amesos & operator=(const Ifpack_Amesos &rhs)
Operator=.
virtual bool HasNormInf() const
Returns true if the this object can provide an approximate Inf-norm, false otherwise.
virtual int Apply(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Applies the matrix to an Epetra_MultiVector.
virtual double ComputeFlops() const
Returns the total number of flops to computate the preconditioner.
virtual int NumApplyInverse() const
Returns the number of calls to ApplyInverse().
void SetNumApplyInverse(const int NumApplyInverse_in)
Sets NumApplyInverse_.
virtual bool UseTranspose() const
Returns the current UseTranspose setting.
void SetList(const Teuchos::ParameterList &List_in)
Set List_.
void SetLabel(const char *Label_in)
Sets the label.
virtual double InitializeTime() const
Returns the total time spent in Initialize().
virtual const char * Label() const
Returns a character string describing the operator.
virtual double InitializeFlops() const
Returns the number of flops in the initialization phase.
virtual int Initialize()
Initializes the preconditioners.
void SetApplyInverseFlops(const double ApplyInverseFlops_in)
Sets ComputeFlops_.
virtual int Compute()
Computes the preconditioners.
virtual double ApplyInverseFlops() const
Returns the total number of flops to apply the preconditioner.
virtual int NumCompute() const
Returns the number of calls to Compute().
void SetComputeFlops(const double ComputeFlops_in)
Sets ComputeFlops_.
void SetIsComputed(const int IsComputed_in)
Sets IsComputed_.
virtual int SetUseTranspose(bool UseTranspose_in)
If set true, transpose of this operator will be applied (not implemented).
virtual double ApplyInverseTime() const
Returns the total time spent in ApplyInverse().
void SetApplyInverseTime(const double ApplyInverseTime_in)
Sets ApplyInverseTime_.
virtual int ApplyInverse(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Applies the preconditioner to X, returns the result in Y.
virtual int SetParameters(Teuchos::ParameterList &List)
Sets all the parameters for the preconditioner.
virtual bool IsComputed() const
Returns true if the preconditioner has been successfully computed.
virtual int NumInitialize() const
Returns the number of calls to Initialize().
virtual double ComputeTime() const
Returns the total time spent in Compute().
virtual const Epetra_Map & OperatorRangeMap() const
Returns the Epetra_Map object associated with the range of this operator.
virtual ~Ifpack_Amesos()
Destructor.
virtual double Condest() const
Returns the estimated condition number, never computes it.
Ifpack_Amesos(Epetra_RowMatrix *Matrix)
Constructor.
virtual std::ostream & Print(std::ostream &os) const
Prints on ostream basic information about this object.
void SetNumCompute(const int NumCompute_in)
Sets NumCompute_.
virtual const Epetra_Map & OperatorDomainMap() const
Returns the Epetra_Map object associated with the domain of this operator.
virtual const Epetra_RowMatrix & Matrix() const
Returns a const reference to the internally stored matrix.
virtual double NormInf() const
Returns the infinity norm of the global matrix (not implemented)
virtual const Epetra_Comm & Comm() const
Returns a pointer to the Epetra_Comm communicator associated with this operator.
void SetComputeTime(const double ComputeTime_in)
Sets ComputeTime_.
void SetInitializeTime(const double InitializeTime_in)
Sets InitializeTime_.
virtual bool IsInitialized() const
Returns true is the preconditioner has been successfully initialized.
void SetNumInitialize(const int NumInitialize_in)
Sets NumInitialize_.
Ifpack_Preconditioner: basic class for preconditioning in Ifpack.