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