Thyra_DefaultProductVector_decl.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_DEFAULT_PRODUCT_VECTOR_DECL_HPP
00030 #define THYRA_DEFAULT_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 
00072   DefaultProductVector(
00073     const RCP<const DefaultProductVectorSpace<Scalar> >  &productSpace
00074     );
00075 
00080   void initialize(
00081     const RCP<const DefaultProductVectorSpace<Scalar> > &productSpace
00082     );
00083 
00088   void initialize(
00089     const RCP<const DefaultProductVectorSpace<Scalar> > &productSpace,
00090     const ArrayView<const RCP<VectorBase<Scalar> > > &vecs
00091     );
00092 
00097   void initialize(
00098     const RCP<const DefaultProductVectorSpace<Scalar> > &productSpace,
00099     const ArrayView<const RCP<const VectorBase<Scalar> > > &vecs
00100     );
00101 
00106   void uninitialize();
00107 
00109 
00112  
00114   std::string description() const;
00115 
00117   void describe(
00118     Teuchos::FancyOStream &out,
00119     const Teuchos::EVerbosityLevel verbLevel
00120     ) const;
00121 
00123 
00126 
00128   void setBlock(int i, const RCP<const VectorBase<Scalar> >& b); 
00130   void setNonconstBlock(int i, const RCP<VectorBase<Scalar> >& b); 
00132 
00135 
00137   RCP<VectorBase<Scalar> > getNonconstVectorBlock(const int k); 
00139   RCP<const VectorBase<Scalar> > getVectorBlock(const int k) const;
00140 
00142 
00145 
00147   RCP<const ProductVectorSpaceBase<Scalar> > productSpace() const;
00149   bool blockIsConst(const int k) const; 
00151   RCP<MultiVectorBase<Scalar> >
00152   getNonconstMultiVectorBlock(const int k);
00154   RCP<const MultiVectorBase<Scalar> >
00155   getMultiVectorBlock(const int k) const;
00156 
00158 
00161 
00163   RCP< const VectorSpaceBase<Scalar> > space() const;
00164 
00166 
00167 protected:
00168 
00171 
00173   void applyOpImpl(
00174     const RTOpPack::RTOpT<Scalar> &op,
00175     const ArrayView<const Ptr<const VectorBase<Scalar> > > &vecs,
00176     const ArrayView<const Ptr<VectorBase<Scalar> > > &targ_vecs,
00177     const Ptr<RTOpPack::ReductTarget> &reduct_obj,
00178     const Index first_ele_offset,
00179     const Index sub_dim,
00180     const Index global_offset
00181     ) const;
00183   void acquireDetachedVectorViewImpl(
00184     const Range1D& rng, RTOpPack::ConstSubVectorView<Scalar>* sub_vec
00185     ) const;
00187   void releaseDetachedVectorViewImpl(
00188     RTOpPack::ConstSubVectorView<Scalar>* sub_vec
00189     ) const;
00191   void acquireNonconstDetachedVectorViewImpl(
00192     const Range1D& rng, RTOpPack::SubVectorView<Scalar>* sub_vec
00193     );
00195   void commitNonconstDetachedVectorViewImpl(
00196     RTOpPack::SubVectorView<Scalar>* sub_vec
00197     );
00199   void setSubVectorImpl(
00200     const RTOpPack::SparseSubVectorT<Scalar>& sub_vec
00201     );
00202 
00204 
00205 public:
00206 
00209 
00211   DefaultProductVector(
00212     const RCP<const DefaultProductVectorSpace<Scalar> > &productSpace_in,
00213     const RCP<VectorBase<Scalar> > vecs[]
00214     )
00215     :numBlocks_(0)
00216     { initialize(productSpace_in, vecs); }
00217 
00219   void initialize(
00220     const RCP<const DefaultProductVectorSpace<Scalar> > &productSpace_in,
00221     const RCP<VectorBase<Scalar> > vecs[]
00222     )
00223     { initialize(productSpace_in, Teuchos::arrayView(vecs, productSpace_in->numBlocks())); }
00224 
00226   void initialize(
00227     const RCP<const DefaultProductVectorSpace<Scalar> > &productSpace_in,
00228     const RCP<const VectorBase<Scalar> > vecs[]
00229     )
00230     { initialize(productSpace_in, Teuchos::arrayView(vecs, productSpace_in->numBlocks())); }
00231 
00233 
00234 private:
00235 
00236   // //////////////////////////////
00237   // Private types
00238 
00239   typedef Teuchos::ConstNonconstObjectContainer<VectorBase<Scalar> > CNVC;
00240 
00241   // //////////////////////////////
00242   // Private data members
00243 
00244   RCP<const DefaultProductVectorSpace<Scalar> > productSpace_;
00245   Array<CNVC> vecs_;
00246   // cache
00247   int numBlocks_;
00248 
00249 };
00250 
00251 
00256 template<class Scalar>
00257 inline
00258 RCP<DefaultProductVector<Scalar> >
00259 defaultProductVector()
00260 {
00261   return Teuchos::rcp(new DefaultProductVector<Scalar>);
00262 }
00263 
00264 
00269 template<class Scalar>
00270 inline
00271 RCP<DefaultProductVector<Scalar> >
00272 defaultProductVector(
00273   const RCP<const DefaultProductVectorSpace<Scalar> > &productSpace
00274   )
00275 {
00276   return Teuchos::rcp(
00277     new DefaultProductVector<Scalar>(productSpace)
00278     );
00279 }
00280 
00281 
00286 template<class Scalar>
00287 RCP<DefaultProductVector<Scalar> >
00288 defaultProductVector(
00289   const RCP<const DefaultProductVectorSpace<Scalar> > &productSpace,
00290   const ArrayView<const RCP<VectorBase<Scalar> > > &vecs
00291   )
00292 {
00293   RCP<DefaultProductVector<Scalar> > pv = defaultProductVector<Scalar>();
00294   pv->initialize(productSpace, vecs);
00295   return pv;
00296 }
00297 
00298 
00303 template<class Scalar>
00304 RCP<DefaultProductVector<Scalar> >
00305 defaultProductVector(
00306   const RCP<const DefaultProductVectorSpace<Scalar> > &productSpace,
00307   const ArrayView<const RCP<const VectorBase<Scalar> > > &vecs
00308   )
00309 {
00310   RCP<DefaultProductVector<Scalar> > pv = defaultProductVector<Scalar>();
00311   pv->initialize(productSpace, vecs);
00312   return pv;
00313 }
00314 
00315 
00317 template<class Scalar>
00318 RCP<DefaultProductVector<Scalar> >
00319 defaultProductVector(
00320   const RCP<const DefaultProductVectorSpace<Scalar> > &productSpace,
00321   const RCP<VectorBase<Scalar> > vecs[]
00322   )
00323 {
00324   return Teuchos::rcp(
00325     new DefaultProductVector<Scalar>(productSpace,vecs)
00326     );
00327 }
00328 
00329 
00331 template<class Scalar>
00332 RCP<DefaultProductVector<Scalar> >
00333 defaultProductVector(
00334   const RCP<const DefaultProductVectorSpace<Scalar> > &productSpace,
00335   const RCP<const VectorBase<Scalar> > vecs[]
00336   )
00337 {
00338   return defaultProductVector<Scalar>(productSpace,
00339     Teuchos::arrayView(vecs, productSpace->numBlocks()));
00340 }
00341 
00342 
00343 } // namespace Thyra
00344 
00345 
00346 #endif // THYRA_DEFAULT_PRODUCT_VECTOR_DECL_HPP

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