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) {};
24: // Construct an IndexSpace form an IndexSpace
25: IndexSpace(esi::IndexSpace<Ordinal>& sourceIndexSpace);
27: // Construct an IndexSpace from a PETSc (old-style) map.
28: IndexSpace(PetscMap sourceIndexSpace);
30: // Basic constructor
31: IndexSpace(MPI_Comm comm, int n, int N);
33: // destructor.
34: virtual ~IndexSpace(void);
36: // Interface for esi::Object ---------------
38: virtual esi::ErrorCode getInterface(const char* name, void*& iface);
39: virtual esi::ErrorCode getInterfacesSupported(esi::Argv * list);
41: // Interface for esi::IndexSpace ---------------
43: // Get the size of this mapped dimension of the problem.
44: virtual esi::ErrorCode getGlobalSize(Ordinal& globalSize);
45: virtual esi::ErrorCode getLocalSize(Ordinal& localSize);
47: // Get the size of this dimension of the problem, as well as
48: // the global offset info for all processors.
49: virtual esi::ErrorCode getGlobalPartitionSizes(Ordinal* globalSizes);
50: virtual esi::ErrorCode getGlobalPartitionOffsets(Ordinal* globalOffsets);
52: virtual esi::ErrorCode getGlobalPartitionSetSize(Ordinal &) {return 1;};
53: virtual esi::ErrorCode getLocalPartitionRank(Ordinal &) {return 1;};
55: virtual esi::ErrorCode getGlobalColorSetSize(Ordinal &) {return 1;};
56: virtual esi::ErrorCode getLocalColors(Ordinal *) {return 1;};
57: virtual esi::ErrorCode getLocalIdentifiers(Ordinal *) {return 1;};
59: // Get the local size offset info in this dimension.
60: virtual esi::ErrorCode getLocalPartitionOffset(Ordinal& localOffset);
62: private:
63: PetscMap map;
64: };
67: /**=========================================================================**/
68: /*
69: This is required for certain C++ compilers (borland,solaris) to
70: allow providing methods directly for IndexSpace<int>
71: */
72: template<>
73: class IndexSpace<int>: public virtual esi::IndexSpace<int>, public esi::petsc::Object
74: {
75: public:
77: // constructor.
78: IndexSpace(MPI_Comm icomm) {};
80: // Construct an IndexSpace form an IndexSpace
81: IndexSpace(esi::IndexSpace<int>& sourceIndexSpace);
83: // Construct an IndexSpace from a PETSc (old-style) map.
84: IndexSpace(PetscMap sourceIndexSpace);
86: // Basic constructor
87: IndexSpace(MPI_Comm comm, int n, int N);
89: // destructor.
90: virtual ~IndexSpace(void);
92: // Interface for esi::Object ---------------
94: virtual esi::ErrorCode getInterface(const char* name, void*& iface);
95: virtual esi::ErrorCode getInterfacesSupported(esi::Argv * list);
97: // Interface for esi::IndexSpace ---------------
99: // Get the size of this mapped dimension of the problem.
100: virtual esi::ErrorCode getGlobalSize(int& globalSize);
101: virtual esi::ErrorCode getLocalSize(int& localSize);
103: // Get the size of this dimension of the problem, as well as
104: // the global offset info for all processors.
105: virtual esi::ErrorCode getGlobalPartitionSizes(int* globalSizes);
106: virtual esi::ErrorCode getGlobalPartitionOffsets(int* globalOffsets);
108: virtual esi::ErrorCode getGlobalPartitionSetSize(int &) {return 1;};
109: virtual esi::ErrorCode getLocalPartitionRank(int &) {return 1;};
111: virtual esi::ErrorCode getGlobalColorSetSize(int &) {return 1;};
112: virtual esi::ErrorCode getLocalColors(int *) {return 1;};
113: virtual esi::ErrorCode getLocalIdentifiers(int *) {return 1;};
115: // Get the local size offset info in this dimension.
116: virtual esi::ErrorCode getLocalPartitionOffset(int& localOffset);
118: private:
119: PetscMap map;
120: };
123: }
125: /* -------------------------------------------------------------------------*/
127: template<class Ordinal> class IndexSpaceFactory
128: #if defined(PETSC_HAVE_CCA)
129: : public virtual gov::cca::Port, public virtual gov::cca::Component
130: #endif
131: {
132: public:
134: // Destructor.
135: virtual ~IndexSpaceFactory(void){};
137: // Interface for gov::cca::Component
138: #if defined(PETSC_HAVE_CCA)
139: virtual void setServices(gov::cca::Services *) = 0;
140: #endif
142: // Construct a IndexSpace
143: virtual esi::ErrorCode getIndexSpace(const char * name,void *comm,int m,esi::IndexSpace<Ordinal>*&v) = 0;
144: };
145: }
147: extern int ESICreateIndexSpace(const char * commname,void *comm,int m,::esi::IndexSpace<int>*&v);
148: #endif