Thyra Version of the Day

Base VectorSpaceBase
class for all SPMD vector spaces with contiguous localtoglobal indexing.
More...
#include <Thyra_SpmdVectorSpaceDefaultBase_decl.hpp>
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) Spmdbased vector spaces. 
Base VectorSpaceBase
class for all SPMD vector spaces with contiguous localtoglobal 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 multivectors 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 multivectors 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 93 of file Thyra_SpmdVectorSpaceDefaultBase_decl.hpp.
Thyra::SpmdVectorSpaceDefaultBase< Scalar >::SpmdVectorSpaceDefaultBase  (  ) 
Definition at line 56 of file Thyra_SpmdVectorSpaceDefaultBase_def.hpp.
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 65 of file Thyra_SpmdVectorSpaceDefaultBase_def.hpp.
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 Spmdbased vector implementations.
Implements Thyra::SpmdVectorSpaceBase< Scalar >.
Definition at line 72 of file Thyra_SpmdVectorSpaceDefaultBase_def.hpp.
std::string Thyra::SpmdVectorSpaceDefaultBase< Scalar >::description  (  )  const [virtual] 
Reimplemented from Teuchos::Describable.
Definition at line 79 of file Thyra_SpmdVectorSpaceDefaultBase_def.hpp.
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 104 of file Thyra_SpmdVectorSpaceDefaultBase_def.hpp.
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 112 of file Thyra_SpmdVectorSpaceDefaultBase_def.hpp.
bool Thyra::SpmdVectorSpaceDefaultBase< Scalar >::isCompatible  (  const VectorSpaceBase< Scalar > &  vecSpc  )  const [virtual] 
Checks the general compatibility of parallel (or serial on one process) Spmdbased vector spaces.
*this
and vecSpace
are both serial incore 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:
return = ( this>hasInCoreView() && vecSpc>hasInCoreView() )  ( (mpiVecSpc = dynamic_cast<const SpmdVectorSpaceDefaultBase<Scalar>*>(&vecSpc)) && this>getComm() == mpiVecSpc>getComm() && this>mapCode() == mpiVecSpc>getComm())
.
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 119 of file Thyra_SpmdVectorSpaceDefaultBase_def.hpp.
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.
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 162 of file Thyra_SpmdVectorSpaceDefaultBase_def.hpp.