Thyra_SpmdMultiVectorBaseDecl.hpp

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_SPMD_MULTI_VECTOR_BASE_DECL_HPP
00030 #define THYRA_SPMD_MULTI_VECTOR_BASE_DECL_HPP
00031 
00032 #include "Thyra_MultiVectorDefaultBaseDecl.hpp"
00033 #include "Thyra_SingleScalarEuclideanLinearOpBaseDecl.hpp"
00034 #include "Teuchos_BLAS.hpp"
00035 
00036 namespace Thyra {
00037 
00039 template<class Scalar> class SpmdVectorSpaceBase;
00040 
00097 template<class Scalar>
00098 class SpmdMultiVectorBase
00099   : virtual public MultiVectorDefaultBase<Scalar>
00100   , virtual public SingleScalarEuclideanLinearOpBase<Scalar>
00101 {
00102 public:
00103 
00104 #ifdef THYRA_INJECT_USING_DECLARATIONS
00105   using SingleScalarEuclideanLinearOpBase<Scalar>::euclideanApply;
00106   using SingleScalarEuclideanLinearOpBase<Scalar>::apply;
00107 #endif
00108 
00111 
00113   SpmdMultiVectorBase();
00114 
00116 
00119 
00123   virtual RCP<const SpmdVectorSpaceBase<Scalar> > spmdSpace() const = 0;
00124 
00149   virtual void getLocalData( Scalar **localValues, Index *leadingDim ) = 0;
00150 
00164   virtual void commitLocalData( Scalar *localValues ) = 0;
00165 
00187   virtual void getLocalData(
00188     const Scalar **localValues, Index *leadingDim
00189     ) const = 0;
00190 
00205   virtual void freeLocalData( const Scalar *localValues ) const = 0;
00206 
00208 
00211 
00213   RCP< const ScalarProdVectorSpaceBase<Scalar> > rangeScalarProdVecSpc() const;
00214 
00216 
00219 
00223   void apply(
00224     const EOpTransp M_trans,
00225     const MultiVectorBase<Scalar> &X,
00226     MultiVectorBase<Scalar> *Y,
00227     const Scalar alpha,
00228     const Scalar beta
00229     ) const;
00230 
00232 
00236   void mvMultiReductApplyOpImpl(
00237     const RTOpPack::RTOpT<Scalar> &primary_op,
00238     const ArrayView<const Ptr<const MultiVectorBase<Scalar> > > &multi_vecs,
00239     const ArrayView<const Ptr<MultiVectorBase<Scalar> > > &targ_multi_vecs,
00240     const ArrayView<const Ptr<RTOpPack::ReductTarget> > &reduct_objs,
00241     const Index primary_first_ele,
00242     const Index primary_sub_dim,
00243     const Index primary_global_offset,
00244     const Index secondary_first_ele,
00245     const Index secondary_sub_dim
00246     ) const;
00248   void acquireDetachedMultiVectorViewImpl(
00249     const Range1D &rowRng,
00250     const Range1D &colRng
00251     ,RTOpPack::ConstSubMultiVectorView<Scalar> *sub_mv
00252     ) const;
00254   void releaseDetachedMultiVectorViewImpl(
00255     RTOpPack::ConstSubMultiVectorView<Scalar>* sub_mv
00256     ) const;
00258   void acquireNonconstDetachedMultiVectorViewImpl(
00259     const Range1D &rowRng,
00260     const Range1D &colRng,
00261     RTOpPack::SubMultiVectorView<Scalar> *sub_mv
00262     );
00264   void commitNonconstDetachedMultiVectorViewImpl(
00265     RTOpPack::SubMultiVectorView<Scalar>* sub_mv
00266     );
00268 
00269 protected:
00270 
00273 
00278   bool opSupported(EOpTransp M_trans) const;
00279 
00285   void euclideanApply(
00286     const EOpTransp                     M_trans
00287     ,const MultiVectorBase<Scalar>    &X
00288     ,MultiVectorBase<Scalar>          *Y
00289     ,const Scalar                     alpha
00290     ,const Scalar                     beta
00291     ) const;
00292 
00294 
00297 
00306   virtual void updateSpmdSpace();
00307 
00312   Range1D validateRowRange( const Range1D& rowRng ) const;
00313 
00318   Range1D validateColRange( const Range1D& rowCol ) const;
00319 
00321   
00322 private:
00323   
00324   // ///////////////////////////////////////
00325   // Private data members
00326   
00327   mutable bool in_applyOp_;
00328 
00329   mutable Teuchos::BLAS<int,Scalar> blas_;
00330 
00331   // cached
00332   Index  globalDim_;
00333   Index  localOffset_;
00334   Index  localSubDim_;
00335   Index  numCols_;
00336 
00337   mutable Scalar *nonconstLocalValuesViewPtr_;
00338   mutable const Scalar *localValuesViewPtr_;
00339   
00340 }; // end class SpmdMultiVectorBase
00341 
00342 } // end namespace Thyra
00343 
00344 #endif // THYRA_SPMD_MULTI_VECTOR_BASE_DECL_HPP

Generated on Wed May 12 21:26:54 2010 for Thyra Operator/Vector Support by  doxygen 1.4.7