Thyra Version of the Day
Loading...
Searching...
No Matches
Thyra_DefaultProductVectorSpace_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_VECTOR_SPACE_DECL_HPP
43#define THYRA_DEFAULT_PRODUCT_VECTOR_SPACE_DECL_HPP
44
45#include "Thyra_ProductVectorSpaceBase.hpp"
46#include "Thyra_VectorSpaceDefaultBase.hpp"
47#include "Teuchos_implicit_cast.hpp"
48
49namespace Thyra {
50
51
135template<class Scalar>
137 : virtual public ProductVectorSpaceBase<Scalar>,
138 virtual protected VectorSpaceDefaultBase<Scalar>
139{
140public:
141
144
147
150 const ArrayView<const RCP<const VectorSpaceBase<Scalar> > > &vecSpaces
151 );
152
191 virtual void initialize(
192 const ArrayView<const RCP<const VectorSpaceBase<Scalar> > > &vecSpaces
193 );
194
201 bool hasBeenCloned() const;
202
223 virtual void uninitialize(
224 const ArrayView<RCP<const VectorSpaceBase<Scalar> > > &vecSpaces = Teuchos::null
225 );
226
235 virtual const RCP<const VectorSpaceBase<Scalar> >* vecSpaces() const;
236
245 virtual const Ordinal* vecSpacesOffsets() const;
246
275 void getVecSpcPoss( Ordinal i, int* kth_vector_space, Ordinal* kth_global_offset ) const;
276
278
281
283 int numBlocks() const;
285 RCP<const VectorSpaceBase<Scalar> > getBlock(const int k) const;
286
288
291
293 Ordinal dim() const;
294
298 bool isCompatible( const VectorSpaceBase<Scalar>& vecSpc ) const;
299
302
306 Scalar scalarProd(
307 const VectorBase<Scalar>& x, const VectorBase<Scalar>& y ) const;
308
312 void scalarProdsImpl(
314 const ArrayView<Scalar> &scalarProds ) const;
315
319 bool hasInCoreView(const Range1D& rng, const EViewType viewType,
320 const EStrideType strideType) const;
321
324
326 RCP< MultiVectorBase<Scalar> > createMembers(int numMembers) const;
327
330
332
335
339 std::string description() const;
340
348 void describe(
350 const Teuchos::EVerbosityLevel verbLevel
351 ) const;
352
354
355protected:
356
357 // ///////////////////////////////////
358 // Protected member functions
359
360private:
361
362 // ///////////////////////////////////
363 // Private types
364
367
368 // ///////////////////////////////////
369 // Private data members
370
371 int numBlocks_;
372 RCP<vecSpaces_t> vecSpaces_;
373 RCP<vecSpacesOffsets_t> vecSpacesOffsets_;
374 // cached info
375 Ordinal dim_;
376 bool isInCore_;
377
378 // ///////////////////////////////////
379 // Private member functions
380
381 void assertInitialized() const;
382
383};
384
385
390template<class Scalar>
391inline
394{
396}
397
398
403template<class Scalar>
404inline
407 const ArrayView<RCP<const VectorSpaceBase<Scalar> > > &vecSpaces
408 )
409{
410 return Teuchos::rcp(new DefaultProductVectorSpace<Scalar>(vecSpaces));
411}
412
413
419template<class Scalar>
420inline
423 const RCP<const VectorSpaceBase<Scalar> > &vecSpace,
424 const int numBlocks
425 )
426{
428 for ( int i = 0; i < numBlocks; ++i )
429 vecSpaceBlocks.push_back(vecSpace);
430 return productVectorSpace<Scalar>(vecSpaceBlocks());
431}
432
433
434// /////////////////////////////////
435// Inline members
436
437
438template<class Scalar>
441{
442 return ( dim_ ? &(*vecSpaces_)[0] : NULL );
443}
444
445
446template<class Scalar>
447inline const Ordinal*
449{
450 return ( dim_ ? &(*vecSpacesOffsets_)[0] : NULL );
451}
452
453
454template<class Scalar>
456{
457 return vecSpaces_.strong_count() > 1;
458}
459
460
461template<class Scalar>
462inline
464{
466#ifdef TEUCHOS_DEBUG
467 TEUCHOS_TEST_FOR_EXCEPT( is_null(vecSpaces_) );
468#endif
469}
470
471
472} // namespace Thyra
473
474
475#endif // THYRA_DEFAULT_PRODUCT_VECTOR_SPACE_DECL_HPP
void push_back(const value_type &x)
DefaultProductVectorSpace()
Default construct to uninitialized.
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
Prints the details about the constituent vector spaces.
RCP< MultiVectorBase< Scalar > > createMembers(int numMembers) const
Returns a DefaultProductMultiVector object.
RCP< const VectorSpaceBase< Scalar > > getBlock(const int k) const
RCP< const VectorSpaceBase< Scalar > > clone() const
Clones the object as promised.
bool hasInCoreView(const Range1D &rng, const EViewType viewType, const EStrideType strideType) const
Returns true if all of the constituent vector spaces return true.
void getVecSpcPoss(Ordinal i, int *kth_vector_space, Ordinal *kth_global_offset) const
Get the position of the vector space object and its offset into a composite vector that owns the ith ...
std::string description() const
Prints just the name DefaultProductVectorSpace along with the overall dimension and the number of blo...
RCP< VectorBase< Scalar > > createMember() const
Returns a DefaultProductVector object.
virtual void initialize(const ArrayView< const RCP< const VectorSpaceBase< Scalar > > > &vecSpaces)
Initialize with a list of constituent vector spaces.
virtual void uninitialize(const ArrayView< RCP< const VectorSpaceBase< Scalar > > > &vecSpaces=Teuchos::null)
Uninitialize.
virtual const RCP< const VectorSpaceBase< Scalar > > * vecSpaces() const
Returns a pointer to an array (of length this->numBlocks()) to the constituent vector spaces.
RCP< DefaultProductVectorSpace< Scalar > > productVectorSpace(const RCP< const VectorSpaceBase< Scalar > > &vecSpace, const int numBlocks)
Nonmember constructor that duplicates a block vector space numBlock times to form a product space.
RCP< DefaultProductVectorSpace< Scalar > > productVectorSpace()
Nonmember constructor that constructs to uninitialized.
RCP< DefaultProductVectorSpace< Scalar > > productVectorSpace(const ArrayView< RCP< const VectorSpaceBase< Scalar > > > &vecSpaces)
Nonmember constructor that takes an array of vector spaces.
RCP< const VectorSpaceFactoryBase< Scalar > > smallVecSpcFcty() const
Returns getBlock(0)->smallVecSpcFcty().
bool isCompatible(const VectorSpaceBase< Scalar > &vecSpc) const
Returns true only if also a product vector space and all constituent vectors are compatible.
Ordinal dim() const
Returns the summation of the constituent vector spaces.
void scalarProdsImpl(const MultiVectorBase< Scalar > &X, const MultiVectorBase< Scalar > &Y, const ArrayView< Scalar > &scalarProds) const
Returns the sum of the scalar products of each of the columns of the constituent multi-vectors.
Scalar scalarProd(const VectorBase< Scalar > &x, const VectorBase< Scalar > &y) const
Returns the sum of the scalar products of the constituent vectors.
virtual const Ordinal * vecSpacesOffsets() const
Returns a pointer to an array (of length this->numBlocks()+1) of offset into each constituent vector ...
bool hasBeenCloned() const
Return if this vector space was cloned.
Interface for a collection of column vectors called a multi-vector.
Abstract interface for finite-dimensional dense vectors.
Abstract interface for objects that represent a space for vectors.
void scalarProds(const MultiVectorBase< Scalar > &X, const MultiVectorBase< Scalar > &Y, const ArrayView< Scalar > &scalarProds_out) const
Return the scalar product of each column in two multi-vectors in the vector space.
Node VectorSpaceBase subclass that provides default implementations for many functions using a defaul...
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
EStrideType
Determine if data is unit stride or non-unit stride.
EViewType
Determines if a view is a direct view of data or a detached copy of data.
Teuchos::Ordinal Ordinal
Type for the dimension of a vector space. `*.
TypeTo implicit_cast(const TypeFrom &t)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)