42 #ifndef THYRA_SPMD_VECTOR_SPACE_BASE_DEF_HPP
43 #define THYRA_SPMD_VECTOR_SPACE_BASE_DEF_HPP
45 #include "Thyra_SpmdVectorSpaceDefaultBase_decl.hpp"
46 #include "Thyra_ScalarProdVectorSpaceBase.hpp"
47 #include "Thyra_DefaultSpmdVectorSpaceFactory.hpp"
48 #include "Thyra_SpmdVectorSpaceUtilities.hpp"
49 #include "Thyra_ProductVectorSpaceBase.hpp"
55 template<
class Scalar>
57 :mapCode_(-1), defaultLocalOffset_(-1), defaultGlobalDim_(-1),
58 localSubDim_(-1), isLocallyReplicated_(false)
65 template<
class Scalar>
68 return defaultLocalOffset_;
72 template<
class Scalar>
79 template<
class Scalar>
82 return isLocallyReplicated_;
86 template<
class Scalar>
90 std::ostringstream ostr;
92 ostr <<
"globalDim="<<this->dim();
93 ostr <<
",localSubDim="<<this->localSubDim();
94 ostr <<
",localOffset="<<this->localOffset();
97 if ( (comm=this->getComm())!=null ) {
98 ostr << comm->description();
111 template<
class Scalar>
114 return defaultGlobalDim_;
118 template<
class Scalar>
122 return smallVecSpcFcty_;
126 template<
class Scalar>
132 using Teuchos::ptrFromRef;
133 using Teuchos::ptr_dynamic_cast;
139 return mapCode() == spmdVecSpc->mapCode();
147 if (pvsb->numBlocks() == 1 ) {
148 return pvsb->getBlock(0)->isCompatible(*
this);
164 template<
class Scalar>
166 const bool isLocallyReplicated_in)
168 namespace SVSU = SpmdVectorSpaceUtilities;
174 localSubDim_ = this->localSubDim();
177 comm = this->getComm();
181 numProcs = comm->getSize();
188 Ordinal sumLocalSubDims = localSubDim_;
190 bool isSerialOrLocallyReplicated =
false;
191 bool isEmpty =
false;
192 bool isDistributed =
false;
194 if (isLocallyReplicated_in) {
196 isSerialOrLocallyReplicated =
true;
197 if (sumLocalSubDims == 0) {
204 sumLocalSubDims = SVSU::computeGlobalDim(*comm, localSubDim_);
206 if (sumLocalSubDims == 0) {
214 sumLocalSubDims / numProcs == globalDim
216 sumLocalSubDims % numProcs == 0
222 isSerialOrLocallyReplicated =
true;
232 isDistributed =
true;
242 defaultLocalOffset_ = 0;
243 defaultGlobalDim_ = 0;
245 else if (isSerialOrLocallyReplicated) {
246 isLocallyReplicated_ =
true;
247 mapCode_ = localSubDim_;
248 defaultLocalOffset_ = 0;
249 defaultGlobalDim_ = localSubDim_;
253 defaultGlobalDim_ = sumLocalSubDims;
254 mapCode_ = SVSU::computeMapCode(*comm, localSubDim_);
255 defaultLocalOffset_ = SVSU::computeLocalOffset(*comm, localSubDim_);
258 smallVecSpcFcty_ = defaultSpmdVectorSpaceFactory<Scalar>(comm);
266 #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)