1*90f02eecSBarry Smith /* $Id: is.h,v 1.32 1996/11/07 15:12:51 bsmith Exp bsmith $ */ 22eac72dbSBarry Smith 32eac72dbSBarry Smith /* 4f8256253SLois Curfman McInnes An index set is a generalization of a subset of integers. Index sets 5f8256253SLois Curfman McInnes are used for defining scatters and gathers. 62eac72dbSBarry Smith */ 72eac72dbSBarry Smith #if !defined(__IS_PACKAGE) 82eac72dbSBarry Smith #define __IS_PACKAGE 92eac72dbSBarry Smith #include "petsc.h" 102eac72dbSBarry Smith 119e25ed09SBarry Smith #define IS_COOKIE PETSC_COOKIE+2 12f0479e8cSBarry Smith 132eac72dbSBarry Smith typedef struct _IS* IS; 142eac72dbSBarry Smith 15639f9d9dSBarry Smith /* 16639f9d9dSBarry Smith Default index set data structures that PETSc provides. 17639f9d9dSBarry Smith */ 18639f9d9dSBarry Smith typedef enum {IS_GENERAL=0, IS_STRIDE=1, IS_BLOCK = 2} ISType; 19537820f0SBarry Smith extern int ISCreateGeneral(MPI_Comm,int,int *,IS *); 20537820f0SBarry Smith extern int ISCreateBlock(MPI_Comm,int,int,int *,IS *); 21537820f0SBarry Smith extern int ISCreateStride(MPI_Comm,int,int,int,IS *); 224b0e389bSBarry Smith 234b0e389bSBarry Smith extern int ISDestroy(IS); 244b0e389bSBarry Smith 25aabeff55SBarry Smith extern int ISSetPermutation(IS); 2677c4ece6SBarry Smith extern int ISPermutation(IS,PetscTruth*); 2708480c60SBarry Smith extern int ISSetIdentity(IS); 2877c4ece6SBarry Smith extern int ISIdentity(IS,PetscTruth*); 2908480c60SBarry Smith 30aabeff55SBarry Smith extern int ISGetIndices(IS,int **); 31aabeff55SBarry Smith extern int ISRestoreIndices(IS,int **); 32aabeff55SBarry Smith extern int ISGetSize(IS,int *); 33aabeff55SBarry Smith extern int ISInvertPermutation(IS,IS*); 34aabeff55SBarry Smith extern int ISView(IS,Viewer); 3577c4ece6SBarry Smith extern int ISEqual(IS, IS, PetscTruth *); 360f453280SSatish Balay extern int ISSort(IS); 3777c4ece6SBarry Smith extern int ISSorted(IS, PetscTruth *); 38612dd529SBarry Smith 39537820f0SBarry Smith extern int ISBlock(IS,PetscTruth*); 40c16cb8f2SBarry Smith extern int ISBlockGetIndices(IS,int **); 41c16cb8f2SBarry Smith extern int ISBlockRestoreIndices(IS,int **); 42537820f0SBarry Smith extern int ISBlockGetSize(IS,int *); 43537820f0SBarry Smith extern int ISBlockGetBlockSize(IS,int *); 44c16cb8f2SBarry Smith 45537820f0SBarry Smith extern int ISStride(IS,PetscTruth*); 46c16cb8f2SBarry Smith extern int ISStrideGetInfo(IS,int *,int*); 47c16cb8f2SBarry Smith 48639f9d9dSBarry Smith /* 49*90f02eecSBarry Smith ISLocalToGlobalMappings are mappings from an arbitrary 50*90f02eecSBarry Smith local ordering from 0 to n-1 to a global PETSc ordering 51*90f02eecSBarry Smith used by a vector or matrix 52*90f02eecSBarry Smith */ 53*90f02eecSBarry Smith struct _ISLocalToGlobalMapping{ 54*90f02eecSBarry Smith int n; 55*90f02eecSBarry Smith int *indices; 56*90f02eecSBarry Smith int refcnt; 57*90f02eecSBarry Smith }; 58*90f02eecSBarry Smith typedef struct _ISLocalToGlobalMapping* ISLocalToGlobalMapping; 59*90f02eecSBarry Smith 60*90f02eecSBarry Smith extern int ISLocalToGlobalMappingCreate(int, int*, ISLocalToGlobalMapping*); 61*90f02eecSBarry Smith extern int ISLocalToGlobalMappingDestroy(ISLocalToGlobalMapping); 62*90f02eecSBarry Smith #define ISLocalToGlobalMappingApply(mp,N,in,out) \ 63*90f02eecSBarry Smith {\ 64*90f02eecSBarry Smith int _i,*_idx = mp->indices; \ 65*90f02eecSBarry Smith for ( _i=0; _i<N; _i++ ) { \ 66*90f02eecSBarry Smith out[_i] = _idx[in[_i]]; \ 67*90f02eecSBarry Smith }\ 68*90f02eecSBarry Smith } 69*90f02eecSBarry Smith #define ISLocalToGlobalMappingReference(mp) mp->refcnt++; 70*90f02eecSBarry Smith extern int ISLocalToGlobalMappingApplyIS(ISLocalToGlobalMapping,IS,IS*); 71*90f02eecSBarry Smith 72*90f02eecSBarry Smith /* 73639f9d9dSBarry Smith ISColorings are sets of IS's that define a coloring 74639f9d9dSBarry Smith of the underlying indices 75639f9d9dSBarry Smith */ 76639f9d9dSBarry Smith struct _ISColoring { 77639f9d9dSBarry Smith int n; 78639f9d9dSBarry Smith IS *is; 79639f9d9dSBarry Smith MPI_Comm comm; 80639f9d9dSBarry Smith }; 81639f9d9dSBarry Smith typedef struct _ISColoring* ISColoring; 82639f9d9dSBarry Smith 83639f9d9dSBarry Smith extern int ISColoringDestroy(ISColoring); 84639f9d9dSBarry Smith extern int ISColoringView(ISColoring,Viewer); 85639f9d9dSBarry Smith extern int ISColoringCreate(MPI_Comm,int,int*,ISColoring*); 86639f9d9dSBarry Smith 87a2ce50c7SBarry Smith #endif 887588ac45SBarry Smith 897588ac45SBarry Smith 90639f9d9dSBarry Smith 91639f9d9dSBarry Smith 92