PlayaVectorTypeBase.hpp
00001
00002
00003
00004
00005 #ifndef PLAYA_VECTORTYPEBASE_HPP
00006 #define PLAYA_VECTORTYPEBASE_HPP
00007
00008 #include "PlayaHandle.hpp"
00009 #include "PlayaVectorSpaceDecl.hpp"
00010 #include "PlayaLinearOperatorDecl.hpp"
00011 #include "PlayaMatrixFactory.hpp"
00012 #include "PlayaGhostImporter.hpp"
00013
00014 namespace Playa
00015 {
00016 using namespace Teuchos;
00017
00021 template <class Scalar>
00022 class VectorTypeBase
00023 {
00024 public:
00026 virtual ~VectorTypeBase() {;}
00027
00033 virtual RCP<const VectorSpaceBase<Scalar> >
00034 createSpace(int dimension,
00035 int nLocal,
00036 const int* locallyOwnedIndices,
00037 const MPIComm& comm) const = 0 ;
00038
00039
00043 virtual VectorSpace<Scalar>
00044 createEvenlyPartitionedSpace(const MPIComm& comm,
00045 int nLocal) const ;
00046
00056 virtual RCP<GhostImporter<Scalar> >
00057 createGhostImporter(const VectorSpace<Scalar>& space,
00058 int nGhost,
00059 const int* ghostIndices) const = 0 ;
00060
00061
00066 virtual RCP<MatrixFactory<Scalar> >
00067 createMatrixFactory(const VectorSpace<Scalar>& domain,
00068 const VectorSpace<Scalar>& range) const = 0 ;
00069
00070
00071 };
00072
00073
00074
00075
00076 template <class Scalar> inline
00077 VectorSpace<Scalar> VectorTypeBase<Scalar>
00078 ::createEvenlyPartitionedSpace(const MPIComm& comm,
00079 int nLocal) const
00080 {
00081 int rank = comm.getRank();
00082 int nProc = comm.getNProc();
00083 int dimension = nLocal * nProc;
00084 Array<int> locallyOwnedIndices(nLocal);
00085 int lowestLocalRow = rank*nLocal;
00086 for (int i=0; i<nLocal; i++)
00087 {
00088 locallyOwnedIndices[i] = lowestLocalRow + i;
00089 }
00090 return this->createSpace(dimension, nLocal, &(locallyOwnedIndices[0]), comm);
00091 }
00092
00093
00094 }
00095
00096 #endif