10 #ifndef THYRA_SPMD_VECTOR_SPACE_BASE_DEF_HPP
11 #define THYRA_SPMD_VECTOR_SPACE_BASE_DEF_HPP
13 #include "Thyra_SpmdVectorSpaceDefaultBase_decl.hpp"
14 #include "Thyra_ScalarProdVectorSpaceBase.hpp"
15 #include "Thyra_DefaultSpmdVectorSpaceFactory.hpp"
16 #include "Thyra_SpmdVectorSpaceUtilities.hpp"
17 #include "Thyra_ProductVectorSpaceBase.hpp"
23 template<
class Scalar>
25 :mapCode_(-1), defaultLocalOffset_(-1), defaultGlobalDim_(-1),
26 localSubDim_(-1), isLocallyReplicated_(false)
33 template<
class Scalar>
36 return defaultLocalOffset_;
40 template<
class Scalar>
47 template<
class Scalar>
50 return isLocallyReplicated_;
54 template<
class Scalar>
58 std::ostringstream ostr;
60 ostr <<
"globalDim="<<this->dim();
61 ostr <<
",localSubDim="<<this->localSubDim();
62 ostr <<
",localOffset="<<this->localOffset();
65 if ( (comm=this->getComm())!=null ) {
66 ostr << comm->description();
79 template<
class Scalar>
82 return defaultGlobalDim_;
86 template<
class Scalar>
90 return smallVecSpcFcty_;
94 template<
class Scalar>
100 using Teuchos::ptrFromRef;
101 using Teuchos::ptr_dynamic_cast;
107 return mapCode() == spmdVecSpc->mapCode();
115 if (pvsb->numBlocks() == 1 ) {
116 return pvsb->getBlock(0)->isCompatible(*
this);
132 template<
class Scalar>
134 const bool isLocallyReplicated_in)
136 namespace SVSU = SpmdVectorSpaceUtilities;
142 localSubDim_ = this->localSubDim();
145 comm = this->getComm();
149 numProcs = comm->getSize();
156 Ordinal sumLocalSubDims = localSubDim_;
158 bool isSerialOrLocallyReplicated =
false;
159 bool isEmpty =
false;
160 bool isDistributed =
false;
162 if (isLocallyReplicated_in) {
164 isSerialOrLocallyReplicated =
true;
165 if (sumLocalSubDims == 0) {
172 sumLocalSubDims = SVSU::computeGlobalDim(*comm, localSubDim_);
174 if (sumLocalSubDims == 0) {
182 sumLocalSubDims / numProcs == globalDim
184 sumLocalSubDims % numProcs == 0
190 isSerialOrLocallyReplicated =
true;
200 isDistributed =
true;
210 defaultLocalOffset_ = 0;
211 defaultGlobalDim_ = 0;
213 else if (isSerialOrLocallyReplicated) {
214 isLocallyReplicated_ =
true;
215 mapCode_ = localSubDim_;
216 defaultLocalOffset_ = 0;
217 defaultGlobalDim_ = localSubDim_;
221 defaultGlobalDim_ = sumLocalSubDims;
222 mapCode_ = SVSU::computeMapCode(*comm, localSubDim_);
223 defaultLocalOffset_ = SVSU::computeLocalOffset(*comm, localSubDim_);
226 smallVecSpcFcty_ = defaultSpmdVectorSpaceFactory<Scalar>(comm);
234 #endif // THYRA_SPMD_VECTOR_SPACE_BASE_DEF_HPP
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...
SpmdVectorSpaceDefaultBase()
Abstract interface for objects that represent a space for vectors.
bool isLocallyReplicated() const
Returns true if vector space is locally replicated space.
Ordinal localOffset() const
virtual void updateState(const Ordinal globalDim, const bool isLocallyReplicated=false)
This function must be called whenever the state of this changes and some internal state must be updat...
Teuchos::Ordinal Ordinal
Type for the dimension of a vector space. `*.
bool nonnull(const boost::shared_ptr< T > &p)
Ordinal dim() const
Returns the sum of the local number of elements on every process.
std::string description() const
#define TEUCHOS_ASSERT(assertion_test)
#define TEUCHOS_ASSERT_EQUALITY(val1, val2)
Base abstract VectorSpaceBase class for all SPMD-based vector spaces.
std::string typeName(const T &t)