Thyra Version of the Day
Thyra_DefaultClusteredSpmdProductVectorSpace_decl.hpp
00001 // @HEADER
00002 // ***********************************************************************
00003 // 
00004 //    Thyra: Interfaces and Support for Abstract Numerical Algorithms
00005 //                 Copyright (2004) Sandia Corporation
00006 // 
00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00008 // license for use of this work by or on behalf of the U.S. Government.
00009 // 
00010 // This library is free software; you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as
00012 // published by the Free Software Foundation; either version 2.1 of the
00013 // License, or (at your option) any later version.
00014 //  
00015 // This library is distributed in the hope that it will be useful, but
00016 // WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 // Lesser General Public License for more details.
00019 //  
00020 // You should have received a copy of the GNU Lesser General Public
00021 // License along with this library; if not, write to the Free Software
00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00023 // USA
00024 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 
00025 // 
00026 // ***********************************************************************
00027 // @HEADER
00028 
00029 #ifndef THYRA_DEFAULT_CLUSTERED_SPMD_PRODUCT_VECTOR_SPACE_DECL_HPP
00030 #define THYRA_DEFAULT_CLUSTERED_SPMD_PRODUCT_VECTOR_SPACE_DECL_HPP
00031 
00032 #include "Thyra_VectorSpaceBase_decl.hpp"
00033 #include "Thyra_ProductVectorSpaceBase.hpp"
00034 #include "Thyra_VectorSpaceDefaultBase.hpp"
00035 #include "Teuchos_Comm.hpp"
00036 
00037 
00038 namespace Thyra {
00039 
00040 
00071 template<class Scalar>
00072 class DefaultClusteredSpmdProductVectorSpace
00073   : public ProductVectorSpaceBase<Scalar>
00074   , protected VectorSpaceDefaultBase<Scalar>
00075 {
00076 public:
00077 
00080 
00082   DefaultClusteredSpmdProductVectorSpace();
00083 
00085   DefaultClusteredSpmdProductVectorSpace(
00086     const Teuchos::RCP<const Teuchos::Comm<Ordinal> >          &intraClusterComm
00087     ,const int                                                       clusterRootRank
00088     ,const Teuchos::RCP<const Teuchos::Comm<Ordinal> >         &interClusterComm
00089     ,const int                                                       numBlocks
00090     ,const Teuchos::RCP<const VectorSpaceBase<Scalar> >      vecSpaces[]
00091     );
00092 
00113   void initialize(
00114     const Teuchos::RCP<const Teuchos::Comm<Ordinal> >          &intraClusterComm
00115     ,const int                                                       clusterRootRank
00116     ,const Teuchos::RCP<const Teuchos::Comm<Ordinal> >         &interClusterComm
00117     ,const int                                                       numBlocks
00118     ,const Teuchos::RCP<const VectorSpaceBase<Scalar> >      vecSpaces[]
00119     );
00120 
00122   Teuchos::RCP<const Teuchos::Comm<Ordinal> > intraClusterComm() const;
00123 
00125   int clusterRootRank() const;
00126 
00128   Teuchos::RCP<const Teuchos::Comm<Ordinal> > interClusterComm() const;
00129 
00133   int clusterSubDim() const;
00134 
00138   int clusterOffset() const;
00139   
00141   
00145   std::string description() const;
00147 
00151   Ordinal dim() const;
00153   bool isCompatible(const VectorSpaceBase<Scalar>& vecSpc) const;
00155   Teuchos::RCP< const VectorSpaceFactoryBase<Scalar> > smallVecSpcFcty() const;
00157   Scalar scalarProd( const VectorBase<Scalar>& x, const VectorBase<Scalar>& y ) const;
00159   void scalarProdsImpl(
00160     const MultiVectorBase<Scalar>& X, const MultiVectorBase<Scalar>& Y,
00161     const ArrayView<Scalar> &scalarProds ) const;
00163   bool isEuclidean() const;
00165   bool hasInCoreView(
00166     const Range1D& rng, const EViewType viewType, const EStrideType strideType
00167     ) const;
00169   Teuchos::RCP< const VectorSpaceBase<Scalar> > clone() const;
00171 
00174 
00176   int numBlocks() const;
00178   Teuchos::RCP<const VectorSpaceBase<Scalar> > getBlock(const int k) const; 
00179 
00181 
00182 protected:
00183 
00186 
00188   Teuchos::RCP<VectorBase<Scalar> > createMember() const;
00190   Teuchos::RCP<MultiVectorBase<Scalar> > createMembers(int numMembers) const;
00191 
00193 
00194 private:
00195 
00196   // //////////////////////////////////////
00197   // Private types
00198 
00199   typedef std::vector<Teuchos::RCP<const VectorSpaceBase<Scalar> > >  vecSpaces_t;
00200 
00201   // //////////////////////////////////////
00202   // Private data members
00203 
00204   Teuchos::RCP<const Teuchos::Comm<Ordinal> >  intraClusterComm_;
00205   int                                                      clusterRootRank_;
00206   Teuchos::RCP<const Teuchos::Comm<Ordinal> >  interClusterComm_;
00207   vecSpaces_t vecSpaces_; // size == numBlocks
00208   bool isEuclidean_;
00209   Ordinal globalDim_;     // The global dimension of all of the block vectors in
00210                         // all of the clusters.
00211   Ordinal clusterSubDim_; // The some of the dimensions of the block vector
00212                         // spaces in this cluster
00213   Ordinal clusterOffset_; // The offset of the first element in the first
00214                         // constituent vector in this cluster in the
00215                         // w.r.t. the global vector.
00216   
00217 };
00218 
00219 
00220 // ///////////////////////////
00221 // Inline defintions
00222 
00223 
00224 template<class Scalar>
00225 Teuchos::RCP<const Teuchos::Comm<Ordinal> >
00226 DefaultClusteredSpmdProductVectorSpace<Scalar>::intraClusterComm() const
00227 {
00228   return intraClusterComm_;
00229 }
00230 
00231 
00232 template<class Scalar>
00233 int DefaultClusteredSpmdProductVectorSpace<Scalar>::clusterRootRank() const
00234 {
00235   return clusterRootRank_;
00236 }
00237 
00238 
00239 template<class Scalar>
00240 Teuchos::RCP<const Teuchos::Comm<Ordinal> >
00241 DefaultClusteredSpmdProductVectorSpace<Scalar>::interClusterComm() const
00242 {
00243   return interClusterComm_;
00244 }
00245 
00246 
00247 template<class Scalar>
00248 int DefaultClusteredSpmdProductVectorSpace<Scalar>::clusterSubDim() const
00249 {
00250   return clusterSubDim_;
00251 }
00252 
00253 
00254 template<class Scalar>
00255 int DefaultClusteredSpmdProductVectorSpace<Scalar>::clusterOffset() const
00256 {
00257   return clusterOffset_;
00258 }
00259 
00260 
00261 } // end namespace Thyra
00262 
00263 
00264 #endif // THYRA_DEFAULT_CLUSTERED_SPMD_PRODUCT_VECTOR_SPACE_DECL_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines