Thyra Package Browser (Single Doxygen Collection) Version of the Day
Thyra_TpetraLinearOp_decl.hpp
Go to the documentation of this file.
00001 // @HEADER
00002 // ***********************************************************************
00003 // 
00004 //    Thyra: Interfaces and Support for Abstract Numerical Algorithms
00005 //                 Copyright (2004) Sandia Corporation
00006 // 
00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00008 // license for use of this work by or on behalf of the U.S. Government.
00009 // 
00010 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions are
00012 // met:
00013 //
00014 // 1. Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 //
00017 // 2. Redistributions in binary form must reproduce the above copyright
00018 // notice, this list of conditions and the following disclaimer in the
00019 // documentation and/or other materials provided with the distribution.
00020 //
00021 // 3. Neither the name of the Corporation nor the names of the
00022 // contributors may be used to endorse or promote products derived from
00023 // this software without specific prior written permission.
00024 //
00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 //
00037 // Questions? Contact Roscoe A. Bartlett (bartlettra@ornl.gov) 
00038 // 
00039 // ***********************************************************************
00040 // @HEADER
00041 
00042 #ifndef THYRA_TPETRA_LINEAR_OP_DECL_HPP
00043 #define THYRA_TPETRA_LINEAR_OP_DECL_HPP
00044 
00045 #include "Thyra_LinearOpDefaultBase.hpp"
00046 #include "Thyra_TpetraVectorSpace_decl.hpp"
00047 #include "Tpetra_Operator.hpp"
00048 #include "Teuchos_ConstNonconstObjectContainer.hpp"
00049 
00050 #if defined(HAVE_THYRA_EPETRA) && defined(HAVE_TPETRA_EPETRA)
00051 #  define HAVE_THYRA_TPETRA_EPETRA
00052 #endif
00053 
00054 #ifdef HAVE_THYRA_TPETRA_EPETRA
00055 #  include "Thyra_EpetraLinearOpBase.hpp"
00056 #  include "Tpetra_EpetraRowMatrix.hpp"
00057 #endif
00058 
00059 
00060 namespace Thyra {
00061 
00062 
00069 template <class Scalar, class LocalOrdinal, class GlobalOrdinal=LocalOrdinal,
00070   class Node=Kokkos::DefaultNode::DefaultNodeType>
00071 class TpetraLinearOp
00072   : virtual public Thyra::LinearOpDefaultBase<Scalar>
00073 #ifdef HAVE_THYRA_TPETRA_EPETRA
00074   , virtual public EpetraLinearOpBase
00075 #endif
00076 {
00077 public:
00078 
00081 
00083   TpetraLinearOp();
00084 
00086   void initialize(
00087     const RCP<const VectorSpaceBase<Scalar> > &rangeSpace,
00088     const RCP<const VectorSpaceBase<Scalar> > &domainSpace,
00089     const RCP<Tpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal,Node> > &tpetraOperator
00090     );
00091 
00093   void constInitialize(
00094     const RCP<const VectorSpaceBase<Scalar> > &rangeSpace,
00095     const RCP<const VectorSpaceBase<Scalar> > &domainSpace,
00096     const RCP<const Tpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal,Node> > &tpetraOperator
00097     );
00098 
00100   RCP<Tpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal,Node> >
00101   getTpetraOperator();
00102 
00104   RCP<const Tpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal,Node> >
00105   getConstTpetraOperator() const;
00106 
00108 
00111 
00113   RCP<const Thyra::VectorSpaceBase<Scalar> > range() const;
00114 
00116   RCP<const Thyra::VectorSpaceBase<Scalar> > domain() const;
00117 
00119 
00120 #ifdef HAVE_THYRA_TPETRA_EPETRA
00121 
00124 
00126   void getNonconstEpetraOpView(
00127     const Ptr<RCP<Epetra_Operator> > &epetraOp,
00128     const Ptr<EOpTransp> &epetraOpTransp,
00129     const Ptr<EApplyEpetraOpAs> &epetraOpApplyAs,
00130     const Ptr<EAdjointEpetraOp> &epetraOpAdjointSupport
00131     );
00133   void getEpetraOpView(
00134     const Ptr<RCP<const Epetra_Operator> > &epetraOp,
00135     const Ptr<EOpTransp> &epetraOpTransp,
00136     const Ptr<EApplyEpetraOpAs> &epetraOpApplyAs,
00137     const Ptr<EAdjointEpetraOp> &epetraOpAdjointSupport
00138     ) const;
00139 
00141 
00142 #endif // HAVE_THYRA_TPETRA_EPETRA
00143 
00144 protected:
00145 
00148 
00150   bool opSupportedImpl(Thyra::EOpTransp M_trans) const;
00151 
00153   void applyImpl(
00154     const Thyra::EOpTransp M_trans,
00155     const Thyra::MultiVectorBase<Scalar> &X_in,
00156     const Teuchos::Ptr<Thyra::MultiVectorBase<Scalar> > &Y_inout,
00157     const Scalar alpha,
00158     const Scalar beta
00159     ) const;
00160 
00162 
00163 private:
00164 
00165   RCP<const VectorSpaceBase<Scalar> >
00166   rangeSpace_;
00167 
00168   RCP<const VectorSpaceBase<Scalar> >
00169   domainSpace_;
00170 
00171   Teuchos::ConstNonconstObjectContainer<Tpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal,Node> >
00172   tpetraOperator_;
00173 
00174 #ifdef HAVE_THYRA_TPETRA_EPETRA
00175   mutable RCP<Epetra_Operator> epetraOp_;
00176 #endif
00177 
00178   template<class TpetraOperator_t>
00179   void initializeImpl(
00180     const RCP<const VectorSpaceBase<Scalar> > &rangeSpace,
00181     const RCP<const VectorSpaceBase<Scalar> > &domainSpace,
00182     const RCP<TpetraOperator_t> &tpetraOperator
00183   );
00184 
00185 };
00186 
00187 
00192 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
00193 RCP<TpetraLinearOp<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
00194 tpetraLinearOp(
00195   const RCP<const VectorSpaceBase<Scalar> > &rangeSpace,
00196   const RCP<const VectorSpaceBase<Scalar> > &domainSpace,
00197   const RCP<Tpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal,Node> > &tpetraOperator
00198   )
00199 {
00200   const RCP<TpetraLinearOp<Scalar, LocalOrdinal, GlobalOrdinal, Node> > op =
00201     Teuchos::rcp(new TpetraLinearOp<Scalar, LocalOrdinal, GlobalOrdinal, Node>);
00202   op->initialize(rangeSpace, domainSpace, tpetraOperator);
00203   return op;
00204 }
00205 
00206 
00211 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
00212 RCP<const TpetraLinearOp<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
00213 constTpetraLinearOp(
00214   const RCP<const VectorSpaceBase<Scalar> > &rangeSpace,
00215   const RCP<const VectorSpaceBase<Scalar> > &domainSpace,
00216   const RCP<const Tpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal,Node> > &tpetraOperator
00217   )
00218 {
00219   const RCP<TpetraLinearOp<Scalar, LocalOrdinal, GlobalOrdinal, Node> > op =
00220     Teuchos::rcp(new TpetraLinearOp<Scalar, LocalOrdinal, GlobalOrdinal, Node>);
00221   op->constInitialize(rangeSpace, domainSpace, tpetraOperator);
00222   return op;
00223 }
00224 
00225 
00226 }  // namespace Thyra
00227 
00228 
00229 #endif  // THYRA_TPETRA_LINEAR_OP_DECL_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines