Thyra Package Browser (Single Doxygen Collection)  Version of the Day
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 "Tpetra_Operator.hpp"
49 
50 #if defined(HAVE_THYRA_EPETRA) && defined(HAVE_TPETRA_EPETRA)
51 # define HAVE_THYRA_TPETRA_EPETRA
52 #endif
53 
54 #ifdef HAVE_THYRA_TPETRA_EPETRA
56 # include "Tpetra_EpetraRowMatrix.hpp"
57 #endif
58 
59 
60 namespace Thyra {
61 
62 
69 template <class Scalar, class LocalOrdinal, class GlobalOrdinal=LocalOrdinal,
70  class Node=Kokkos::DefaultNode::DefaultNodeType>
72  : virtual public Thyra::LinearOpDefaultBase<Scalar>
73 #ifdef HAVE_THYRA_TPETRA_EPETRA
74  , virtual public EpetraLinearOpBase
75 #endif
76 {
77 public:
78 
81 
84 
86  void initialize(
87  const RCP<const VectorSpaceBase<Scalar> > &rangeSpace,
88  const RCP<const VectorSpaceBase<Scalar> > &domainSpace,
89  const RCP<Tpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal,Node> > &tpetraOperator
90  );
91 
93  void constInitialize(
94  const RCP<const VectorSpaceBase<Scalar> > &rangeSpace,
95  const RCP<const VectorSpaceBase<Scalar> > &domainSpace,
96  const RCP<const Tpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal,Node> > &tpetraOperator
97  );
98 
102 
105  getConstTpetraOperator() const;
106 
108 
111 
114 
117 
119 
120 #ifdef HAVE_THYRA_TPETRA_EPETRA
121 
124 
126  void getNonconstEpetraOpView(
127  const Ptr<RCP<Epetra_Operator> > &epetraOp,
128  const Ptr<EOpTransp> &epetraOpTransp,
129  const Ptr<EApplyEpetraOpAs> &epetraOpApplyAs,
130  const Ptr<EAdjointEpetraOp> &epetraOpAdjointSupport
131  );
133  void getEpetraOpView(
134  const Ptr<RCP<const Epetra_Operator> > &epetraOp,
135  const Ptr<EOpTransp> &epetraOpTransp,
136  const Ptr<EApplyEpetraOpAs> &epetraOpApplyAs,
137  const Ptr<EAdjointEpetraOp> &epetraOpAdjointSupport
138  ) const;
139 
141 
142 #endif // HAVE_THYRA_TPETRA_EPETRA
143 
144 protected:
145 
148 
150  bool opSupportedImpl(Thyra::EOpTransp M_trans) const;
151 
153  void applyImpl(
154  const Thyra::EOpTransp M_trans,
155  const Thyra::MultiVectorBase<Scalar> &X_in,
156  const Teuchos::Ptr<Thyra::MultiVectorBase<Scalar> > &Y_inout,
157  const Scalar alpha,
158  const Scalar beta
159  ) const;
160 
162 
163 private:
164 
167 
170 
173 
174 #ifdef HAVE_THYRA_TPETRA_EPETRA
175  mutable RCP<Epetra_Operator> epetraOp_;
176 #endif
177 
178  template<class TpetraOperator_t>
179  void initializeImpl(
180  const RCP<const VectorSpaceBase<Scalar> > &rangeSpace,
181  const RCP<const VectorSpaceBase<Scalar> > &domainSpace,
182  const RCP<TpetraOperator_t> &tpetraOperator
183  );
184 
185 };
186 
187 
192 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
195  const RCP<const VectorSpaceBase<Scalar> > &rangeSpace,
196  const RCP<const VectorSpaceBase<Scalar> > &domainSpace,
197  const RCP<Tpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal,Node> > &tpetraOperator
198  )
199 {
202  op->initialize(rangeSpace, domainSpace, tpetraOperator);
203  return op;
204 }
205 
206 
211 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
214  const RCP<const VectorSpaceBase<Scalar> > &rangeSpace,
215  const RCP<const VectorSpaceBase<Scalar> > &domainSpace,
216  const RCP<const Tpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal,Node> > &tpetraOperator
217  )
218 {
221  op->constInitialize(rangeSpace, domainSpace, tpetraOperator);
222  return op;
223 }
224 
225 
226 } // namespace Thyra
227 
228 
229 #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...
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
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.
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.
Teuchos::ConstNonconstObjectContainer< Tpetra::Operator< Scalar, LocalOrdinal, GlobalOrdinal, Node > > tpetraOperator_
RCP< const VectorSpaceBase< Scalar > > rangeSpace_
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.