IFPACK  Development
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 
52 class Epetra_Map;
53 class Epetra_Time;
54 class Epetra_Comm;
55 class Amesos_BaseSolver;
57 class Epetra_RowMatrix;
58 
60 
82 
83 public:
84 
86 
89 
91  Ifpack_Amesos(const Ifpack_Amesos& rhs);
92 
95 
97  virtual ~Ifpack_Amesos() {};
99 
101 
103 
105 
115  virtual int SetUseTranspose(bool UseTranspose_in);
117 
119 
121 
129  virtual int Apply(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
130 
132 
143  virtual int ApplyInverse(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
144 
146  virtual double NormInf() const;
148 
150 
152  virtual const char * Label() const;
153 
155  virtual bool UseTranspose() const;
156 
158  virtual bool HasNormInf() const;
159 
161  virtual const Epetra_Comm & Comm() const;
162 
164  virtual const Epetra_Map & OperatorDomainMap() const;
165 
167  virtual const Epetra_Map & OperatorRangeMap() const;
168 
170 
172 
174  virtual bool IsInitialized() const
175  {
176  return(IsInitialized_);
177  }
178 
180 
183  virtual int Initialize();
184 
186  virtual bool IsComputed() const
187  {
188  return(IsComputed_);
189  }
190 
192 
195  virtual int Compute();
196 
198 
205  virtual int SetParameters(Teuchos::ParameterList& List);
206 
208 
210 
212  virtual const Epetra_RowMatrix& Matrix() const
213  {
214  return(*Matrix_);
215  }
216 
218  virtual double Condest(const Ifpack_CondestType CT = Ifpack_Cheap,
219  const int MaxIters = 1550,
220  const double Tol = 1e-9,
221  Epetra_RowMatrix* Matrix_in= 0);
222 
224  virtual double Condest() const
225  {
226  return(Condest_);
227  }
228 
230  virtual int NumInitialize() const
231  {
232  return(NumInitialize_);
233  }
234 
236  virtual int NumCompute() const
237  {
238  return(NumCompute_);
239  }
240 
242  virtual int NumApplyInverse() const
243  {
244  return(NumApplyInverse_);
245  }
246 
248  virtual double InitializeTime() const
249  {
250  return(InitializeTime_);
251  }
252 
254  virtual double ComputeTime() const
255  {
256  return(ComputeTime_);
257  }
258 
260  virtual double ApplyInverseTime() const
261  {
262  return(ApplyInverseTime_);
263  }
264 
266  virtual double InitializeFlops() const
267  {
268  return(0.0);
269  }
270 
272  virtual double ComputeFlops() const
273  {
274  return(ComputeFlops_);
275  }
276 
278  virtual double ApplyInverseFlops() const
279  {
280  return(ApplyInverseFlops_);
281  }
282 
283  // Returns a constant reference to the internally stored
284  virtual const Teuchos::ParameterList& List() const
285  {
286  return(List_);
287  }
288 
290  virtual std::ostream& Print(std::ostream& os) const;
291 
293 
294 protected:
295 
297 
299  inline void SetLabel(const char* Label_in)
300  {
301  Label_ = Label_in;
302  }
303 
305  inline void SetIsInitialized(const bool IsInitialized_in)
306  {
307  IsInitialized_ = IsInitialized_in;
308  }
309 
311  inline void SetIsComputed(const int IsComputed_in)
312  {
313  IsComputed_ = IsComputed_in;
314  }
315 
317  inline void SetNumInitialize(const int NumInitialize_in)
318  {
319  NumInitialize_ = NumInitialize_in;
320  }
321 
323  inline void SetNumCompute(const int NumCompute_in)
324  {
325  NumCompute_ = NumCompute_in;
326  }
327 
329  inline void SetNumApplyInverse(const int NumApplyInverse_in)
330  {
331  NumApplyInverse_ = NumApplyInverse_in;
332  }
333 
335  inline void SetInitializeTime(const double InitializeTime_in)
336  {
337  InitializeTime_ = InitializeTime_in;
338  }
339 
341  inline void SetComputeTime(const double ComputeTime_in)
342  {
343  ComputeTime_ = ComputeTime_in;
344  }
345 
347  inline void SetApplyInverseTime(const double ApplyInverseTime_in)
348  {
349  ApplyInverseTime_ = ApplyInverseTime_in;
350  }
351 
353  inline void SetComputeFlops(const double ComputeFlops_in)
354  {
355  ComputeFlops_ = ComputeFlops_in;
356  }
357 
359  inline void SetApplyInverseFlops(const double ApplyInverseFlops_in)
360  {
361  ApplyInverseFlops_ = ApplyInverseFlops_in;
362  }
363 
365  inline void SetList(const Teuchos::ParameterList& List_in)
366  {
367  List_ = List_in;
368  }
370 
371 private:
372 
374  Teuchos::RefCountPtr<const Epetra_RowMatrix> Matrix_;
375 
377  Teuchos::RefCountPtr<Epetra_LinearProblem> Problem_;
379  Teuchos::RefCountPtr<Amesos_BaseSolver> Solver_;
381  Teuchos::ParameterList List_;
382 
384  std::string Label_;
386  bool IsEmpty_;
388  bool IsInitialized_;
390  bool IsComputed_;
392  bool UseTranspose_;
393 
395  int NumInitialize_;
397  int NumCompute_;
399  mutable int NumApplyInverse_;
400 
402  double InitializeTime_;
404  double ComputeTime_;
406  mutable double ApplyInverseTime_;
408  Teuchos::RefCountPtr<Epetra_Time> Time_;
409 
411  double ComputeFlops_;
413  double ApplyInverseFlops_;
414 
416  double Condest_;
417 };
418 
419 #endif // IFPACK_AMESOS_H
Ifpack_Amesos::Apply
virtual int Apply(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Applies the matrix to an Epetra_MultiVector.
Definition: Ifpack_Amesos.cpp:252
Ifpack_Amesos::OperatorDomainMap
virtual const Epetra_Map & OperatorDomainMap() const
Returns the Epetra_Map object associated with the domain of this operator.
Definition: Ifpack_Amesos.cpp:325
Ifpack_Amesos::SetList
void SetList(const Teuchos::ParameterList &List_in)
Set List_.
Definition: Ifpack_Amesos.h:365
Ifpack_Amesos::SetLabel
void SetLabel(const char *Label_in)
Sets the label.
Definition: Ifpack_Amesos.h:299
Ifpack_Amesos
Ifpack_Amesos: a class to use Amesos' factorizations as preconditioners.
Definition: Ifpack_Amesos.h:81
Ifpack_Amesos::Comm
virtual const Epetra_Comm & Comm() const
Returns a pointer to the Epetra_Comm communicator associated with this operator.
Definition: Ifpack_Amesos.cpp:319
Ifpack_Amesos::NumInitialize
virtual int NumInitialize() const
Returns the number of calls to Initialize().
Definition: Ifpack_Amesos.h:230
Ifpack_Amesos::IsComputed
virtual bool IsComputed() const
Returns true if the preconditioner has been successfully computed.
Definition: Ifpack_Amesos.h:186
Ifpack_Amesos::SetApplyInverseTime
void SetApplyInverseTime(const double ApplyInverseTime_in)
Sets ApplyInverseTime_.
Definition: Ifpack_Amesos.h:347
Ifpack_Amesos::NumApplyInverse
virtual int NumApplyInverse() const
Returns the number of calls to ApplyInverse().
Definition: Ifpack_Amesos.h:242
Ifpack_Amesos::Matrix
virtual const Epetra_RowMatrix & Matrix() const
Returns a const reference to the internally stored matrix.
Definition: Ifpack_Amesos.h:212
Ifpack_Amesos::SetIsComputed
void SetIsComputed(const int IsComputed_in)
Sets IsComputed_.
Definition: Ifpack_Amesos.h:311
Ifpack_Amesos::NormInf
virtual double NormInf() const
Returns the infinity norm of the global matrix (not implemented)
Definition: Ifpack_Amesos.cpp:295
Ifpack_Amesos::SetNumInitialize
void SetNumInitialize(const int NumInitialize_in)
Sets NumInitialize_.
Definition: Ifpack_Amesos.h:317
Ifpack_Amesos::Initialize
virtual int Initialize()
Initializes the preconditioners.
Definition: Ifpack_Amesos.cpp:126
Ifpack_Amesos::SetComputeTime
void SetComputeTime(const double ComputeTime_in)
Sets ComputeTime_.
Definition: Ifpack_Amesos.h:341
Ifpack_Amesos::SetNumCompute
void SetNumCompute(const int NumCompute_in)
Sets NumCompute_.
Definition: Ifpack_Amesos.h:323
Ifpack_Amesos::SetParameters
virtual int SetParameters(Teuchos::ParameterList &List)
Sets all the parameters for the preconditioner.
Definition: Ifpack_Amesos.cpp:117
Ifpack_Amesos::Print
virtual std::ostream & Print(std::ostream &os) const
Prints on ostream basic information about this object.
Definition: Ifpack_Amesos.cpp:352
Epetra_Comm
Ifpack_Amesos::SetComputeFlops
void SetComputeFlops(const double ComputeFlops_in)
Sets ComputeFlops_.
Definition: Ifpack_Amesos.h:353
Ifpack_Amesos::Label
virtual const char * Label() const
Returns a character string describing the operator.
Definition: Ifpack_Amesos.cpp:301
Epetra_RowMatrix
Epetra_LinearProblem
Ifpack_Amesos::Condest
virtual double Condest() const
Returns the estimated condition number, never computes it.
Definition: Ifpack_Amesos.h:224
Ifpack_Amesos::SetInitializeTime
void SetInitializeTime(const double InitializeTime_in)
Sets InitializeTime_.
Definition: Ifpack_Amesos.h:335
Ifpack_Amesos::HasNormInf
virtual bool HasNormInf() const
Returns true if the this object can provide an approximate Inf-norm, false otherwise.
Definition: Ifpack_Amesos.cpp:313
Ifpack_Amesos::IsInitialized
virtual bool IsInitialized() const
Returns true is the preconditioner has been successfully initialized.
Definition: Ifpack_Amesos.h:174
Ifpack_Amesos::InitializeTime
virtual double InitializeTime() const
Returns the total time spent in Initialize().
Definition: Ifpack_Amesos.h:248
Ifpack_Amesos::ApplyInverseTime
virtual double ApplyInverseTime() const
Returns the total time spent in ApplyInverse().
Definition: Ifpack_Amesos.h:260
Epetra_Time
Epetra_MultiVector
Ifpack_Preconditioner
Ifpack_Preconditioner: basic class for preconditioning in Ifpack.
Definition: Ifpack_Preconditioner.h:136
Ifpack_Amesos::Compute
virtual int Compute()
Computes the preconditioners.
Definition: Ifpack_Amesos.cpp:212
Ifpack_Amesos::operator=
Ifpack_Amesos & operator=(const Ifpack_Amesos &rhs)
Operator=.
Ifpack_Amesos::SetUseTranspose
virtual int SetUseTranspose(bool UseTranspose_in)
If set true, transpose of this operator will be applied (not implemented).
Definition: Ifpack_Amesos.cpp:239
Ifpack_Amesos::SetApplyInverseFlops
void SetApplyInverseFlops(const double ApplyInverseFlops_in)
Sets ComputeFlops_.
Definition: Ifpack_Amesos.h:359
Ifpack_Amesos::OperatorRangeMap
virtual const Epetra_Map & OperatorRangeMap() const
Returns the Epetra_Map object associated with the range of this operator.
Definition: Ifpack_Amesos.cpp:331
Ifpack_Amesos::SetIsInitialized
void SetIsInitialized(const bool IsInitialized_in)
Sets IsInitialized_.
Definition: Ifpack_Amesos.h:305
Ifpack_Amesos::UseTranspose
virtual bool UseTranspose() const
Returns the current UseTranspose setting.
Definition: Ifpack_Amesos.cpp:307
Ifpack_Amesos::Ifpack_Amesos
Ifpack_Amesos(Epetra_RowMatrix *Matrix)
Constructor.
Definition: Ifpack_Amesos.cpp:59
Ifpack_Amesos::ComputeTime
virtual double ComputeTime() const
Returns the total time spent in Compute().
Definition: Ifpack_Amesos.h:254
Ifpack_Amesos::SetNumApplyInverse
void SetNumApplyInverse(const int NumApplyInverse_in)
Sets NumApplyInverse_.
Definition: Ifpack_Amesos.h:329
Epetra_Map
Ifpack_Amesos::InitializeFlops
virtual double InitializeFlops() const
Returns the number of flops in the initialization phase.
Definition: Ifpack_Amesos.h:266
Ifpack_Amesos::~Ifpack_Amesos
virtual ~Ifpack_Amesos()
Destructor.
Definition: Ifpack_Amesos.h:98
Ifpack_Amesos::ComputeFlops
virtual double ComputeFlops() const
Returns the total number of flops to computate the preconditioner.
Definition: Ifpack_Amesos.h:272
Ifpack_Amesos::NumCompute
virtual int NumCompute() const
Returns the number of calls to Compute().
Definition: Ifpack_Amesos.h:236
Ifpack_Amesos::ApplyInverseFlops
virtual double ApplyInverseFlops() const
Returns the total number of flops to apply the preconditioner.
Definition: Ifpack_Amesos.h:278
Ifpack_Amesos::ApplyInverse
virtual int ApplyInverse(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Applies the preconditioner to X, returns the result in Y.
Definition: Ifpack_Amesos.cpp:261