43 #ifndef IFPACK2_DIAGONAL_DECL_HPP 44 #define IFPACK2_DIAGONAL_DECL_HPP 46 #include "Ifpack2_Preconditioner.hpp" 67 template<
class MatrixType>
68 class Diagonal :
virtual public Ifpack2::Preconditioner<typename MatrixType::scalar_type,typename MatrixType::local_ordinal_type,typename MatrixType::global_ordinal_type,typename MatrixType::node_type> {
71 typedef typename MatrixType::scalar_type Scalar;
72 typedef typename MatrixType::local_ordinal_type LocalOrdinal;
73 typedef typename MatrixType::global_ordinal_type GlobalOrdinal;
74 typedef typename MatrixType::node_type Node;
75 typedef typename Teuchos::ScalarTraits<Scalar>::magnitudeType magnitudeType;
78 Diagonal(
const Teuchos::RCP<const MatrixType>& A);
89 Diagonal(
const Teuchos::RCP<
const Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> >& diag);
106 return(isInitialized_);
131 void apply(
const Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& X,
132 Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& Y,
133 Teuchos::ETransp mode = Teuchos::NO_TRANS,
134 Scalar alpha = Teuchos::ScalarTraits<Scalar>::one(),
135 Scalar beta = Teuchos::ScalarTraits<Scalar>::zero())
const;
138 const Teuchos::RCP<const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> >&
getDomainMap()
const 139 {
return domainMap_; }
142 const Teuchos::RCP<const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> >&
getRangeMap()
const 143 {
return rangeMap_; }
152 void applyMat(
const Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& X,
153 Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& Y,
154 Teuchos::ETransp mode = Teuchos::NO_TRANS)
const;
173 template <
class DomainScalar,
class RangeScalar>
174 void applyTempl(
const Tpetra::MultiVector<DomainScalar,LocalOrdinal,GlobalOrdinal,Node>& X,
175 Tpetra::MultiVector<RangeScalar,LocalOrdinal,GlobalOrdinal,Node>& Y,
176 Teuchos::ETransp mode = Teuchos::NO_TRANS,
177 RangeScalar alpha = Teuchos::ScalarTraits<Scalar>::one(),
178 RangeScalar beta = Teuchos::ScalarTraits<Scalar>::zero())
const;
182 LocalOrdinal MaxIters = 1550,
183 magnitudeType Tol = 1e-9,
184 const Teuchos::Ptr<
const Tpetra::RowMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> > &matrix = Teuchos::null);
196 const Teuchos::RCP<const Teuchos::Comm<int> > &
getComm()
const;
199 Teuchos::RCP<const Tpetra::RowMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> >
getMatrix()
const 235 void describe(Teuchos::FancyOStream &out,
const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default)
const;
242 Teuchos::RCP<const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> > domainMap_;
243 Teuchos::RCP<const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> > rangeMap_;
244 Teuchos::RCP<const MatrixType> matrix_;
245 Teuchos::RCP<const Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> > inversediag_;
246 Teuchos::ArrayRCP<size_t> offsets_;
248 mutable int numInitialize_;
249 mutable int numCompute_;
250 mutable int numApply_;
252 double initializeTime_;
256 magnitudeType condEst_;
273 template<
class MatrixType,
class VectorType>
274 Teuchos::RCP<Ifpack2::Diagonal<MatrixType> >
std::string description() const
Return a simple one-line description of this object.
Definition: Ifpack2_Diagonal_def.hpp:234
void applyMat(const Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Y, Teuchos::ETransp mode=Teuchos::NO_TRANS) const
Applies the matrix to a Tpetra::MultiVector.
CondestType
Ifpack2::CondestType: enum to define the type of condition number estimate.
Definition: Ifpack2_CondestType.hpp:50
const Teuchos::RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > & getDomainMap() const
Returns the Tpetra::Map object associated with the domain of this operator.
Definition: Ifpack2_Diagonal_decl.hpp:138
const Teuchos::RCP< const Teuchos::Comm< int > > & getComm() const
Returns the Tpetra::BlockMap object associated with the range of this matrix operator.
Teuchos::RCP< Ifpack2::Diagonal< MatrixType > > createDiagonalPreconditioner(const Teuchos::RCP< const VectorType > &invdiag)
Definition: Ifpack2_Diagonal_decl.hpp:275
A class for diagonal preconditioning.
Definition: Ifpack2_Diagonal_decl.hpp:68
bool isInitialized() const
Returns true if the preconditioner has been successfully initialized.
Definition: Ifpack2_Diagonal_decl.hpp:105
magnitudeType computeCondEst(CondestType CT=Cheap, LocalOrdinal MaxIters=1550, magnitudeType Tol=1e-9, const Teuchos::Ptr< const Tpetra::RowMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &matrix=Teuchos::null)
Computes the estimated condition number and returns the value.
Definition: Ifpack2_Diagonal_def.hpp:185
double getApplyFlops() const
Returns the number of flops for the application of the preconditioner.
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
Applies the preconditioner to X, returns the result in Y.
Definition: Ifpack2_Diagonal_def.hpp:129
const Teuchos::RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > & getRangeMap() const
Returns the Tpetra::Map object associated with the range of this operator.
Definition: Ifpack2_Diagonal_decl.hpp:142
double getComputeFlops() const
Returns the number of flops in the computation phase.
void compute()
compute the preconditioner
Definition: Ifpack2_Diagonal_def.hpp:106
Base class for all Ifpack2 preconditioners.
Definition: Ifpack2_Preconditioner.hpp:130
void applyTempl(const Tpetra::MultiVector< DomainScalar, LocalOrdinal, GlobalOrdinal, Node > &X, Tpetra::MultiVector< RangeScalar, LocalOrdinal, GlobalOrdinal, Node > &Y, Teuchos::ETransp mode=Teuchos::NO_TRANS, RangeScalar alpha=Teuchos::ScalarTraits< Scalar >::one(), RangeScalar beta=Teuchos::ScalarTraits< Scalar >::zero()) const
Applies the preconditioner to X, returns the result in Y.
Definition: Ifpack2_Diagonal_def.hpp:147
virtual ~Diagonal()
Destructor.
Definition: Ifpack2_Diagonal_def.hpp:82
double getComputeTime() const
Returns the time spent in compute().
Definition: Ifpack2_Diagonal_def.hpp:224
int getNumCompute() const
Returns the number of calls to compute().
Definition: Ifpack2_Diagonal_def.hpp:209
magnitudeType getCondEst() const
Returns the computed estimated condition number, or -1.0 if no computed.
Definition: Ifpack2_Diagonal_decl.hpp:192
double getInitializeTime() const
Returns the time spent in initialize().
Definition: Ifpack2_Diagonal_def.hpp:219
void setParameters(const Teuchos::ParameterList ¶ms)
Sets parameters on this object.
Definition: Ifpack2_Diagonal_def.hpp:87
Diagonal(const Teuchos::RCP< const MatrixType > &A)
Constructor to create a Diagonal preconditioner using a Tpetra::CrsMatrix.
Definition: Ifpack2_Diagonal_def.hpp:52
int getNumInitialize() const
Returns the number of calls to initialize().
Definition: Ifpack2_Diagonal_def.hpp:204
double getApplyTime() const
Returns the time spent in apply().
Definition: Ifpack2_Diagonal_def.hpp:229
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Print the object with some verbosity level to an FancyOStream object.
Definition: Ifpack2_Diagonal_def.hpp:240
Teuchos::RCP< const Tpetra::RowMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getMatrix() const
Returns a reference to the matrix to be preconditioned.
Definition: Ifpack2_Diagonal_decl.hpp:199
Ifpack2::Container: a pure virtual class for creating and solving local linear problems.
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:67
void initialize()
Initialize.
Definition: Ifpack2_Diagonal_def.hpp:92
cheap estimate
Definition: Ifpack2_CondestType.hpp:51
int getNumApply() const
Returns the number of calls to apply().
Definition: Ifpack2_Diagonal_def.hpp:214
bool isComputed() const
Return true if compute() has been called.
Definition: Ifpack2_Diagonal_decl.hpp:113