Thyra_DefaultSpmdVector.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_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::RefCountPtr<const SpmdVectorSpaceBase<Scalar> >  &spmdSpace
00048   ,const Teuchos::RefCountPtr<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::RefCountPtr<const SpmdVectorSpaceBase<Scalar> >  &spmdSpace
00058   ,const Teuchos::RefCountPtr<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::RefCountPtr<const SpmdVectorSpaceBase<Scalar> >  *spmdSpace
00076   ,Teuchos::RefCountPtr<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 Teuchos::Describable
00092 
00093 template<class Scalar>
00094 std::string DefaultSpmdVector<Scalar>::description() const
00095 {
00096   return (std::string("DefaultSpmdVector<")
00097           + Teuchos::ScalarTraits<Scalar>::name() + std::string(">"));
00098 }
00099 
00100 // Overridden from SpmdVectorBase
00101 
00102 template<class Scalar>
00103 Teuchos::RefCountPtr<const SpmdVectorSpaceBase<Scalar> >
00104 DefaultSpmdVector<Scalar>::spmdSpace() const
00105 {
00106   return spmdSpace_;
00107 }
00108 
00109 template<class Scalar>
00110 void DefaultSpmdVector<Scalar>::getLocalData(
00111   Scalar** localValues, Index* stride
00112   )
00113 {
00114 #ifdef TEUCHOS_DEBUG
00115   TEST_FOR_EXCEPT( localValues==NULL );
00116   TEST_FOR_EXCEPT( stride==NULL );
00117 #endif
00118   *localValues = &*localValues_;
00119   *stride = stride_;
00120 }
00121 
00122 template<class Scalar>
00123 void DefaultSpmdVector<Scalar>::commitLocalData( Scalar* localValues )
00124 {
00125 #ifdef TEUCHOS_DEBUG
00126   TEST_FOR_EXCEPT( localValues!=&*localValues_ );
00127 #endif
00128   // Nothing to commit!
00129 }
00130 
00131 template<class Scalar>
00132 void DefaultSpmdVector<Scalar>::getLocalData(
00133   const Scalar** localValues, Index* stride
00134   ) const
00135 {
00136 #ifdef TEUCHOS_DEBUG
00137   TEST_FOR_EXCEPT( localValues==NULL );
00138   TEST_FOR_EXCEPT( stride==NULL );
00139 #endif
00140   *localValues = &*localValues_;
00141   *stride = stride_;
00142 }
00143 
00144 template<class Scalar>
00145 void DefaultSpmdVector<Scalar>::freeLocalData(
00146   const Scalar* localValues
00147   ) const
00148 {
00149 #ifdef TEUCHOS_DEBUG
00150   TEST_FOR_EXCEPT( localValues!=&*localValues_ );
00151 #endif
00152   // Nothing to free!
00153 }
00154 
00155 } // end namespace Thyra
00156 
00157 #endif // THYRA_DEFAULT_SPMD_VECTOR_HPP

Generated on Thu Sep 18 12:33:02 2008 for Thyra Package Browser (Single Doxygen Collection) by doxygen 1.3.9.1