xref: /petsc/include/petscis.h (revision 488ecbaffa467bb032d31d7eb20bc6d0ef6d986c)
1 /* $Id: is.h,v 1.47 1998/06/11 19:59:10 bsmith Exp balay $ */
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_H)
8 #define __IS_H
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,const int[],IS *);
20 extern int   ISCreateBlock(MPI_Comm,int,int,const 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 extern int   ISDifference(IS,IS,IS*);
39 extern int   ISSum(IS,IS,IS*);
40 
41 extern int   ISBlock(IS,PetscTruth*);
42 extern int   ISBlockGetIndices(IS,int *[]);
43 extern int   ISBlockRestoreIndices(IS,int *[]);
44 extern int   ISBlockGetSize(IS,int *);
45 extern int   ISBlockGetBlockSize(IS,int *);
46 
47 extern int   ISStride(IS,PetscTruth*);
48 extern int   ISStrideGetInfo(IS,int *,int*);
49 
50 extern int   ISStrideToGeneral(IS);
51 
52 extern int   ISDuplicate(IS, IS*);
53 extern int   ISAllGather(IS, IS*);
54 
55 /* --------------------------------------------------------------------------*/
56 
57 /*
58    ISLocalToGlobalMappings are mappings from an arbitrary
59   local ordering from 0 to n-1 to a global PETSc ordering
60   used by a vector or matrix.
61 
62    Note: mapping from Local to Global is scalable; but Global
63   to local may not be if the range of global values represented locally
64   is very large.
65 */
66 #define IS_LTOGM_COOKIE PETSC_COOKIE+12
67 typedef struct _p_ISLocalToGlobalMapping* ISLocalToGlobalMapping;
68 typedef enum {IS_GTOLM_MASK,IS_GTOLM_DROP} ISGlobalToLocalMappingType;
69 
70 extern int ISLocalToGlobalMappingCreate(MPI_Comm,int,const int[],ISLocalToGlobalMapping*);
71 extern int ISLocalToGlobalMappingCreateIS(IS,ISLocalToGlobalMapping *);
72 extern int ISLocalToGlobalMappingView(ISLocalToGlobalMapping,Viewer);
73 extern int ISLocalToGlobalMappingDestroy(ISLocalToGlobalMapping);
74 extern int ISLocalToGlobalMappingApply(ISLocalToGlobalMapping,int,const int[],int[]);
75 extern int ISLocalToGlobalMappingApplyIS(ISLocalToGlobalMapping,IS,IS*);
76 extern int ISGlobalToLocalMappingApply(ISLocalToGlobalMapping,ISGlobalToLocalMappingType,
77                                        int,const int[],int*,int[]);
78 
79 /* --------------------------------------------------------------------------*/
80 
81 /*
82      ISColorings are sets of IS's that define a coloring
83    of the underlying indices
84 */
85 struct _p_ISColoring {
86   int      n;
87   IS       *is;
88   MPI_Comm comm;
89 };
90 typedef struct _p_ISColoring* ISColoring;
91 
92 extern int ISColoringCreate(MPI_Comm,int,const int[],ISColoring*);
93 extern int ISColoringDestroy(ISColoring);
94 extern int ISColoringView(ISColoring,Viewer);
95 extern int ISColoringGetIS(ISColoring,int*,IS*[]);
96 
97 /* --------------------------------------------------------------------------*/
98 
99 extern int ISPartitioningToNumbering(IS,IS*);
100 extern int ISPartitioningCount(IS,int[]);
101 
102 #endif
103 
104 
105 
106 
107