|
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_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 Ordinal global_offset 00159 ) const; 00161 void acquireDetachedVectorViewImpl( 00162 const Range1D& rng, RTOpPack::ConstSubVectorView<Scalar>* sub_vec 00163 ) const; 00165 void releaseDetachedVectorViewImpl( 00166 RTOpPack::ConstSubVectorView<Scalar>* sub_vec 00167 ) const; 00169 void acquireNonconstDetachedVectorViewImpl( 00170 const Range1D& rng, RTOpPack::SubVectorView<Scalar>* sub_vec 00171 ); 00173 void commitNonconstDetachedVectorViewImpl( 00174 RTOpPack::SubVectorView<Scalar>* sub_vec 00175 ); 00177 void setSubVectorImpl( 00178 const RTOpPack::SparseSubVectorT<Scalar>& sub_vec 00179 ); 00180 00182 00183 private: 00184 00185 // ////////////////////////////// 00186 // Private types 00187 00188 typedef Teuchos::ConstNonconstObjectContainer<MultiVectorBase<Scalar> > CNMVC; 00189 00190 // ////////////////////////////// 00191 // Private data members 00192 00193 int numBlocks_; 00194 RCP<const DefaultMultiVectorProductVectorSpace<Scalar> > productSpace_; 00195 CNMVC multiVec_; 00196 00197 // ////////////////////////////// 00198 // Private member functions 00199 00200 RCP<const DefaultProductVector<Scalar> > 00201 getDefaultProductVector() const; 00202 00203 }; 00204 00205 00211 template<class Scalar> 00212 inline 00213 RCP<DefaultMultiVectorProductVector<Scalar> > 00214 multiVectorProductVector( 00215 const RCP<const DefaultMultiVectorProductVectorSpace<Scalar> > &productSpace, 00216 const RCP<MultiVectorBase<Scalar> > &multiVec 00217 ) 00218 { 00219 RCP<DefaultMultiVectorProductVector<Scalar> > multiVecProdVec 00220 = Teuchos::rcp(new DefaultMultiVectorProductVector<Scalar>()); 00221 multiVecProdVec->initialize(productSpace,multiVec); 00222 return multiVecProdVec; 00223 } 00224 00225 00231 template<class Scalar> 00232 inline 00233 RCP<const DefaultMultiVectorProductVector<Scalar> > 00234 multiVectorProductVector( 00235 const RCP<const DefaultMultiVectorProductVectorSpace<Scalar> > &productSpace, 00236 const RCP<const MultiVectorBase<Scalar> > &multiVec 00237 ) 00238 { 00239 RCP<DefaultMultiVectorProductVector<Scalar> > multiVecProdVec 00240 = Teuchos::rcp(new DefaultMultiVectorProductVector<Scalar>()); 00241 multiVecProdVec->initialize(productSpace,multiVec); 00242 return multiVecProdVec; 00243 } 00244 00245 00246 // ToDo: Add non-const and const versions of the nonmember constructor 00247 // functions to wrap already created multi-vectors once needed! 00248 00249 00255 template<class Scalar> 00256 inline 00257 RCP<DefaultMultiVectorProductVector<Scalar> > 00258 multiVectorProductVector( 00259 const RCP<const DefaultMultiVectorProductVectorSpace<Scalar> > &productSpace 00260 ) 00261 { 00262 #ifdef TEUCHOS_DEBUG 00263 TEST_FOR_EXCEPT(is_null(productSpace)); 00264 #endif 00265 return multiVectorProductVector( 00266 productSpace, 00267 createMembers(productSpace->getBlock(0),productSpace->numBlocks()) 00268 ); 00269 } 00270 00271 00272 } // namespace Thyra 00273 00274 00275 #endif // THYRA_MULTI_VECTOR_PRODUCT_VECTOR_DECL_HPP
1.7.4