1 /* $Id: is.h,v 1.32 1996/11/07 15:12:51 bsmith Exp bsmith $ */ 2 3 /* 4 An index set is a generalization of a subset of integers. Index sets 5 are used for defining scatters and gathers. 6 */ 7 #if !defined(__IS_PACKAGE) 8 #define __IS_PACKAGE 9 #include "petsc.h" 10 11 #define IS_COOKIE PETSC_COOKIE+2 12 13 typedef struct _IS* IS; 14 15 /* 16 Default index set data structures that PETSc provides. 17 */ 18 typedef enum {IS_GENERAL=0, IS_STRIDE=1, IS_BLOCK = 2} ISType; 19 extern int ISCreateGeneral(MPI_Comm,int,int *,IS *); 20 extern int ISCreateBlock(MPI_Comm,int,int,int *,IS *); 21 extern int ISCreateStride(MPI_Comm,int,int,int,IS *); 22 23 extern int ISDestroy(IS); 24 25 extern int ISSetPermutation(IS); 26 extern int ISPermutation(IS,PetscTruth*); 27 extern int ISSetIdentity(IS); 28 extern int ISIdentity(IS,PetscTruth*); 29 30 extern int ISGetIndices(IS,int **); 31 extern int ISRestoreIndices(IS,int **); 32 extern int ISGetSize(IS,int *); 33 extern int ISInvertPermutation(IS,IS*); 34 extern int ISView(IS,Viewer); 35 extern int ISEqual(IS, IS, PetscTruth *); 36 extern int ISSort(IS); 37 extern int ISSorted(IS, PetscTruth *); 38 39 extern int ISBlock(IS,PetscTruth*); 40 extern int ISBlockGetIndices(IS,int **); 41 extern int ISBlockRestoreIndices(IS,int **); 42 extern int ISBlockGetSize(IS,int *); 43 extern int ISBlockGetBlockSize(IS,int *); 44 45 extern int ISStride(IS,PetscTruth*); 46 extern int ISStrideGetInfo(IS,int *,int*); 47 48 /* 49 ISLocalToGlobalMappings are mappings from an arbitrary 50 local ordering from 0 to n-1 to a global PETSc ordering 51 used by a vector or matrix 52 */ 53 struct _ISLocalToGlobalMapping{ 54 int n; 55 int *indices; 56 int refcnt; 57 }; 58 typedef struct _ISLocalToGlobalMapping* ISLocalToGlobalMapping; 59 60 extern int ISLocalToGlobalMappingCreate(int, int*, ISLocalToGlobalMapping*); 61 extern int ISLocalToGlobalMappingDestroy(ISLocalToGlobalMapping); 62 #define ISLocalToGlobalMappingApply(mp,N,in,out) \ 63 {\ 64 int _i,*_idx = mp->indices; \ 65 for ( _i=0; _i<N; _i++ ) { \ 66 out[_i] = _idx[in[_i]]; \ 67 }\ 68 } 69 #define ISLocalToGlobalMappingReference(mp) mp->refcnt++; 70 extern int ISLocalToGlobalMappingApplyIS(ISLocalToGlobalMapping,IS,IS*); 71 72 /* 73 ISColorings are sets of IS's that define a coloring 74 of the underlying indices 75 */ 76 struct _ISColoring { 77 int n; 78 IS *is; 79 MPI_Comm comm; 80 }; 81 typedef struct _ISColoring* ISColoring; 82 83 extern int ISColoringDestroy(ISColoring); 84 extern int ISColoringView(ISColoring,Viewer); 85 extern int ISColoringCreate(MPI_Comm,int,int*,ISColoring*); 86 87 #endif 88 89 90 91 92