Thyra Version of the Day
Thyra_DefaultMultiVectorProductVector_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 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions are
00012 // met:
00013 //
00014 // 1. Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 //
00017 // 2. Redistributions in binary form must reproduce the above copyright
00018 // notice, this list of conditions and the following disclaimer in the
00019 // documentation and/or other materials provided with the distribution.
00020 //
00021 // 3. Neither the name of the Corporation nor the names of the
00022 // contributors may be used to endorse or promote products derived from
00023 // this software without specific prior written permission.
00024 //
00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 //
00037 // Questions? Contact Roscoe A. Bartlett (bartlettra@ornl.gov) 
00038 // 
00039 // ***********************************************************************
00040 // @HEADER
00041 
00042 #ifndef THYRA_MULTI_VECTOR_PRODUCT_VECTOR_DECL_HPP
00043 #define THYRA_MULTI_VECTOR_PRODUCT_VECTOR_DECL_HPP
00044 
00045 
00046 #include "Thyra_ProductVectorBase.hpp" // Interface
00047 #include "Thyra_VectorDefaultBase.hpp" // Implementation
00048 #include "Thyra_DefaultProductVector.hpp"
00049 #include "Teuchos_ConstNonconstObjectContainer.hpp"
00050 
00051 
00052 namespace Thyra {
00053 
00054 
00055 template<class Scalar> class DefaultMultiVectorProductVectorSpace;
00056 
00057 
00069 template<class Scalar>
00070 class DefaultMultiVectorProductVector
00071   : virtual public ProductVectorBase<Scalar>,
00072     virtual protected VectorDefaultBase<Scalar>
00073 {
00074 public:
00075 
00078 
00080   DefaultMultiVectorProductVector();
00081 
00083   void initialize(
00084     const RCP<const DefaultMultiVectorProductVectorSpace<Scalar> > &productSpace,
00085     const RCP<MultiVectorBase<Scalar> > &multiVec
00086     );
00087 
00089   void initialize(
00090     const RCP<const DefaultMultiVectorProductVectorSpace<Scalar> > &productSpace,
00091     const RCP<const MultiVectorBase<Scalar> > &multiVec
00092     );
00093 
00094   // ToDo: Add const version of above function also when needed!
00095 
00097   RCP<MultiVectorBase<Scalar> >
00098   getNonconstMultiVector();
00099 
00101   RCP<const MultiVectorBase<Scalar> >
00102   getMultiVector() const;
00103 
00105   void uninitialize();
00106 
00108 
00111                                                 
00113   std::string description() const;
00114 
00116   void describe(
00117     Teuchos::FancyOStream &out,
00118     const Teuchos::EVerbosityLevel verbLevel
00119     ) const;
00120 
00122 
00125 
00127   RCP<VectorBase<Scalar> >
00128   getNonconstVectorBlock(const int k); 
00130   RCP<const VectorBase<Scalar> >
00131   getVectorBlock(const int k) const;
00132 
00134 
00137 
00139   RCP<const ProductVectorSpaceBase<Scalar> >
00140   productSpace() const;
00142   bool blockIsConst(const int k) const; 
00144   RCP<MultiVectorBase<Scalar> >
00145   getNonconstMultiVectorBlock(const int k);
00147   RCP<const MultiVectorBase<Scalar> >
00148   getMultiVectorBlock(const int k) const;
00149 
00151 
00154 
00156   RCP< const VectorSpaceBase<Scalar> > space() const;
00157 
00159 
00160 protected:
00161 
00164 
00166   void applyOpImpl(
00167     const RTOpPack::RTOpT<Scalar> &op,
00168     const ArrayView<const Ptr<const VectorBase<Scalar> > > &vecs,
00169     const ArrayView<const Ptr<VectorBase<Scalar> > > &targ_vecs,
00170     const Ptr<RTOpPack::ReductTarget> &reduct_obj,
00171     const Ordinal global_offset
00172     ) const;
00174   void acquireDetachedVectorViewImpl(
00175     const Range1D& rng, RTOpPack::ConstSubVectorView<Scalar>* sub_vec
00176     ) const;
00178   void releaseDetachedVectorViewImpl(
00179     RTOpPack::ConstSubVectorView<Scalar>* sub_vec
00180     ) const;
00182   void acquireNonconstDetachedVectorViewImpl(
00183     const Range1D& rng, RTOpPack::SubVectorView<Scalar>* sub_vec
00184     );
00186   void commitNonconstDetachedVectorViewImpl(
00187     RTOpPack::SubVectorView<Scalar>* sub_vec
00188     );
00190   void setSubVectorImpl(
00191     const RTOpPack::SparseSubVectorT<Scalar>& sub_vec
00192     );
00193 
00195 
00196 private:
00197 
00198   // //////////////////////////////
00199   // Private types
00200 
00201   typedef Teuchos::ConstNonconstObjectContainer<MultiVectorBase<Scalar> > CNMVC;
00202 
00203   // //////////////////////////////
00204   // Private data members
00205 
00206   int numBlocks_;
00207   RCP<const DefaultMultiVectorProductVectorSpace<Scalar> > productSpace_;
00208   CNMVC multiVec_;
00209 
00210   // //////////////////////////////
00211   // Private member functions
00212 
00213   RCP<const DefaultProductVector<Scalar> >
00214   getDefaultProductVector() const;
00215 
00216 };
00217 
00218 
00224 template<class Scalar>
00225 inline
00226 RCP<DefaultMultiVectorProductVector<Scalar> >
00227 multiVectorProductVector(
00228   const RCP<const DefaultMultiVectorProductVectorSpace<Scalar> > &productSpace,
00229   const RCP<MultiVectorBase<Scalar> > &multiVec
00230   )
00231 {
00232   RCP<DefaultMultiVectorProductVector<Scalar> > multiVecProdVec
00233     = Teuchos::rcp(new DefaultMultiVectorProductVector<Scalar>());
00234   multiVecProdVec->initialize(productSpace,multiVec);
00235   return multiVecProdVec;
00236 }
00237 
00238 
00244 template<class Scalar>
00245 inline
00246 RCP<const DefaultMultiVectorProductVector<Scalar> >
00247 multiVectorProductVector(
00248   const RCP<const DefaultMultiVectorProductVectorSpace<Scalar> > &productSpace,
00249   const RCP<const MultiVectorBase<Scalar> > &multiVec
00250   )
00251 {
00252   RCP<DefaultMultiVectorProductVector<Scalar> > multiVecProdVec
00253     = Teuchos::rcp(new DefaultMultiVectorProductVector<Scalar>());
00254   multiVecProdVec->initialize(productSpace,multiVec);
00255   return multiVecProdVec;
00256 }
00257 
00258 
00259 // ToDo: Add non-const and const versions of the nonmember constructor
00260 // functions to wrap already created multi-vectors once needed!
00261 
00262 
00268 template<class Scalar>
00269 inline
00270 RCP<DefaultMultiVectorProductVector<Scalar> >
00271 multiVectorProductVector(
00272   const RCP<const DefaultMultiVectorProductVectorSpace<Scalar> > &productSpace
00273   )
00274 {
00275 #ifdef TEUCHOS_DEBUG
00276   TEUCHOS_TEST_FOR_EXCEPT(is_null(productSpace));
00277 #endif
00278   return multiVectorProductVector(
00279     productSpace,
00280     createMembers(productSpace->getBlock(0),productSpace->numBlocks())
00281     );
00282 }
00283 
00284 
00285 } // namespace Thyra
00286 
00287 
00288 #endif // THYRA_MULTI_VECTOR_PRODUCT_VECTOR_DECL_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines