00001 /* @HEADER@ */ 00002 // 00003 /* @HEADER@ */ 00004 00005 #ifndef PLAYA_VECTORSPACEDECL_HPP 00006 #define PLAYA_VECTORSPACEDECL_HPP 00007 00008 #include "PlayaDefs.hpp" 00009 #include "PlayaHandle.hpp" 00010 #include "PlayaVectorSpaceBaseDecl.hpp" 00011 #include "PlayaBlockIteratorDecl.hpp" 00012 00013 namespace Playa 00014 { 00015 using namespace Teuchos; 00016 00020 template <class Scalar> 00021 class VectorSpace : public Playa::Handle< const VectorSpaceBase<Scalar> > 00022 { 00023 public: 00024 HANDLE_CTORS(VectorSpace<Scalar>, const VectorSpaceBase<Scalar>); 00025 00027 Vector<Scalar> createMember() const ; 00028 00030 int dim() const {return this->ptr()->dim();} 00031 00033 int baseGlobalNaturalIndex() const ; 00034 00036 int numLocalElements() const ; 00037 00039 const MPIComm& comm() const {return this->ptr()->comm();} 00040 00042 bool isCompatible(const VectorSpace<Scalar>& vecSpc) const; 00043 00044 00046 bool operator==(const VectorSpace<Scalar>& other) const ; 00047 00048 00050 bool operator!=(const VectorSpace<Scalar>& other) const ; 00051 00052 00054 bool contains(const Vector<Scalar>& vec) const ; 00055 00056 00058 int numBlocks() const ; 00059 00061 bool isBlockSpace() const ; 00062 00064 const VectorSpace<Scalar>& getBlock(int i) const ; 00065 00067 const VectorSpace<Scalar>& getBlock(const BlockIterator<Scalar>& iter) const ; 00068 00070 const VectorSpace<Scalar>& getBlock(const std::deque<int>& iter) const ; 00071 00073 BlockIterator<Scalar> beginBlock() const ; 00074 00076 BlockIterator<Scalar> endBlock() const ; 00077 00079 int mapToGNI(const BlockIterator<Scalar>& b, int indexWithinBlock) const ; 00080 00082 bool containsGNI(int gni) const ; 00083 00085 void getBlockAndOffsetFromGNI(int gni, 00086 BlockIterator<Scalar>& block, int& indexWithinBlock) const ; 00087 00088 protected: 00089 00090 00091 }; 00092 00093 #define PLAYA_CHECK_SPACES(space1, space2) \ 00094 TEUCHOS_TEST_FOR_EXCEPTION(!space1.isCompatible(space2), std::runtime_error, \ 00095 "incompatible spaces " << space1 << " and " << space2) 00096 00097 00098 template <class Scalar> 00099 STREAM_OUT(VectorSpace<Scalar>) 00100 00101 00102 00103 } 00104 00105 00106 #endif