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,const int[],int*,int*[]);
66: /* --------------------------------------------------------------------------*/
67: #define IS_LTOGM_COOKIE PETSC_COOKIE+12
69: /*S
70: ISLocalToGlobalMapping - 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 ISLocalToGlobalMappingCreateNC(MPI_Comm,int,const int[],ISLocalToGlobalMapping*);
111: EXTERN int ISLocalToGlobalMappingCreateIS(IS,ISLocalToGlobalMapping *);
112: EXTERN int ISLocalToGlobalMappingView(ISLocalToGlobalMapping,PetscViewer);
113: EXTERN int ISLocalToGlobalMappingDestroy(ISLocalToGlobalMapping);
114: EXTERN int ISLocalToGlobalMappingApplyIS(ISLocalToGlobalMapping,IS,IS*);
115: EXTERN int ISGlobalToLocalMappingApply(ISLocalToGlobalMapping,ISGlobalToLocalMappingType,int,const int[],int*,int[]);
116: EXTERN int ISLocalToGlobalMappingGetSize(ISLocalToGlobalMapping,int*);
117: EXTERN int ISLocalToGlobalMappingGetInfo(ISLocalToGlobalMapping,int*,int*[],int*[],int**[]);
118: EXTERN int ISLocalToGlobalMappingRestoreInfo(ISLocalToGlobalMapping,int*,int*[],int*[],int**[]);
119: EXTERN int ISLocalToGlobalMappingBlock(ISLocalToGlobalMapping,int,ISLocalToGlobalMapping*);
121: #define ISLocalToGlobalMappingApply(mapping,N,in,out) 0;\
122: {\
123: int _i,*_idx = (mapping)->indices,_Nmax = (mapping)->n;\
124: for (_i=0; _i<N; _i++) {\
125: if ((in)[_i] < 0) {(out)[_i] = (in)[_i]; continue;}\
126: if ((in)[_i] >= _Nmax) SETERRQ3(PETSC_ERR_ARG_OUTOFRANGE,"Local index %d too large %d (max) at %d",(in)[_i],_Nmax,_i);\
127: (out)[_i] = _idx[(in)[_i]];\
128: }\
129: }
131: /* --------------------------------------------------------------------------*/
132: /*E
133: ISColoringType - determines if the coloring is for the entire parallel grid/graph/matrix
134: or for just the local ghosted portion
136: Level: beginner
138: $ IS_COLORING_LOCAL - does not include the colors for ghost points
139: $ IS_COLORING_GHOSTED - includes colors for ghost points
141: .seealso: DAGetColoring()
142: E*/
143: typedef enum {IS_COLORING_LOCAL,IS_COLORING_GHOSTED} ISColoringType;
145: #define MPIU_COLORING_VALUE MPI_CHAR
146: #define IS_COLORING_MAX 255
147: typedef unsigned char ISColoringValue;
148: EXTERN int ISAllGatherColors(MPI_Comm,int,ISColoringValue*,int*,ISColoringValue*[]);
150: /*S
151: ISColoring - sets of IS's that define a coloring
152: of the underlying indices
154: Level: intermediate
156: Notes:
157: One should not access the *is records below directly because they may not yet
158: have been created. One should use ISColoringGetIS() to make sure they are
159: created when needed.
161: .seealso: ISColoringCreate(), ISColoringGetIS(), ISColoringView(), ISColoringGetIS()
162: S*/
163: struct _p_ISColoring {
164: int refct;
165: int n; /* number of colors */
166: IS *is; /* for each color indicates columns */
167: MPI_Comm comm;
168: ISColoringValue *colors; /* for each column indicates color */
169: int N; /* number of columns */
170: ISColoringType ctype;
171: };
172: typedef struct _p_ISColoring* ISColoring;
174: EXTERN int ISColoringCreate(MPI_Comm,int,const ISColoringValue[],ISColoring*);
175: EXTERN int ISColoringDestroy(ISColoring);
176: EXTERN int ISColoringView(ISColoring,PetscViewer);
177: EXTERN int ISColoringGetIS(ISColoring,int*,IS*[]);
178: EXTERN int ISColoringRestoreIS(ISColoring,IS*[]);
179: #define ISColoringReference(coloring) ((coloring)->refct++,0)
180: #define ISColoringSetType(coloring,type) ((coloring)->ctype = type,0)
182: /* --------------------------------------------------------------------------*/
184: EXTERN int ISPartitioningToNumbering(IS,IS*);
185: EXTERN int ISPartitioningCount(IS,int[]);
187: #endif