Thyra Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Thyra_TpetraLinearOp_decl.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Thyra: Interfaces and Support for Abstract Numerical Algorithms
5 // Copyright (2004) 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 Roscoe A. Bartlett (bartlettra@ornl.gov)
38 //
39 // ***********************************************************************
40 // @HEADER
41 
42 #ifndef THYRA_TPETRA_LINEAR_OP_DECL_HPP
43 #define THYRA_TPETRA_LINEAR_OP_DECL_HPP
44 
45 #include "Thyra_LinearOpDefaultBase.hpp"
47 #include "Thyra_ScaledLinearOpBase.hpp"
48 #include "Thyra_RowStatLinearOpBase.hpp"
49 #include "Tpetra_Operator.hpp"
51 
52 #if defined(HAVE_THYRA_EPETRA) && defined(HAVE_TPETRA_EPETRA)
53 # define HAVE_THYRA_TPETRA_EPETRA
54 #endif
55 
56 #ifdef HAVE_THYRA_TPETRA_EPETRA
58 # include "Tpetra_EpetraRowMatrix.hpp"
59 #endif
60 
61 
62 namespace Thyra {
63 
64 
71 template <class Scalar, class LocalOrdinal, class GlobalOrdinal=LocalOrdinal,
72  class Node=KokkosClassic::DefaultNode::DefaultNodeType>
74  : virtual public Thyra::LinearOpDefaultBase<Scalar>,
75  virtual public ScaledLinearOpBase<Scalar>,
76  virtual public Thyra::RowStatLinearOpBase<Scalar>
77 #ifdef HAVE_THYRA_TPETRA_EPETRA
78  , virtual public EpetraLinearOpBase
79 #endif
80 {
81 public:
82 
85 
88 
90  void initialize(
91  const RCP<const VectorSpaceBase<Scalar> > &rangeSpace,
92  const RCP<const VectorSpaceBase<Scalar> > &domainSpace,
93  const RCP<Tpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal,Node> > &tpetraOperator
94  );
95 
97  void constInitialize(
98  const RCP<const VectorSpaceBase<Scalar> > &rangeSpace,
99  const RCP<const VectorSpaceBase<Scalar> > &domainSpace,
100  const RCP<const Tpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal,Node> > &tpetraOperator
101  );
102 
106 
109  getConstTpetraOperator() const;
110 
112 
115 
118 
121 
123 
124 #ifdef HAVE_THYRA_TPETRA_EPETRA
125 
128 
130  void getNonconstEpetraOpView(
131  const Ptr<RCP<Epetra_Operator> > &epetraOp,
132  const Ptr<EOpTransp> &epetraOpTransp,
133  const Ptr<EApplyEpetraOpAs> &epetraOpApplyAs,
134  const Ptr<EAdjointEpetraOp> &epetraOpAdjointSupport
135  );
137  void getEpetraOpView(
138  const Ptr<RCP<const Epetra_Operator> > &epetraOp,
139  const Ptr<EOpTransp> &epetraOpTransp,
140  const Ptr<EApplyEpetraOpAs> &epetraOpApplyAs,
141  const Ptr<EAdjointEpetraOp> &epetraOpAdjointSupport
142  ) const;
143 
145 
146 #endif // HAVE_THYRA_TPETRA_EPETRA
147 
148 protected:
149 
152 
154  bool opSupportedImpl(Thyra::EOpTransp M_trans) const;
155 
157  void applyImpl(
158  const Thyra::EOpTransp M_trans,
159  const Thyra::MultiVectorBase<Scalar> &X_in,
160  const Teuchos::Ptr<Thyra::MultiVectorBase<Scalar> > &Y_inout,
161  const Scalar alpha,
162  const Scalar beta
163  ) const;
164 
166 
169 
171  virtual bool supportsScaleLeftImpl() const;
172 
174  virtual bool supportsScaleRightImpl() const;
175 
177  virtual void scaleLeftImpl(const VectorBase<Scalar> &row_scaling);
178 
180  virtual void scaleRightImpl(const VectorBase<Scalar> &col_scaling);
181 
183 
186 
188  virtual bool rowStatIsSupportedImpl(
189  const RowStatLinearOpBaseUtils::ERowStat rowStat) const;
190 
192  virtual void getRowStatImpl(
193  const RowStatLinearOpBaseUtils::ERowStat rowStat,
194  const Ptr<VectorBase<Scalar> > &rowStatVec) const;
195 
197 
198 private:
199 
202 
205 
208 
209 #ifdef HAVE_THYRA_TPETRA_EPETRA
210  mutable RCP<Epetra_Operator> epetraOp_;
211 #endif
212 
213  template<class TpetraOperator_t>
214  void initializeImpl(
215  const RCP<const VectorSpaceBase<Scalar> > &rangeSpace,
216  const RCP<const VectorSpaceBase<Scalar> > &domainSpace,
217  const RCP<TpetraOperator_t> &tpetraOperator
218  );
219 
220 };
221 
222 
227 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
230  const RCP<const VectorSpaceBase<Scalar> > &rangeSpace,
231  const RCP<const VectorSpaceBase<Scalar> > &domainSpace,
232  const RCP<Tpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal,Node> > &tpetraOperator
233  )
234 {
237  op->initialize(rangeSpace, domainSpace, tpetraOperator);
238  return op;
239 }
240 
241 
246 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
249  const RCP<const VectorSpaceBase<Scalar> > &rangeSpace,
250  const RCP<const VectorSpaceBase<Scalar> > &domainSpace,
251  const RCP<const Tpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal,Node> > &tpetraOperator
252  )
253 {
256  op->constInitialize(rangeSpace, domainSpace, tpetraOperator);
257  return op;
258 }
259 
260 
261 } // namespace Thyra
262 
263 
264 #endif // THYRA_TPETRA_LINEAR_OP_DECL_HPP
void initializeImpl(const RCP< const VectorSpaceBase< Scalar > > &rangeSpace, const RCP< const VectorSpaceBase< Scalar > > &domainSpace, const RCP< TpetraOperator_t > &tpetraOperator)
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...
virtual void getRowStatImpl(const RowStatLinearOpBaseUtils::ERowStat rowStat, const Ptr< VectorBase< Scalar > > &rowStatVec) const
bool opSupportedImpl(Thyra::EOpTransp M_trans) const
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)
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.
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.
virtual void scaleLeftImpl(const VectorBase< Scalar > &row_scaling)
Teuchos::ConstNonconstObjectContainer< Tpetra::Operator< Scalar, LocalOrdinal, GlobalOrdinal, Node > > tpetraOperator_
virtual void scaleRightImpl(const VectorBase< Scalar > &col_scaling)
RCP< const VectorSpaceBase< Scalar > > rangeSpace_
virtual bool supportsScaleRightImpl() const
RCP< const VectorSpaceBase< Scalar > > domainSpace_
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.