Thyra_SpmdVectorBaseDecl.hpp

Go to the documentation of this file.
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 #include "Thyra_VectorDefaultBaseDecl.hpp"
00033 #include "Thyra_SpmdVectorSpaceDefaultBaseDecl.hpp"
00034 
00035 //#define THYRA_SPMD_VECTOR_BASE_DUMP
00036 
00037 namespace Thyra {
00038 
00100 template<class Scalar>
00101 class SpmdVectorBase : virtual public VectorDefaultBase<Scalar> {
00102 public:
00103 
00105   using VectorDefaultBase<Scalar>::applyOp;
00107   using VectorDefaultBase<Scalar>::acquireDetachedView;
00109   using VectorDefaultBase<Scalar>::releaseDetachedView;
00111   using VectorDefaultBase<Scalar>::commitDetachedView;
00112 
00114   SpmdVectorBase();
00115 
00118 
00121   virtual Teuchos::RefCountPtr<const SpmdVectorSpaceBase<Scalar> > spmdSpace() const = 0;
00122 
00148   virtual void getLocalData( Scalar** localValues, Index* stride ) = 0;
00149 
00164   virtual void commitLocalData( Scalar* localValues ) = 0;
00165 
00167 
00170 
00203   virtual void getLocalData( const Scalar** localValues, Index* stride ) const;
00204 
00221   virtual void freeLocalData( const Scalar* localValues ) const;
00222 
00238   void applyOp(
00239     const Teuchos::Comm<Index>      *comm
00240     ,const RTOpPack::RTOpT<Scalar>  &op
00241     ,const int                      num_vecs
00242     ,const VectorBase<Scalar>*const vecs[]
00243     ,const int                      num_targ_vecs
00244     ,VectorBase<Scalar>*const        targ_vecs[]
00245     ,RTOpPack::ReductTarget         *reduct_obj
00246     ,const Index                    first_ele_offset
00247     ,const Index                    sub_dim
00248     ,const Index                    global_offset
00249     ) const;
00250 
00252 
00255 
00257   Teuchos::RefCountPtr<const VectorSpaceBase<Scalar> > space() const;
00259   void applyOp(
00260     const RTOpPack::RTOpT<Scalar>   &op
00261     ,const int                      num_vecs
00262     ,const VectorBase<Scalar>*const vecs[]
00263     ,const int                      num_targ_vecs
00264     ,VectorBase<Scalar>*const       targ_vecs[]
00265     ,RTOpPack::ReductTarget         *reduct_obj
00266     ,const Index                    first_ele_offset
00267     ,const Index                    sub_dim
00268     ,const Index                    global_offset
00269     ) const;
00271   void acquireDetachedView( const Range1D& rng, RTOpPack::ConstSubVectorView<Scalar>* sub_vec ) const;
00273   void releaseDetachedView( RTOpPack::ConstSubVectorView<Scalar>* sub_vec ) const;
00275   void acquireDetachedView( const Range1D& rng, RTOpPack::SubVectorView<Scalar>* sub_vec );
00277   void commitDetachedView( RTOpPack::SubVectorView<Scalar>* sub_vec );
00278 
00280 
00281 protected:
00282 
00286   virtual void updateSpmdSpace();
00287 
00288 private:
00289 
00290   // ///////////////////////////////////////
00291   // Private data members
00292   
00293   mutable bool in_applyOp_;
00294 
00295   // Cached (only on vector space!)
00296   mutable Index  globalDim_;
00297   mutable Index  localOffset_;
00298   mutable Index  localSubDim_;
00299 
00300   // /////////////////////////////////////
00301   // Private member functions
00302 
00303   Range1D validateRange( const Range1D& rng_in ) const;
00304 
00305 #ifdef THYRA_SPMD_VECTOR_BASE_DUMP
00306 public:
00307   static bool show_dump;
00308 #endif // THYRA_SPMD_VECTOR_BASE_DUMP
00309 
00310 }; // end class SpmdVectorBase
00311 
00312 } // end namespace Thyra
00313 
00314 #endif // THYRA_SPMD_VECTOR_BASE_DECL_HPP

Generated on Thu Sep 18 12:33:03 2008 for Thyra Package Browser (Single Doxygen Collection) by doxygen 1.3.9.1