|
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 // 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 "Thyra_ScaledLinearOpBase.hpp" 00048 #include "Thyra_RowStatLinearOpBase.hpp" 00049 #include "Tpetra_Operator.hpp" 00050 #include "Teuchos_ConstNonconstObjectContainer.hpp" 00051 00052 #if defined(HAVE_THYRA_EPETRA) && defined(HAVE_TPETRA_EPETRA) 00053 # define HAVE_THYRA_TPETRA_EPETRA 00054 #endif 00055 00056 #ifdef HAVE_THYRA_TPETRA_EPETRA 00057 # include "Thyra_EpetraLinearOpBase.hpp" 00058 # include "Tpetra_EpetraRowMatrix.hpp" 00059 #endif 00060 00061 00062 namespace Thyra { 00063 00064 00071 template <class Scalar, class LocalOrdinal, class GlobalOrdinal=LocalOrdinal, 00072 class Node=KokkosClassic::DefaultNode::DefaultNodeType> 00073 class TpetraLinearOp 00074 : virtual public Thyra::LinearOpDefaultBase<Scalar>, 00075 virtual public ScaledLinearOpBase<Scalar>, 00076 virtual public Thyra::RowStatLinearOpBase<Scalar> 00077 #ifdef HAVE_THYRA_TPETRA_EPETRA 00078 , virtual public EpetraLinearOpBase 00079 #endif 00080 { 00081 public: 00082 00085 00087 TpetraLinearOp(); 00088 00090 void initialize( 00091 const RCP<const VectorSpaceBase<Scalar> > &rangeSpace, 00092 const RCP<const VectorSpaceBase<Scalar> > &domainSpace, 00093 const RCP<Tpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal,Node> > &tpetraOperator 00094 ); 00095 00097 void constInitialize( 00098 const RCP<const VectorSpaceBase<Scalar> > &rangeSpace, 00099 const RCP<const VectorSpaceBase<Scalar> > &domainSpace, 00100 const RCP<const Tpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal,Node> > &tpetraOperator 00101 ); 00102 00104 RCP<Tpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal,Node> > 00105 getTpetraOperator(); 00106 00108 RCP<const Tpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal,Node> > 00109 getConstTpetraOperator() const; 00110 00112 00115 00117 RCP<const Thyra::VectorSpaceBase<Scalar> > range() const; 00118 00120 RCP<const Thyra::VectorSpaceBase<Scalar> > domain() const; 00121 00123 00124 #ifdef HAVE_THYRA_TPETRA_EPETRA 00125 00128 00130 void getNonconstEpetraOpView( 00131 const Ptr<RCP<Epetra_Operator> > &epetraOp, 00132 const Ptr<EOpTransp> &epetraOpTransp, 00133 const Ptr<EApplyEpetraOpAs> &epetraOpApplyAs, 00134 const Ptr<EAdjointEpetraOp> &epetraOpAdjointSupport 00135 ); 00137 void getEpetraOpView( 00138 const Ptr<RCP<const Epetra_Operator> > &epetraOp, 00139 const Ptr<EOpTransp> &epetraOpTransp, 00140 const Ptr<EApplyEpetraOpAs> &epetraOpApplyAs, 00141 const Ptr<EAdjointEpetraOp> &epetraOpAdjointSupport 00142 ) const; 00143 00145 00146 #endif // HAVE_THYRA_TPETRA_EPETRA 00147 00148 protected: 00149 00152 00154 bool opSupportedImpl(Thyra::EOpTransp M_trans) const; 00155 00157 void applyImpl( 00158 const Thyra::EOpTransp M_trans, 00159 const Thyra::MultiVectorBase<Scalar> &X_in, 00160 const Teuchos::Ptr<Thyra::MultiVectorBase<Scalar> > &Y_inout, 00161 const Scalar alpha, 00162 const Scalar beta 00163 ) const; 00164 00166 00169 00171 virtual bool supportsScaleLeftImpl() const; 00172 00174 virtual bool supportsScaleRightImpl() const; 00175 00177 virtual void scaleLeftImpl(const VectorBase<Scalar> &row_scaling); 00178 00180 virtual void scaleRightImpl(const VectorBase<Scalar> &col_scaling); 00181 00183 00186 00188 virtual bool rowStatIsSupportedImpl( 00189 const RowStatLinearOpBaseUtils::ERowStat rowStat) const; 00190 00192 virtual void getRowStatImpl( 00193 const RowStatLinearOpBaseUtils::ERowStat rowStat, 00194 const Ptr<VectorBase<Scalar> > &rowStatVec) const; 00195 00197 00198 private: 00199 00200 RCP<const VectorSpaceBase<Scalar> > 00201 rangeSpace_; 00202 00203 RCP<const VectorSpaceBase<Scalar> > 00204 domainSpace_; 00205 00206 Teuchos::ConstNonconstObjectContainer<Tpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal,Node> > 00207 tpetraOperator_; 00208 00209 #ifdef HAVE_THYRA_TPETRA_EPETRA 00210 mutable RCP<Epetra_Operator> epetraOp_; 00211 #endif 00212 00213 template<class TpetraOperator_t> 00214 void initializeImpl( 00215 const RCP<const VectorSpaceBase<Scalar> > &rangeSpace, 00216 const RCP<const VectorSpaceBase<Scalar> > &domainSpace, 00217 const RCP<TpetraOperator_t> &tpetraOperator 00218 ); 00219 00220 }; 00221 00222 00227 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node> 00228 RCP<TpetraLinearOp<Scalar, LocalOrdinal, GlobalOrdinal, Node> > 00229 tpetraLinearOp( 00230 const RCP<const VectorSpaceBase<Scalar> > &rangeSpace, 00231 const RCP<const VectorSpaceBase<Scalar> > &domainSpace, 00232 const RCP<Tpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal,Node> > &tpetraOperator 00233 ) 00234 { 00235 const RCP<TpetraLinearOp<Scalar, LocalOrdinal, GlobalOrdinal, Node> > op = 00236 Teuchos::rcp(new TpetraLinearOp<Scalar, LocalOrdinal, GlobalOrdinal, Node>); 00237 op->initialize(rangeSpace, domainSpace, tpetraOperator); 00238 return op; 00239 } 00240 00241 00246 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node> 00247 RCP<const TpetraLinearOp<Scalar, LocalOrdinal, GlobalOrdinal, Node> > 00248 constTpetraLinearOp( 00249 const RCP<const VectorSpaceBase<Scalar> > &rangeSpace, 00250 const RCP<const VectorSpaceBase<Scalar> > &domainSpace, 00251 const RCP<const Tpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal,Node> > &tpetraOperator 00252 ) 00253 { 00254 const RCP<TpetraLinearOp<Scalar, LocalOrdinal, GlobalOrdinal, Node> > op = 00255 Teuchos::rcp(new TpetraLinearOp<Scalar, LocalOrdinal, GlobalOrdinal, Node>); 00256 op->constInitialize(rangeSpace, domainSpace, tpetraOperator); 00257 return op; 00258 } 00259 00260 00261 } // namespace Thyra 00262 00263 00264 #endif // THYRA_TPETRA_LINEAR_OP_DECL_HPP
1.7.6.1