|
Thyra Package Browser (Single Doxygen Collection) Version of the Day
|
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 Ordinal global_offset 00179 ) const; 00181 void acquireDetachedVectorViewImpl( 00182 const Range1D& rng, RTOpPack::ConstSubVectorView<Scalar>* sub_vec 00183 ) const; 00185 void releaseDetachedVectorViewImpl( 00186 RTOpPack::ConstSubVectorView<Scalar>* sub_vec 00187 ) const; 00189 void acquireNonconstDetachedVectorViewImpl( 00190 const Range1D& rng, RTOpPack::SubVectorView<Scalar>* sub_vec 00191 ); 00193 void commitNonconstDetachedVectorViewImpl( 00194 RTOpPack::SubVectorView<Scalar>* sub_vec 00195 ); 00197 void setSubVectorImpl( 00198 const RTOpPack::SparseSubVectorT<Scalar>& sub_vec 00199 ); 00200 00202 00203 public: 00204 00207 00209 DefaultProductVector( 00210 const RCP<const DefaultProductVectorSpace<Scalar> > &productSpace_in, 00211 const RCP<VectorBase<Scalar> > vecs[] 00212 ) 00213 :numBlocks_(0) 00214 { initialize(productSpace_in, vecs); } 00215 00217 void initialize( 00218 const RCP<const DefaultProductVectorSpace<Scalar> > &productSpace_in, 00219 const RCP<VectorBase<Scalar> > vecs[] 00220 ) 00221 { initialize(productSpace_in, Teuchos::arrayView(vecs, productSpace_in->numBlocks())); } 00222 00224 void initialize( 00225 const RCP<const DefaultProductVectorSpace<Scalar> > &productSpace_in, 00226 const RCP<const VectorBase<Scalar> > vecs[] 00227 ) 00228 { initialize(productSpace_in, Teuchos::arrayView(vecs, productSpace_in->numBlocks())); } 00229 00231 00232 private: 00233 00234 // ////////////////////////////// 00235 // Private types 00236 00237 typedef Teuchos::ConstNonconstObjectContainer<VectorBase<Scalar> > CNVC; 00238 00239 // ////////////////////////////// 00240 // Private data members 00241 00242 RCP<const DefaultProductVectorSpace<Scalar> > productSpace_; 00243 Array<CNVC> vecs_; 00244 // cache 00245 int numBlocks_; 00246 00247 }; 00248 00249 00254 template<class Scalar> 00255 inline 00256 RCP<DefaultProductVector<Scalar> > 00257 defaultProductVector() 00258 { 00259 return Teuchos::rcp(new DefaultProductVector<Scalar>); 00260 } 00261 00262 00267 template<class Scalar> 00268 inline 00269 RCP<DefaultProductVector<Scalar> > 00270 defaultProductVector( 00271 const RCP<const DefaultProductVectorSpace<Scalar> > &productSpace 00272 ) 00273 { 00274 return Teuchos::rcp( 00275 new DefaultProductVector<Scalar>(productSpace) 00276 ); 00277 } 00278 00279 00284 template<class Scalar> 00285 RCP<DefaultProductVector<Scalar> > 00286 defaultProductVector( 00287 const RCP<const DefaultProductVectorSpace<Scalar> > &productSpace, 00288 const ArrayView<const RCP<VectorBase<Scalar> > > &vecs 00289 ) 00290 { 00291 RCP<DefaultProductVector<Scalar> > pv = defaultProductVector<Scalar>(); 00292 pv->initialize(productSpace, vecs); 00293 return pv; 00294 } 00295 00296 00301 template<class Scalar> 00302 RCP<DefaultProductVector<Scalar> > 00303 defaultProductVector( 00304 const RCP<const DefaultProductVectorSpace<Scalar> > &productSpace, 00305 const ArrayView<const RCP<const VectorBase<Scalar> > > &vecs 00306 ) 00307 { 00308 RCP<DefaultProductVector<Scalar> > pv = defaultProductVector<Scalar>(); 00309 pv->initialize(productSpace, vecs); 00310 return pv; 00311 } 00312 00313 00319 template<class Scalar> 00320 RCP<ProductVectorBase<Scalar> > 00321 castOrCreateNonconstProductVectorBase(const RCP<VectorBase<Scalar> > v); 00322 00323 00329 template<class Scalar> 00330 RCP<const ProductVectorBase<Scalar> > 00331 castOrCreateProductVectorBase(const RCP<const VectorBase<Scalar> > v); 00332 00333 00335 template<class Scalar> 00336 RCP<DefaultProductVector<Scalar> > 00337 defaultProductVector( 00338 const RCP<const DefaultProductVectorSpace<Scalar> > &productSpace, 00339 const RCP<VectorBase<Scalar> > vecs[] 00340 ) 00341 { 00342 return Teuchos::rcp( 00343 new DefaultProductVector<Scalar>(productSpace,vecs) 00344 ); 00345 } 00346 00347 00349 template<class Scalar> 00350 RCP<DefaultProductVector<Scalar> > 00351 defaultProductVector( 00352 const RCP<const DefaultProductVectorSpace<Scalar> > &productSpace, 00353 const RCP<const VectorBase<Scalar> > vecs[] 00354 ) 00355 { 00356 return defaultProductVector<Scalar>(productSpace, 00357 Teuchos::arrayView(vecs, productSpace->numBlocks())); 00358 } 00359 00360 00361 } // namespace Thyra 00362 00363 00364 #endif // THYRA_DEFAULT_PRODUCT_VECTOR_DECL_HPP
1.7.4