Actual source code: petscis.h
1: /* $Id: petscis.h,v 1.63 2001/06/21 21:15:49 bsmith Exp $ */
3: /*
4: An index set is a generalization of a subset of integers. Index sets
5: are used for defining scatters and gathers.
6: */
9: #include petsc.h
10: PETSC_EXTERN_CXX_BEGIN
12: extern int IS_COOKIE;
14: /*S
15: IS - Abstract PETSc object that indexing.
17: Level: beginner
19: Concepts: indexing, stride
21: .seealso: ISCreateGeneral(), ISCreateBlock(), ISCreateStride(), ISGetIndices(), ISDestroy()
22: S*/
23: typedef struct _p_IS* IS;
25: /*
26: Default index set data structures that PETSc provides.
27: */
28: typedef enum {IS_GENERAL=0,IS_STRIDE=1,IS_BLOCK = 2} ISType;
29: EXTERN int ISCreateGeneral(MPI_Comm,int,const int[],IS *);
30: EXTERN int ISCreateBlock(MPI_Comm,int,int,const int[],IS *);
31: EXTERN int ISCreateStride(MPI_Comm,int,int,int,IS *);
33: EXTERN int ISDestroy(IS);
35: EXTERN int ISSetPermutation(IS);
36: EXTERN int ISPermutation(IS,PetscTruth*);
37: EXTERN int ISSetIdentity(IS);
38: EXTERN int ISIdentity(IS,PetscTruth*);
40: EXTERN int ISGetIndices(IS,int *[]);
41: EXTERN int ISRestoreIndices(IS,int *[]);
42: EXTERN int ISGetSize(IS,int *);
43: EXTERN int ISGetLocalSize(IS,int *);
44: EXTERN int ISInvertPermutation(IS,int,IS*);
45: EXTERN int ISView(IS,PetscViewer);
46: EXTERN int ISEqual(IS,IS,PetscTruth *);
47: EXTERN int ISSort(IS);
48: EXTERN int ISSorted(IS,PetscTruth *);
49: EXTERN int ISDifference(IS,IS,IS*);
50: EXTERN int ISSum(IS,IS,IS*);
52: EXTERN int ISBlock(IS,PetscTruth*);
53: EXTERN int ISBlockGetIndices(IS,int *[]);
54: EXTERN int ISBlockRestoreIndices(IS,int *[]);
55: EXTERN int ISBlockGetSize(IS,int *);
56: EXTERN int ISBlockGetBlockSize(IS,int *);
58: EXTERN int ISStride(IS,PetscTruth*);
59: EXTERN int ISStrideGetInfo(IS,int *,int*);
61: EXTERN int ISStrideToGeneral(IS);
63: EXTERN int ISDuplicate(IS,IS*);
64: EXTERN int ISAllGather(IS,IS*);
65: EXTERN int ISAllGatherIndices(MPI_Comm,int,const int[],int*,int*[]);
67: /* --------------------------------------------------------------------------*/
68: extern int IS_LTOGM_COOKIE;
70: /*S
71: ISLocalToGlobalMapping - mappings from an arbitrary
72: local ordering from 0 to n-1 to a global PETSc ordering
73: used by a vector or matrix.
75: Level: intermediate
77: Note: mapping from Local to Global is scalable; but Global
78: to Local may not be if the range of global values represented locally
79: is very large.
81: Note: the ISLocalToGlobalMapping is actually a private object; it is included
82: here for the MACRO ISLocalToGlobalMappingApply() to allow it to be inlined since
83: it is used so often.
85: .seealso: ISLocalToGlobalMappingCreate()
86: S*/
87: struct _p_ISLocalToGlobalMapping{
88: PETSCHEADER(int)
89: int n; /* number of local indices */
90: int *indices; /* global index of each local index */
91: int globalstart; /* first global referenced in indices */
92: int globalend; /* last + 1 global referenced in indices */
93: int *globals; /* local index for each global index between start and end */
94: };
95: typedef struct _p_ISLocalToGlobalMapping* ISLocalToGlobalMapping;
97: /*E
98: ISGlobalToLocalMappingType - Indicates if missing global indices are
100: IS_GTOLM_MASK - missing global indices are replaced with -1
101: IS_GTOLM_DROP - missing global indices are dropped
103: Level: beginner
105: .seealso: ISGlobalToLocalMappingApply()
107: E*/
108: typedef enum {IS_GTOLM_MASK,IS_GTOLM_DROP} ISGlobalToLocalMappingType;
110: EXTERN int ISLocalToGlobalMappingCreate(MPI_Comm,int,const int[],ISLocalToGlobalMapping*);
111: EXTERN int ISLocalToGlobalMappingCreateNC(MPI_Comm,int,const int[],ISLocalToGlobalMapping*);
112: EXTERN int ISLocalToGlobalMappingCreateIS(IS,ISLocalToGlobalMapping *);
113: EXTERN int ISLocalToGlobalMappingView(ISLocalToGlobalMapping,PetscViewer);
114: EXTERN int ISLocalToGlobalMappingDestroy(ISLocalToGlobalMapping);
115: EXTERN int ISLocalToGlobalMappingApplyIS(ISLocalToGlobalMapping,IS,IS*);
116: EXTERN int ISGlobalToLocalMappingApply(ISLocalToGlobalMapping,ISGlobalToLocalMappingType,int,const int[],int*,int[]);
117: EXTERN int ISLocalToGlobalMappingGetSize(ISLocalToGlobalMapping,int*);
118: EXTERN int ISLocalToGlobalMappingGetInfo(ISLocalToGlobalMapping,int*,int*[],int*[],int**[]);
119: EXTERN int ISLocalToGlobalMappingRestoreInfo(ISLocalToGlobalMapping,int*,int*[],int*[],int**[]);
120: EXTERN int ISLocalToGlobalMappingBlock(ISLocalToGlobalMapping,int,ISLocalToGlobalMapping*);
122: #define ISLocalToGlobalMappingApply(mapping,N,in,out) 0;\
123: {\
124: int _i,*_idx = (mapping)->indices,_Nmax = (mapping)->n;\
125: for (_i=0; _i<N; _i++) {\
126: if ((in)[_i] < 0) {(out)[_i] = (in)[_i]; continue;}\
127: if ((in)[_i] >= _Nmax) SETERRQ3(PETSC_ERR_ARG_OUTOFRANGE,"Local index %d too large %d (max) at %d",(in)[_i],_Nmax,_i);\
128: (out)[_i] = _idx[(in)[_i]];\
129: }\
130: }
132: /* --------------------------------------------------------------------------*/
133: /*E
134: ISColoringType - determines if the coloring is for the entire parallel grid/graph/matrix
135: or for just the local ghosted portion
137: Level: beginner
139: $ IS_COLORING_LOCAL - does not include the colors for ghost points
140: $ IS_COLORING_GHOSTED - includes colors for ghost points
142: .seealso: DAGetColoring()
143: E*/
144: typedef enum {IS_COLORING_LOCAL,IS_COLORING_GHOSTED} ISColoringType;
146: #define MPIU_COLORING_VALUE MPI_CHAR
147: #define IS_COLORING_MAX 255
148: typedef unsigned char ISColoringValue;
149: EXTERN int ISAllGatherColors(MPI_Comm,int,ISColoringValue*,int*,ISColoringValue*[]);
151: /*S
152: ISColoring - sets of IS's that define a coloring
153: of the underlying indices
155: Level: intermediate
157: Notes:
158: One should not access the *is records below directly because they may not yet
159: have been created. One should use ISColoringGetIS() to make sure they are
160: created when needed.
162: .seealso: ISColoringCreate(), ISColoringGetIS(), ISColoringView(), ISColoringGetIS()
163: S*/
164: struct _p_ISColoring {
165: int refct;
166: int n; /* number of colors */
167: IS *is; /* for each color indicates columns */
168: MPI_Comm comm;
169: ISColoringValue *colors; /* for each column indicates color */
170: int N; /* number of columns */
171: ISColoringType ctype;
172: };
173: typedef struct _p_ISColoring* ISColoring;
175: EXTERN int ISColoringCreate(MPI_Comm,int,const ISColoringValue[],ISColoring*);
176: EXTERN int ISColoringDestroy(ISColoring);
177: EXTERN int ISColoringView(ISColoring,PetscViewer);
178: EXTERN int ISColoringGetIS(ISColoring,int*,IS*[]);
179: EXTERN int ISColoringRestoreIS(ISColoring,IS*[]);
180: #define ISColoringReference(coloring) ((coloring)->refct++,0)
181: #define ISColoringSetType(coloring,type) ((coloring)->ctype = type,0)
183: /* --------------------------------------------------------------------------*/
185: EXTERN int ISPartitioningToNumbering(IS,IS*);
186: EXTERN int ISPartitioningCount(IS,int[]);
188: EXTERN int ISCompressIndicesGeneral(int,int,int,const IS[],IS[]);
189: EXTERN int ISCompressIndicesSorted(int,int,int,const IS[],IS[]);
190: EXTERN int ISExpandIndicesGeneral(int,int,int,const IS[],IS[]);
192: PETSC_EXTERN_CXX_END
193: #endif