Thyra  Version of the Day
Thyra_DefaultProductMultiVector_decl.hpp
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Thyra: Interfaces and Support for Abstract Numerical Algorithms
5 // Copyright (2004) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Roscoe A. Bartlett (bartlettra@ornl.gov)
38 //
39 // ***********************************************************************
40 // @HEADER
41 
42 #ifndef THYRA_DEFAULT_PRODUCT_MULTI_VECTOR_DECL_HPP
43 #define THYRA_DEFAULT_PRODUCT_MULTI_VECTOR_DECL_HPP
44 
45 #include "Thyra_ProductMultiVectorBase.hpp"
46 #include "Thyra_MultiVectorDefaultBase.hpp"
47 #include "Teuchos_ConstNonconstObjectContainer.hpp"
48 
49 
50 namespace Thyra {
51 
52 
54 template <class Scalar> class DefaultProductVectorSpace;
55 
56 
70 template<class Scalar>
72  : virtual public ProductMultiVectorBase<Scalar>,
73  virtual protected MultiVectorDefaultBase<Scalar>
74 {
75 public:
76 
79 
82 
84  void initialize(
86  const int numMembers
87  );
88 
90  void initialize(
92  const ArrayView<const RCP<MultiVectorBase<Scalar> > > &multiVecs
93  );
94 
96  void initialize(
98  const ArrayView<const RCP<const MultiVectorBase<Scalar> > > &multiVecs
99  );
100 
105  void uninitialize();
106 
108 
111 
113  std::string description() const;
114 
116  void describe(
117  Teuchos::FancyOStream &out,
118  const Teuchos::EVerbosityLevel verbLevel
119  ) const;
120 
122 
125 
127  RCP<const ProductVectorSpaceBase<Scalar> >
128  productSpace() const;
130  bool blockIsConst(const int k) const;
132  RCP<MultiVectorBase<Scalar> >
133  getNonconstMultiVectorBlock(const int k);
135  RCP<const MultiVectorBase<Scalar> >
136  getMultiVectorBlock(const int k) const;
137 
139 
143  RCP<MultiVectorBase<Scalar> > clone_mv() const;
144 
146 
149 
151  RCP< const VectorSpaceBase<Scalar> >
152  range() const;
154  RCP< const VectorSpaceBase<Scalar> >
155  domain() const;
156 
158 
159 protected:
160 
163 
165  void assignImpl(Scalar alpha);
167  RCP<const VectorBase<Scalar> > colImpl(Ordinal j) const;
169  RCP<VectorBase<Scalar> > nonconstColImpl(Ordinal j);
171  RCP<const MultiVectorBase<Scalar> >
172  contigSubViewImpl( const Range1D& colRng ) const;
174  RCP<MultiVectorBase<Scalar> >
175  nonconstContigSubViewImpl( const Range1D& colRng );
177  RCP<const MultiVectorBase<Scalar> >
178  nonContigSubViewImpl( const ArrayView<const int> &cols ) const;
180  RCP<MultiVectorBase<Scalar> >
181  nonconstNonContigSubViewImpl( const ArrayView<const int> &cols );
184  const RTOpPack::RTOpT<Scalar> &primary_op,
185  const ArrayView<const Ptr<const MultiVectorBase<Scalar> > > &multi_vecs,
186  const ArrayView<const Ptr<MultiVectorBase<Scalar> > > &targ_multi_vecs,
187  const ArrayView<const Ptr<RTOpPack::ReductTarget> > &reduct_objs,
188  const Ordinal primary_global_offset
189  ) const;
192  const Range1D &rowRng,
193  const Range1D &colRng,
195  ) const;
199  ) const;
202  const Range1D &rowRng,
203  const Range1D &colRng,
205  );
209  );
210 
212 
215 
217  bool opSupportedImpl(EOpTransp M_trans) const;
218 
220  void applyImpl(
221  const EOpTransp M_trans,
222  const MultiVectorBase<Scalar> &X,
223  const Ptr<MultiVectorBase<Scalar> > &Y,
224  const Scalar alpha,
225  const Scalar beta
226  ) const;
227 
229 
230 public:
231 
232 private:
233 
234  // //////////////////////////////
235  // Private types
236 
237  typedef Teuchos::ConstNonconstObjectContainer<MultiVectorBase<Scalar> > CNMVC;
238 
239  // //////////////////////////////
240  // Private data members
241 
242  RCP<const DefaultProductVectorSpace<Scalar> > productSpace_;
243  Teuchos::Array<CNMVC> multiVecs_;
244  // cache
245  int numBlocks_;
246 
247  // //////////////////////////////
248  // Private member functions
249 
250  template<class MultiVectorType>
251  void initializeImpl(
253  const ArrayView<const RCP<MultiVectorType> > &multiVecs
254  );
255 
256  void assertInitialized() const;
257 
258  void validateColIndex(const int j) const;
259 
260 };
261 
262 
267 template<class Scalar>
268 RCP<DefaultProductMultiVector<Scalar> >
269 defaultProductMultiVector();
270 
271 
276 template<class Scalar>
277 RCP<DefaultProductMultiVector<Scalar> >
278 defaultProductMultiVector(
279  const RCP<const DefaultProductVectorSpace<Scalar> > &productSpace,
280  const int numMembers
281  );
282 
283 
288 template<class Scalar>
289 RCP<DefaultProductMultiVector<Scalar> >
290 defaultProductMultiVector(
291  const RCP<const DefaultProductVectorSpace<Scalar> > &productSpace,
292  const ArrayView<const RCP<MultiVectorBase<Scalar> > > &multiVecs
293  );
294 
295 
300 template<class Scalar>
301 RCP<DefaultProductMultiVector<Scalar> >
302 defaultProductMultiVector(
303  const RCP<const DefaultProductVectorSpace<Scalar> > &productSpace,
304  const ArrayView<const RCP<const MultiVectorBase<Scalar> > > &multiVecs
305  );
306 
307 
314 template<class Scalar>
315 RCP<const ProductMultiVectorBase<Scalar> >
316 castOrCreateSingleBlockProductMultiVector(
317  const RCP<const DefaultProductVectorSpace<Scalar> > &productSpace,
318  const RCP<const MultiVectorBase<Scalar> > &mv
319  );
320 
321 
328 template<class Scalar>
329 RCP<ProductMultiVectorBase<Scalar> >
330 nonconstCastOrCreateSingleBlockProductMultiVector(
331  const RCP<const DefaultProductVectorSpace<Scalar> > &productSpace,
332  const RCP<MultiVectorBase<Scalar> > &mv
333  );
334 
335 
336 // /////////////////////////
337 // Inline members
338 
339 
340 #ifndef TEUCHOS_DEBUG
341 
342 
343 template<class Scalar>
344 inline
346 {}
347 
348 
349 template<class Scalar>
350 inline
351 void DefaultProductMultiVector<Scalar>::validateColIndex(const int j) const
352 {}
353 
354 
355 #endif // TEUCHOS_DEBUG
356 
357 
358 } // namespace Thyra
359 
360 
361 #endif // THYRA_DEFAULT_PRODUCT_MULTI_VECTOR_DECL_HPP
Base interface for product multi-vectors.
EOpTransp
Enumeration for determining how a linear operator is applied. `*.
void releaseDetachedMultiVectorViewImpl(RTOpPack::ConstSubMultiVectorView< Scalar > *sub_mv) const
void mvMultiReductApplyOpImpl(const RTOpPack::RTOpT< Scalar > &primary_op, const ArrayView< const Ptr< const MultiVectorBase< Scalar > > > &multi_vecs, const ArrayView< const Ptr< MultiVectorBase< Scalar > > > &targ_multi_vecs, const ArrayView< const Ptr< RTOpPack::ReductTarget > > &reduct_objs, const Ordinal primary_global_offset) const
RCP< const MultiVectorBase< Scalar > > getMultiVectorBlock(const int k) const
RCP< const VectorBase< Scalar > > colImpl(Ordinal j) const
RCP< VectorBase< Scalar > > nonconstColImpl(Ordinal j)
RCP< const MultiVectorBase< Scalar > > contigSubViewImpl(const Range1D &colRng) const
RCP< const MultiVectorBase< Scalar > > nonContigSubViewImpl(const ArrayView< const int > &cols) const
void applyImpl(const EOpTransp M_trans, const MultiVectorBase< Scalar > &X, const Ptr< MultiVectorBase< Scalar > > &Y, const Scalar alpha, const Scalar beta) const
Node subclass that uses a default MultiVectorBase implementation to provide default implementations f...
RCP< MultiVectorBase< Scalar > > getNonconstMultiVectorBlock(const int k)
Teuchos::Ordinal Ordinal
Type for the dimension of a vector space. `*.
void acquireNonconstDetachedMultiVectorViewImpl(const Range1D &rowRng, const Range1D &colRng, RTOpPack::SubMultiVectorView< Scalar > *sub_mv)
RCP< const ProductVectorSpaceBase< Scalar > > productSpace() const
Interface for a collection of column vectors called a multi-vector.
RCP< MultiVectorBase< Scalar > > nonconstContigSubViewImpl(const Range1D &colRng)
Concrete implementation of a product multi-vector.
RCP< MultiVectorBase< Scalar > > clone_mv() const
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
RCP< const VectorSpaceBase< Scalar > > range() const
void acquireDetachedMultiVectorViewImpl(const Range1D &rowRng, const Range1D &colRng, RTOpPack::ConstSubMultiVectorView< Scalar > *sub_mv) const
void commitNonconstDetachedMultiVectorViewImpl(RTOpPack::SubMultiVectorView< Scalar > *sub_mv)
void initialize(const RCP< const DefaultProductVectorSpace< Scalar > > &productSpace, const int numMembers)
RCP< const VectorSpaceBase< Scalar > > domain() const
RCP< MultiVectorBase< Scalar > > nonconstNonContigSubViewImpl(const ArrayView< const int > &cols)
Teuchos::Range1D Range1D