Ifpack2 Templated Preconditioning Package  Version 1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Ifpack2_Preconditioner.hpp
1 /*@HEADER
2 // ***********************************************************************
3 //
4 // Ifpack2: Tempated Object-Oriented Algebraic Preconditioner Package
5 // Copyright (2009) 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 IFPACK2_PRECONDITIONER_HPP
44 #define IFPACK2_PRECONDITIONER_HPP
45 
46 #include "Ifpack2_ConfigDefs.hpp"
47 #include "Ifpack2_CondestType.hpp"
48 #include "Kokkos_DefaultNode.hpp"
49 #include "Tpetra_Operator.hpp"
50 #include "Tpetra_RowMatrix.hpp"
52 #include "Teuchos_ScalarTraits.hpp"
53 #include <iostream>
54 
55 namespace Ifpack2 {
56 
58 
129 template<class Scalar, class LocalOrdinal = int, class GlobalOrdinal = LocalOrdinal, class Node = Kokkos::DefaultNode::DefaultNodeType>
130 class Preconditioner : virtual public Tpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal,Node> {
131 
132  public:
133  typedef typename Teuchos::ScalarTraits<Scalar>::magnitudeType magnitudeType;
134 
136  virtual ~Preconditioner(){}
137 
140 
143 
146 
148  virtual void apply(const Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> &X,
149  Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> &Y,
151  Scalar alpha = Teuchos::ScalarTraits<Scalar>::one(),
152  Scalar beta = Teuchos::ScalarTraits<Scalar>::zero()) const = 0;
153 
155 
157  virtual void setParameters(const Teuchos::ParameterList& List) = 0;
158 
160  virtual void initialize() = 0;
161 
163  virtual bool isInitialized() const = 0;
164 
166  virtual void compute() = 0;
167 
169  virtual bool isComputed() const = 0;
170 
172  virtual magnitudeType computeCondEst(CondestType CT = Ifpack2::Cheap,
173  LocalOrdinal MaxIters = 1550,
174  magnitudeType Tol = 1e-9,
175  const Teuchos::Ptr<const Tpetra::RowMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> > &Matrix = Teuchos::null) = 0;
176 
178  virtual magnitudeType getCondEst() const = 0;
179 
182 
184  virtual int getNumInitialize() const = 0;
185 
187  virtual int getNumCompute() const = 0;
188 
190  virtual int getNumApply() const = 0;
191 
193  virtual double getInitializeTime() const = 0;
194 
196  virtual double getComputeTime() const = 0;
197 
199  virtual double getApplyTime() const = 0;
200 
201 };//class Preconditioner
202 
203 }//namespace Ifpack2
204 
205 #endif // IFPACK2_PRECONDITIONER_HPP
CondestType
Ifpack2::CondestType: enum to define the type of condition number estimate.
Definition: Ifpack2_CondestType.hpp:50
virtual int getNumApply() const =0
Returns the number of calls to apply().
virtual Teuchos::RCP< const Tpetra::RowMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getMatrix() const =0
Returns a pointer to the input matrix.
virtual magnitudeType getCondEst() const =0
Returns the computed condition number estimate, or -1.0 if not computed.
virtual void compute()=0
Computes all (coefficient) data necessary to apply the preconditioner.
virtual const Teuchos::RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > & getDomainMap() const =0
Returns the Map associated with the domain of this operator, which must be compatible with X...
virtual int getNumCompute() const =0
Returns the number of calls to compute().
Base class for all Ifpack2 preconditioners.
Definition: Ifpack2_Preconditioner.hpp:130
virtual double getInitializeTime() const =0
Returns the time spent in initialize().
virtual void initialize()=0
Computes all (graph-related) data necessary to initialize the preconditioner.
virtual bool isComputed() const =0
Returns true if the preconditioner has been successfully computed, false otherwise.
virtual int getNumInitialize() const =0
Returns the number of calls to initialize().
virtual void setParameters(const Teuchos::ParameterList &List)=0
Sets all parameters for the preconditioner.
virtual double getComputeTime() const =0
Returns the time spent in compute().
virtual magnitudeType computeCondEst(CondestType CT=Ifpack2::Cheap, LocalOrdinal MaxIters=1550, magnitudeType Tol=1e-9, const Teuchos::Ptr< const Tpetra::RowMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &Matrix=Teuchos::null)=0
Computes the condition number estimate and returns its value.
virtual void apply(const Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Y, Teuchos::ETransp mode=Teuchos::NO_TRANS, Scalar alpha=Teuchos::ScalarTraits< Scalar >::one(), Scalar beta=Teuchos::ScalarTraits< Scalar >::zero()) const =0
Applies the effect of the preconditioner.
virtual ~Preconditioner()
Destructor.
Definition: Ifpack2_Preconditioner.hpp:136
cheap estimate
Definition: Ifpack2_CondestType.hpp:51
virtual bool isInitialized() const =0
Returns true if the preconditioner has been successfully initialized, false otherwise.
virtual double getApplyTime() const =0
Returns the time spent in apply().
virtual const Teuchos::RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > & getRangeMap() const =0
Returns the Map associated with the range of this operator, which must be compatible with Y...