Thyra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Thyra_DefaultClusteredSpmdProductVectorSpace_decl.hpp
1 // @HEADER
2 // *****************************************************************************
3 // Thyra: Interfaces and Support for Abstract Numerical Algorithms
4 //
5 // Copyright 2004 NTESS and the Thyra contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef THYRA_DEFAULT_CLUSTERED_SPMD_PRODUCT_VECTOR_SPACE_DECL_HPP
11 #define THYRA_DEFAULT_CLUSTERED_SPMD_PRODUCT_VECTOR_SPACE_DECL_HPP
12 
13 #include "Thyra_VectorSpaceBase_decl.hpp"
14 #include "Thyra_ProductVectorSpaceBase.hpp"
15 #include "Thyra_VectorSpaceDefaultBase.hpp"
16 #include "Teuchos_Comm.hpp"
17 
18 
19 namespace Thyra {
20 
21 
52 template<class Scalar>
53 class DefaultClusteredSpmdProductVectorSpace
54  : public ProductVectorSpaceBase<Scalar>
55  , protected VectorSpaceDefaultBase<Scalar>
56 {
57 public:
58 
61 
64 
67  const RCP<const Teuchos::Comm<Ordinal> > &intraClusterComm
68  ,const int clusterRootRank
69  ,const RCP<const Teuchos::Comm<Ordinal> > &interClusterComm
70  ,const int numBlocks
71  ,const RCP<const VectorSpaceBase<Scalar> > vecSpaces[]
72  );
73 
94  void initialize(
95  const RCP<const Teuchos::Comm<Ordinal> > &intraClusterComm
96  ,const int clusterRootRank
97  ,const RCP<const Teuchos::Comm<Ordinal> > &interClusterComm
98  ,const int numBlocks
99  ,const RCP<const VectorSpaceBase<Scalar> > vecSpaces[]
100  );
101 
103  RCP<const Teuchos::Comm<Ordinal> > intraClusterComm() const;
104 
106  int clusterRootRank() const;
107 
109  RCP<const Teuchos::Comm<Ordinal> > interClusterComm() const;
110 
114  int clusterSubDim() const;
115 
119  int clusterOffset() const;
120 
122 
126  std::string description() const;
128 
132  Ordinal dim() const;
134  bool isCompatible(const VectorSpaceBase<Scalar>& vecSpc) const;
136  RCP< const VectorSpaceFactoryBase<Scalar> > smallVecSpcFcty() const;
138  Scalar scalarProd( const VectorBase<Scalar>& x, const VectorBase<Scalar>& y ) const;
140  void scalarProdsImpl(
141  const MultiVectorBase<Scalar>& X, const MultiVectorBase<Scalar>& Y,
142  const ArrayView<Scalar> &scalarProds ) const;
144  bool isEuclidean() const;
146  bool hasInCoreView(
147  const Range1D& rng, const EViewType viewType, const EStrideType strideType
148  ) const;
150  RCP< const VectorSpaceBase<Scalar> > clone() const;
152 
155 
157  int numBlocks() const;
159  RCP<const VectorSpaceBase<Scalar> > getBlock(const int k) const;
160 
162 
163 protected:
164 
167 
169  RCP<VectorBase<Scalar> > createMember() const;
171  RCP<MultiVectorBase<Scalar> > createMembers(int numMembers) const;
172 
174 
175 private:
176 
177  // //////////////////////////////////////
178  // Private types
179 
180  typedef std::vector<RCP<const VectorSpaceBase<Scalar> > > vecSpaces_t;
181 
182  // //////////////////////////////////////
183  // Private data members
184 
185  RCP<const Teuchos::Comm<Ordinal> > intraClusterComm_;
186  int clusterRootRank_;
187  RCP<const Teuchos::Comm<Ordinal> > interClusterComm_;
188  vecSpaces_t vecSpaces_; // size == numBlocks
189  bool isEuclidean_;
190  Ordinal globalDim_; // The global dimension of all of the block vectors in
191  // all of the clusters.
192  Ordinal clusterSubDim_; // The some of the dimensions of the block vector
193  // spaces in this cluster
194  Ordinal clusterOffset_; // The offset of the first element in the first
195  // constituent vector in this cluster in the
196  // w.r.t. the global vector.
197 
198 };
199 
200 
201 // ///////////////////////////
202 // Inline defintions
203 
204 
205 template<class Scalar>
206 RCP<const Teuchos::Comm<Ordinal> >
208 {
209  return intraClusterComm_;
210 }
211 
212 
213 template<class Scalar>
215 {
216  return clusterRootRank_;
217 }
218 
219 
220 template<class Scalar>
223 {
224  return interClusterComm_;
225 }
226 
227 
228 template<class Scalar>
230 {
231  return clusterSubDim_;
232 }
233 
234 
235 template<class Scalar>
237 {
238  return clusterOffset_;
239 }
240 
241 
242 } // end namespace Thyra
243 
244 
245 #endif // THYRA_DEFAULT_CLUSTERED_SPMD_PRODUCT_VECTOR_SPACE_DECL_HPP
void scalarProdsImpl(const MultiVectorBase< Scalar > &X, const MultiVectorBase< Scalar > &Y, const ArrayView< Scalar > &scalarProds) const
bool isCompatible(const VectorSpaceBase< Scalar > &vecSpc) const
Scalar scalarProd(const VectorBase< Scalar > &x, const VectorBase< Scalar > &y) const
RCP< const VectorSpaceBase< Scalar > > getBlock(const int k) const
RCP< const VectorSpaceFactoryBase< Scalar > > smallVecSpcFcty() const
EViewType
Determines if a view is a direct view of data or a detached copy of data.
Teuchos::Ordinal Ordinal
Type for the dimension of a vector space. `*.
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.
void scalarProds(const MultiVectorBase< Scalar > &X, const MultiVectorBase< Scalar > &Y, const ArrayView< Scalar > &scalarProds_out) const
Return the scalar product of each column in two multi-vectors in the vector space.
bool hasInCoreView(const Range1D &rng, const EViewType viewType, const EStrideType strideType) const
Teuchos::Range1D Range1D