xref: /petsc/include/petscis.h (revision 8cc058d9cd56c1ccb3be12a47760ddfc446aaffc)
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 <petscviewertypes.h>
9 #include <petscsf.h>
10 
11 #define IS_FILE_CLASSID 1211218
12 PETSC_EXTERN PetscClassId IS_CLASSID;
13 
14 PETSC_EXTERN PetscErrorCode ISInitializePackage(const char[]);
15 
16 /*S
17      IS - Abstract PETSc object that allows indexing.
18 
19    Level: beginner
20 
21   Concepts: indexing, stride
22 
23 .seealso:  ISCreateGeneral(), ISCreateBlock(), ISCreateStride(), ISGetIndices(), ISDestroy()
24 S*/
25 typedef struct _p_IS* IS;
26 
27 /*J
28     ISType - String with the name of a PETSc vector or the creation function
29        with an optional dynamic library name, for example
30        http://www.mcs.anl.gov/petsc/lib.a:myveccreate()
31 
32    Level: beginner
33 
34 .seealso: ISSetType(), IS
35 J*/
36 typedef const char* ISType;
37 #define ISGENERAL      "general"
38 #define ISSTRIDE       "stride"
39 #define ISBLOCK        "block"
40 
41 /* Dynamic creation and loading functions */
42 PETSC_EXTERN PetscFunctionList ISList;
43 PETSC_EXTERN PetscBool         ISRegisterAllCalled;
44 PETSC_EXTERN PetscErrorCode ISSetType(IS, ISType);
45 PETSC_EXTERN PetscErrorCode ISGetType(IS, ISType *);
46 PETSC_EXTERN PetscErrorCode ISRegister(const char[],const char[],const char[],PetscErrorCode (*)(IS));
47 PETSC_EXTERN PetscErrorCode ISRegisterAll(const char []);
48 PETSC_EXTERN PetscErrorCode ISRegisterDestroy(void);
49 PETSC_EXTERN PetscErrorCode ISCreate(MPI_Comm,IS*);
50 
51 /*MC
52   ISRegisterDynamic - Adds a new index set implementation
53 
54   Synopsis:
55   #include "petscis.h"
56   PetscErrorCode ISRegisterDynamic(const char *name, const char *path, const char *func_name, PetscErrorCode (*create_func)(IS))
57 
58   Not Collective
59 
60   Input Parameters:
61 + name        - The name of a new user-defined creation routine
62 . path        - The path (either absolute or relative) of the library containing this routine
63 . func_name   - The name of routine to create method context
64 - create_func - The creation routine itself
65 
66   Notes:
67   ISRegisterDynamic() may be called multiple times to add several user-defined vectors
68 
69   If dynamic libraries are used, then the fourth input argument (routine_create) is ignored.
70 
71   Sample usage:
72 .vb
73     ISRegisterDynamic("my_is_name","/home/username/my_lib/lib/libO/solaris/libmy.a", "MyISCreate", MyISCreate);
74 .ve
75 
76   Then, your vector type can be chosen with the procedural interface via
77 .vb
78     ISCreate(MPI_Comm, IS *);
79     ISSetType(IS,"my_is_name");
80 .ve
81    or at runtime via the option
82 .vb
83     -is_type my_is_name
84 .ve
85 
86   Notes: $PETSC_ARCH occuring in pathname will be replaced with appropriate values.
87          If your function is not being put into a shared library then use ISRegister() instead
88 
89   This is no ISSetFromOptions() and the current implementations do not have a way to dynamically determine type, so
90   dynamic registration of custom IS types will be of limited use to users.
91 
92   Level: developer
93 
94 .keywords: IS, register
95 .seealso: ISRegisterAll(), ISRegisterDestroy(), ISRegister()
96 M*/
97 #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
98 #define ISRegisterDynamic(a,b,c,d) ISRegister(a,b,c,0)
99 #else
100 #define ISRegisterDynamic(a,b,c,d) ISRegister(a,b,c,d)
101 #endif
102 
103 /*
104     Default index set data structures that PETSc provides.
105 */
106 PETSC_EXTERN PetscErrorCode ISCreateGeneral(MPI_Comm,PetscInt,const PetscInt[],PetscCopyMode,IS *);
107 PETSC_EXTERN PetscErrorCode ISGeneralSetIndices(IS,PetscInt,const PetscInt[],PetscCopyMode);
108 PETSC_EXTERN PetscErrorCode ISCreateBlock(MPI_Comm,PetscInt,PetscInt,const PetscInt[],PetscCopyMode,IS *);
109 PETSC_EXTERN PetscErrorCode ISBlockSetIndices(IS,PetscInt,PetscInt,const PetscInt[],PetscCopyMode);
110 PETSC_EXTERN PetscErrorCode ISCreateStride(MPI_Comm,PetscInt,PetscInt,PetscInt,IS *);
111 PETSC_EXTERN PetscErrorCode ISStrideSetStride(IS,PetscInt,PetscInt,PetscInt);
112 
113 PETSC_EXTERN PetscErrorCode ISDestroy(IS*);
114 PETSC_EXTERN PetscErrorCode ISSetPermutation(IS);
115 PETSC_EXTERN PetscErrorCode ISPermutation(IS,PetscBool *);
116 PETSC_EXTERN PetscErrorCode ISSetIdentity(IS);
117 PETSC_EXTERN PetscErrorCode ISIdentity(IS,PetscBool *);
118 PETSC_EXTERN PetscErrorCode ISContiguousLocal(IS,PetscInt,PetscInt,PetscInt*,PetscBool*);
119 
120 PETSC_EXTERN PetscErrorCode ISGetIndices(IS,const PetscInt *[]);
121 PETSC_EXTERN PetscErrorCode ISRestoreIndices(IS,const PetscInt *[]);
122 PETSC_EXTERN PetscErrorCode ISGetTotalIndices(IS,const PetscInt *[]);
123 PETSC_EXTERN PetscErrorCode ISRestoreTotalIndices(IS,const PetscInt *[]);
124 PETSC_EXTERN PetscErrorCode ISGetNonlocalIndices(IS,const PetscInt *[]);
125 PETSC_EXTERN PetscErrorCode ISRestoreNonlocalIndices(IS,const PetscInt *[]);
126 PETSC_EXTERN PetscErrorCode ISGetNonlocalIS(IS, IS *is);
127 PETSC_EXTERN PetscErrorCode ISRestoreNonlocalIS(IS, IS *is);
128 PETSC_EXTERN PetscErrorCode ISGetSize(IS,PetscInt *);
129 PETSC_EXTERN PetscErrorCode ISGetLocalSize(IS,PetscInt *);
130 PETSC_EXTERN PetscErrorCode ISInvertPermutation(IS,PetscInt,IS*);
131 PETSC_EXTERN PetscErrorCode ISView(IS,PetscViewer);
132 PETSC_EXTERN PetscErrorCode ISEqual(IS,IS,PetscBool  *);
133 PETSC_EXTERN PetscErrorCode ISSort(IS);
134 PETSC_EXTERN PetscErrorCode ISSorted(IS,PetscBool  *);
135 PETSC_EXTERN PetscErrorCode ISDifference(IS,IS,IS*);
136 PETSC_EXTERN PetscErrorCode ISSum(IS,IS,IS*);
137 PETSC_EXTERN PetscErrorCode ISExpand(IS,IS,IS*);
138 PETSC_EXTERN PetscErrorCode ISGetMinMax(IS,PetscInt*,PetscInt*);
139 
140 PETSC_EXTERN PetscErrorCode ISBlockGetIndices(IS,const PetscInt *[]);
141 PETSC_EXTERN PetscErrorCode ISBlockRestoreIndices(IS,const PetscInt *[]);
142 PETSC_EXTERN PetscErrorCode ISBlockGetLocalSize(IS,PetscInt *);
143 PETSC_EXTERN PetscErrorCode ISBlockGetSize(IS,PetscInt *);
144 PETSC_EXTERN PetscErrorCode ISGetBlockSize(IS,PetscInt*);
145 PETSC_EXTERN PetscErrorCode ISSetBlockSize(IS,PetscInt);
146 
147 PETSC_EXTERN PetscErrorCode ISStrideGetInfo(IS,PetscInt *,PetscInt*);
148 
149 PETSC_EXTERN PetscErrorCode ISToGeneral(IS);
150 
151 PETSC_EXTERN PetscErrorCode ISDuplicate(IS,IS*);
152 PETSC_EXTERN PetscErrorCode ISCopy(IS,IS);
153 PETSC_EXTERN PetscErrorCode ISAllGather(IS,IS*);
154 PETSC_EXTERN PetscErrorCode ISComplement(IS,PetscInt,PetscInt,IS*);
155 PETSC_EXTERN PetscErrorCode ISConcatenate(MPI_Comm,PetscInt,const IS[],IS*);
156 PETSC_EXTERN PetscErrorCode ISListToPair(MPI_Comm,PetscInt, IS[],IS*,IS*);
157 PETSC_EXTERN PetscErrorCode ISPairToList(IS,IS,PetscInt*, IS *[]);
158 PETSC_EXTERN PetscErrorCode ISEmbed(IS,IS,PetscBool,IS*);
159 PETSC_EXTERN PetscErrorCode ISOnComm(IS,MPI_Comm,PetscCopyMode,IS*);
160 
161 /* --------------------------------------------------------------------------*/
162 PETSC_EXTERN PetscClassId IS_LTOGM_CLASSID;
163 
164 /*S
165    ISLocalToGlobalMapping - mappings from an arbitrary
166       local ordering from 0 to n-1 to a global PETSc ordering
167       used by a vector or matrix.
168 
169    Level: intermediate
170 
171    Note: mapping from Local to Global is scalable; but Global
172   to Local may not be if the range of global values represented locally
173   is very large.
174 
175    Note: the ISLocalToGlobalMapping is actually a private object; it is included
176   here for the inline function ISLocalToGlobalMappingApply() to allow it to be inlined since
177   it is used so often.
178 
179 .seealso:  ISLocalToGlobalMappingCreate()
180 S*/
181 typedef struct _p_ISLocalToGlobalMapping* ISLocalToGlobalMapping;
182 
183 /*E
184     ISGlobalToLocalMappingType - Indicates if missing global indices are
185 
186    IS_GTOLM_MASK - missing global indices are replaced with -1
187    IS_GTOLM_DROP - missing global indices are dropped
188 
189    Level: beginner
190 
191 .seealso: ISGlobalToLocalMappingApply()
192 
193 E*/
194 typedef enum {IS_GTOLM_MASK,IS_GTOLM_DROP} ISGlobalToLocalMappingType;
195 
196 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingCreate(MPI_Comm,PetscInt,const PetscInt[],PetscCopyMode,ISLocalToGlobalMapping*);
197 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingCreateIS(IS,ISLocalToGlobalMapping *);
198 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingCreateSF(PetscSF,PetscInt,ISLocalToGlobalMapping*);
199 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingView(ISLocalToGlobalMapping,PetscViewer);
200 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingDestroy(ISLocalToGlobalMapping*);
201 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingApplyIS(ISLocalToGlobalMapping,IS,IS*);
202 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingApply(ISLocalToGlobalMapping,PetscInt,const PetscInt[],PetscInt[]);
203 PETSC_EXTERN PetscErrorCode ISGlobalToLocalMappingApply(ISLocalToGlobalMapping,ISGlobalToLocalMappingType,PetscInt,const PetscInt[],PetscInt*,PetscInt[]);
204 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingGetSize(ISLocalToGlobalMapping,PetscInt*);
205 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingGetInfo(ISLocalToGlobalMapping,PetscInt*,PetscInt*[],PetscInt*[],PetscInt**[]);
206 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingRestoreInfo(ISLocalToGlobalMapping,PetscInt*,PetscInt*[],PetscInt*[],PetscInt**[]);
207 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingGetIndices(ISLocalToGlobalMapping,const PetscInt**);
208 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingRestoreIndices(ISLocalToGlobalMapping,const PetscInt**);
209 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingBlock(ISLocalToGlobalMapping,PetscInt,ISLocalToGlobalMapping*);
210 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingUnBlock(ISLocalToGlobalMapping,PetscInt,ISLocalToGlobalMapping*);
211 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingConcatenate(MPI_Comm,PetscInt,const ISLocalToGlobalMapping[],ISLocalToGlobalMapping*);
212 PETSC_EXTERN PetscErrorCode ISG2LMapApply(ISLocalToGlobalMapping,PetscInt,const PetscInt[],PetscInt[]);
213 
214 /* --------------------------------------------------------------------------*/
215 /*E
216     ISColoringType - determines if the coloring is for the entire parallel grid/graph/matrix
217                      or for just the local ghosted portion
218 
219     Level: beginner
220 
221 $   IS_COLORING_GLOBAL - does not include the colors for ghost points, this is used when the function
222 $                        is called synchronously in parallel. This requires generating a "parallel coloring".
223 $   IS_COLORING_GHOSTED - includes colors for ghost points, this is used when the function can be called
224 $                         seperately on individual processes with the ghost points already filled in. Does not
225 $                         require a "parallel coloring", rather each process colors its local + ghost part.
226 $                         Using this can result in much less parallel communication. In the paradigm of
227 $                         DMGetLocalVector() and DMGetGlobalVector() this could be called IS_COLORING_LOCAL
228 
229 .seealso: DMCreateColoring()
230 E*/
231 typedef enum {IS_COLORING_GLOBAL,IS_COLORING_GHOSTED} ISColoringType;
232 PETSC_EXTERN const char *const ISColoringTypes[];
233 typedef unsigned PETSC_IS_COLOR_VALUE_TYPE ISColoringValue;
234 PETSC_EXTERN PetscErrorCode ISAllGatherColors(MPI_Comm,PetscInt,ISColoringValue*,PetscInt*,ISColoringValue*[]);
235 
236 /*S
237      ISColoring - sets of IS's that define a coloring
238               of the underlying indices
239 
240    Level: intermediate
241 
242     Notes:
243         One should not access the *is records below directly because they may not yet
244     have been created. One should use ISColoringGetIS() to make sure they are
245     created when needed.
246 
247     Developer Note: this is not a PetscObject
248 
249 .seealso:  ISColoringCreate(), ISColoringGetIS(), ISColoringView(), ISColoringGetIS()
250 S*/
251 struct _n_ISColoring {
252   PetscInt        refct;
253   PetscInt        n;                /* number of colors */
254   IS              *is;              /* for each color indicates columns */
255   MPI_Comm        comm;
256   ISColoringValue *colors;          /* for each column indicates color */
257   PetscInt        N;                /* number of columns */
258   ISColoringType  ctype;
259 };
260 typedef struct _n_ISColoring* ISColoring;
261 
262 PETSC_EXTERN PetscErrorCode ISColoringCreate(MPI_Comm,PetscInt,PetscInt,const ISColoringValue[],ISColoring*);
263 PETSC_EXTERN PetscErrorCode ISColoringDestroy(ISColoring*);
264 PETSC_EXTERN PetscErrorCode ISColoringView(ISColoring,PetscViewer);
265 PETSC_EXTERN PetscErrorCode ISColoringGetIS(ISColoring,PetscInt*,IS*[]);
266 PETSC_EXTERN PetscErrorCode ISColoringRestoreIS(ISColoring,IS*[]);
267 PETSC_EXTERN PetscErrorCode ISColoringReference(ISColoring);
268 PETSC_EXTERN PetscErrorCode ISColoringSetType(ISColoring,ISColoringType);
269 
270 
271 /* --------------------------------------------------------------------------*/
272 
273 PETSC_EXTERN PetscErrorCode ISPartitioningToNumbering(IS,IS*);
274 PETSC_EXTERN PetscErrorCode ISPartitioningCount(IS,PetscInt,PetscInt[]);
275 
276 PETSC_EXTERN PetscErrorCode ISCompressIndicesGeneral(PetscInt,PetscInt,PetscInt,PetscInt,const IS[],IS[]);
277 PETSC_EXTERN PetscErrorCode ISCompressIndicesSorted(PetscInt,PetscInt,PetscInt,const IS[],IS[]);
278 PETSC_EXTERN PetscErrorCode ISExpandIndicesGeneral(PetscInt,PetscInt,PetscInt,PetscInt,const IS[],IS[]);
279 
280 /*S
281      PetscLayout - defines layout of vectors and matrices across processes (which rows are owned by which processes)
282 
283    Level: developer
284 
285 
286 .seealso:  PetscLayoutCreate(), PetscLayoutDestroy()
287 S*/
288 typedef struct _n_PetscLayout* PetscLayout;
289 struct _n_PetscLayout{
290   MPI_Comm               comm;
291   PetscInt               n,N;         /* local, global vector size */
292   PetscInt               rstart,rend; /* local start, local end + 1 */
293   PetscInt               *range;      /* the offset of each processor */
294   PetscInt               bs;          /* number of elements in each block (generally for multi-component problems) Do NOT multiply above numbers by bs */
295   PetscInt               refcnt;      /* MPI Vecs obtained with VecDuplicate() and from MatGetVecs() reuse map of input object */
296   ISLocalToGlobalMapping mapping;     /* mapping used in Vec/MatSetValuesLocal() */
297   ISLocalToGlobalMapping bmapping;    /* mapping used in Vec/MatSetValuesBlockedLocal() */
298   PetscInt               *trstarts;   /* local start for each thread */
299 };
300 
301 PETSC_EXTERN PetscErrorCode PetscLayoutCreate(MPI_Comm,PetscLayout*);
302 PETSC_EXTERN PetscErrorCode PetscLayoutSetUp(PetscLayout);
303 PETSC_EXTERN PetscErrorCode PetscLayoutDestroy(PetscLayout*);
304 PETSC_EXTERN PetscErrorCode PetscLayoutDuplicate(PetscLayout,PetscLayout*);
305 PETSC_EXTERN PetscErrorCode PetscLayoutReference(PetscLayout,PetscLayout*);
306 PETSC_EXTERN PetscErrorCode PetscLayoutSetLocalSize(PetscLayout,PetscInt);
307 PETSC_EXTERN PetscErrorCode PetscLayoutGetLocalSize(PetscLayout,PetscInt *);
308 PETSC_EXTERN PetscErrorCode PetscLayoutSetSize(PetscLayout,PetscInt);
309 PETSC_EXTERN PetscErrorCode PetscLayoutGetSize(PetscLayout,PetscInt *);
310 PETSC_EXTERN PetscErrorCode PetscLayoutSetBlockSize(PetscLayout,PetscInt);
311 PETSC_EXTERN PetscErrorCode PetscLayoutGetBlockSize(PetscLayout,PetscInt*);
312 PETSC_EXTERN PetscErrorCode PetscLayoutGetRange(PetscLayout,PetscInt *,PetscInt *);
313 PETSC_EXTERN PetscErrorCode PetscLayoutGetRanges(PetscLayout,const PetscInt *[]);
314 PETSC_EXTERN PetscErrorCode PetscLayoutSetISLocalToGlobalMapping(PetscLayout,ISLocalToGlobalMapping);
315 PETSC_EXTERN PetscErrorCode PetscLayoutSetISLocalToGlobalMappingBlock(PetscLayout,ISLocalToGlobalMapping);
316 PETSC_EXTERN PetscErrorCode PetscSFSetGraphLayout(PetscSF,PetscLayout,PetscInt,const PetscInt*,PetscCopyMode,const PetscInt*);
317 
318 #undef __FUNCT__
319 #define __FUNCT__ "PetscLayoutFindOwner"
320 /*@C
321      PetscLayoutFindOwner - Find the owning rank for a global index
322 
323     Not Collective
324 
325    Input Parameters:
326 +    map - the layout
327 -    idx - global index to find the owner of
328 
329    Output Parameter:
330 .    owner - the owning rank
331 
332    Level: developer
333 
334     Fortran Notes:
335       Not available from Fortran
336 
337 @*/
338 PETSC_STATIC_INLINE PetscErrorCode PetscLayoutFindOwner(PetscLayout map,PetscInt idx,PetscInt *owner)
339 {
340   PetscErrorCode ierr;
341   PetscMPIInt    lo = 0,hi,t;
342 
343   PetscFunctionBegin;
344   *owner = -1;                  /* GCC erroneously issues warning about possibly uninitialized use when error condition */
345   if (!((map->n >= 0) && (map->N >= 0) && (map->range))) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONGSTATE,"PetscLayoutSetUp() must be called first");
346   if (idx < 0 || idx > map->N) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Index %D is out of range",idx);
347   ierr = MPI_Comm_size(map->comm,&hi);CHKERRQ(ierr);
348   while (hi - lo > 1) {
349     t = lo + (hi - lo) / 2;
350     if (idx < map->range[t]) hi = t;
351     else                     lo = t;
352   }
353   *owner = lo;
354   PetscFunctionReturn(0);
355 }
356 
357 #undef __FUNCT__
358 #define __FUNCT__ "PetscLayoutFindOwnerIndex"
359 /*@C
360      PetscLayoutFindOwnerIndex - Find the owning rank and the local index for a global index
361 
362     Not Collective
363 
364    Input Parameters:
365 +    map   - the layout
366 -    idx   - global index to find the owner of
367 
368    Output Parameter:
369 +    owner - the owning rank
370 -    lidx  - local index used by the owner for idx
371 
372    Level: developer
373 
374     Fortran Notes:
375       Not available from Fortran
376 
377 @*/
378 PETSC_STATIC_INLINE PetscErrorCode PetscLayoutFindOwnerIndex(PetscLayout map,PetscInt idx,PetscInt *owner, PetscInt *lidx)
379 {
380   PetscErrorCode ierr;
381   PetscMPIInt    lo = 0,hi,t;
382 
383   PetscFunctionBegin;
384   if (!((map->n >= 0) && (map->N >= 0) && (map->range))) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONGSTATE,"PetscLayoutSetUp() must be called first");
385   if (idx < 0 || idx > map->N) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Index %D is out of range",idx);
386   ierr = MPI_Comm_size(map->comm,&hi);CHKERRQ(ierr);
387   while (hi - lo > 1) {
388     t = lo + (hi - lo) / 2;
389     if (idx < map->range[t]) hi = t;
390     else                     lo = t;
391   }
392   *owner = lo;
393   *lidx  = idx-map->range[lo];
394   PetscFunctionReturn(0);
395 }
396 
397 PETSC_EXTERN PetscClassId PETSC_SECTION_CLASSID;
398 
399 /*S
400   PetscSection - Mapping from integers in a designated range to contiguous sets of integers.
401 
402   In contrast to IS, which maps from integers to single integers, the range of a PetscSection is in the space of
403   contiguous sets of integers. These ranges are frequently interpreted as domains of other array-like objects,
404   especially other PetscSections, Vecs, and ISs. The domain is set with PetscSectionSetChart() and does not need to
405   start at 0. For each point in the domain of a PetscSection, the output set is represented through an offset and a
406   count, which are set using PetscSectionSetOffset() and PetscSectionSetDof() respectively. Lookup is typically using
407   accessors or routines like VecGetValuesSection().
408 
409   Level: developer
410 
411 .seealso:  PetscSectionCreate(), PetscSectionDestroy()
412 S*/
413 typedef struct _p_PetscSection *PetscSection;
414 PETSC_EXTERN PetscErrorCode PetscSectionCreate(MPI_Comm,PetscSection*);
415 PETSC_EXTERN PetscErrorCode PetscSectionClone(PetscSection, PetscSection*);
416 PETSC_EXTERN PetscErrorCode PetscSectionGetNumFields(PetscSection, PetscInt *);
417 PETSC_EXTERN PetscErrorCode PetscSectionSetNumFields(PetscSection, PetscInt);
418 PETSC_EXTERN PetscErrorCode PetscSectionGetFieldName(PetscSection, PetscInt, const char *[]);
419 PETSC_EXTERN PetscErrorCode PetscSectionSetFieldName(PetscSection, PetscInt, const char []);
420 PETSC_EXTERN PetscErrorCode PetscSectionGetFieldComponents(PetscSection, PetscInt, PetscInt *);
421 PETSC_EXTERN PetscErrorCode PetscSectionSetFieldComponents(PetscSection, PetscInt, PetscInt);
422 PETSC_EXTERN PetscErrorCode PetscSectionGetChart(PetscSection, PetscInt *, PetscInt *);
423 PETSC_EXTERN PetscErrorCode PetscSectionSetChart(PetscSection, PetscInt, PetscInt);
424 PETSC_EXTERN PetscErrorCode PetscSectionGetDof(PetscSection, PetscInt, PetscInt*);
425 PETSC_EXTERN PetscErrorCode PetscSectionSetDof(PetscSection, PetscInt, PetscInt);
426 PETSC_EXTERN PetscErrorCode PetscSectionAddDof(PetscSection, PetscInt, PetscInt);
427 PETSC_EXTERN PetscErrorCode PetscSectionGetFieldDof(PetscSection, PetscInt, PetscInt, PetscInt*);
428 PETSC_EXTERN PetscErrorCode PetscSectionSetFieldDof(PetscSection, PetscInt, PetscInt, PetscInt);
429 PETSC_EXTERN PetscErrorCode PetscSectionAddFieldDof(PetscSection, PetscInt, PetscInt, PetscInt);
430 PETSC_EXTERN PetscErrorCode PetscSectionGetConstraintDof(PetscSection, PetscInt, PetscInt*);
431 PETSC_EXTERN PetscErrorCode PetscSectionSetConstraintDof(PetscSection, PetscInt, PetscInt);
432 PETSC_EXTERN PetscErrorCode PetscSectionAddConstraintDof(PetscSection, PetscInt, PetscInt);
433 PETSC_EXTERN PetscErrorCode PetscSectionGetFieldConstraintDof(PetscSection, PetscInt, PetscInt, PetscInt*);
434 PETSC_EXTERN PetscErrorCode PetscSectionSetFieldConstraintDof(PetscSection, PetscInt, PetscInt, PetscInt);
435 PETSC_EXTERN PetscErrorCode PetscSectionAddFieldConstraintDof(PetscSection, PetscInt, PetscInt, PetscInt);
436 PETSC_EXTERN PetscErrorCode PetscSectionGetConstraintIndices(PetscSection, PetscInt, const PetscInt**);
437 PETSC_EXTERN PetscErrorCode PetscSectionSetConstraintIndices(PetscSection, PetscInt, const PetscInt*);
438 PETSC_EXTERN PetscErrorCode PetscSectionGetFieldConstraintIndices(PetscSection, PetscInt, PetscInt, const PetscInt**);
439 PETSC_EXTERN PetscErrorCode PetscSectionSetFieldConstraintIndices(PetscSection, PetscInt, PetscInt, const PetscInt*);
440 PETSC_EXTERN PetscErrorCode PetscSectionSetUpBC(PetscSection);
441 PETSC_EXTERN PetscErrorCode PetscSectionSetUp(PetscSection);
442 PETSC_EXTERN PetscErrorCode PetscSectionGetMaxDof(PetscSection, PetscInt*);
443 PETSC_EXTERN PetscErrorCode PetscSectionGetStorageSize(PetscSection, PetscInt*);
444 PETSC_EXTERN PetscErrorCode PetscSectionGetConstrainedStorageSize(PetscSection, PetscInt*);
445 PETSC_EXTERN PetscErrorCode PetscSectionGetOffset(PetscSection, PetscInt, PetscInt*);
446 PETSC_EXTERN PetscErrorCode PetscSectionSetOffset(PetscSection, PetscInt, PetscInt);
447 PETSC_EXTERN PetscErrorCode PetscSectionGetFieldOffset(PetscSection, PetscInt, PetscInt, PetscInt*);
448 PETSC_EXTERN PetscErrorCode PetscSectionSetFieldOffset(PetscSection, PetscInt, PetscInt, PetscInt);
449 PETSC_EXTERN PetscErrorCode PetscSectionGetOffsetRange(PetscSection, PetscInt *, PetscInt *);
450 PETSC_EXTERN PetscErrorCode PetscSectionView(PetscSection, PetscViewer);
451 PETSC_EXTERN PetscErrorCode PetscSectionReset(PetscSection);
452 PETSC_EXTERN PetscErrorCode PetscSectionDestroy(PetscSection*);
453 PETSC_EXTERN PetscErrorCode PetscSectionCreateGlobalSection(PetscSection, PetscSF, PetscBool, PetscSection *);
454 PETSC_EXTERN PetscErrorCode PetscSectionCreateGlobalSectionCensored(PetscSection, PetscSF, PetscBool, PetscInt, const PetscInt [], PetscSection *);
455 PETSC_EXTERN PetscErrorCode PetscSectionCreateSubsection(PetscSection, PetscInt, PetscInt [], PetscSection *);
456 PETSC_EXTERN PetscErrorCode PetscSectionCreateSubmeshSection(PetscSection, IS, PetscSection *);
457 PETSC_EXTERN PetscErrorCode PetscSectionGetPointLayout(MPI_Comm, PetscSection, PetscLayout *);
458 PETSC_EXTERN PetscErrorCode PetscSectionGetValueLayout(MPI_Comm, PetscSection, PetscLayout *);
459 
460 /* PetscSF support */
461 PETSC_EXTERN PetscErrorCode PetscSFConvertPartition(PetscSF, PetscSection, IS, ISLocalToGlobalMapping *, PetscSF *);
462 PETSC_EXTERN PetscErrorCode PetscSFCreateRemoteOffsets(PetscSF, PetscSection, PetscSection, PetscInt **);
463 PETSC_EXTERN PetscErrorCode PetscSFDistributeSection(PetscSF, PetscSection, PetscInt **, PetscSection);
464 PETSC_EXTERN PetscErrorCode PetscSFCreateSectionSF(PetscSF, PetscSection, PetscInt [], PetscSection, PetscSF *);
465 
466 /* Reset __FUNCT__ in case the user does not define it themselves */
467 #undef __FUNCT__
468 #define __FUNCT__ "User provided function"
469 
470 #endif
471