Actual source code: petscis.h
1: /* $Id: petscis.h,v 1.61 2001/04/10 19:34:48 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: #define IS_COOKIE PETSC_COOKIE+2
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*);
65: /* --------------------------------------------------------------------------*/
66: #define IS_LTOGM_COOKIE PETSC_COOKIE+12
68: /*S
69: ISLocalToGlobalMappings - mappings from an arbitrary
70: local ordering from 0 to n-1 to a global PETSc ordering
71: used by a vector or matrix.
73: Level: intermediate
75: Note: mapping from Local to Global is scalable; but Global
76: to Local may not be if the range of global values represented locally
77: is very large.
79: Note: the ISLocalToGlobalMapping is actually a private object; it is included
80: here for the MACRO ISLocalToGlobalMappingApply() to allow it to be inlined since
81: it is used so often.
83: .seealso: ISLocalToGlobalMappingCreate()
84: S*/
85: struct _p_ISLocalToGlobalMapping{
86: PETSCHEADER(int)
87: int n; /* number of local indices */
88: int *indices; /* global index of each local index */
89: int globalstart; /* first global referenced in indices */
90: int globalend; /* last + 1 global referenced in indices */
91: int *globals; /* local index for each global index between start and end */
92: };
93: typedef struct _p_ISLocalToGlobalMapping* ISLocalToGlobalMapping;
95: /*E
96: ISGlobalToLocalMappingType - Indicates if missing global indices are
98: IS_GTOLM_MASK - missing global indices are replaced with -1
99: IS_GTOLM_DROP - missing global indices are dropped
101: Level: beginner
103: .seealso: ISGlobalToLocalMappingApply()
105: E*/
106: typedef enum {IS_GTOLM_MASK,IS_GTOLM_DROP} ISGlobalToLocalMappingType;
108: EXTERN int ISLocalToGlobalMappingCreate(MPI_Comm,int,const int[],ISLocalToGlobalMapping*);
109: EXTERN int ISLocalToGlobalMappingCreateIS(IS,ISLocalToGlobalMapping *);
110: EXTERN int ISLocalToGlobalMappingView(ISLocalToGlobalMapping,PetscViewer);
111: EXTERN int ISLocalToGlobalMappingDestroy(ISLocalToGlobalMapping);
112: EXTERN int ISLocalToGlobalMappingApplyIS(ISLocalToGlobalMapping,IS,IS*);
113: EXTERN int ISGlobalToLocalMappingApply(ISLocalToGlobalMapping,ISGlobalToLocalMappingType,int,const int[],int*,int[]);
114: EXTERN int ISLocalToGlobalMappingGetSize(ISLocalToGlobalMapping,int*);
115: EXTERN int ISLocalToGlobalMappingGetInfo(ISLocalToGlobalMapping,int*,int**,int**,int***);
116: EXTERN int ISLocalToGlobalMappingRestoreInfo(ISLocalToGlobalMapping,int*,int**,int**,int***);
117: EXTERN int ISLocalToGlobalMappingBlock(ISLocalToGlobalMapping,int,ISLocalToGlobalMapping*);
119: #define ISLocalToGlobalMappingApply(mapping,N,in,out) 0;
120: {
121: int _i,*_idx = (mapping)->indices,_Nmax = (mapping)->n;
122: for (_i=0; _i<N; _i++) {
123: if ((in)[_i] < 0) {(out)[_i] = (in)[_i]; continue;}
124: if ((in)[_i] >= _Nmax) SETERRQ3(PETSC_ERR_ARG_OUTOFRANGE,"Local index %d too large %d (max) at %d",(in)[_i],_Nmax,_i);
125: (out)[_i] = _idx[(in)[_i]];
126: }
127: }
129: /* --------------------------------------------------------------------------*/
130: /*E
131: ISColoringType - determines if the coloring is for the entire parallel grid/graph/matrix
132: or for just the local ghosted portion
134: Level: beginner
136: .seealso: DAGetColoring()
137: E*/
138: typedef enum {IS_COLORING_GLOBAL,IS_COLORING_LOCAL} ISColoringType;
140: /*S
141: ISColorings - sets of IS's that define a coloring
142: of the underlying indices
144: Level: intermediate
146: Notes:
147: One should not access the *is records below directly because they may not yet
148: have been created. One should use ISColoringGetIS() to make sure they are
149: created when needed.
151: .seealso: ISColoringCreate(), ISColoringGetIS(), ISColoringView(), ISColoringGetIS()
152: S*/
153: struct _p_ISColoring {
154: int n; /* number of colors */
155: IS *is; /* for each color indicates columns */
156: MPI_Comm comm;
157: int *colors; /* for each column indicates color */
158: int N; /* number of columns */
159: ISColoringType ctype;
160: };
161: typedef struct _p_ISColoring* ISColoring;
163: EXTERN int ISColoringCreate(MPI_Comm,int,const int[],ISColoring*);
164: EXTERN int ISColoringDestroy(ISColoring);
165: EXTERN int ISColoringView(ISColoring,PetscViewer);
166: EXTERN int ISColoringGetIS(ISColoring,int*,IS*[]);
167: EXTERN int ISColoringRestoreIS(ISColoring,IS*[]);
169: /* --------------------------------------------------------------------------*/
171: EXTERN int ISPartitioningToNumbering(IS,IS*);
172: EXTERN int ISPartitioningCount(IS,int[]);
174: #endif