Thyra_SpmdVectorBaseDecl.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_VECTOR_BASE_DECL_HPP
00030 #define THYRA_SPMD_VECTOR_BASE_DECL_HPP
00031 
00032 
00033 #include "Thyra_VectorDefaultBaseDecl.hpp"
00034 #include "Thyra_SpmdVectorSpaceDefaultBaseDecl.hpp"
00035 
00036 
00037 //#define THYRA_SPMD_VECTOR_BASE_DUMP
00038 
00039 
00040 namespace Thyra {
00041 
00042 
00104 template<class Scalar>
00105 class SpmdVectorBase : virtual public VectorDefaultBase<Scalar> {
00106 public:
00107 
00109   SpmdVectorBase();
00110 
00113 
00116   virtual Teuchos::RCP<const SpmdVectorSpaceBase<Scalar> > spmdSpace() const = 0;
00117 
00143   virtual void getLocalData( Scalar** localValues, Index* stride ) = 0;
00144 
00159   virtual void commitLocalData( Scalar* localValues ) = 0;
00160 
00162 
00165 
00198   virtual void getLocalData( const Scalar** localValues, Index* stride ) const;
00199 
00216   virtual void freeLocalData( const Scalar* localValues ) const;
00217 
00233   void applyOp(
00234     const Teuchos::Comm<Index>      *comm
00235     ,const RTOpPack::RTOpT<Scalar>  &op
00236     ,const int                      num_vecs
00237     ,const VectorBase<Scalar>*const vecs[]
00238     ,const int                      num_targ_vecs
00239     ,VectorBase<Scalar>*const        targ_vecs[]
00240     ,RTOpPack::ReductTarget         *reduct_obj
00241     ,const Index                    first_ele_offset
00242     ,const Index                    sub_dim
00243     ,const Index                    global_offset
00244     ) const;
00245 
00247 
00251   std::string description() const;
00253 
00256 
00258   Teuchos::RCP<const VectorSpaceBase<Scalar> > space() const;
00260   void applyOp(
00261     const RTOpPack::RTOpT<Scalar>   &op
00262     ,const int                      num_vecs
00263     ,const VectorBase<Scalar>*const vecs[]
00264     ,const int                      num_targ_vecs
00265     ,VectorBase<Scalar>*const       targ_vecs[]
00266     ,RTOpPack::ReductTarget         *reduct_obj
00267     ,const Index                    first_ele_offset
00268     ,const Index                    sub_dim
00269     ,const Index                    global_offset
00270     ) const;
00272   void acquireDetachedVectorViewImpl(
00273     const Range1D& rng, RTOpPack::ConstSubVectorView<Scalar>* sub_vec
00274     ) const;
00276   void releaseDetachedVectorViewImpl(
00277     RTOpPack::ConstSubVectorView<Scalar>* sub_vec
00278     ) const;
00280   void acquireNonconstDetachedVectorViewImpl(
00281     const Range1D& rng, RTOpPack::SubVectorView<Scalar>* sub_vec
00282     );
00284   void commitNonconstDetachedVectorViewImpl(
00285     RTOpPack::SubVectorView<Scalar>* sub_vec
00286     );
00287 
00289 
00290 protected:
00291 
00295   virtual void updateSpmdSpace();
00296 
00297 private:
00298 
00299   // ///////////////////////////////////////
00300   // Private data members
00301   
00302   mutable bool in_applyOp_;
00303 
00304   // Cached (only on vector space!)
00305   mutable Index  globalDim_;
00306   mutable Index  localOffset_;
00307   mutable Index  localSubDim_;
00308 
00309   // /////////////////////////////////////
00310   // Private member functions
00311 
00312   Range1D validateRange( const Range1D& rng_in ) const;
00313 
00314 #ifdef THYRA_SPMD_VECTOR_BASE_DUMP
00315 public:
00316   static bool show_dump;
00317 #endif // THYRA_SPMD_VECTOR_BASE_DUMP
00318 
00319 }; // end class SpmdVectorBase
00320 
00321 
00322 } // end namespace Thyra
00323 
00324 
00325 #endif // THYRA_SPMD_VECTOR_BASE_DECL_HPP

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