00001 /* @HEADER@ */ 00002 /* *********************************************************************** 00003 // 00004 // TSFExtended: Trilinos Solver Framework Extended 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 TSFVECTORSPACEDECL_HPP 00030 #define TSFVECTORSPACEDECL_HPP 00031 00032 #include "SundanceDefs.hpp" 00033 #include "Thyra_VectorSpaceBase.hpp" 00034 #include "SundanceHandle.hpp" 00035 #include "TSFSequentialIteratorDecl.hpp" 00036 00037 00038 00039 namespace TSFExtended 00040 { 00041 using namespace Teuchos; 00042 00043 template<class Scalar> class Vector; 00044 00045 /** 00046 * Implementation of the Handle for the Vector class. This wraps a 00047 * TSFCoreVector 00048 */ 00049 template <class Scalar> 00050 class VectorSpace : public Sundance::Handle< const Thyra::VectorSpaceBase<Scalar> > 00051 { 00052 public: 00053 HANDLE_CTORS(VectorSpace<Scalar>, const Thyra::VectorSpaceBase<Scalar>); 00054 00055 /** Create a new element of this vector space */ 00056 Vector<Scalar> createMember() const ; 00057 00058 /** Return the dimension of the space */ 00059 int dim() const {return this->ptr()->dim();} 00060 00061 /** Return the lowest global index accessible on this processor */ 00062 int lowestLocallyOwnedIndex() const ; 00063 00064 /** Return the number of elements owned by this processor */ 00065 int numLocalElements() const ; 00066 00067 /** Check compatibility with another space. Implementation note: 00068 * we don't know if the argument vec space is a handle to another 00069 * vector space or the contents of a handle, and we want the operation 00070 * to work the same in either case. We can make this work as 00071 * follows: have the argument check compatibility with the contents 00072 * of this handle. If the argument is a handle, the process 00073 * will be repeated, interchanging places again so that both handles 00074 * are dereferenced. If the argument is not a handle, then it 00075 * ends up comparing to the concrete contents of this handle, giving the 00076 * same results. */ 00077 bool isCompatible(const VectorSpace<Scalar>& vecSpc) const; 00078 00079 00080 /** test equality between two spaces */ 00081 bool operator==(const VectorSpace<Scalar>& other) const ; 00082 00083 00084 /** test inequality of two spaces */ 00085 bool operator!=(const VectorSpace<Scalar>& other) const ; 00086 00087 00088 /** test whether the space contains a given vector */ 00089 bool contains(const Vector<Scalar>& vec) const ; 00090 00091 00092 /** return the number of subblocks. */ 00093 int numBlocks() const ; 00094 00095 /** get the i-th subblock */ 00096 VectorSpace<Scalar> getBlock(int i) const ; 00097 00098 00099 /** set the i-th subblock */ 00100 void setBlock(int i, const VectorSpace<Scalar>& space); 00101 00102 00103 /** */ 00104 SequentialIterator<Scalar> begin() const ; 00105 00106 /** */ 00107 SequentialIterator<Scalar> end() const ; 00108 00109 /** */ 00110 bool advanceIndex(OrdType& blockIndex, OrdType& indexInCurrentBlock, OrdType& globalIndex) const ; 00111 }; 00112 00113 template <class Scalar> 00114 STREAM_OUT(VectorSpace<Scalar>) 00115 00116 } 00117 00118 00119 #endif