|
Thyra Package Browser (Single Doxygen Collection) Version of the Day
|
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 // This library is free software; you can redistribute it and/or modify 00011 // it under the terms of the GNU Lesser General Public License as 00012 // published by the Free Software Foundation; either version 2.1 of the 00013 // License, or (at your option) any later version. 00014 // 00015 // This library is distributed in the hope that it will be useful, but 00016 // WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 // Lesser General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU Lesser General Public 00021 // License along with this library; if not, write to the Free Software 00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00023 // USA 00024 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 00025 // 00026 // *********************************************************************** 00027 // @HEADER 00028 00029 #ifndef THYRA_TPETRA_LINEAR_OP_DECL_HPP 00030 #define THYRA_TPETRA_LINEAR_OP_DECL_HPP 00031 00032 #include "Thyra_LinearOpDefaultBase.hpp" 00033 #include "Thyra_TpetraVectorSpace_decl.hpp" 00034 #include "Tpetra_Operator.hpp" 00035 #include "Teuchos_ConstNonconstObjectContainer.hpp" 00036 00037 #if defined(HAVE_THYRA_EPETRA) && defined(HAVE_TPETRA_EPETRA) 00038 # define HAVE_THYRA_TPETRA_EPETRA 00039 #endif 00040 00041 #ifdef HAVE_THYRA_TPETRA_EPETRA 00042 # include "Thyra_EpetraLinearOpBase.hpp" 00043 # include "Tpetra_EpetraRowMatrix.hpp" 00044 #endif 00045 00046 00047 namespace Thyra { 00048 00049 00056 template <class Scalar, class LocalOrdinal, class GlobalOrdinal=LocalOrdinal, 00057 class Node=Kokkos::DefaultNode::DefaultNodeType> 00058 class TpetraLinearOp 00059 : virtual public Thyra::LinearOpDefaultBase<Scalar> 00060 #ifdef HAVE_THYRA_TPETRA_EPETRA 00061 , virtual public EpetraLinearOpBase 00062 #endif 00063 { 00064 public: 00065 00068 00070 TpetraLinearOp(); 00071 00073 void initialize( 00074 const RCP<const VectorSpaceBase<Scalar> > &rangeSpace, 00075 const RCP<const VectorSpaceBase<Scalar> > &domainSpace, 00076 const RCP<Tpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal,Node> > &tpetraOperator 00077 ); 00078 00080 void constInitialize( 00081 const RCP<const VectorSpaceBase<Scalar> > &rangeSpace, 00082 const RCP<const VectorSpaceBase<Scalar> > &domainSpace, 00083 const RCP<const Tpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal,Node> > &tpetraOperator 00084 ); 00085 00087 RCP<Tpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal,Node> > 00088 getTpetraOperator(); 00089 00091 RCP<const Tpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal,Node> > 00092 getConstTpetraOperator() const; 00093 00095 00096 #ifdef HAVE_THYRA_TPETRA_EPETRA 00097 00100 00102 RCP<const Thyra::VectorSpaceBase<Scalar> > range() const; 00103 00105 RCP<const Thyra::VectorSpaceBase<Scalar> > domain() const; 00106 00108 00111 00113 void getNonconstEpetraOpView( 00114 const Ptr<RCP<Epetra_Operator> > &epetraOp, 00115 const Ptr<EOpTransp> &epetraOpTransp, 00116 const Ptr<EApplyEpetraOpAs> &epetraOpApplyAs, 00117 const Ptr<EAdjointEpetraOp> &epetraOpAdjointSupport 00118 ); 00120 void getEpetraOpView( 00121 const Ptr<RCP<const Epetra_Operator> > &epetraOp, 00122 const Ptr<EOpTransp> &epetraOpTransp, 00123 const Ptr<EApplyEpetraOpAs> &epetraOpApplyAs, 00124 const Ptr<EAdjointEpetraOp> &epetraOpAdjointSupport 00125 ) const; 00126 00128 00129 #endif // HAVE_THYRA_TPETRA_EPETRA 00130 00131 protected: 00132 00135 00137 bool opSupportedImpl(Thyra::EOpTransp M_trans) const; 00138 00140 void applyImpl( 00141 const Thyra::EOpTransp M_trans, 00142 const Thyra::MultiVectorBase<Scalar> &X_in, 00143 const Teuchos::Ptr<Thyra::MultiVectorBase<Scalar> > &Y_inout, 00144 const Scalar alpha, 00145 const Scalar beta 00146 ) const; 00147 00149 00150 private: 00151 00152 RCP<const VectorSpaceBase<Scalar> > 00153 rangeSpace_; 00154 00155 RCP<const VectorSpaceBase<Scalar> > 00156 domainSpace_; 00157 00158 Teuchos::ConstNonconstObjectContainer<Tpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal,Node> > 00159 tpetraOperator_; 00160 00161 #ifdef HAVE_THYRA_TPETRA_EPETRA 00162 mutable RCP<Epetra_Operator> epetraOp_; 00163 #endif 00164 00165 template<class TpetraOperator_t> 00166 void initializeImpl( 00167 const RCP<const VectorSpaceBase<Scalar> > &rangeSpace, 00168 const RCP<const VectorSpaceBase<Scalar> > &domainSpace, 00169 const RCP<TpetraOperator_t> &tpetraOperator 00170 ); 00171 00172 }; 00173 00174 00179 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node> 00180 RCP<TpetraLinearOp<Scalar, LocalOrdinal, GlobalOrdinal, Node> > 00181 tpetraLinearOp( 00182 const RCP<const VectorSpaceBase<Scalar> > &rangeSpace, 00183 const RCP<const VectorSpaceBase<Scalar> > &domainSpace, 00184 const RCP<Tpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal,Node> > &tpetraOperator 00185 ) 00186 { 00187 const RCP<TpetraLinearOp<Scalar, LocalOrdinal, GlobalOrdinal, Node> > op = 00188 Teuchos::rcp(new TpetraLinearOp<Scalar, LocalOrdinal, GlobalOrdinal, Node>); 00189 op->initialize(rangeSpace, domainSpace, tpetraOperator); 00190 return op; 00191 } 00192 00193 00198 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node> 00199 RCP<const TpetraLinearOp<Scalar, LocalOrdinal, GlobalOrdinal, Node> > 00200 constTpetraLinearOp( 00201 const RCP<const VectorSpaceBase<Scalar> > &rangeSpace, 00202 const RCP<const VectorSpaceBase<Scalar> > &domainSpace, 00203 const RCP<const Tpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal,Node> > &tpetraOperator 00204 ) 00205 { 00206 const RCP<TpetraLinearOp<Scalar, LocalOrdinal, GlobalOrdinal, Node> > op = 00207 Teuchos::rcp(new TpetraLinearOp<Scalar, LocalOrdinal, GlobalOrdinal, Node>); 00208 op->constInitialize(rangeSpace, domainSpace, tpetraOperator); 00209 return op; 00210 } 00211 00212 00213 } // namespace Thyra 00214 00215 00216 #endif // THYRA_TPETRA_LINEAR_OP_DECL_HPP
1.7.4