xref: /petsc/include/petscis.h (revision 56cd22ae330b334c2f3e3e29533369e7780beb71)
1 /* $Id: is.h,v 1.34 1997/05/23 18:39:08 balay 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 _p_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 
50 /*
51    ISLocalToGlobalMappings are mappings from an arbitrary
52   local ordering from 0 to n-1 to a global PETSc ordering
53   used by a vector or matrix
54 */
55 struct _p_ISLocalToGlobalMapping{
56   int n;
57   int *indices;
58   int refcnt;
59 };
60 typedef struct _p_ISLocalToGlobalMapping* ISLocalToGlobalMapping;
61 
62 extern int ISLocalToGlobalMappingCreate(int, int*, ISLocalToGlobalMapping*);
63 extern int ISLocalToGlobalMappingDestroy(ISLocalToGlobalMapping);
64 #define ISLocalToGlobalMappingApply(mp,N,in,out) \
65   {\
66    int _i,*_idx = mp->indices; \
67    for ( _i=0; _i<N; _i++ ) { \
68      out[_i] = _idx[in[_i]]; \
69    }\
70   }
71 #define ISLocalToGlobalMappingReference(mp) mp->refcnt++;
72 extern int ISLocalToGlobalMappingApplyIS(ISLocalToGlobalMapping,IS,IS*);
73 
74 /* --------------------------------------------------------------------------*/
75 
76 /*
77      ISColorings are sets of IS's that define a coloring
78    of the underlying indices
79 */
80 struct _p_ISColoring {
81   int      n;
82   IS       *is;
83   MPI_Comm comm;
84 };
85 typedef struct _p_ISColoring* ISColoring;
86 
87 extern int ISColoringDestroy(ISColoring);
88 extern int ISColoringView(ISColoring,Viewer);
89 extern int ISColoringCreate(MPI_Comm,int,int*,ISColoring*);
90 
91 #endif
92 
93 
94 
95 
96