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 
00105   using SingleScalarEuclideanLinearOpBase<Scalar>::euclideanApply;
00107   using SingleScalarEuclideanLinearOpBase<Scalar>::apply;
00108 
00111 
00113   SpmdMultiVectorBase();
00114 
00116 
00119 
00123   virtual Teuchos::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   Teuchos::RCP< const ScalarProdVectorSpaceBase<Scalar> > rangeScalarProdVecSpc() const;
00214 
00216 
00219 
00223   void apply(
00224     const ETransp 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 int num_multi_vecs,
00239     const MultiVectorBase<Scalar>*const multi_vecs[],
00240     const int num_targ_multi_vecs,
00241     MultiVectorBase<Scalar>*const targ_multi_vecs[],
00242     RTOpPack::ReductTarget*const reduct_objs[],
00243     const Index primary_first_ele,
00244     const Index primary_sub_dim,
00245     const Index primary_global_offset,
00246     const Index secondary_first_ele,
00247     const Index secondary_sub_dim
00248     ) const;
00250   void acquireDetachedMultiVectorViewImpl(
00251     const Range1D &rowRng,
00252     const Range1D &colRng
00253     ,RTOpPack::ConstSubMultiVectorView<Scalar> *sub_mv
00254     ) const;
00256   void releaseDetachedMultiVectorViewImpl(
00257     RTOpPack::ConstSubMultiVectorView<Scalar>* sub_mv
00258     ) const;
00260   void acquireNonconstDetachedMultiVectorViewImpl(
00261     const Range1D &rowRng,
00262     const Range1D &colRng,
00263     RTOpPack::SubMultiVectorView<Scalar> *sub_mv
00264     );
00266   void commitNonconstDetachedMultiVectorViewImpl(
00267     RTOpPack::SubMultiVectorView<Scalar>* sub_mv
00268     );
00270 
00271 protected:
00272 
00275 
00280   bool opSupported(ETransp M_trans) const;
00281 
00287   void euclideanApply(
00288     const ETransp                     M_trans
00289     ,const MultiVectorBase<Scalar>    &X
00290     ,MultiVectorBase<Scalar>          *Y
00291     ,const Scalar                     alpha
00292     ,const Scalar                     beta
00293     ) const;
00294 
00296 
00299 
00308   virtual void updateSpmdSpace();
00309 
00314   Range1D validateRowRange( const Range1D& rowRng ) const;
00315 
00320   Range1D validateColRange( const Range1D& rowCol ) const;
00321 
00323   
00324 private:
00325   
00326   // ///////////////////////////////////////
00327   // Private data members
00328   
00329   mutable bool in_applyOp_;
00330 
00331   mutable Teuchos::BLAS<int,Scalar> blas_;
00332 
00333   // cached
00334   Index  globalDim_;
00335   Index  localOffset_;
00336   Index  localSubDim_;
00337   Index  numCols_;
00338 
00339   mutable Scalar *nonconstLocalValuesViewPtr_;
00340   mutable const Scalar *localValuesViewPtr_;
00341   
00342 }; // end class SpmdMultiVectorBase
00343 
00344 } // end namespace Thyra
00345 
00346 #endif // THYRA_SPMD_MULTI_VECTOR_BASE_DECL_HPP

Generated on Tue Oct 20 12:46:59 2009 for Thyra Operator/Vector Support by doxygen 1.4.7