Ifpack Package Browser (Single Doxygen Collection)  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Ifpack_Amesos.h
Go to the documentation of this file.
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 
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_;
382 
384  std::string Label_;
386  bool IsEmpty_;
393 
399  mutable int NumApplyInverse_;
400 
404  double ComputeTime_;
406  mutable double ApplyInverseTime_;
408  Teuchos::RefCountPtr<Epetra_Time> Time_;
409 
414 
416  double Condest_;
417 };
418 
419 #endif // IFPACK_AMESOS_H
virtual const Epetra_Map & OperatorRangeMap() const
Returns the Epetra_Map object associated with the range of this operator.
void SetComputeFlops(const double ComputeFlops_in)
Sets ComputeFlops_.
void SetComputeTime(const double ComputeTime_in)
Sets ComputeTime_.
void SetNumInitialize(const int NumInitialize_in)
Sets NumInitialize_.
virtual double ComputeTime() const
Returns the total time spent in Compute().
virtual int NumInitialize() const
Returns the number of calls to Initialize().
double Condest_
Contains the estimated condition number.
virtual double ApplyInverseTime() const
Returns the total time spent in ApplyInverse().
virtual int SetParameters(Teuchos::ParameterList &List)
Sets all the parameters for the preconditioner.
virtual double ComputeFlops() const
Returns the total number of flops to computate the preconditioner.
bool UseTranspose_
If true, the preconditioner solves for the transpose of the matrix.
double ComputeTime_
Contains the time for all successful calls to Compute().
virtual int NumCompute() const
Returns the number of calls to Compute().
int NumApplyInverse_
Contains the number of successful call to ApplyInverse().
std::string Label_
Contains the label of this object.
int NumInitialize_
Contains the number of successful calls to Initialize().
Ifpack_Amesos(Epetra_RowMatrix *Matrix)
Constructor.
virtual double ApplyInverseFlops() const
Returns the total number of flops to apply the preconditioner.
Teuchos::ParameterList List_
Contains a copy of the input parameter list.
virtual int Apply(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Applies the matrix to an Epetra_MultiVector.
void SetIsInitialized(const bool IsInitialized_in)
Sets IsInitialized_.
virtual const Epetra_RowMatrix & Matrix() const
Returns a const reference to the internally stored matrix.
void SetList(const Teuchos::ParameterList &List_in)
Set List_.
Teuchos::RefCountPtr< Amesos_BaseSolver > Solver_
Amesos solver, use to apply the inverse of the local matrix.
double InitializeTime_
Contains the time for all successful calls to Initialize().
virtual double InitializeFlops() const
Returns the number of flops in the initialization phase.
virtual bool IsComputed() const
Returns true if the preconditioner has been successfully computed.
virtual const Teuchos::ParameterList & List() const
Teuchos::RefCountPtr< const Epetra_RowMatrix > Matrix_
Pointers to the matrix to be preconditioned.
Ifpack_CondestType
Ifpack_CondestType: enum to define the type of condition number estimate.
Ifpack_Amesos: a class to use Amesos&#39; factorizations as preconditioners.
Definition: Ifpack_Amesos.h:81
virtual int Compute()
Computes the preconditioners.
double ComputeFlops_
Contains the number of flops for Compute().
void SetApplyInverseTime(const double ApplyInverseTime_in)
Sets ApplyInverseTime_.
virtual int Initialize()
Initializes the preconditioners.
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 const Epetra_Map & OperatorDomainMap() const
Returns the Epetra_Map object associated with the domain of this operator.
Ifpack_Preconditioner: basic class for preconditioning in Ifpack.
virtual const char * Label() const
Returns a character string describing the operator.
virtual double Condest() const
Returns the estimated condition number, never computes it.
Teuchos::RefCountPtr< Epetra_LinearProblem > Problem_
Linear problem required by Solver_.
virtual int ApplyInverse(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Applies the preconditioner to X, returns the result in Y.
virtual double InitializeTime() const
Returns the total time spent in Initialize().
virtual int NumApplyInverse() const
Returns the number of calls to ApplyInverse().
virtual bool UseTranspose() const
Returns the current UseTranspose setting.
bool IsComputed_
If true, the preconditioner has been successfully computed.
void SetNumApplyInverse(const int NumApplyInverse_in)
Sets NumApplyInverse_.
bool IsInitialized_
If true, the preconditioner has been successfully initialized.
void SetNumCompute(const int NumCompute_in)
Sets NumCompute_.
virtual bool HasNormInf() const
Returns true if the this object can provide an approximate Inf-norm, false otherwise.
void SetLabel(const char *Label_in)
Sets the label.
virtual ~Ifpack_Amesos()
Destructor.
Definition: Ifpack_Amesos.h:98
cheap estimate
int NumCompute_
Contains the number of successful call to Compute().
Ifpack_Amesos & operator=(const Ifpack_Amesos &rhs)
Operator=.
virtual bool IsInitialized() const
Returns true is the preconditioner has been successfully initialized.
double ApplyInverseTime_
Contains the time for all successful calls to ApplyInverse().
bool IsEmpty_
If true, the linear system on this processor is empty, thus the preconditioner is null operation...
virtual double NormInf() const
Returns the infinity norm of the global matrix (not implemented)
void SetInitializeTime(const double InitializeTime_in)
Sets InitializeTime_.
double ApplyInverseFlops_
Contain sthe number of flops for ApplyInverse().
virtual const Epetra_Comm & Comm() const
Returns a pointer to the Epetra_Comm communicator associated with this operator.
virtual std::ostream & Print(std::ostream &os) const
Prints on ostream basic information about this object.
Teuchos::RefCountPtr< Epetra_Time > Time_
Time object.
void SetApplyInverseFlops(const double ApplyInverseFlops_in)
Sets ComputeFlops_.