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 //
4 // Thyra: Interfaces and Support for Abstract Numerical Algorithms
5 // Copyright (2004) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Roscoe A. Bartlett (bartlettra@ornl.gov)
38 //
39 // ***********************************************************************
40 // @HEADER
41 
42 #ifndef THYRA_DEFAULT_CLUSTERED_SPMD_PRODUCT_VECTOR_SPACE_DECL_HPP
43 #define THYRA_DEFAULT_CLUSTERED_SPMD_PRODUCT_VECTOR_SPACE_DECL_HPP
44 
45 #include "Thyra_VectorSpaceBase_decl.hpp"
46 #include "Thyra_ProductVectorSpaceBase.hpp"
47 #include "Thyra_VectorSpaceDefaultBase.hpp"
48 #include "Teuchos_Comm.hpp"
49 
50 
51 namespace Thyra {
52 
53 
84 template<class Scalar>
85 class DefaultClusteredSpmdProductVectorSpace
86  : public ProductVectorSpaceBase<Scalar>
87  , protected VectorSpaceDefaultBase<Scalar>
88 {
89 public:
90 
93 
96 
99  const RCP<const Teuchos::Comm<Ordinal> > &intraClusterComm
100  ,const int clusterRootRank
101  ,const RCP<const Teuchos::Comm<Ordinal> > &interClusterComm
102  ,const int numBlocks
103  ,const RCP<const VectorSpaceBase<Scalar> > vecSpaces[]
104  );
105 
126  void initialize(
127  const RCP<const Teuchos::Comm<Ordinal> > &intraClusterComm
128  ,const int clusterRootRank
129  ,const RCP<const Teuchos::Comm<Ordinal> > &interClusterComm
130  ,const int numBlocks
131  ,const RCP<const VectorSpaceBase<Scalar> > vecSpaces[]
132  );
133 
135  RCP<const Teuchos::Comm<Ordinal> > intraClusterComm() const;
136 
138  int clusterRootRank() const;
139 
141  RCP<const Teuchos::Comm<Ordinal> > interClusterComm() const;
142 
146  int clusterSubDim() const;
147 
151  int clusterOffset() const;
152 
154 
158  std::string description() const;
160 
164  Ordinal dim() const;
166  bool isCompatible(const VectorSpaceBase<Scalar>& vecSpc) const;
168  RCP< const VectorSpaceFactoryBase<Scalar> > smallVecSpcFcty() const;
170  Scalar scalarProd( const VectorBase<Scalar>& x, const VectorBase<Scalar>& y ) const;
172  void scalarProdsImpl(
173  const MultiVectorBase<Scalar>& X, const MultiVectorBase<Scalar>& Y,
174  const ArrayView<Scalar> &scalarProds ) const;
176  bool isEuclidean() const;
178  bool hasInCoreView(
179  const Range1D& rng, const EViewType viewType, const EStrideType strideType
180  ) const;
182  RCP< const VectorSpaceBase<Scalar> > clone() const;
184 
187 
189  int numBlocks() const;
191  RCP<const VectorSpaceBase<Scalar> > getBlock(const int k) const;
192 
194 
195 protected:
196 
199 
201  RCP<VectorBase<Scalar> > createMember() const;
203  RCP<MultiVectorBase<Scalar> > createMembers(int numMembers) const;
204 
206 
207 private:
208 
209  // //////////////////////////////////////
210  // Private types
211 
212  typedef std::vector<RCP<const VectorSpaceBase<Scalar> > > vecSpaces_t;
213 
214  // //////////////////////////////////////
215  // Private data members
216 
217  RCP<const Teuchos::Comm<Ordinal> > intraClusterComm_;
218  int clusterRootRank_;
219  RCP<const Teuchos::Comm<Ordinal> > interClusterComm_;
220  vecSpaces_t vecSpaces_; // size == numBlocks
221  bool isEuclidean_;
222  Ordinal globalDim_; // The global dimension of all of the block vectors in
223  // all of the clusters.
224  Ordinal clusterSubDim_; // The some of the dimensions of the block vector
225  // spaces in this cluster
226  Ordinal clusterOffset_; // The offset of the first element in the first
227  // constituent vector in this cluster in the
228  // w.r.t. the global vector.
229 
230 };
231 
232 
233 // ///////////////////////////
234 // Inline defintions
235 
236 
237 template<class Scalar>
238 RCP<const Teuchos::Comm<Ordinal> >
240 {
241  return intraClusterComm_;
242 }
243 
244 
245 template<class Scalar>
247 {
248  return clusterRootRank_;
249 }
250 
251 
252 template<class Scalar>
255 {
256  return interClusterComm_;
257 }
258 
259 
260 template<class Scalar>
262 {
263  return clusterSubDim_;
264 }
265 
266 
267 template<class Scalar>
269 {
270  return clusterOffset_;
271 }
272 
273 
274 } // end namespace Thyra
275 
276 
277 #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