Thyra Version of the Day
Loading...
Searching...
No Matches
Thyra_DefaultProductVectorSpace_decl.hpp
1// @HEADER
2// *****************************************************************************
3// Thyra: Interfaces and Support for Abstract Numerical Algorithms
4//
5// Copyright 2004 NTESS and the Thyra contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
10#ifndef THYRA_DEFAULT_PRODUCT_VECTOR_SPACE_DECL_HPP
11#define THYRA_DEFAULT_PRODUCT_VECTOR_SPACE_DECL_HPP
12
13#include "Thyra_ProductVectorSpaceBase.hpp"
14#include "Thyra_VectorSpaceDefaultBase.hpp"
15#include "Teuchos_implicit_cast.hpp"
16
17namespace Thyra {
18
19
103template<class Scalar>
105 : virtual public ProductVectorSpaceBase<Scalar>,
106 virtual protected VectorSpaceDefaultBase<Scalar>
107{
108public:
109
112
115
118 const ArrayView<const RCP<const VectorSpaceBase<Scalar> > > &vecSpaces
119 );
120
159 virtual void initialize(
160 const ArrayView<const RCP<const VectorSpaceBase<Scalar> > > &vecSpaces
161 );
162
169 bool hasBeenCloned() const;
170
191 virtual void uninitialize(
193 );
194
203 virtual const RCP<const VectorSpaceBase<Scalar> >* vecSpaces() const;
204
213 virtual const Ordinal* vecSpacesOffsets() const;
214
243 void getVecSpcPoss( Ordinal i, int* kth_vector_space, Ordinal* kth_global_offset ) const;
244
246
249
251 int numBlocks() const;
253 RCP<const VectorSpaceBase<Scalar> > getBlock(const int k) const;
254
256
259
261 Ordinal dim() const;
262
266 bool isCompatible( const VectorSpaceBase<Scalar>& vecSpc ) const;
267
270
274 Scalar scalarProd(
275 const VectorBase<Scalar>& x, const VectorBase<Scalar>& y ) const;
276
280 void scalarProdsImpl(
282 const ArrayView<Scalar> &scalarProds ) const;
283
287 bool hasInCoreView(const Range1D& rng, const EViewType viewType,
288 const EStrideType strideType) const;
289
292
294 RCP< MultiVectorBase<Scalar> > createMembers(int numMembers) const;
295
298
300
303
307 std::string description() const;
308
316 void describe(
318 const Teuchos::EVerbosityLevel verbLevel
319 ) const;
320
322
323protected:
324
325 // ///////////////////////////////////
326 // Protected member functions
327
328private:
329
330 // ///////////////////////////////////
331 // Private types
332
335
336 // ///////////////////////////////////
337 // Private data members
338
339 int numBlocks_;
340 RCP<vecSpaces_t> vecSpaces_;
341 RCP<vecSpacesOffsets_t> vecSpacesOffsets_;
342 // cached info
343 Ordinal dim_;
344 bool isInCore_;
345
346 // ///////////////////////////////////
347 // Private member functions
348
349 void assertInitialized() const;
350
351};
352
353
358template<class Scalar>
359inline
365
366
371template<class Scalar>
372inline
375 const ArrayView<RCP<const VectorSpaceBase<Scalar> > > &vecSpaces
376 )
377{
378 return Teuchos::rcp(new DefaultProductVectorSpace<Scalar>(vecSpaces));
379}
380
381
387template<class Scalar>
388inline
391 const RCP<const VectorSpaceBase<Scalar> > &vecSpace,
392 const int numBlocks
393 )
394{
396 for ( int i = 0; i < numBlocks; ++i )
397 vecSpaceBlocks.push_back(vecSpace);
398 return productVectorSpace<Scalar>(vecSpaceBlocks());
399}
400
401
402// /////////////////////////////////
403// Inline members
404
405
406template<class Scalar>
409{
410 return ( dim_ ? &(*vecSpaces_)[0] : NULL );
411}
412
413
414template<class Scalar>
415inline const Ordinal*
417{
418 return ( dim_ ? &(*vecSpacesOffsets_)[0] : NULL );
419}
420
421
422template<class Scalar>
424{
425 return vecSpaces_.strong_count() > 1;
426}
427
428
429template<class Scalar>
430inline
432{
434#ifdef TEUCHOS_DEBUG
435 TEUCHOS_TEST_FOR_EXCEPT( is_null(vecSpaces_) );
436#endif
437}
438
439
440} // namespace Thyra
441
442
443#endif // THYRA_DEFAULT_PRODUCT_VECTOR_SPACE_DECL_HPP
void push_back(const value_type &x)
int strong_count() const
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)
T_To & dyn_cast(T_From &from)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)