10 #ifndef THYRA_DEFAULT_CLUSTERED_SPMD_PRODUCT_VECTOR_SPACE_HPP
11 #define THYRA_DEFAULT_CLUSTERED_SPMD_PRODUCT_VECTOR_SPACE_HPP
13 #include "Thyra_DefaultClusteredSpmdProductVectorSpace_decl.hpp"
14 #include "Thyra_SpmdVectorSpaceBase.hpp"
15 #include "Thyra_DefaultClusteredSpmdProductVector.hpp"
16 #include "Thyra_VectorSpaceDefaultBase.hpp"
17 #include "Thyra_VectorStdOps.hpp"
18 #include "Thyra_MultiVectorStdOps.hpp"
19 #include "Thyra_SpmdVectorSpaceUtilities.hpp"
20 #include "Teuchos_implicit_cast.hpp"
21 #include "Teuchos_CommHelpers.hpp"
27 template<
class Scalar>
29 :clusterRootRank_(-1), isEuclidean_(false), globalDim_(0), clusterSubDim_(-1),
33 template<
class Scalar>
36 ,
const int clusterRootRank_in
38 ,
const int numBlocks_in
44 initialize(intraClusterComm_in,clusterRootRank_in,interClusterComm_in,numBlocks_in,vecSpaces);
47 template<
class Scalar>
50 ,
const int clusterRootRank_in
52 ,
const int numBlocks_in
57 intraClusterComm_ = intraClusterComm_in.assert_not_null();
58 clusterRootRank_ = clusterRootRank_in;
59 interClusterComm_ = interClusterComm_in;
60 vecSpaces_.resize(numBlocks_in);
63 for(
int k = 0; k < numBlocks_in; ++k ) {
64 l_clusterSubDim += vecSpaces[k]->dim();
65 if(!vecSpaces[k]->isEuclidean())
67 vecSpaces_[k] = vecSpaces[k];
71 if(interClusterComm_.get()) {
72 clusterOffset_ = SpmdVectorSpaceUtilities::computeLocalOffset(
73 *interClusterComm_,l_clusterSubDim
75 globalDim_ = SpmdVectorSpaceUtilities::computeGlobalDim(
76 *interClusterComm_,l_clusterSubDim
82 Ordinal buff[num] = { clusterOffset_, globalDim_ };
83 Teuchos::broadcast<Ordinal>(*intraClusterComm_, clusterRootRank_, num, &buff[0]);
84 clusterOffset_ = buff[0];
89 clusterSubDim_ = l_clusterSubDim;
98 template<
class Scalar>
101 std::ostringstream oss;
102 oss <<
"DefaultClusteredSpmdProductVectorSpace{";
103 oss <<
"numBlocks="<<vecSpaces_.size();
104 oss <<
",globalDim="<<globalDim_;
105 oss <<
",clusterOffset="<<clusterOffset_;
112 template<
class Scalar>
118 template<
class Scalar>
128 Teuchos::ptr_dynamic_cast<
const DCSPVS>(Teuchos::ptrFromRef(vecSpc),
false);
132 if (vecSpaces_.size() != dcspvs->vecSpaces_.size()) {
135 const int l_numBlocks = vecSpaces_.size();
136 for(
int k = 0; k < l_numBlocks; ++k ) {
137 if (!vecSpaces_[k]->isCompatible(*dcspvs->vecSpaces_[k])) {
144 template<
class Scalar>
148 if(!vecSpaces_.size())
149 return Teuchos::null;
150 return vecSpaces_[0]->smallVecSpcFcty();
153 template<
class Scalar>
159 this->scalarProds(x, y, scalarProds_out());
160 return scalarProds_out[0];
163 template<
class Scalar>
169 !isEuclidean_, std::logic_error
170 ,
"Error, have not implemented support for none Euclidean scalar products yet!"
172 return dots(X, Y, scalarProds_out);
183 template<
class Scalar>
189 template<
class Scalar>
197 template<
class Scalar>
206 template<
class Scalar>
209 return vecSpaces_.size();
212 template<
class Scalar>
218 return vecSpaces_[k];
223 template<
class Scalar>
231 template<
class Scalar>
241 #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)