Thyra_DefaultMultiVectorProductVectorSpace.hpp

Go to the documentation of this file.
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_MULTI_VECTOR_PRODUCT_VECTOR_SPACE_HPP
00030 #define THYRA_MULTI_VECTOR_PRODUCT_VECTOR_SPACE_HPP
00031 
00032 
00033 #include "Thyra_DefaultMultiVectorProductVectorSpaceDecl.hpp"
00034 #include "Thyra_DefaultMultiVectorProductVector.hpp"
00035 
00036 
00037 namespace Thyra {
00038 
00039 
00040 // Constructors/initializers/accessors
00041 
00042 
00043 template<class Scalar>
00044 DefaultMultiVectorProductVectorSpace<Scalar>::DefaultMultiVectorProductVectorSpace()
00045   : numColumns_(-1)
00046 {}
00047 
00048 
00049 template<class Scalar>
00050 void DefaultMultiVectorProductVectorSpace<Scalar>::initialize(
00051   const Teuchos::RCP<const VectorSpaceBase<Scalar> > &space,
00052   const int numColumns
00053   )
00054 {
00055 #ifdef TEUCHOS_DEBUG
00056   TEST_FOR_EXCEPT(is_null(space));
00057   TEST_FOR_EXCEPT(numColumns <= 0);
00058 #endif
00059   space_ = space;
00060   numColumns_ = numColumns;
00061   defaultProdVecSpc_ = productVectorSpace(space,numColumns);
00062 }
00063 
00064 
00065 template<class Scalar>
00066 void DefaultMultiVectorProductVectorSpace<Scalar>::uninitialize(
00067   Teuchos::RCP<const VectorSpaceBase<Scalar> > *space,
00068   int *numColumns
00069   )
00070 {
00071   TEST_FOR_EXCEPT("ToDo: Implement when needed!");
00072 }
00073   
00074   
00075 // Overridden from DefaultMultiVectorProductVectorSpace
00076 
00077 
00078 template<class Scalar>
00079 int DefaultMultiVectorProductVectorSpace<Scalar>::numBlocks() const
00080 {
00081   return numColumns_;
00082 }
00083 
00084 
00085 template<class Scalar>
00086 Teuchos::RCP<const VectorSpaceBase<Scalar> >
00087 DefaultMultiVectorProductVectorSpace<Scalar>::getBlock(const int k) const
00088 {
00089   TEST_FOR_EXCEPT( k < 0 || numColumns_ < k );
00090   return space_;
00091 }
00092 
00093 
00094 // Overridden from VectorSpaceBase
00095 
00096 
00097 template<class Scalar>
00098 Index DefaultMultiVectorProductVectorSpace<Scalar>::dim() const
00099 {
00100   return numColumns_ * space_->dim();
00101 }
00102 
00103 
00104 template<class Scalar>
00105 bool DefaultMultiVectorProductVectorSpace<Scalar>::isCompatible(
00106   const VectorSpaceBase<Scalar>& vecSpc
00107   ) const
00108 {
00109   const DefaultMultiVectorProductVectorSpace<Scalar> *multiVecProdVecSpc
00110     = dynamic_cast<const DefaultMultiVectorProductVectorSpace<Scalar>*>(&vecSpc);
00111   if ( multiVecProdVecSpc != 0 ) {
00112     return (
00113       ( numColumns_ == multiVecProdVecSpc->numColumns_ )
00114       && 
00115       ( space_->isCompatible(*multiVecProdVecSpc->space_) )
00116       );
00117   }
00118   return false;
00119 }
00120 
00121 
00122 template<class Scalar>
00123 Teuchos::RCP< VectorBase<Scalar> >
00124 DefaultMultiVectorProductVectorSpace<Scalar>::createMember() const
00125 {
00126   return multiVectorProductVector<Scalar>(
00127     Teuchos::rcp(new DefaultMultiVectorProductVectorSpace<Scalar>(*this))
00128     );
00129 }
00130 
00131 
00132 template<class Scalar>
00133 Scalar DefaultMultiVectorProductVectorSpace<Scalar>::scalarProd(
00134   const VectorBase<Scalar> &x_in,
00135   const VectorBase<Scalar> &y_in
00136   ) const
00137 {
00138   return defaultProdVecSpc_->scalarProd(x_in,y_in);
00139   // 2007/05/23: rabartl: ToDo: Implement this in a more efficient way using
00140   // the block scalar product using a single global reduction!
00141 }
00142 
00143 template<class Scalar>
00144 void DefaultMultiVectorProductVectorSpace<Scalar>::scalarProds(
00145   const MultiVectorBase<Scalar> &X_in,
00146   const MultiVectorBase<Scalar> &Y_in,
00147   Scalar scalar_prods[]
00148   ) const
00149 {
00150   defaultProdVecSpc_->scalarProds(X_in,Y_in,scalar_prods);
00151   // 2007/05/23: rabartl: ToDo: Implement this in a more efficient way once
00152   // you have a specialized multi-vector implementation.
00153 }
00154 
00155 template<class Scalar>
00156 bool DefaultMultiVectorProductVectorSpace<Scalar>::hasInCoreView(
00157   const Range1D& rng_in, const EViewType viewType, const EStrideType strideType
00158   ) const
00159 {
00160   return defaultProdVecSpc_->hasInCoreView(rng_in,viewType,strideType);
00161 }
00162 
00163 template<class Scalar>
00164 Teuchos::RCP< const VectorSpaceFactoryBase<Scalar> >
00165 DefaultMultiVectorProductVectorSpace<Scalar>::smallVecSpcFcty() const
00166 {
00167   if (!is_null(space_))
00168     return space_->smallVecSpcFcty();
00169   return Teuchos::null;
00170 }
00171 
00172 template<class Scalar>
00173 Teuchos::RCP< MultiVectorBase<Scalar> >
00174 DefaultMultiVectorProductVectorSpace<Scalar>::createMembers(int numMembers) const
00175 {
00176   return VectorSpaceDefaultBase<Scalar>::createMembers(numMembers);
00177   // 2007/05/23: rabartl: ToDo: Return MultiVectorProductMultiVector object
00178   // once MultiVectorProductMultiVector is created when needed!
00179 }
00180 
00181 
00182 template<class Scalar>
00183 Teuchos::RCP< const VectorSpaceBase<Scalar> >
00184 DefaultMultiVectorProductVectorSpace<Scalar>::clone() const
00185 {
00186   // Warning! If the client uninitialized this object then changes the
00187   // constituent vector spaces then we are in trouble!  The client is warned
00188   // in documentation!
00189   Teuchos::RCP<DefaultMultiVectorProductVectorSpace<Scalar> >
00190     mvpvs = Teuchos::rcp(new DefaultMultiVectorProductVectorSpace<Scalar>());
00191   mvpvs->numColumns_ = numColumns_;
00192   mvpvs->space_ = space_;
00193   mvpvs->defaultProdVecSpc_ = defaultProdVecSpc_;
00194   return mvpvs;
00195 }
00196 
00197 
00198 // Overridden from Teuchos::Describable
00199 
00200                                                 
00201 template<class Scalar>
00202 std::string DefaultMultiVectorProductVectorSpace<Scalar>::description() const
00203 {
00204   assertInitialized();
00205   std::ostringstream oss;
00206   oss
00207     << Teuchos::Describable::description() << "{"
00208     << "dim="<<this->dim()
00209     << ",numBlocks="<<numColumns_
00210     << "}";
00211   return oss.str();
00212 }
00213 
00214 
00215 template<class Scalar>
00216 void DefaultMultiVectorProductVectorSpace<Scalar>::describe(
00217   Teuchos::FancyOStream                &out_arg
00218   ,const Teuchos::EVerbosityLevel      verbLevel
00219   ) const
00220 {
00221   typedef Teuchos::ScalarTraits<Scalar>  ST;
00222   using Teuchos::RCP;
00223   using Teuchos::FancyOStream;
00224   using Teuchos::OSTab;
00225   assertInitialized();
00226   RCP<FancyOStream> out = rcp(&out_arg,false);
00227   OSTab tab(out);
00228   switch(verbLevel) {
00229     case Teuchos::VERB_DEFAULT:
00230     case Teuchos::VERB_LOW:
00231       *out << this->description() << std::endl;
00232       break;
00233     case Teuchos::VERB_MEDIUM:
00234     case Teuchos::VERB_HIGH:
00235     case Teuchos::VERB_EXTREME:
00236     {
00237       *out
00238         << this->description() << std::endl;
00239       OSTab tab(out);
00240       *out
00241         <<  "Constituent vector space 'space' is the same for all spaces V[0],V[1],,,V[numBlocks-1]:\n";
00242       tab.incrTab();
00243       *out << "space = " << Teuchos::describe(*space_,verbLevel);
00244       break;
00245     }
00246     default:
00247       TEST_FOR_EXCEPT(true); // Should never get here!
00248   }
00249 }
00250 
00251 
00252 } // namespace Thyra
00253 
00254 
00255 #endif // THYRA_MULTI_VECTOR_PRODUCT_VECTOR_SPACE_HPP

Generated on Tue Oct 20 12:47:25 2009 for Thyra Package Browser (Single Doxygen Collection) by doxygen 1.4.7