Actual source code: indexspace.h

  1: #ifndef __PETSc_IndexSpace_h__

  4: // this contains the definition of PetscMap
 5:  #include petscvec.h

 7:  #include esi/petsc/object.h

  9: // The esi::petsc::IndexSpace supports the esi::IndexSpace interfaces

 11: #include "esi/IndexSpace.h"

 13: namespace esi{namespace petsc{

 15: /**=========================================================================**/
 16: template<class Ordinal>
 17: class IndexSpace : public virtual esi::IndexSpace<Ordinal>, public esi::petsc::Object
 18: {
 19:   public:

 21:     // constructor.
 22:     IndexSpace(MPI_Comm icomm) {this->map = 0;};
 23:     IndexSpace() {this->map = 0;};

 25:     // Construct an IndexSpace form an IndexSpace
 26:     IndexSpace(esi::IndexSpace<Ordinal>& sourceIndexSpace);

 28:     // Construct an IndexSpace from a PETSc (old-style) map.
 29:     IndexSpace(PetscMap sourceIndexSpace);

 31:     // Basic constructor
 32:     IndexSpace(MPI_Comm comm, int n, int N);

 34:     // destructor.
 35:     virtual ~IndexSpace(void);

 37:     //  Interface for esi::Object  ---------------

 39:     virtual esi::ErrorCode getInterface(const char* name, void*& iface);
 40:     virtual esi::ErrorCode getInterfacesSupported(esi::Argv * list);

 42:     //  Interface for esi::IndexSpace  ---------------

 44:     // Get the size of this mapped dimension of the problem.
 45:     virtual esi::ErrorCode getGlobalSize(Ordinal& globalSize);
 46:     virtual esi::ErrorCode getLocalSize(Ordinal& localSize);

 48:     // Get the size of this dimension of the problem, as well as
 49:     // the global offset info for all processors.
 50:     virtual esi::ErrorCode getGlobalPartitionSizes(Ordinal* globalSizes);
 51:     virtual esi::ErrorCode getGlobalPartitionOffsets(Ordinal* globalOffsets);

 53:     virtual esi::ErrorCode getGlobalPartitionSetSize(Ordinal &) {return 1;};
 54:     virtual esi::ErrorCode getLocalPartitionRank(Ordinal &) {return 1;};

 56:     virtual esi::ErrorCode getGlobalColorSetSize(Ordinal &) {return 1;};
 57:     virtual esi::ErrorCode getLocalColors(Ordinal *) {return 1;};
 58:     virtual esi::ErrorCode getLocalIdentifiers(Ordinal *) {return 1;};

 60:     // Get the local size offset info in this dimension.
 61:     virtual esi::ErrorCode getLocalPartitionOffset(Ordinal& localOffset);

 63:   class Factory : public virtual ::esi::IndexSpace<Ordinal>::Factory
 64:   {
 65:     public:

 67:     // Destructor.
 68:     virtual ~Factory(void){};

 70:     // Construct a IndexSpace
 71:     virtual esi::ErrorCode create(const char * name,void *comm,int m,int M,int base,esi::IndexSpace<Ordinal>*&v);
 72:   };

 74:   private:
 75:     PetscMap map;
 76: };


 79: /**=========================================================================**/
 80: /*
 81:     This is required for certain C++ compilers (borland,solaris) to 
 82:    allow providing methods directly for IndexSpace<int>
 83: */
 84: template<>
 85: class IndexSpace<int>: public virtual esi::IndexSpace<int>, public esi::petsc::Object
 86: {
 87:   public:

 89:     // constructor.
 90:     IndexSpace(MPI_Comm icomm) {};

 92:     // Construct an IndexSpace form an IndexSpace
 93:     IndexSpace(esi::IndexSpace<int>& sourceIndexSpace);

 95:     // Construct an IndexSpace from a PETSc (old-style) map.
 96:     IndexSpace(PetscMap sourceIndexSpace);

 98:     // Basic constructor
 99:     IndexSpace(MPI_Comm comm, int n, int N);

101:     // destructor.
102:     virtual ~IndexSpace(void);

104:     //  Interface for esi::Object  ---------------

106:     virtual esi::ErrorCode getInterface(const char* name, void*& iface);
107:     virtual esi::ErrorCode getInterfacesSupported(esi::Argv * list);

109:     //  Interface for esi::IndexSpace  ---------------

111:     // Get the size of this mapped dimension of the problem.
112:     virtual esi::ErrorCode getGlobalSize(int& globalSize);
113:     virtual esi::ErrorCode getLocalSize(int& localSize);

115:     // Get the size of this dimension of the problem, as well as
116:     // the global offset info for all processors.
117:     virtual esi::ErrorCode getGlobalPartitionSizes(int* globalSizes);
118:     virtual esi::ErrorCode getGlobalPartitionOffsets(int* globalOffsets);

120:     virtual esi::ErrorCode getGlobalPartitionSetSize(int &) {return 1;};
121:     virtual esi::ErrorCode getLocalPartitionRank(int &) {return 1;};

123:     virtual esi::ErrorCode getGlobalColorSetSize(int &) {return 1;};
124:     virtual esi::ErrorCode getLocalColors(int *) {return 1;};
125:     virtual esi::ErrorCode getLocalIdentifiers(int *) {return 1;};

127:     // Get the local size offset info in this dimension.
128:     virtual esi::ErrorCode getLocalPartitionOffset(int& localOffset);

130:     class Factory : public virtual ::esi::IndexSpace<int>::Factory
131:   {
132:     public:

134:     // Destructor.
135:     virtual ~Factory(void){};

137:     // Construct a IndexSpace
138:     virtual esi::ErrorCode create(const char * name,void *comm,int m,int M,int base,esi::IndexSpace<int>*&v);
139:   };

141:   private:
142:     PetscMap map;
143: };

145: }}

147: extern int ESICreateIndexSpace(const char * commname,void *comm,int m,::esi::IndexSpace<int>*&v);
148: #endif