Thyra Package Browser (Single Doxygen Collection) Version of the Day
Thyra_DefaultSpmdVector_def.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_DEF_HPP
00030 #define THYRA_DEFAULT_SPMD_VECTOR_DEF_HPP
00031 
00032 
00033 #include "Thyra_DefaultSpmdVector_decl.hpp"
00034 #include "Thyra_SpmdVectorBase.hpp"
00035 #include "Thyra_SpmdVectorSpaceDefaultBase.hpp"
00036 
00037 
00038 namespace Thyra {
00039 
00040 
00041 // Constructors/initializers/accessors
00042 
00043 
00044 template<class Scalar>
00045 DefaultSpmdVector<Scalar>::DefaultSpmdVector()
00046   :stride_(0)
00047 {}
00048 
00049 
00050 template<class Scalar>
00051 DefaultSpmdVector<Scalar>::DefaultSpmdVector(
00052   const RCP<const SpmdVectorSpaceBase<Scalar> > &spmdSpace_in,
00053   const ArrayRCP<Scalar> &localValues,
00054   const Ordinal stride
00055   )
00056 {
00057   initialize(spmdSpace_in, localValues, stride);
00058 }
00059 
00060 
00061 template<class Scalar>
00062 void DefaultSpmdVector<Scalar>::initialize(
00063   const RCP<const SpmdVectorSpaceBase<Scalar> > &spmdSpace_in
00064   ,const ArrayRCP<Scalar> &localValues
00065   ,const Ordinal stride
00066   )
00067 {
00068 #ifdef TEUCHOS_DEBUG
00069   TEST_FOR_EXCEPT(is_null(spmdSpace_in));
00070   TEST_FOR_EXCEPT(spmdSpace_in->localSubDim() > 0 && localValues.get()==NULL);
00071   TEST_FOR_EXCEPT(stride==0);
00072 #endif
00073   spmdSpace_ = spmdSpace_in;
00074   localValues_ = localValues;
00075   stride_ = stride;
00076   this->updateSpmdSpace();
00077 }
00078 
00079 
00080 template<class Scalar>
00081 void DefaultSpmdVector<Scalar>::uninitialize(
00082   RCP<const SpmdVectorSpaceBase<Scalar> > *spmdSpace_in
00083   ,ArrayRCP<Scalar> *localValues
00084   ,Ordinal *stride
00085   )
00086 {
00087   if(spmdSpace_in) *spmdSpace_in = spmdSpace_;
00088   if(localValues) *localValues = localValues_;
00089   if(stride) *stride = stride_;
00090 
00091   spmdSpace_ = Teuchos::null;
00092   localValues_ = Teuchos::null;
00093   stride_ = 0;
00094 
00095   this->updateSpmdSpace();
00096 }
00097 
00098 
00099 // Overridden from SpmdVectorBase
00100 
00101 
00102 template<class Scalar>
00103 RCP<const SpmdVectorSpaceBase<Scalar> >
00104 DefaultSpmdVector<Scalar>::spmdSpace() const
00105 {
00106   return spmdSpace_;
00107 }
00108 
00109 
00110 template<class Scalar>
00111 void DefaultSpmdVector<Scalar>::getNonconstLocalDataImpl(
00112   const Ptr<ArrayRCP<Scalar> > &localValues )
00113 {
00114   *localValues = localValues_;
00115 }
00116 
00117 
00118 template<class Scalar>
00119 void DefaultSpmdVector<Scalar>::getLocalDataImpl(
00120   const Ptr<ArrayRCP<const Scalar> > &localValues ) const
00121 {
00122   *localValues = localValues_;
00123 }
00124 
00125 
00126 } // end namespace Thyra
00127 
00128 
00129 #endif // THYRA_DEFAULT_SPMD_VECTOR_DEF_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines