1 /*
2    An index set is a generalization of a subset of integers.  Index sets
3    are used for defining scatters and gathers.
4 */
5 #if !defined(PETSCIS_H)
6 #define PETSCIS_H
7 #include <petscsys.h>
8 #include <petscsftypes.h>
9 #include <petscsectiontypes.h>
10 #include <petscistypes.h>    /*I  "petscis.h" I*/
11 
12 #define IS_FILE_CLASSID 1211218
13 PETSC_EXTERN PetscClassId IS_CLASSID;
14 
15 PETSC_EXTERN PetscErrorCode ISInitializePackage(void);
16 
17 /*J
18     ISType - String with the name of a PETSc index set type
19 
20    Level: beginner
21 
22 .seealso: ISSetType(), IS, ISCreate(), ISRegister()
23 J*/
24 typedef const char* ISType;
25 #define ISGENERAL      "general"
26 #define ISSTRIDE       "stride"
27 #define ISBLOCK        "block"
28 
29 /* Dynamic creation and loading functions */
30 PETSC_EXTERN PetscFunctionList ISList;
31 PETSC_EXTERN PetscErrorCode ISSetType(IS, ISType);
32 PETSC_EXTERN PetscErrorCode ISGetType(IS, ISType *);
33 PETSC_EXTERN PetscErrorCode ISRegister(const char[],PetscErrorCode (*)(IS));
34 PETSC_EXTERN PetscErrorCode ISCreate(MPI_Comm,IS*);
35 
36 /*
37     Default index set data structures that PETSc provides.
38 */
39 PETSC_EXTERN PetscErrorCode ISCreateGeneral(MPI_Comm,PetscInt,const PetscInt[],PetscCopyMode,IS *);
40 PETSC_EXTERN PetscErrorCode ISGeneralSetIndices(IS,PetscInt,const PetscInt[],PetscCopyMode);
41 PETSC_EXTERN PetscErrorCode ISCreateBlock(MPI_Comm,PetscInt,PetscInt,const PetscInt[],PetscCopyMode,IS *);
42 PETSC_EXTERN PetscErrorCode ISBlockSetIndices(IS,PetscInt,PetscInt,const PetscInt[],PetscCopyMode);
43 PETSC_EXTERN PetscErrorCode ISCreateStride(MPI_Comm,PetscInt,PetscInt,PetscInt,IS *);
44 PETSC_EXTERN PetscErrorCode ISStrideSetStride(IS,PetscInt,PetscInt,PetscInt);
45 
46 PETSC_EXTERN PetscErrorCode ISDestroy(IS*);
47 PETSC_EXTERN PetscErrorCode ISSetPermutation(IS);
48 PETSC_EXTERN PetscErrorCode ISPermutation(IS,PetscBool *);
49 PETSC_EXTERN PetscErrorCode ISSetIdentity(IS);
50 PETSC_EXTERN PetscErrorCode ISIdentity(IS,PetscBool *);
51 PETSC_EXTERN PetscErrorCode ISContiguousLocal(IS,PetscInt,PetscInt,PetscInt*,PetscBool*);
52 
53 /*E
54     ISInfo - Info that may either be computed or set as known for an index set
55 
56     Level: beginner
57 
58    Any additions/changes here MUST also be made in include/petsc/finclude/petscis.h
59    Any additions/changes here must also be made in src/vec/vec/interface/dlregisvec.c in ISInfos[]
60 
61    Developer Notes:
62     Entries that are negative need not be called collectively by all processes.
63 
64 .seealso: ISSetInfo()
65 E*/
66 typedef enum {IS_INFO_MIN = -1,
67               IS_SORTED = 0,
68               IS_UNIQUE = 1,
69               IS_PERMUTATION = 2,
70               IS_INTERVAL = 3,
71               IS_IDENTITY = 4,
72               IS_INFO_MAX = 5} ISInfo;
73 
74 typedef enum {IS_LOCAL, IS_GLOBAL} ISInfoType;
75 
76 PETSC_EXTERN PetscErrorCode ISSetInfo(IS,ISInfo,ISInfoType,PetscBool,PetscBool);
77 PETSC_EXTERN PetscErrorCode ISGetInfo(IS,ISInfo,ISInfoType,PetscBool,PetscBool*);
78 PETSC_EXTERN PetscErrorCode ISClearInfoCache(IS,PetscBool);
79 PETSC_EXTERN PetscErrorCode ISGetIndices(IS,const PetscInt *[]);
80 PETSC_EXTERN PetscErrorCode ISRestoreIndices(IS,const PetscInt *[]);
81 PETSC_EXTERN PetscErrorCode ISGetTotalIndices(IS,const PetscInt *[]);
82 PETSC_EXTERN PetscErrorCode ISRestoreTotalIndices(IS,const PetscInt *[]);
83 PETSC_EXTERN PetscErrorCode ISGetNonlocalIndices(IS,const PetscInt *[]);
84 PETSC_EXTERN PetscErrorCode ISRestoreNonlocalIndices(IS,const PetscInt *[]);
85 PETSC_EXTERN PetscErrorCode ISGetNonlocalIS(IS, IS *is);
86 PETSC_EXTERN PetscErrorCode ISRestoreNonlocalIS(IS, IS *is);
87 PETSC_EXTERN PetscErrorCode ISGetSize(IS,PetscInt *);
88 PETSC_EXTERN PetscErrorCode ISGetLocalSize(IS,PetscInt *);
89 PETSC_EXTERN PetscErrorCode ISInvertPermutation(IS,PetscInt,IS*);
90 PETSC_EXTERN PetscErrorCode ISView(IS,PetscViewer);
91 PETSC_EXTERN PetscErrorCode ISViewFromOptions(IS,PetscObject,const char[]);
92 PETSC_EXTERN PetscErrorCode ISLoad(IS,PetscViewer);
93 PETSC_EXTERN PetscErrorCode ISEqual(IS,IS,PetscBool  *);
94 PETSC_EXTERN PetscErrorCode ISEqualUnsorted(IS,IS,PetscBool *);
95 PETSC_EXTERN PetscErrorCode ISSort(IS);
96 PETSC_EXTERN PetscErrorCode ISSortRemoveDups(IS);
97 PETSC_EXTERN PetscErrorCode ISSorted(IS,PetscBool  *);
98 PETSC_EXTERN PetscErrorCode ISDifference(IS,IS,IS*);
99 PETSC_EXTERN PetscErrorCode ISSum(IS,IS,IS*);
100 PETSC_EXTERN PetscErrorCode ISExpand(IS,IS,IS*);
101 PETSC_EXTERN PetscErrorCode ISIntersect(IS,IS,IS*);
102 PETSC_EXTERN PetscErrorCode ISGetMinMax(IS,PetscInt*,PetscInt*);
103 
104 PETSC_EXTERN PetscErrorCode ISLocate(IS,PetscInt,PetscInt*);
105 PETSC_EXTERN PetscErrorCode ISGetPointRange(IS,PetscInt*,PetscInt*,const PetscInt**);
106 PETSC_EXTERN PetscErrorCode ISRestorePointRange(IS,PetscInt*,PetscInt*,const PetscInt**);
107 PETSC_EXTERN PetscErrorCode ISGetPointSubrange(IS,PetscInt,PetscInt,const PetscInt*);
108 
109 PETSC_EXTERN PetscErrorCode ISBlockGetIndices(IS,const PetscInt *[]);
110 PETSC_EXTERN PetscErrorCode ISBlockRestoreIndices(IS,const PetscInt *[]);
111 PETSC_EXTERN PetscErrorCode ISBlockGetLocalSize(IS,PetscInt *);
112 PETSC_EXTERN PetscErrorCode ISBlockGetSize(IS,PetscInt *);
113 PETSC_EXTERN PetscErrorCode ISGetBlockSize(IS,PetscInt*);
114 PETSC_EXTERN PetscErrorCode ISSetBlockSize(IS,PetscInt);
115 
116 PETSC_EXTERN PetscErrorCode ISStrideGetInfo(IS,PetscInt *,PetscInt*);
117 
118 PETSC_EXTERN PetscErrorCode ISToGeneral(IS);
119 
120 PETSC_EXTERN PetscErrorCode ISDuplicate(IS,IS*);
121 PETSC_EXTERN PetscErrorCode ISCopy(IS,IS);
122 PETSC_EXTERN PetscErrorCode ISAllGather(IS,IS*);
123 PETSC_EXTERN PetscErrorCode ISComplement(IS,PetscInt,PetscInt,IS*);
124 PETSC_EXTERN PetscErrorCode ISConcatenate(MPI_Comm,PetscInt,const IS[],IS*);
125 PETSC_EXTERN PetscErrorCode ISListToPair(MPI_Comm,PetscInt, IS[],IS*,IS*);
126 PETSC_EXTERN PetscErrorCode ISPairToList(IS,IS,PetscInt*, IS *[]);
127 PETSC_EXTERN PetscErrorCode ISEmbed(IS,IS,PetscBool,IS*);
128 PETSC_EXTERN PetscErrorCode ISSortPermutation(IS,PetscBool,IS*);
129 PETSC_EXTERN PetscErrorCode ISOnComm(IS,MPI_Comm,PetscCopyMode,IS*);
130 PETSC_EXTERN PetscErrorCode ISRenumber(IS,IS,PetscInt*,IS*);
131 PETSC_EXTERN PetscErrorCode ISCreateSubIS(IS,IS,IS*);
132 
133 PETSC_EXTERN PetscErrorCode ISGeneralFilter(IS,PetscInt,PetscInt);
134 
135 /* --------------------------------------------------------------------------*/
136 PETSC_EXTERN PetscClassId IS_LTOGM_CLASSID;
137 
138 /*E
139     ISGlobalToLocalMappingMode - Indicates mapping behavior if global indices are missing
140 
141    IS_GTOLM_MASK - missing global indices are masked by mapping them to a local index of -1
142    IS_GTOLM_DROP - missing global indices are dropped
143 
144    Level: beginner
145 
146 .seealso: ISGlobalToLocalMappingApplyBlock(), ISGlobalToLocalMappingApply()
147 
148 E*/
149 typedef enum {IS_GTOLM_MASK,IS_GTOLM_DROP} ISGlobalToLocalMappingMode;
150 
151 /*J
152     ISLocalToGlobalMappingType - String with the name of a mapping method
153 
154    Level: beginner
155 
156 .seealso: ISLocalToGlobalMappingSetType(), ISLocalToGlobalSetFromOptions()
157 J*/
158 typedef const char* ISLocalToGlobalMappingType;
159 #define ISLOCALTOGLOBALMAPPINGBASIC "basic"
160 #define ISLOCALTOGLOBALMAPPINGHASH  "hash"
161 
162 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingSetType(ISLocalToGlobalMapping,ISLocalToGlobalMappingType);
163 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingRegister(const char[],PetscErrorCode (*)(ISLocalToGlobalMapping));
164 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingRegisterAll(void);
165 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingCreate(MPI_Comm,PetscInt,PetscInt,const PetscInt[],PetscCopyMode,ISLocalToGlobalMapping*);
166 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingCreateIS(IS,ISLocalToGlobalMapping *);
167 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingCreateSF(PetscSF,PetscInt,ISLocalToGlobalMapping*);
168 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingSetFromOptions(ISLocalToGlobalMapping);
169 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingSetUp(ISLocalToGlobalMapping);
170 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingView(ISLocalToGlobalMapping,PetscViewer);
171 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingViewFromOptions(ISLocalToGlobalMapping,PetscObject,const char[]);
172 
173 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingDestroy(ISLocalToGlobalMapping*);
174 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingApply(ISLocalToGlobalMapping,PetscInt,const PetscInt[],PetscInt[]);
175 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingApplyBlock(ISLocalToGlobalMapping,PetscInt,const PetscInt[],PetscInt[]);
176 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingApplyIS(ISLocalToGlobalMapping,IS,IS*);
177 PETSC_EXTERN PetscErrorCode ISGlobalToLocalMappingApply(ISLocalToGlobalMapping,ISGlobalToLocalMappingMode,PetscInt,const PetscInt[],PetscInt*,PetscInt[]);
178 PETSC_EXTERN PetscErrorCode ISGlobalToLocalMappingApplyBlock(ISLocalToGlobalMapping,ISGlobalToLocalMappingMode,PetscInt,const PetscInt[],PetscInt*,PetscInt[]);
179 PETSC_EXTERN PetscErrorCode ISGlobalToLocalMappingApplyIS(ISLocalToGlobalMapping,ISGlobalToLocalMappingMode,IS,IS*);
180 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingGetSize(ISLocalToGlobalMapping,PetscInt*);
181 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingGetNodeInfo(ISLocalToGlobalMapping,PetscInt*,PetscInt*[],PetscInt**[]);
182 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingRestoreNodeInfo(ISLocalToGlobalMapping,PetscInt*,PetscInt*[],PetscInt**[]);
183 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingGetInfo(ISLocalToGlobalMapping,PetscInt*,PetscInt*[],PetscInt*[],PetscInt**[]);
184 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingRestoreInfo(ISLocalToGlobalMapping,PetscInt*,PetscInt*[],PetscInt*[],PetscInt**[]);
185 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingGetBlockInfo(ISLocalToGlobalMapping,PetscInt*,PetscInt*[],PetscInt*[],PetscInt**[]);
186 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingRestoreBlockInfo(ISLocalToGlobalMapping,PetscInt*,PetscInt*[],PetscInt*[],PetscInt**[]);
187 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingGetIndices(ISLocalToGlobalMapping,const PetscInt**);
188 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingRestoreIndices(ISLocalToGlobalMapping,const PetscInt**);
189 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingGetBlockIndices(ISLocalToGlobalMapping,const PetscInt**);
190 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingRestoreBlockIndices(ISLocalToGlobalMapping,const PetscInt**);
191 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingConcatenate(MPI_Comm,PetscInt,const ISLocalToGlobalMapping[],ISLocalToGlobalMapping*);
192 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingGetBlockSize(ISLocalToGlobalMapping,PetscInt*);
193 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingSetBlockSize(ISLocalToGlobalMapping,PetscInt);
194 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingDuplicate(ISLocalToGlobalMapping,ISLocalToGlobalMapping*);
195 
196 
197 /* --------------------------------------------------------------------------*/
198 /*E
199     ISColoringType - determines if the coloring is for the entire parallel grid/graph/matrix
200                      or for just the local ghosted portion
201 
202     Level: beginner
203 
204 $   IS_COLORING_GLOBAL - does not include the colors for ghost points, this is used when the function
205 $                        is called synchronously in parallel. This requires generating a "parallel coloring".
206 $   IS_COLORING_LOCAL - includes colors for ghost points, this is used when the function can be called
207 $                         separately on individual processes with the ghost points already filled in. Does not
208 $                         require a "parallel coloring", rather each process colors its local + ghost part.
209 $                         Using this can result in much less parallel communication. Currently only works
210 $                         with DMDA and if you call MatFDColoringSetFunction() with the local function.
211 
212 .seealso: DMCreateColoring()
213 E*/
214 typedef enum {IS_COLORING_GLOBAL,IS_COLORING_LOCAL} ISColoringType;
215 PETSC_EXTERN const char *const ISColoringTypes[];
216 typedef unsigned PETSC_IS_COLORING_VALUE_TYPE ISColoringValue;
217 #define IS_COLORING_MAX PETSC_IS_COLORING_MAX
218 #define MPIU_COLORING_VALUE PETSC_MPIU_IS_COLORING_VALUE_TYPE
219 PETSC_EXTERN PetscErrorCode ISAllGatherColors(MPI_Comm,PetscInt,ISColoringValue*,PetscInt*,ISColoringValue*[]);
220 
221 PETSC_EXTERN PetscErrorCode ISColoringCreate(MPI_Comm,PetscInt,PetscInt,const ISColoringValue[],PetscCopyMode,ISColoring*);
222 PETSC_EXTERN PetscErrorCode ISColoringDestroy(ISColoring*);
223 PETSC_EXTERN PetscErrorCode ISColoringView(ISColoring,PetscViewer);
224 PETSC_EXTERN PetscErrorCode ISColoringViewFromOptions(ISColoring,PetscObject,const char[]);
225 PETSC_EXTERN PetscErrorCode ISColoringGetIS(ISColoring,PetscCopyMode,PetscInt*,IS*[]);
226 PETSC_EXTERN PetscErrorCode ISColoringRestoreIS(ISColoring,PetscCopyMode,IS*[]);
227 PETSC_EXTERN PetscErrorCode ISColoringReference(ISColoring);
228 PETSC_EXTERN PetscErrorCode ISColoringSetType(ISColoring,ISColoringType);
229 PETSC_EXTERN PetscErrorCode ISColoringGetType(ISColoring,ISColoringType*);
230 PETSC_EXTERN PetscErrorCode ISColoringGetColors(ISColoring,PetscInt*,PetscInt*,const ISColoringValue**);
231 
232 /* --------------------------------------------------------------------------*/
233 PETSC_EXTERN PetscErrorCode ISBuildTwoSided(IS,IS,IS*);
234 PETSC_EXTERN PetscErrorCode ISPartitioningToNumbering(IS,IS*);
235 PETSC_EXTERN PetscErrorCode ISPartitioningCount(IS,PetscInt,PetscInt[]);
236 
237 PETSC_EXTERN PetscErrorCode ISCompressIndicesGeneral(PetscInt,PetscInt,PetscInt,PetscInt,const IS[],IS[]);
238 PETSC_EXTERN PetscErrorCode ISCompressIndicesSorted(PetscInt,PetscInt,PetscInt,const IS[],IS[]);
239 PETSC_EXTERN PetscErrorCode ISExpandIndicesGeneral(PetscInt,PetscInt,PetscInt,PetscInt,const IS[],IS[]);
240 
241 
242 struct _n_PetscLayout{
243   MPI_Comm               comm;
244   PetscInt               n,N;         /* local, global vector size */
245   PetscInt               rstart,rend; /* local start, local end + 1 */
246   PetscInt               *range;      /* the offset of each processor */
247   PetscBool              range_alloc; /* should range be freed in Destroy? */
248   PetscInt               bs;          /* number of elements in each block (generally for multi-component
249                                        * problems). Defaults to -1 and can be arbitrarily lazy so always use
250                                        * PetscAbs(map->bs) when accessing directly and expecting result to be
251                                        * positive. Do NOT multiply above numbers by bs */
252   PetscInt               refcnt;      /* MPI Vecs obtained with VecDuplicate() and from MatCreateVecs() reuse map of input object */
253   ISLocalToGlobalMapping mapping;     /* mapping used in Vec/MatSetValuesLocal() */
254   PetscBool              setupcalled; /* Forbid setup more than once */
255   PetscInt               oldn,oldN;   /* Checking if setup is allowed */
256   PetscInt               oldbs;       /* And again */
257 };
258 
259 /*@C
260      PetscLayoutFindOwner - Find the owning rank for a global index
261 
262     Not Collective
263 
264    Input Parameters:
265 +    map - the layout
266 -    idx - global index to find the owner of
267 
268    Output Parameter:
269 .    owner - the owning rank
270 
271    Level: developer
272 
273     Fortran Notes:
274       Not available from Fortran
275 
276 @*/
PetscLayoutFindOwner(PetscLayout map,PetscInt idx,PetscMPIInt * owner)277 PETSC_STATIC_INLINE PetscErrorCode PetscLayoutFindOwner(PetscLayout map,PetscInt idx,PetscMPIInt *owner)
278 {
279   PetscErrorCode ierr;
280   PetscMPIInt    lo = 0,hi,t;
281 
282   PetscFunctionBegin;
283   *owner = -1;                  /* GCC erroneously issues warning about possibly uninitialized use when error condition */
284   if (!((map->n >= 0) && (map->N >= 0) && (map->range))) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONGSTATE,"PetscLayoutSetUp() must be called first");
285   if (idx < 0 || idx > map->N) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Index %D is out of range",idx);
286   ierr = MPI_Comm_size(map->comm,&hi);CHKERRQ(ierr);
287   while (hi - lo > 1) {
288     t = lo + (hi - lo) / 2;
289     if (idx < map->range[t]) hi = t;
290     else                     lo = t;
291   }
292   *owner = lo;
293   PetscFunctionReturn(0);
294 }
295 
296 /*@C
297      PetscLayoutFindOwnerIndex - Find the owning rank and the local index for a global index
298 
299     Not Collective
300 
301    Input Parameters:
302 +    map   - the layout
303 -    idx   - global index to find the owner of
304 
305    Output Parameter:
306 +    owner - the owning rank
307 -    lidx  - local index used by the owner for idx
308 
309    Level: developer
310 
311     Fortran Notes:
312       Not available from Fortran
313 
314 @*/
PetscLayoutFindOwnerIndex(PetscLayout map,PetscInt idx,PetscMPIInt * owner,PetscInt * lidx)315 PETSC_STATIC_INLINE PetscErrorCode PetscLayoutFindOwnerIndex(PetscLayout map,PetscInt idx,PetscMPIInt *owner,PetscInt *lidx)
316 {
317   PetscErrorCode ierr;
318   PetscMPIInt    lo = 0,hi,t;
319 
320   PetscFunctionBegin;
321   if (!((map->n >= 0) && (map->N >= 0) && (map->range))) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONGSTATE,"PetscLayoutSetUp() must be called first");
322   if (idx < 0 || idx > map->N) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Index %D is out of range",idx);
323   ierr = MPI_Comm_size(map->comm,&hi);CHKERRQ(ierr);
324   while (hi - lo > 1) {
325     t = lo + (hi - lo) / 2;
326     if (idx < map->range[t]) hi = t;
327     else                     lo = t;
328   }
329   if (owner) *owner = lo;
330   if (lidx) *lidx  = idx-map->range[lo];
331   PetscFunctionReturn(0);
332 }
333 
334 PETSC_EXTERN PetscErrorCode PetscLayoutCreate(MPI_Comm,PetscLayout*);
335 PETSC_EXTERN PetscErrorCode PetscLayoutCreateFromSizes(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscLayout*);
336 PETSC_EXTERN PetscErrorCode PetscLayoutCreateFromRanges(MPI_Comm,const PetscInt[],PetscCopyMode,PetscInt,PetscLayout*);
337 PETSC_EXTERN PetscErrorCode PetscLayoutSetUp(PetscLayout);
338 PETSC_EXTERN PetscErrorCode PetscLayoutDestroy(PetscLayout*);
339 PETSC_EXTERN PetscErrorCode PetscLayoutDuplicate(PetscLayout,PetscLayout*);
340 PETSC_EXTERN PetscErrorCode PetscLayoutReference(PetscLayout,PetscLayout*);
341 PETSC_EXTERN PetscErrorCode PetscLayoutSetLocalSize(PetscLayout,PetscInt);
342 PETSC_EXTERN PetscErrorCode PetscLayoutGetLocalSize(PetscLayout,PetscInt *);
343 PETSC_EXTERN PetscErrorCode PetscLayoutSetSize(PetscLayout,PetscInt);
344 PETSC_EXTERN PetscErrorCode PetscLayoutGetSize(PetscLayout,PetscInt *);
345 PETSC_EXTERN PetscErrorCode PetscLayoutSetBlockSize(PetscLayout,PetscInt);
346 PETSC_EXTERN PetscErrorCode PetscLayoutGetBlockSize(PetscLayout,PetscInt*);
347 PETSC_EXTERN PetscErrorCode PetscLayoutGetRange(PetscLayout,PetscInt *,PetscInt *);
348 PETSC_EXTERN PetscErrorCode PetscLayoutGetRanges(PetscLayout,const PetscInt *[]);
349 PETSC_EXTERN PetscErrorCode PetscLayoutCompare(PetscLayout,PetscLayout,PetscBool*);
350 PETSC_EXTERN PetscErrorCode PetscLayoutSetISLocalToGlobalMapping(PetscLayout,ISLocalToGlobalMapping);
351 PETSC_EXTERN PetscErrorCode PetscLayoutMapLocal(PetscLayout,PetscInt,const PetscInt[],PetscInt*,PetscInt**,PetscInt**);
352 PETSC_EXTERN PetscErrorCode PetscSFSetGraphLayout(PetscSF,PetscLayout,PetscInt,const PetscInt*,PetscCopyMode,const PetscInt*);
353 PETSC_EXTERN PetscErrorCode PetscLayoutsCreateSF(PetscLayout,PetscLayout,PetscSF*);
354 
355 PETSC_EXTERN PetscErrorCode PetscParallelSortInt(PetscLayout, PetscLayout, PetscInt*, PetscInt*);
356 
357 PETSC_EXTERN PetscErrorCode ISGetLayout(IS, PetscLayout *);
358 
359 /* PetscSF support */
360 PETSC_EXTERN PetscErrorCode PetscSFConvertPartition(PetscSF, PetscSection, IS, ISLocalToGlobalMapping *, PetscSF *);
361 PETSC_EXTERN PetscErrorCode PetscSFCreateRemoteOffsets(PetscSF, PetscSection, PetscSection, PetscInt **);
362 PETSC_EXTERN PetscErrorCode PetscSFDistributeSection(PetscSF, PetscSection, PetscInt **, PetscSection);
363 PETSC_EXTERN PetscErrorCode PetscSFCreateSectionSF(PetscSF, PetscSection, PetscInt [], PetscSection, PetscSF *);
364 
365 #endif
366