Thyra Version of the Day
Public Member Functions | Protected Member Functions
Thyra::SpmdVectorSpaceDefaultBase< Scalar > Class Template Reference

Base VectorSpaceBase class for all SPMD vector spaces with contiguous local-to-global indexing. More...

#include <Thyra_SpmdVectorSpaceDefaultBase_decl.hpp>

Inheritance diagram for Thyra::SpmdVectorSpaceDefaultBase< Scalar >:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 SpmdVectorSpaceDefaultBase ()
 

Protected Member Functions

virtual void updateState (const Ordinal globalDim)
 This function must be called whenever the state of this changes and some internal state must be updated.

Overridden from SpmdVectorSpaceBase

Ordinal localOffset () const
 
Ordinal mapCode () const
 

Overridden form Teuchos::Describable

std::string description () const
 

Overridden from VectorSpaceBase

Ordinal dim () const
 Returns the sum of the local number of elements on every process.
Teuchos::RCP< const
VectorSpaceFactoryBase< Scalar > > 
smallVecSpcFcty () const
 Returns a DefaultSpmdVectorSpaceFactory object that has been given getComm().
bool isCompatible (const VectorSpaceBase< Scalar > &vecSpc) const
 Checks the general compatibility of parallel (or serial on one process) Spmd-based vector spaces.

Detailed Description

template<class Scalar>
class Thyra::SpmdVectorSpaceDefaultBase< Scalar >

Base VectorSpaceBase class for all SPMD vector spaces with contiguous local-to-global indexing.

See SpmdVectorSpaceBase for details on what this class represents in an abstract way.

Notes to subclass developers:

The pure virtual methods mpiComm(), localSubDim() and createMember() are the only functions that must be overridden.

If this this is in an uninitialized state then localSubDim() should return 0.

It should never be necessary to override the virtual functions mapCode() and isCompatible() as these functions have very good and very general implementations.

If optimized implementations of multi-vectors can be supported, then the createMembers() method should also be overridden.

This class defines a very general default implementation for smallVecSpcFcty() that returns a DefaultSpmdVectorSpaceFactory object which in turn can be used to create DefaultSpmdVectorSpace objects. These are the vector space objects that are used by the domain space of multi-vectors created by createMembers(). The class DefaultSpmdVectorSpace creates DefaultSpmdVector and DefaultSpmdMultiVector objects. This implementation of smallVecSpcFcty() is very general should be very appropriate for many different concrete implementations.

Note: It is very important that subclasses call the updateState() function whenever the state of *this changes in a way that might affect the behavior of any of the public member functions. For example, if a different value of localSubDim() will be returned the next time it is called by a client, then updateState() needs to be called by the subclass. External clients should never need to worry about this function and that is why updateState() is declared protected.

Definition at line 80 of file Thyra_SpmdVectorSpaceDefaultBase_decl.hpp.


Constructor & Destructor Documentation

template<class Scalar >
Thyra::SpmdVectorSpaceDefaultBase< Scalar >::SpmdVectorSpaceDefaultBase ( )

Definition at line 43 of file Thyra_SpmdVectorSpaceDefaultBase_def.hpp.


Member Function Documentation

template<class Scalar >
Ordinal Thyra::SpmdVectorSpaceDefaultBase< Scalar >::localOffset ( ) const [virtual]

This method has a default implementation which just assigns this offset based on counting up localSubDim() on each process and then setting localOffset() by the rank of the process. For example, if there are 5 elements in process 0 and 4 elements in process rank, then localOffset on each of these processes will be set as: localOffset=0 on process 0, localOffset=5 on process 1, localOffset=9 on process 2 and so on.

Implements Thyra::SpmdVectorSpaceBase< Scalar >.

Definition at line 52 of file Thyra_SpmdVectorSpaceDefaultBase_def.hpp.

template<class Scalar >
Ordinal Thyra::SpmdVectorSpaceDefaultBase< Scalar >::mapCode ( ) const [virtual]

This method takes the data getComm(), numProc (where numProc=this->getComm()->size()), localOffset() or localSubDim() on each process and then uses it to compute a value for mapCode (using a single global reduction if numProc > 1) which is returned from this function.

The value returned from this default implementation of this method must not be changed or this approach breaks down. The only reason for overriding this method is for the subclass to be alerted of when this method is called but not what is returned from this method. If a subclass developer does not understand what this means then don't override this method!

The default implementation will always return return > 0 (unless this is uninitialized) so that if this method is overridden to return return <= then this is a flag that the underlying vector map does not satisfy the assumptions of this vector space interface and vectors that are in *this vector space can not collaborate with other Spmd-based vector implementations.

Implements Thyra::SpmdVectorSpaceBase< Scalar >.

Definition at line 59 of file Thyra_SpmdVectorSpaceDefaultBase_def.hpp.

template<class Scalar >
std::string Thyra::SpmdVectorSpaceDefaultBase< Scalar >::description ( ) const [virtual]

Reimplemented from Teuchos::Describable.

Definition at line 66 of file Thyra_SpmdVectorSpaceDefaultBase_def.hpp.

template<class Scalar >
Ordinal Thyra::SpmdVectorSpaceDefaultBase< Scalar >::dim ( ) const [virtual]

Returns the sum of the local number of elements on every process.

Implements Thyra::VectorSpaceBase< Scalar >.

Definition at line 91 of file Thyra_SpmdVectorSpaceDefaultBase_def.hpp.

template<class Scalar >
Teuchos::RCP< const VectorSpaceFactoryBase< Scalar > > Thyra::SpmdVectorSpaceDefaultBase< Scalar >::smallVecSpcFcty ( ) const [virtual]

Returns a DefaultSpmdVectorSpaceFactory object that has been given getComm().

Implements Thyra::VectorSpaceBase< Scalar >.

Definition at line 99 of file Thyra_SpmdVectorSpaceDefaultBase_def.hpp.

template<class Scalar >
bool Thyra::SpmdVectorSpaceDefaultBase< Scalar >::isCompatible ( const VectorSpaceBase< Scalar > &  vecSpc) const [virtual]

Checks the general compatibility of parallel (or serial on one process) Spmd-based vector spaces.

Returns:
Returns true if *this and vecSpace are both serial in-core vectors or if vecSpc is of type SpmdVectorSpaceDefaultBase<Scalar> and both *this and vecSpc have the same Spmd communicators and the same mapping of elements to processes.

Postconditions:

If the mapping of vector elements to processes is not as described above then this method should be overridden in a way that is specific to the vector implementation.

Implements Thyra::VectorSpaceBase< Scalar >.

Definition at line 106 of file Thyra_SpmdVectorSpaceDefaultBase_def.hpp.

template<class Scalar >
void Thyra::SpmdVectorSpaceDefaultBase< Scalar >::updateState ( const Ordinal  globalDim) [protected, virtual]

This function must be called whenever the state of this changes and some internal state must be updated.

Parameters:
globalDim[in] If globalDim > 0 then this determines the global dimension of the vector space. If globalDim==this->localSubDim() then this is a locally replicated vector space. If globalDim < 0 then the global dimension is computed using a global reduction. If this->getComm()->size()==1 then this argument is ignored.

Note that calling this function may involve one or more global reductions being called if this is parallel vector space so it should only be called when needed by subclasses.

Usually, this operation only needs to be called once for every *new* parallel vector space constructed and very few parallel vector spaces will be created per application usually.

Definition at line 149 of file Thyra_SpmdVectorSpaceDefaultBase_def.hpp.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines