Thyra_DefaultMultiVectorProductVectorDecl.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_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;
00144 
00146 
00147 protected:
00148 
00151 
00153   void applyOpImpl(
00154     const RTOpPack::RTOpT<Scalar> &op,
00155     const ArrayView<const Ptr<const VectorBase<Scalar> > > &vecs,
00156     const ArrayView<const Ptr<VectorBase<Scalar> > > &targ_vecs,
00157     const Ptr<RTOpPack::ReductTarget> &reduct_obj,
00158     const Index first_ele_offset,
00159     const Index sub_dim,
00160     const Index global_offset
00161     ) const;
00163   void acquireDetachedVectorViewImpl(
00164     const Range1D& rng, RTOpPack::ConstSubVectorView<Scalar>* sub_vec
00165     ) const;
00167   void releaseDetachedVectorViewImpl(
00168     RTOpPack::ConstSubVectorView<Scalar>* sub_vec
00169     ) const;
00171   void acquireNonconstDetachedVectorViewImpl(
00172     const Range1D& rng, RTOpPack::SubVectorView<Scalar>* sub_vec
00173     );
00175   void commitNonconstDetachedVectorViewImpl(
00176     RTOpPack::SubVectorView<Scalar>* sub_vec
00177     );
00179   void setSubVectorImpl(
00180     const RTOpPack::SparseSubVectorT<Scalar>& sub_vec
00181     );
00182 
00184 
00185 private:
00186 
00187   // //////////////////////////////
00188   // Private types
00189 
00190   typedef Teuchos::ConstNonconstObjectContainer<MultiVectorBase<Scalar> > CNMVC;
00191 
00192   // //////////////////////////////
00193   // Private data members
00194 
00195   int numBlocks_;
00196   RCP<const DefaultMultiVectorProductVectorSpace<Scalar> > productSpace_;
00197   CNMVC multiVec_;
00198 
00199   // //////////////////////////////
00200   // Private member functions
00201 
00202   RCP<const DefaultProductVector<Scalar> >
00203   getDefaultProductVector() const;
00204 
00205 };
00206 
00207 
00213 template<class Scalar>
00214 inline
00215 RCP<DefaultMultiVectorProductVector<Scalar> >
00216 multiVectorProductVector(
00217   const RCP<const DefaultMultiVectorProductVectorSpace<Scalar> > &productSpace,
00218   const RCP<MultiVectorBase<Scalar> > &multiVec
00219   )
00220 {
00221   RCP<DefaultMultiVectorProductVector<Scalar> > multiVecProdVec
00222     = Teuchos::rcp(new DefaultMultiVectorProductVector<Scalar>());
00223   multiVecProdVec->initialize(productSpace,multiVec);
00224   return multiVecProdVec;
00225 }
00226 
00227 
00233 template<class Scalar>
00234 inline
00235 RCP<const DefaultMultiVectorProductVector<Scalar> >
00236 multiVectorProductVector(
00237   const RCP<const DefaultMultiVectorProductVectorSpace<Scalar> > &productSpace,
00238   const RCP<const MultiVectorBase<Scalar> > &multiVec
00239   )
00240 {
00241   RCP<DefaultMultiVectorProductVector<Scalar> > multiVecProdVec
00242     = Teuchos::rcp(new DefaultMultiVectorProductVector<Scalar>());
00243   multiVecProdVec->initialize(productSpace,multiVec);
00244   return multiVecProdVec;
00245 }
00246 
00247 
00248 // ToDo: Add non-const and const versions of the nonmember constructor
00249 // functions to wrap already created multi-vectors once needed!
00250 
00251 
00257 template<class Scalar>
00258 inline
00259 RCP<DefaultMultiVectorProductVector<Scalar> >
00260 multiVectorProductVector(
00261   const RCP<const DefaultMultiVectorProductVectorSpace<Scalar> > &productSpace
00262   )
00263 {
00264 #ifdef TEUCHOS_DEBUG
00265   TEST_FOR_EXCEPT(is_null(productSpace));
00266 #endif
00267   return multiVectorProductVector(
00268     productSpace,
00269     createMembers(productSpace->getBlock(0),productSpace->numBlocks())
00270     );
00271 }
00272 
00273 
00274 } // namespace Thyra
00275 
00276 
00277 #endif // THYRA_MULTI_VECTOR_PRODUCT_VECTOR_DECL_HPP

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