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

Generated on Thu Sep 18 12:39:52 2008 for Thyra ANA Operator/VectorBase Interfaces and Related Software by doxygen 1.3.9.1