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_SpmdVectorSpaceDefaultBase_decl.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 
00122   RTOpPack::SubVectorView<Scalar> getNonconstLocalSubVector();
00123 
00128   RTOpPack::ConstSubVectorView<Scalar> getLocalSubVector() const;
00129 
00154   virtual void getLocalData( Scalar** localValues, Index* stride ) = 0;
00155 
00170   virtual void commitLocalData( Scalar* localValues ) = 0;
00171 
00173 
00176 
00208   virtual void getLocalData( const Scalar** localValues, Index* stride ) const;
00209 
00226   virtual void freeLocalData( const Scalar* localValues ) const;
00227 
00233   virtual void applyOpImplWithComm(
00234     const Ptr<const Teuchos::Comm<Index> > &comm,
00235     const RTOpPack::RTOpT<Scalar> &op,
00236     const ArrayView<const Ptr<const VectorBase<Scalar> > > &vecs,
00237     const ArrayView<const Ptr<VectorBase<Scalar> > > &targ_vecs,
00238     const Ptr<RTOpPack::ReductTarget> &reduct_obj,
00239     const Index first_ele_offset,
00240     const Index sub_dim,
00241     const Index global_offset
00242     ) const;
00243 
00245 
00249   std::string description() const;
00251 
00254 
00256   Teuchos::RCP<const VectorSpaceBase<Scalar> > space() const;
00257 
00259 
00260 protected:
00261 
00264 
00267   void applyOpImpl(
00268     const RTOpPack::RTOpT<Scalar> &op,
00269     const ArrayView<const Ptr<const VectorBase<Scalar> > > &vecs,
00270     const ArrayView<const Ptr<VectorBase<Scalar> > > &targ_vecs,
00271     const Ptr<RTOpPack::ReductTarget> &reduct_obj,
00272     const Index first_ele_offset,
00273     const Index sub_dim,
00274     const Index global_offset
00275     ) const;
00277   void acquireDetachedVectorViewImpl(
00278     const Range1D& rng, RTOpPack::ConstSubVectorView<Scalar>* sub_vec
00279     ) const;
00281   void releaseDetachedVectorViewImpl(
00282     RTOpPack::ConstSubVectorView<Scalar>* sub_vec
00283     ) const;
00285   void acquireNonconstDetachedVectorViewImpl(
00286     const Range1D& rng, RTOpPack::SubVectorView<Scalar>* sub_vec
00287     );
00289   void commitNonconstDetachedVectorViewImpl(
00290     RTOpPack::SubVectorView<Scalar>* sub_vec
00291     );
00292 
00294 
00297 
00301   virtual void updateSpmdSpace();
00302 
00304 
00305 private:
00306 
00307   // ///////////////////////////////////////
00308   // Private data members
00309   
00310   mutable bool in_applyOpImpl_;
00311 
00312   // Cached (only on vector space!)
00313   mutable Index  globalDim_;
00314   mutable Index  localOffset_;
00315   mutable Index  localSubDim_;
00316 
00317   // /////////////////////////////////////
00318   // Private member functions
00319 
00320   Range1D validateRange( const Range1D& rng_in ) const;
00321 
00322 #ifdef THYRA_SPMD_VECTOR_BASE_DUMP
00323 public:
00324   static bool show_dump;
00325 #endif // THYRA_SPMD_VECTOR_BASE_DUMP
00326 
00327 }; // end class SpmdVectorBase
00328 
00329 
00330 } // end namespace Thyra
00331 
00332 
00333 #endif // THYRA_SPMD_VECTOR_BASE_DECL_HPP

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