Thyra_DefaultSpmdVector.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_SPMD_VECTOR_HPP
00030 #define THYRA_DEFAULT_SPMD_VECTOR_HPP
00031 
00032 #include "Thyra_DefaultSpmdVectorDecl.hpp"
00033 #include "Thyra_SpmdVectorBase.hpp"
00034 #include "Thyra_SpmdVectorSpaceDefaultBase.hpp"
00035 
00036 namespace Thyra {
00037 
00038 // Constructors/initializers/accessors
00039 
00040 template<class Scalar>
00041 DefaultSpmdVector<Scalar>::DefaultSpmdVector()
00042   :stride_(0)
00043 {}
00044 
00045 template<class Scalar>
00046 DefaultSpmdVector<Scalar>::DefaultSpmdVector(
00047   const Teuchos::RCP<const SpmdVectorSpaceBase<Scalar> >  &spmdSpace
00048   ,const Teuchos::RCP<Scalar>                             &localValues
00049   ,const Index                                                    stride
00050   )
00051 {
00052   initialize(spmdSpace,localValues,stride);
00053 }
00054 
00055 template<class Scalar>
00056 void DefaultSpmdVector<Scalar>::initialize(
00057   const Teuchos::RCP<const SpmdVectorSpaceBase<Scalar> >  &spmdSpace
00058   ,const Teuchos::RCP<Scalar>                             &localValues
00059   ,const Index                                                    stride
00060   )
00061 {
00062 #ifdef TEUCHOS_DEBUG
00063   TEST_FOR_EXCEPT(spmdSpace.get()==NULL);
00064   TEST_FOR_EXCEPT(spmdSpace->localSubDim() > 0 && localValues.get()==NULL);
00065   TEST_FOR_EXCEPT(stride==0);
00066 #endif
00067   spmdSpace_      = spmdSpace;
00068   localValues_   = localValues;
00069   stride_        = stride;
00070   this->updateSpmdSpace();
00071 }
00072 
00073 template<class Scalar>
00074 void DefaultSpmdVector<Scalar>::uninitialize(
00075   Teuchos::RCP<const SpmdVectorSpaceBase<Scalar> >  *spmdSpace
00076   ,Teuchos::RCP<Scalar>                             *localValues
00077   ,Index                                                    *stride
00078   )
00079 {
00080   if(spmdSpace)      *spmdSpace       = spmdSpace_;
00081   if(localValues)   *localValues    = localValues_;
00082   if(stride)        *stride         = stride_;
00083 
00084   spmdSpace_       = Teuchos::null;
00085   localValues_    = Teuchos::null;
00086   stride_         = 0;
00087 
00088   this->updateSpmdSpace();
00089 }
00090 
00091 // Overridden from SpmdVectorBase
00092 
00093 template<class Scalar>
00094 Teuchos::RCP<const SpmdVectorSpaceBase<Scalar> >
00095 DefaultSpmdVector<Scalar>::spmdSpace() const
00096 {
00097   return spmdSpace_;
00098 }
00099 
00100 template<class Scalar>
00101 void DefaultSpmdVector<Scalar>::getLocalData(
00102   Scalar** localValues, Index* stride
00103   )
00104 {
00105 #ifdef TEUCHOS_DEBUG
00106   TEST_FOR_EXCEPT( localValues==NULL );
00107   TEST_FOR_EXCEPT( stride==NULL );
00108 #endif
00109   *localValues = &*localValues_;
00110   *stride = stride_;
00111 }
00112 
00113 template<class Scalar>
00114 void DefaultSpmdVector<Scalar>::commitLocalData( Scalar* localValues )
00115 {
00116 #ifdef TEUCHOS_DEBUG
00117   TEST_FOR_EXCEPT( localValues!=&*localValues_ );
00118 #endif
00119   // Nothing to commit!
00120 }
00121 
00122 template<class Scalar>
00123 void DefaultSpmdVector<Scalar>::getLocalData(
00124   const Scalar** localValues, Index* stride
00125   ) const
00126 {
00127 #ifdef TEUCHOS_DEBUG
00128   TEST_FOR_EXCEPT( localValues==NULL );
00129   TEST_FOR_EXCEPT( stride==NULL );
00130 #endif
00131   *localValues = &*localValues_;
00132   *stride = stride_;
00133 }
00134 
00135 template<class Scalar>
00136 void DefaultSpmdVector<Scalar>::freeLocalData(
00137   const Scalar* localValues
00138   ) const
00139 {
00140 #ifdef TEUCHOS_DEBUG
00141   TEST_FOR_EXCEPT( localValues!=&*localValues_ );
00142 #endif
00143   // Nothing to free!
00144 }
00145 
00146 } // end namespace Thyra
00147 
00148 #endif // THYRA_DEFAULT_SPMD_VECTOR_HPP

Generated on Tue Oct 20 12:46:58 2009 for Thyra Operator/Vector Support by doxygen 1.4.7