Thyra_DefaultProductVectorDecl.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_PRODUCT_VECTOR_DECL_HPP
00030 #define THYRA_PRODUCT_VECTOR_DECL_HPP
00031 
00032 #include "Thyra_ProductVectorBase.hpp"
00033 #include "Thyra_VectorDefaultBase.hpp"
00034 #include "Teuchos_ConstNonconstObjectContainer.hpp"
00035 #include "Teuchos_as.hpp"
00036 
00037 
00038 namespace Thyra {
00039 
00040 
00042 template <class Scalar> class DefaultProductVectorSpace;
00043 
00044 
00058 template<class Scalar>
00059 class DefaultProductVector
00060   : virtual public ProductVectorBase<Scalar>,
00061     virtual protected VectorDefaultBase<Scalar>
00062 {
00063 public:
00064 
00067 
00069   DefaultProductVector(
00070     const Teuchos::RCP<const DefaultProductVectorSpace<Scalar> >  &productSpace
00071     );
00072 
00074   DefaultProductVector(
00075     const Teuchos::RCP<const DefaultProductVectorSpace<Scalar> >  &productSpace
00076     ,const Teuchos::RCP<VectorBase<Scalar> >                      vecs[]
00077     );
00078 
00080   DefaultProductVector(
00081     const Teuchos::RCP<const DefaultProductVectorSpace<Scalar> >  &productSpace
00082     ,const Teuchos::RCP<const VectorBase<Scalar> >                vecs[]
00083     );
00084 
00089   void initialize(
00090     const Teuchos::RCP<const DefaultProductVectorSpace<Scalar> >  &productSpace
00091     );
00092 
00097   void initialize(
00098     const Teuchos::RCP<const DefaultProductVectorSpace<Scalar> >  &productSpace
00099     ,const Teuchos::RCP<VectorBase<Scalar> >                      vecs[]
00100     );
00101 
00106   void initialize(
00107     const Teuchos::RCP<const DefaultProductVectorSpace<Scalar> >  &productSpace
00108     ,const Teuchos::RCP<const VectorBase<Scalar> >                vecs[]
00109     );
00110 
00115   void uninitialize();
00116 
00118 
00121                                                 
00123   std::string description() const;
00124 
00126   void describe(
00127     Teuchos::FancyOStream &out,
00128     const Teuchos::EVerbosityLevel verbLevel
00129     ) const;
00130 
00132 
00135 
00137   Teuchos::RCP<VectorBase<Scalar> > getNonconstVectorBlock(const int k); 
00139   Teuchos::RCP<const VectorBase<Scalar> > getVectorBlock(const int k) const;
00140 
00142 
00146   void setBlock(int i, const Teuchos::RCP<const VectorBase<Scalar> >& b); 
00148   void setNonconstBlock(int i, const Teuchos::RCP<VectorBase<Scalar> >& b); 
00150 
00153 
00155   Teuchos::RCP<const ProductVectorSpaceBase<Scalar> > productSpace() const;
00157   bool blockIsConst(const int k) const; 
00159   Teuchos::RCP<MultiVectorBase<Scalar> >
00160   getNonconstMultiVectorBlock(const int k);
00162   Teuchos::RCP<const MultiVectorBase<Scalar> >
00163   getMultiVectorBlock(const int k) const;
00164 
00166 
00169 
00171   Teuchos::RCP< const VectorSpaceBase<Scalar> > space() const;
00173   void applyOp(
00174     const RTOpPack::RTOpT<Scalar>    &op
00175     ,const int                       num_vecs
00176     ,const VectorBase<Scalar>*const  vecs[]
00177     ,const int                       num_targ_vecs
00178     ,VectorBase<Scalar>*const        targ_vecs[]
00179     ,RTOpPack::ReductTarget          *reduct_obj
00180     ,const Index                     first_ele
00181     ,const Index                     sub_dim
00182     ,const Index                     global_offset
00183     ) const;
00185   void acquireDetachedVectorViewImpl(
00186     const Range1D& rng, RTOpPack::ConstSubVectorView<Scalar>* sub_vec
00187     ) const;
00189   void releaseDetachedVectorViewImpl(
00190     RTOpPack::ConstSubVectorView<Scalar>* sub_vec
00191     ) const;
00193   void acquireNonconstDetachedVectorViewImpl(
00194     const Range1D& rng, RTOpPack::SubVectorView<Scalar>* sub_vec
00195     );
00197   void commitNonconstDetachedVectorViewImpl(
00198     RTOpPack::SubVectorView<Scalar>* sub_vec
00199     );
00201   void setSubVector(
00202     const RTOpPack::SparseSubVectorT<Scalar>& sub_vec
00203     );
00204 
00206 
00207 private:
00208 
00209   // //////////////////////////////
00210   // Private types
00211 
00212   typedef Teuchos::ConstNonconstObjectContainer<VectorBase<Scalar> > CNVC;
00213 
00214   // //////////////////////////////
00215   // Private data members
00216 
00217   Teuchos::RCP<const DefaultProductVectorSpace<Scalar> >  productSpace_;
00218   Teuchos::Array<CNVC> vecs_;
00219   // cache
00220   int numBlocks_;
00221 
00222 protected:
00223 
00224   // //////////////////////////////
00225   // Protected member functions
00226 
00227   // Added to allow TSFExtended DefaultProductVector to derive from this.
00228   DefaultProductVector();
00229 
00230 };
00231 
00232 
00237 template<class Scalar>
00238 inline
00239 Teuchos::RCP<DefaultProductVector<Scalar> >
00240 defaultProductVector(
00241   const Teuchos::RCP<const DefaultProductVectorSpace<Scalar> > &productSpace
00242   )
00243 {
00244   return Teuchos::rcp(
00245     new DefaultProductVector<Scalar>(productSpace)
00246     );
00247 }
00248 
00249 
00254 template<class Scalar>
00255 Teuchos::RCP<DefaultProductVector<Scalar> >
00256 defaultProductVector(
00257   const Teuchos::RCP<const DefaultProductVectorSpace<Scalar> > &productSpace,
00258   const Teuchos::RCP<VectorBase<Scalar> > vecs[]
00259   )
00260 {
00261   return Teuchos::rcp(
00262     new DefaultProductVector<Scalar>(productSpace,vecs)
00263     );
00264 }
00265 
00266 
00271 template<class Scalar>
00272 Teuchos::RCP<DefaultProductVector<Scalar> >
00273 defaultProductVector(
00274   const Teuchos::RCP<const DefaultProductVectorSpace<Scalar> > &productSpace,
00275   const Teuchos::RCP<const VectorBase<Scalar> > vecs[]
00276   )
00277 {
00278   return Teuchos::rcp(
00279     new DefaultProductVector<Scalar>(productSpace,vecs)
00280     );
00281 }
00282 
00283 
00288 template<class Scalar>
00289 Teuchos::RCP<DefaultProductVector<Scalar> >
00290 defaultProductVector(
00291   const Teuchos::RCP<const DefaultProductVectorSpace<Scalar> > &productSpace,
00292   const Teuchos::Array<Teuchos::RCP<const VectorBase<Scalar> > > &vecs
00293   )
00294 {
00295 #ifdef TEUCHOS_DEBUG
00296   TEST_FOR_EXCEPT( Teuchos::as<int>(vecs.size()) != productSpace->numBlocks() );
00297 #endif
00298   return defaultProductVector(productSpace,&vecs[0]);
00299 }
00300 
00301 
00302 } // namespace Thyra
00303 
00304 
00305 #endif // THYRA_PRODUCT_VECTOR_DECL_HPP

Generated on Tue Oct 20 12:47:25 2009 for Thyra Package Browser (Single Doxygen Collection) by doxygen 1.4.7