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
11: extern int IS_COOKIE;
13: /*S
14: IS - Abstract PETSc object that indexing.
16: Level: beginner
18: Concepts: indexing, stride
20: .seealso: ISCreateGeneral(), ISCreateBlock(), ISCreateStride(), ISGetIndices(), ISDestroy()
21: S*/
22: typedef struct _p_IS* IS;
24: /*
25: Default index set data structures that PETSc provides.
26: */
27: typedef enum {IS_GENERAL=0,IS_STRIDE=1,IS_BLOCK = 2} ISType;
28: EXTERN int ISCreateGeneral(MPI_Comm,int,const int[],IS *);
29: EXTERN int ISCreateBlock(MPI_Comm,int,int,const int[],IS *);
30: EXTERN int ISCreateStride(MPI_Comm,int,int,int,IS *);
32: EXTERN int ISDestroy(IS);
34: EXTERN int ISSetPermutation(IS);
35: EXTERN int ISPermutation(IS,PetscTruth*);
36: EXTERN int ISSetIdentity(IS);
37: EXTERN int ISIdentity(IS,PetscTruth*);
39: EXTERN int ISGetIndices(IS,int *[]);
40: EXTERN int ISRestoreIndices(IS,int *[]);
41: EXTERN int ISGetSize(IS,int *);
42: EXTERN int ISGetLocalSize(IS,int *);
43: EXTERN int ISInvertPermutation(IS,int,IS*);
44: EXTERN int ISView(IS,PetscViewer);
45: EXTERN int ISEqual(IS,IS,PetscTruth *);
46: EXTERN int ISSort(IS);
47: EXTERN int ISSorted(IS,PetscTruth *);
48: EXTERN int ISDifference(IS,IS,IS*);
49: EXTERN int ISSum(IS,IS,IS*);
51: EXTERN int ISBlock(IS,PetscTruth*);
52: EXTERN int ISBlockGetIndices(IS,int *[]);
53: EXTERN int ISBlockRestoreIndices(IS,int *[]);
54: EXTERN int ISBlockGetSize(IS,int *);
55: EXTERN int ISBlockGetBlockSize(IS,int *);
57: EXTERN int ISStride(IS,PetscTruth*);
58: EXTERN int ISStrideGetInfo(IS,int *,int*);
60: EXTERN int ISStrideToGeneral(IS);
62: EXTERN int ISDuplicate(IS,IS*);
63: EXTERN int ISAllGather(IS,IS*);
64: EXTERN int ISAllGatherIndices(MPI_Comm,int,int*,int*,int**);
66: /* --------------------------------------------------------------------------*/
67: #define IS_LTOGM_COOKIE PETSC_COOKIE+12
69: /*S
70: ISLocalToGlobalMappings - mappings from an arbitrary
71: local ordering from 0 to n-1 to a global PETSc ordering
72: used by a vector or matrix.
74: Level: intermediate
76: Note: mapping from Local to Global is scalable; but Global
77: to Local may not be if the range of global values represented locally
78: is very large.
80: Note: the ISLocalToGlobalMapping is actually a private object; it is included
81: here for the MACRO ISLocalToGlobalMappingApply() to allow it to be inlined since
82: it is used so often.
84: .seealso: ISLocalToGlobalMappingCreate()
85: S*/
86: struct _p_ISLocalToGlobalMapping{
87: PETSCHEADER(int)
88: int n; /* number of local indices */
89: int *indices; /* global index of each local index */
90: int globalstart; /* first global referenced in indices */
91: int globalend; /* last + 1 global referenced in indices */
92: int *globals; /* local index for each global index between start and end */
93: };
94: typedef struct _p_ISLocalToGlobalMapping* ISLocalToGlobalMapping;
96: /*E
97: ISGlobalToLocalMappingType - Indicates if missing global indices are
99: IS_GTOLM_MASK - missing global indices are replaced with -1
100: IS_GTOLM_DROP - missing global indices are dropped
102: Level: beginner
104: .seealso: ISGlobalToLocalMappingApply()
106: E*/
107: typedef enum {IS_GTOLM_MASK,IS_GTOLM_DROP} ISGlobalToLocalMappingType;
109: EXTERN int ISLocalToGlobalMappingCreate(MPI_Comm,int,const int[],ISLocalToGlobalMapping*);
110: EXTERN int ISLocalToGlobalMappingCreateIS(IS,ISLocalToGlobalMapping *);
111: EXTERN int ISLocalToGlobalMappingView(ISLocalToGlobalMapping,PetscViewer);
112: EXTERN int ISLocalToGlobalMappingDestroy(ISLocalToGlobalMapping);
113: EXTERN int ISLocalToGlobalMappingApplyIS(ISLocalToGlobalMapping,IS,IS*);
114: EXTERN int ISGlobalToLocalMappingApply(ISLocalToGlobalMapping,ISGlobalToLocalMappingType,int,const int[],int*,int[]);
115: EXTERN int ISLocalToGlobalMappingGetSize(ISLocalToGlobalMapping,int*);
116: EXTERN int ISLocalToGlobalMappingGetInfo(ISLocalToGlobalMapping,int*,int**,int**,int***);
117: EXTERN int ISLocalToGlobalMappingRestoreInfo(ISLocalToGlobalMapping,int*,int**,int**,int***);
118: EXTERN int ISLocalToGlobalMappingBlock(ISLocalToGlobalMapping,int,ISLocalToGlobalMapping*);
120: #define ISLocalToGlobalMappingApply(mapping,N,in,out) 0;
121: {
122: int _i,*_idx = (mapping)->indices,_Nmax = (mapping)->n;
123: for (_i=0; _i<N; _i++) {
124: if ((in)[_i] < 0) {(out)[_i] = (in)[_i]; continue;}
125: if ((in)[_i] >= _Nmax) SETERRQ3(PETSC_ERR_ARG_OUTOFRANGE,"Local index %d too large %d (max) at %d",(in)[_i],_Nmax,_i);
126: (out)[_i] = _idx[(in)[_i]];
127: }
128: }
130: /* --------------------------------------------------------------------------*/
131: /*E
132: ISColoringType - determines if the coloring is for the entire parallel grid/graph/matrix
133: or for just the local ghosted portion
135: Level: beginner
137: $ IS_COLORING_LOCAL - does not include the colors for ghost points
138: $ IS_COLORING_GHOSTED - includes colors for ghost points
140: .seealso: DAGetColoring()
141: E*/
142: typedef enum {IS_COLORING_LOCAL,IS_COLORING_GHOSTED} ISColoringType;
144: /*S
145: ISColorings - sets of IS's that define a coloring
146: of the underlying indices
148: Level: intermediate
150: Notes:
151: One should not access the *is records below directly because they may not yet
152: have been created. One should use ISColoringGetIS() to make sure they are
153: created when needed.
155: .seealso: ISColoringCreate(), ISColoringGetIS(), ISColoringView(), ISColoringGetIS()
156: S*/
157: struct _p_ISColoring {
158: int refct;
159: int n; /* number of colors */
160: IS *is; /* for each color indicates columns */
161: MPI_Comm comm;
162: int *colors; /* for each column indicates color */
163: int N; /* number of columns */
164: ISColoringType ctype;
165: };
166: typedef struct _p_ISColoring* ISColoring;
168: EXTERN int ISColoringCreate(MPI_Comm,int,const int[],ISColoring*);
169: EXTERN int ISColoringDestroy(ISColoring);
170: EXTERN int ISColoringView(ISColoring,PetscViewer);
171: EXTERN int ISColoringGetIS(ISColoring,int*,IS*[]);
172: EXTERN int ISColoringRestoreIS(ISColoring,IS*[]);
173: #define ISColoringReference(coloring) ((coloring)->refct++,0)
174: #define ISColoringSetType(coloring,type) ((coloring)->ctype = type,0)
176: /* --------------------------------------------------------------------------*/
178: EXTERN int ISPartitioningToNumbering(IS,IS*);
179: EXTERN int ISPartitioningCount(IS,int[]);
181: #endif