Thyra_DefaultMultiVectorProductVectorDecl.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_MULTI_VECTOR_PRODUCT_VECTOR_DECL_HPP
00030 #define THYRA_MULTI_VECTOR_PRODUCT_VECTOR_DECL_HPP
00031 
00032 
00033 #include "Thyra_ProductVectorBase.hpp" // Interface
00034 #include "Thyra_VectorDefaultBase.hpp" // Implementation
00035 #include "Thyra_DefaultProductVector.hpp"
00036 #include "Teuchos_ConstNonconstObjectContainer.hpp"
00037 
00038 
00039 namespace Thyra {
00040 
00041 
00042 template<class Scalar> class DefaultMultiVectorProductVectorSpace;
00043 
00044 
00056 template<class Scalar>
00057 class DefaultMultiVectorProductVector
00058   : virtual public ProductVectorBase<Scalar>,
00059     virtual protected VectorDefaultBase<Scalar>
00060 {
00061 public:
00062 
00065 
00067   DefaultMultiVectorProductVector();
00068 
00070   void initialize(
00071     const RCP<const DefaultMultiVectorProductVectorSpace<Scalar> > &productSpace,
00072     const RCP<MultiVectorBase<Scalar> > &multiVec
00073     );
00074 
00076   void initialize(
00077     const RCP<const DefaultMultiVectorProductVectorSpace<Scalar> > &productSpace,
00078     const RCP<const MultiVectorBase<Scalar> > &multiVec
00079     );
00080 
00081   // ToDo: Add const version of above function also when needed!
00082 
00084   RCP<MultiVectorBase<Scalar> >
00085   getNonconstMultiVector();
00086 
00088   RCP<const MultiVectorBase<Scalar> >
00089   getMultiVector() const;
00090 
00092   void uninitialize();
00093 
00095 
00098                                                 
00100   std::string description() const;
00101 
00103   void describe(
00104     Teuchos::FancyOStream &out,
00105     const Teuchos::EVerbosityLevel verbLevel
00106     ) const;
00107 
00109 
00112 
00114   RCP<VectorBase<Scalar> >
00115   getNonconstVectorBlock(const int k); 
00117   RCP<const VectorBase<Scalar> >
00118   getVectorBlock(const int k) const;
00119 
00121 
00124 
00126   RCP<const ProductVectorSpaceBase<Scalar> >
00127   productSpace() const;
00129   bool blockIsConst(const int k) const; 
00131   RCP<MultiVectorBase<Scalar> >
00132   getNonconstMultiVectorBlock(const int k);
00134   RCP<const MultiVectorBase<Scalar> >
00135   getMultiVectorBlock(const int k) const;
00136 
00138 
00141 
00143   RCP< const VectorSpaceBase<Scalar> > space() const;
00145   void applyOp(
00146     const RTOpPack::RTOpT<Scalar> &op,
00147     const int num_vecs,
00148     const VectorBase<Scalar>*const vecs[],
00149     const int num_targ_vecs,
00150     VectorBase<Scalar>*const targ_vecs[],
00151     RTOpPack::ReductTarget *reduct_obj,
00152     const Index first_ele,
00153     const Index sub_dim,
00154     const Index global_offset
00155     ) const;
00157   void acquireDetachedVectorViewImpl(
00158     const Range1D& rng, RTOpPack::ConstSubVectorView<Scalar>* sub_vec
00159     ) const;
00161   void releaseDetachedVectorViewImpl(
00162     RTOpPack::ConstSubVectorView<Scalar>* sub_vec
00163     ) const;
00165   void acquireNonconstDetachedVectorViewImpl(
00166     const Range1D& rng, RTOpPack::SubVectorView<Scalar>* sub_vec
00167     );
00169   void commitNonconstDetachedVectorViewImpl(
00170     RTOpPack::SubVectorView<Scalar>* sub_vec
00171     );
00173   void setSubVector(
00174     const RTOpPack::SparseSubVectorT<Scalar>& sub_vec
00175     );
00176 
00178 
00179 private:
00180 
00181   // //////////////////////////////
00182   // Private types
00183 
00184   typedef Teuchos::ConstNonconstObjectContainer<MultiVectorBase<Scalar> > CNMVC;
00185 
00186   // //////////////////////////////
00187   // Private data members
00188 
00189   int numBlocks_;
00190   RCP<const DefaultMultiVectorProductVectorSpace<Scalar> > productSpace_;
00191   CNMVC multiVec_;
00192 
00193   // //////////////////////////////
00194   // Private member functions
00195 
00196   RCP<const DefaultProductVector<Scalar> >
00197   getDefaultProductVector() const;
00198 
00199 };
00200 
00201 
00207 template<class Scalar>
00208 inline
00209 RCP<DefaultMultiVectorProductVector<Scalar> >
00210 multiVectorProductVector(
00211   const RCP<const DefaultMultiVectorProductVectorSpace<Scalar> > &productSpace,
00212   const RCP<MultiVectorBase<Scalar> > &multiVec
00213   )
00214 {
00215   RCP<DefaultMultiVectorProductVector<Scalar> > multiVecProdVec
00216     = Teuchos::rcp(new DefaultMultiVectorProductVector<Scalar>());
00217   multiVecProdVec->initialize(productSpace,multiVec);
00218   return multiVecProdVec;
00219 }
00220 
00221 
00227 template<class Scalar>
00228 inline
00229 RCP<const DefaultMultiVectorProductVector<Scalar> >
00230 multiVectorProductVector(
00231   const RCP<const DefaultMultiVectorProductVectorSpace<Scalar> > &productSpace,
00232   const RCP<const MultiVectorBase<Scalar> > &multiVec
00233   )
00234 {
00235   RCP<DefaultMultiVectorProductVector<Scalar> > multiVecProdVec
00236     = Teuchos::rcp(new DefaultMultiVectorProductVector<Scalar>());
00237   multiVecProdVec->initialize(productSpace,multiVec);
00238   return multiVecProdVec;
00239 }
00240 
00241 
00242 // ToDo: Add non-const and const versions of the nonmember constructor
00243 // functions to wrap already created multi-vectors once needed!
00244 
00245 
00251 template<class Scalar>
00252 inline
00253 RCP<DefaultMultiVectorProductVector<Scalar> >
00254 multiVectorProductVector(
00255   const RCP<const DefaultMultiVectorProductVectorSpace<Scalar> > &productSpace
00256   )
00257 {
00258 #ifdef TEUCHOS_DEBUG
00259   TEST_FOR_EXCEPT(is_null(productSpace));
00260 #endif
00261   return multiVectorProductVector(
00262     productSpace,
00263     createMembers(productSpace->getBlock(0),productSpace->numBlocks())
00264     );
00265 }
00266 
00267 
00268 } // namespace Thyra
00269 
00270 
00271 #endif // THYRA_MULTI_VECTOR_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