00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
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"
00034 #include "Thyra_VectorDefaultBase.hpp"
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
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
00189
00190 typedef Teuchos::ConstNonconstObjectContainer<MultiVectorBase<Scalar> > CNMVC;
00191
00192
00193
00194
00195 int numBlocks_;
00196 RCP<const DefaultMultiVectorProductVectorSpace<Scalar> > productSpace_;
00197 CNMVC multiVec_;
00198
00199
00200
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
00249
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 }
00275
00276
00277 #endif // THYRA_MULTI_VECTOR_PRODUCT_VECTOR_DECL_HPP