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 
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 
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 
293 protected:
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 
370 private:
371 
373  Teuchos::RefCountPtr<const Epetra_RowMatrix> Matrix_;
374 
376  Teuchos::RefCountPtr<Epetra_LinearProblem> Problem_;
378  Teuchos::RefCountPtr<Amesos_BaseSolver> Solver_;
381 
383  std::string Label_;
385  bool IsEmpty_;
392 
398  mutable int NumApplyInverse_;
399 
403  double ComputeTime_;
405  mutable double ApplyInverseTime_;
407  Teuchos::RefCountPtr<Epetra_Time> Time_;
408 
413 
415  double Condest_;
416 };
417 
418 #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_.