Thyra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Thyra_TpetraLinearOp_decl.hpp
1 // @HEADER
2 // *****************************************************************************
3 // Thyra: Interfaces and Support for Abstract Numerical Algorithms
4 //
5 // Copyright 2004 NTESS and the Thyra contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef THYRA_TPETRA_LINEAR_OP_DECL_HPP
11 #define THYRA_TPETRA_LINEAR_OP_DECL_HPP
12 
13 #include "Thyra_LinearOpDefaultBase.hpp"
14 #include "Thyra_TpetraVectorSpace_decl.hpp"
15 #include "Thyra_ScaledLinearOpBase.hpp"
16 #include "Thyra_RowStatLinearOpBase.hpp"
17 #include "Tpetra_Operator.hpp"
18 #include "Teuchos_ConstNonconstObjectContainer.hpp"
19 
20 #if defined(HAVE_THYRA_EPETRA) && defined(HAVE_TPETRA_EPETRA)
21 # define HAVE_THYRA_TPETRA_EPETRA
22 #endif
23 
24 #ifdef HAVE_THYRA_TPETRA_EPETRA
25 # include "Thyra_EpetraLinearOpBase.hpp"
26 # include "Tpetra_EpetraRowMatrix.hpp"
27 #endif
28 
29 
30 namespace Thyra {
31 
32 
39 template <class Scalar, class LocalOrdinal, class GlobalOrdinal=LocalOrdinal,
40  class Node=Tpetra::KokkosClassic::DefaultNode::DefaultNodeType>
42  : virtual public Thyra::LinearOpDefaultBase<Scalar>,
43  virtual public ScaledLinearOpBase<Scalar>,
44  virtual public Thyra::RowStatLinearOpBase<Scalar>
45 #ifdef HAVE_THYRA_TPETRA_EPETRA
46  , virtual public EpetraLinearOpBase
47 #endif
48 {
49 public:
50 
53 
56 
58  void initialize(
59  const RCP<const VectorSpaceBase<Scalar> > &rangeSpace,
60  const RCP<const VectorSpaceBase<Scalar> > &domainSpace,
62  );
63 
65  void constInitialize(
66  const RCP<const VectorSpaceBase<Scalar> > &rangeSpace,
67  const RCP<const VectorSpaceBase<Scalar> > &domainSpace,
69  );
70 
74 
77  getConstTpetraOperator() const;
78 
80 
83 
86 
89 
91 
92 #ifdef HAVE_THYRA_TPETRA_EPETRA
93 
96 
98  void getNonconstEpetraOpView(
99  const Ptr<RCP<Epetra_Operator> > &epetraOp,
100  const Ptr<EOpTransp> &epetraOpTransp,
101  const Ptr<EApplyEpetraOpAs> &epetraOpApplyAs,
102  const Ptr<EAdjointEpetraOp> &epetraOpAdjointSupport
103  );
105  void getEpetraOpView(
106  const Ptr<RCP<const Epetra_Operator> > &epetraOp,
107  const Ptr<EOpTransp> &epetraOpTransp,
108  const Ptr<EApplyEpetraOpAs> &epetraOpApplyAs,
109  const Ptr<EAdjointEpetraOp> &epetraOpAdjointSupport
110  ) const;
111 
113 
114 #endif // HAVE_THYRA_TPETRA_EPETRA
115 
116 protected:
117 
120 
122  bool opSupportedImpl(Thyra::EOpTransp M_trans) const;
123 
125  void applyImpl(
126  const Thyra::EOpTransp M_trans,
127  const Thyra::MultiVectorBase<Scalar> &X_in,
129  const Scalar alpha,
130  const Scalar beta
131  ) const;
132 
134 
137 
139  virtual bool supportsScaleLeftImpl() const;
140 
142  virtual bool supportsScaleRightImpl() const;
143 
145  virtual void scaleLeftImpl(const VectorBase<Scalar> &row_scaling);
146 
148  virtual void scaleRightImpl(const VectorBase<Scalar> &col_scaling);
149 
151 
154 
156  virtual bool rowStatIsSupportedImpl(
157  const RowStatLinearOpBaseUtils::ERowStat rowStat) const;
158 
160  virtual void getRowStatImpl(
161  const RowStatLinearOpBaseUtils::ERowStat rowStat,
162  const Ptr<VectorBase<Scalar> > &rowStatVec) const;
163 
165 
166 private:
167 
169  rangeSpace_;
170 
172  domainSpace_;
173 
175  tpetraOperator_;
176 
177 #ifdef HAVE_THYRA_TPETRA_EPETRA
178  mutable RCP<Epetra_Operator> epetraOp_;
179 #endif
180 
181  template<class TpetraOperator_t>
182  void initializeImpl(
183  const RCP<const VectorSpaceBase<Scalar> > &rangeSpace,
184  const RCP<const VectorSpaceBase<Scalar> > &domainSpace,
185  const RCP<TpetraOperator_t> &tpetraOperator
186  );
187 
188 };
189 
190 
195 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
198  const RCP<const VectorSpaceBase<Scalar> > &rangeSpace,
199  const RCP<const VectorSpaceBase<Scalar> > &domainSpace,
201  )
202 {
205  op->initialize(rangeSpace, domainSpace, tpetraOperator);
206  return op;
207 }
208 
209 
214 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
217  const RCP<const VectorSpaceBase<Scalar> > &rangeSpace,
218  const RCP<const VectorSpaceBase<Scalar> > &domainSpace,
220  )
221 {
224  op->constInitialize(rangeSpace, domainSpace, tpetraOperator);
225  return op;
226 }
227 
228 
229 } // namespace Thyra
230 
231 
232 #endif // THYRA_TPETRA_LINEAR_OP_DECL_HPP
EOpTransp
Enumeration for determining how a linear operator is applied. `*.
void constInitialize(const RCP< const VectorSpaceBase< Scalar > > &rangeSpace, const RCP< const VectorSpaceBase< Scalar > > &domainSpace, const RCP< const Tpetra::Operator< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &tpetraOperator)
Initialize.
Abstract base class for all LinearOpBase objects that can return an Epetra_Operator view of themselve...
Node subclass that provides a good default implementation for the describe() function.
virtual void getRowStatImpl(const RowStatLinearOpBaseUtils::ERowStat rowStat, const Ptr< VectorBase< Scalar > > &rowStatVec) const
bool opSupportedImpl(Thyra::EOpTransp M_trans) const
Abstract interface for objects that represent a space for vectors.
RCP< const Tpetra::Operator< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getConstTpetraOperator() const
Get embedded const Tpetra::Operator.
void applyImpl(const Thyra::EOpTransp M_trans, const Thyra::MultiVectorBase< Scalar > &X_in, const Teuchos::Ptr< Thyra::MultiVectorBase< Scalar > > &Y_inout, const Scalar alpha, const Scalar beta) const
virtual bool rowStatIsSupportedImpl(const RowStatLinearOpBaseUtils::ERowStat rowStat) const
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Interface for a collection of column vectors called a multi-vector.
RCP< const TpetraLinearOp< Scalar, LocalOrdinal, GlobalOrdinal, Node > > constTpetraLinearOp(const RCP< const VectorSpaceBase< Scalar > > &rangeSpace, const RCP< const VectorSpaceBase< Scalar > > &domainSpace, const RCP< const Tpetra::Operator< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &tpetraOperator)
Nonmmeber constructor for TpetraLinearOp.
virtual bool supportsScaleLeftImpl() const
RCP< const Thyra::VectorSpaceBase< Scalar > > range() const
RCP< Tpetra::Operator< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getTpetraOperator()
Get embedded non-const Tpetra::Operator.
Abstract interface for finite-dimensional dense vectors.
RCP< TpetraLinearOp< Scalar, LocalOrdinal, GlobalOrdinal, Node > > tpetraLinearOp(const RCP< const VectorSpaceBase< Scalar > > &rangeSpace, const RCP< const VectorSpaceBase< Scalar > > &domainSpace, const RCP< Tpetra::Operator< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &tpetraOperator)
Nonmmeber constructor for TpetraLinearOp.
TpetraLinearOp()
Construct to uninitialized.
Applies left or right sclaing to the linear operator.
virtual void scaleLeftImpl(const VectorBase< Scalar > &row_scaling)
virtual void scaleRightImpl(const VectorBase< Scalar > &col_scaling)
Interface for exxtracting row statistics as a VectorBase from a supporting LinearOpBase object...
virtual bool supportsScaleRightImpl() const
void initialize(const RCP< const VectorSpaceBase< Scalar > > &rangeSpace, const RCP< const VectorSpaceBase< Scalar > > &domainSpace, const RCP< Tpetra::Operator< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &tpetraOperator)
Initialize.
RCP< const Thyra::VectorSpaceBase< Scalar > > domain() const
Concrete Thyra::LinearOpBase subclass for Tpetra::Operator.