42 #ifndef THYRA_DEFAULT_CLUSTERED_SPMD_PRODUCT_VECTOR_SPACE_HPP
43 #define THYRA_DEFAULT_CLUSTERED_SPMD_PRODUCT_VECTOR_SPACE_HPP
45 #include "Thyra_DefaultClusteredSpmdProductVectorSpace_decl.hpp"
46 #include "Thyra_SpmdVectorSpaceBase.hpp"
47 #include "Thyra_DefaultClusteredSpmdProductVector.hpp"
48 #include "Thyra_VectorSpaceDefaultBase.hpp"
49 #include "Thyra_VectorStdOps.hpp"
50 #include "Thyra_MultiVectorStdOps.hpp"
51 #include "Thyra_SpmdVectorSpaceUtilities.hpp"
52 #include "Teuchos_implicit_cast.hpp"
53 #include "Teuchos_CommHelpers.hpp"
59 template<
class Scalar>
61 :clusterRootRank_(-1), isEuclidean_(false), globalDim_(0), clusterSubDim_(-1),
65 template<
class Scalar>
68 ,
const int clusterRootRank_in
70 ,
const int numBlocks_in
76 initialize(intraClusterComm_in,clusterRootRank_in,interClusterComm_in,numBlocks_in,vecSpaces);
79 template<
class Scalar>
82 ,
const int clusterRootRank_in
84 ,
const int numBlocks_in
89 intraClusterComm_ = intraClusterComm_in.assert_not_null();
90 clusterRootRank_ = clusterRootRank_in;
91 interClusterComm_ = interClusterComm_in;
92 vecSpaces_.resize(numBlocks_in);
95 for(
int k = 0; k < numBlocks_in; ++k ) {
96 l_clusterSubDim += vecSpaces[k]->dim();
97 if(!vecSpaces[k]->isEuclidean())
99 vecSpaces_[k] = vecSpaces[k];
103 if(interClusterComm_.get()) {
104 clusterOffset_ = SpmdVectorSpaceUtilities::computeLocalOffset(
105 *interClusterComm_,l_clusterSubDim
107 globalDim_ = SpmdVectorSpaceUtilities::computeGlobalDim(
108 *interClusterComm_,l_clusterSubDim
114 Ordinal buff[num] = { clusterOffset_, globalDim_ };
115 Teuchos::broadcast<Ordinal>(*intraClusterComm_, clusterRootRank_, num, &buff[0]);
116 clusterOffset_ = buff[0];
117 globalDim_ = buff[1];
121 clusterSubDim_ = l_clusterSubDim;
130 template<
class Scalar>
133 std::ostringstream oss;
134 oss <<
"DefaultClusteredSpmdProductVectorSpace{";
135 oss <<
"numBlocks="<<vecSpaces_.size();
136 oss <<
",globalDim="<<globalDim_;
137 oss <<
",clusterOffset="<<clusterOffset_;
144 template<
class Scalar>
150 template<
class Scalar>
160 Teuchos::ptr_dynamic_cast<
const DCSPVS>(Teuchos::ptrFromRef(vecSpc),
false);
164 if (vecSpaces_.size() != dcspvs->vecSpaces_.size()) {
167 const int l_numBlocks = vecSpaces_.size();
168 for(
int k = 0; k < l_numBlocks; ++k ) {
169 if (!vecSpaces_[k]->isCompatible(*dcspvs->vecSpaces_[k])) {
176 template<
class Scalar>
180 if(!vecSpaces_.size())
181 return Teuchos::null;
182 return vecSpaces_[0]->smallVecSpcFcty();
185 template<
class Scalar>
191 this->scalarProds(x, y, scalarProds_out());
192 return scalarProds_out[0];
195 template<
class Scalar>
201 !isEuclidean_, std::logic_error
202 ,
"Error, have not implemented support for none Euclidean scalar products yet!"
204 return dots(X, Y, scalarProds_out);
215 template<
class Scalar>
221 template<
class Scalar>
229 template<
class Scalar>
238 template<
class Scalar>
241 return vecSpaces_.size();
244 template<
class Scalar>
250 return vecSpaces_[k];
255 template<
class Scalar>
263 template<
class Scalar>
273 #endif // THYRA_DEFAULT_CLUSTERED_SPMD_PRODUCT_VECTOR_SPACE_HPP
void scalarProdsImpl(const MultiVectorBase< Scalar > &X, const MultiVectorBase< Scalar > &Y, const ArrayView< Scalar > &scalarProds) const
std::string description() const
bool is_null(const boost::shared_ptr< T > &p)
bool isCompatible(const VectorSpaceBase< Scalar > &vecSpc) const
Scalar scalarProd(const VectorBase< Scalar > &x, const VectorBase< Scalar > &y) const
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
RCP< const VectorSpaceBase< Scalar > > getBlock(const int k) const
Abstract interface for objects that represent a space for vectors.
RCP< const VectorSpaceFactoryBase< Scalar > > smallVecSpcFcty() const
EViewType
Determines if a view is a direct view of data or a detached copy of data.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Teuchos::Ordinal Ordinal
Type for the dimension of a vector space. `*.
Interface for a collection of column vectors called a multi-vector.
RCP< MultiVectorBase< Scalar > > createMembers(int numMembers) const
RCP< VectorBase< Scalar > > createMember() const
Concrete implementation of a clustered Spmd-based product vector.
TypeTo implicit_cast(const TypeFrom &t)
Abstract interface for finite-dimensional dense vectors.
DefaultClusteredSpmdProductVectorSpace()
RCP< MultiVectorBase< Scalar > > createMembers(int numMembers) const
void initialize(const RCP< const Teuchos::Comm< Ordinal > > &intraClusterComm, const int clusterRootRank, const RCP< const Teuchos::Comm< Ordinal > > &interClusterComm, const int numBlocks, const RCP< const VectorSpaceBase< Scalar > > vecSpaces[])
Initalize.
EStrideType
Determine if data is unit stride or non-unit stride.
RCP< const VectorSpaceBase< Scalar > > clone() const
bool hasInCoreView(const Range1D &rng, const EViewType viewType, const EStrideType strideType) const
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)