Actual source code: petscis.h
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: #pragma once
7: #include <petscsys.h>
8: #include <petscsftypes.h>
9: #include <petscsectiontypes.h>
10: #include <petscistypes.h>
12: /* MANSEC = Vec */
13: /* SUBMANSEC = IS */
15: #define IS_FILE_CLASSID 1211218
16: PETSC_EXTERN PetscClassId IS_CLASSID;
18: PETSC_EXTERN PetscErrorCode ISInitializePackage(void);
19: PETSC_EXTERN PetscErrorCode ISFinalizePackage(void);
21: /*J
22: ISType - String with the name of a PETSc index set type
24: Values:
25: + `ISGENERAL` - the values are stored with an array of indices and generally have no structure
26: . `ISSTRIDE` - the values have a simple structure of an initial offset and then a step size between values
27: - `ISBLOCK` - values are an array of indices, each representing a block (of the same common length) of values
29: Level: beginner
31: .seealso: `ISSetType()`, `IS`, `ISCreateGeneral()`, `ISCreateStride()`, `ISCreateBlock()`, `ISCreate()`, `ISRegister()`,
32: `VecScatterCreate()`, `MatGetSubMatrices()`
33: J*/
34: typedef const char *ISType;
35: #define ISGENERAL "general"
36: #define ISSTRIDE "stride"
37: #define ISBLOCK "block"
39: /* Dynamic creation and loading functions */
40: PETSC_EXTERN PetscFunctionList ISList;
41: PETSC_EXTERN PetscErrorCode ISSetType(IS, ISType);
42: PETSC_EXTERN PetscErrorCode ISGetType(IS, ISType *);
43: PETSC_EXTERN PetscErrorCode ISRegister(const char[], PetscErrorCode (*)(IS));
44: PETSC_EXTERN PetscErrorCode ISRegisterAll(void);
45: PETSC_EXTERN PetscErrorCode ISCreate(MPI_Comm, IS *);
47: PETSC_EXTERN PetscErrorCode ISDestroy(IS *);
48: PETSC_EXTERN PetscErrorCode ISSetPermutation(IS);
49: PETSC_EXTERN PetscErrorCode ISPermutation(IS, PetscBool *);
50: PETSC_EXTERN PetscErrorCode ISSetIdentity(IS);
51: PETSC_EXTERN PetscErrorCode ISIdentity(IS, PetscBool *);
52: PETSC_EXTERN PetscErrorCode ISContiguousLocal(IS, PetscInt, PetscInt, PetscInt *, PetscBool *);
54: /*E
55: ISInfo - Info that may either be computed or set as known for an index set
57: Level: intermediate
59: Developer Note:
60: Entries that are negative need not be called collectively by all processes.
62: .seealso: `IS`, `ISType`, `ISSetInfo()`
63: E*/
64: typedef enum {
65: IS_INFO_MIN = -1,
66: IS_SORTED = 0,
67: IS_UNIQUE = 1,
68: IS_PERMUTATION = 2,
69: IS_INTERVAL = 3,
70: IS_IDENTITY = 4,
71: IS_INFO_MAX = 5
72: } ISInfo;
74: /*E
75: ISInfoType - Selects whether an `ISInfo` property of an `IS` is recorded with respect to the local indices on this MPI process or to the full global index set
77: Values:
78: + `IS_LOCAL` - the property holds for the local portion of the `IS`
79: - `IS_GLOBAL` - the property holds for the entire (parallel) index set
81: Level: intermediate
83: Note:
84: Some properties (for example `IS_SORTED`) may be true locally but not globally; `ISInfoType` lets the caller specify which interpretation is wanted in `ISSetInfo()`/`ISGetInfo()`.
86: .seealso: `IS`, `ISInfo`, `ISSetInfo()`, `ISGetInfo()`, `ISClearInfoCache()`
87: E*/
88: typedef enum {
89: IS_LOCAL,
90: IS_GLOBAL
91: } ISInfoType;
93: PETSC_EXTERN PetscErrorCode ISSetInfo(IS, ISInfo, ISInfoType, PetscBool, PetscBool);
94: PETSC_EXTERN PetscErrorCode ISGetInfo(IS, ISInfo, ISInfoType, PetscBool, PetscBool *);
95: PETSC_EXTERN PetscErrorCode ISClearInfoCache(IS, PetscBool);
96: PETSC_EXTERN PetscErrorCode ISGetIndices(IS, const PetscInt *[]);
97: PETSC_EXTERN PetscErrorCode ISRestoreIndices(IS, const PetscInt *[]);
98: PETSC_EXTERN PetscErrorCode ISGetTotalIndices(IS, const PetscInt *[]);
99: PETSC_EXTERN PetscErrorCode ISRestoreTotalIndices(IS, const PetscInt *[]);
100: PETSC_EXTERN PetscErrorCode ISGetNonlocalIndices(IS, const PetscInt *[]);
101: PETSC_EXTERN PetscErrorCode ISRestoreNonlocalIndices(IS, const PetscInt *[]);
102: PETSC_EXTERN PetscErrorCode ISGetNonlocalIS(IS, IS *);
103: PETSC_EXTERN PetscErrorCode ISRestoreNonlocalIS(IS, IS *);
104: PETSC_EXTERN PetscErrorCode ISGetSize(IS, PetscInt *);
105: PETSC_EXTERN PetscErrorCode ISGetLocalSize(IS, PetscInt *);
106: PETSC_EXTERN PetscErrorCode ISInvertPermutation(IS, PetscInt, IS *);
107: PETSC_EXTERN PetscErrorCode ISView(IS, PetscViewer);
108: PETSC_EXTERN PetscErrorCode ISViewFromOptions(IS, PetscObject, const char[]);
109: PETSC_EXTERN PetscErrorCode ISLoad(IS, PetscViewer);
110: PETSC_EXTERN PetscErrorCode ISEqual(IS, IS, PetscBool *);
111: PETSC_EXTERN PetscErrorCode ISEqualUnsorted(IS, IS, PetscBool *);
112: PETSC_EXTERN PetscErrorCode ISSort(IS);
113: PETSC_EXTERN PetscErrorCode ISSortRemoveDups(IS);
114: PETSC_EXTERN PetscErrorCode ISSorted(IS, PetscBool *);
115: PETSC_EXTERN PetscErrorCode ISDifference(IS, IS, IS *);
116: PETSC_EXTERN PetscErrorCode ISSum(IS, IS, IS *);
117: PETSC_EXTERN PetscErrorCode ISExpand(IS, IS, IS *);
118: PETSC_EXTERN PetscErrorCode ISIntersect(IS, IS, IS *);
119: PETSC_EXTERN PetscErrorCode ISGetMinMax(IS, PetscInt *, PetscInt *);
121: PETSC_EXTERN PetscErrorCode ISLocate(IS, PetscInt, PetscInt *);
122: PETSC_EXTERN PetscErrorCode ISGetPointRange(IS, PetscInt *, PetscInt *, const PetscInt *[]);
123: PETSC_EXTERN PetscErrorCode ISRestorePointRange(IS, PetscInt *, PetscInt *, const PetscInt *[]);
124: PETSC_EXTERN PetscErrorCode ISGetPointSubrange(IS, PetscInt, PetscInt, const PetscInt *);
126: PETSC_EXTERN PetscErrorCode ISGetBlockSize(IS, PetscInt *);
127: PETSC_EXTERN PetscErrorCode ISSetBlockSize(IS, PetscInt);
128: PETSC_EXTERN PetscErrorCode ISGetCompressOutput(IS, PetscBool *);
129: PETSC_EXTERN PetscErrorCode ISSetCompressOutput(IS, PetscBool);
131: PETSC_EXTERN PetscErrorCode ISToGeneral(IS);
133: PETSC_EXTERN PetscErrorCode ISDuplicate(IS, IS *);
134: PETSC_EXTERN PetscErrorCode ISCopy(IS, IS);
135: PETSC_EXTERN PetscErrorCode ISShift(IS, PetscInt, IS);
136: PETSC_EXTERN PetscErrorCode ISAllGather(IS, IS *);
137: PETSC_EXTERN PetscErrorCode ISComplement(IS, PetscInt, PetscInt, IS *);
138: PETSC_EXTERN PetscErrorCode ISConcatenate(MPI_Comm, PetscInt, const IS[], IS *);
139: PETSC_EXTERN PetscErrorCode ISListToPair(MPI_Comm, PetscInt, IS[], IS *, IS *);
140: PETSC_EXTERN PetscErrorCode ISPairToList(IS, IS, PetscInt *, IS *[]);
141: PETSC_EXTERN PetscErrorCode ISEmbed(IS, IS, PetscBool, IS *);
142: PETSC_EXTERN PetscErrorCode ISSortPermutation(IS, PetscBool, IS *);
143: PETSC_EXTERN PetscErrorCode ISOnComm(IS, MPI_Comm, PetscCopyMode, IS *);
144: PETSC_EXTERN PetscErrorCode ISRenumber(IS, IS, PetscInt *, IS *);
145: PETSC_EXTERN PetscErrorCode ISCreateSubIS(IS, IS, IS *);
147: /* ISGENERAL specific */
148: PETSC_EXTERN PetscErrorCode ISCreateGeneral(MPI_Comm, PetscInt, const PetscInt[], PetscCopyMode, IS *);
149: PETSC_EXTERN PetscErrorCode ISGeneralSetIndices(IS, PetscInt, const PetscInt[], PetscCopyMode);
150: PETSC_EXTERN PetscErrorCode ISGeneralSetIndicesFromMask(IS, PetscInt, PetscInt, const PetscBool[]);
151: PETSC_EXTERN PetscErrorCode ISGeneralFilter(IS, PetscInt, PetscInt);
153: /* ISBLOCK specific */
154: PETSC_EXTERN PetscErrorCode ISCreateBlock(MPI_Comm, PetscInt, PetscInt, const PetscInt[], PetscCopyMode, IS *);
155: PETSC_EXTERN PetscErrorCode ISBlockSetIndices(IS, PetscInt, PetscInt, const PetscInt[], PetscCopyMode);
156: PETSC_EXTERN PetscErrorCode ISBlockGetIndices(IS, const PetscInt *[]);
157: PETSC_EXTERN PetscErrorCode ISBlockRestoreIndices(IS, const PetscInt *[]);
158: PETSC_EXTERN PetscErrorCode ISBlockGetLocalSize(IS, PetscInt *);
159: PETSC_EXTERN PetscErrorCode ISBlockGetSize(IS, PetscInt *);
161: /* ISSTRIDE specific */
162: PETSC_EXTERN PetscErrorCode ISCreateStride(MPI_Comm, PetscInt, PetscInt, PetscInt, IS *);
163: PETSC_EXTERN PetscErrorCode ISStrideSetStride(IS, PetscInt, PetscInt, PetscInt);
164: PETSC_EXTERN PetscErrorCode ISStrideGetInfo(IS, PetscInt *, PetscInt *);
166: #define IS_LTOGM_FILE_CLASSID 1211217
167: PETSC_EXTERN PetscClassId IS_LTOGM_CLASSID;
169: /*E
170: ISGlobalToLocalMappingMode - Indicates mapping behavior if global indices are missing
172: Values:
173: + `IS_GTOLM_MASK` - missing global indices are masked by mapping them to a local index of -1
174: - `IS_GTOLM_DROP` - missing global indices are dropped
176: Level: beginner
178: .seealso: `ISGlobalToLocalMappingApplyBlock()`, `ISGlobalToLocalMappingApply()`
179: E*/
180: typedef enum {
181: IS_GTOLM_MASK,
182: IS_GTOLM_DROP
183: } ISGlobalToLocalMappingMode;
185: /*J
186: ISLocalToGlobalMappingType - String with the name of a mapping method
188: Values:
189: + `ISLOCALTOGLOBALMAPPINGBASIC` - a non-memory scalable way of storing `ISLocalToGlobalMapping` that allows applying `ISGlobalToLocalMappingApply()` efficiently
190: - `ISLOCALTOGLOBALMAPPINGHASH` - a memory scalable way of storing `ISLocalToGlobalMapping` that allows applying `ISGlobalToLocalMappingApply()` reasonably efficiently
192: Level: beginner
194: .seealso: `ISLocalToGlobalMapping`, `ISLocalToGlobalMappingSetType()`, `ISLocalToGlobalSetFromOptions()`, `ISGlobalToLocalMappingMode`
195: J*/
196: typedef const char *ISLocalToGlobalMappingType;
197: #define ISLOCALTOGLOBALMAPPINGBASIC "basic"
198: #define ISLOCALTOGLOBALMAPPINGHASH "hash"
200: PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingSetType(ISLocalToGlobalMapping, ISLocalToGlobalMappingType);
201: PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingGetType(ISLocalToGlobalMapping, ISLocalToGlobalMappingType *);
202: PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingRegister(const char[], PetscErrorCode (*)(ISLocalToGlobalMapping));
203: PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingRegisterAll(void);
204: PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingCreate(MPI_Comm, PetscInt, PetscInt, const PetscInt[], PetscCopyMode, ISLocalToGlobalMapping *);
205: PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingCreateIS(IS, ISLocalToGlobalMapping *);
206: PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingCreateSF(PetscSF, PetscInt, ISLocalToGlobalMapping *);
207: PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingSetFromOptions(ISLocalToGlobalMapping);
208: PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingView(ISLocalToGlobalMapping, PetscViewer);
209: PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingLoad(ISLocalToGlobalMapping, PetscViewer);
210: PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingViewFromOptions(ISLocalToGlobalMapping, PetscObject, const char[]);
211: PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingConcatenate(MPI_Comm, PetscInt, const ISLocalToGlobalMapping[], ISLocalToGlobalMapping *);
212: PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingDuplicate(ISLocalToGlobalMapping, ISLocalToGlobalMapping *);
213: PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingDestroy(ISLocalToGlobalMapping *);
214: PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingGetSize(ISLocalToGlobalMapping, PetscInt *);
215: PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingGetIndices(ISLocalToGlobalMapping, const PetscInt *[]);
216: PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingRestoreIndices(ISLocalToGlobalMapping, const PetscInt *[]);
217: PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingGetBlockIndices(ISLocalToGlobalMapping, const PetscInt *[]);
218: PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingRestoreBlockIndices(ISLocalToGlobalMapping, const PetscInt *[]);
219: PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingGetBlockSize(ISLocalToGlobalMapping, PetscInt *);
220: PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingSetBlockSize(ISLocalToGlobalMapping, PetscInt);
222: PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingApply(ISLocalToGlobalMapping, PetscInt, const PetscInt[], PetscInt[]);
223: PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingApplyBlock(ISLocalToGlobalMapping, PetscInt, const PetscInt[], PetscInt[]);
224: PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingApplyIS(ISLocalToGlobalMapping, IS, IS *);
225: PETSC_EXTERN PetscErrorCode ISGlobalToLocalMappingApply(ISLocalToGlobalMapping, ISGlobalToLocalMappingMode, PetscInt, const PetscInt[], PetscInt *, PetscInt[]);
226: PETSC_EXTERN PetscErrorCode ISGlobalToLocalMappingApplyBlock(ISLocalToGlobalMapping, ISGlobalToLocalMappingMode, PetscInt, const PetscInt[], PetscInt *, PetscInt[]);
227: PETSC_EXTERN PetscErrorCode ISGlobalToLocalMappingApplyIS(ISLocalToGlobalMapping, ISGlobalToLocalMappingMode, IS, IS *);
229: PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingGetNodeInfo(ISLocalToGlobalMapping, PetscInt *, PetscInt *[], PetscInt **[]);
230: PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingRestoreNodeInfo(ISLocalToGlobalMapping, PetscInt *, PetscInt *[], PetscInt **[]);
231: PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingGetInfo(ISLocalToGlobalMapping, PetscInt *, PetscInt *[], PetscInt *[], PetscInt **[]);
232: PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingRestoreInfo(ISLocalToGlobalMapping, PetscInt *, PetscInt *[], PetscInt *[], PetscInt **[]);
233: PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingGetBlockNodeInfo(ISLocalToGlobalMapping, PetscInt *, PetscInt *[], PetscInt **[]);
234: PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingRestoreBlockNodeInfo(ISLocalToGlobalMapping, PetscInt *, PetscInt *[], PetscInt **[]);
235: PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingGetBlockInfo(ISLocalToGlobalMapping, PetscInt *, PetscInt *[], PetscInt *[], PetscInt **[]);
236: PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingRestoreBlockInfo(ISLocalToGlobalMapping, PetscInt *, PetscInt *[], PetscInt *[], PetscInt **[]);
237: PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingGetBlockMultiLeavesSF(ISLocalToGlobalMapping, PetscSF *);
239: /*E
240: ISColoringType - determines if the coloring is for the entire parallel grid/graph/matrix
241: or for just the local ghosted portion
243: Values:
244: + `IS_COLORING_GLOBAL` - does not include the colors for ghost points, this is used when the function
245: is called synchronously in parallel. This requires generating a "parallel coloring".
246: - `IS_COLORING_LOCAL` - includes colors for ghost points, this is used when the function can be called
247: separately on individual processes with the ghost points already filled in. Does not
248: require a "parallel coloring", rather each process colors its local + ghost part.
249: Using this can result in much less parallel communication. Currently only works
250: with `DMDA` and if you call `MatFDColoringSetFunction()` with the local function.
252: Level: beginner
254: .seealso: `ISColoring`, `ISColoringSetType()`, `ISColoringGetType()`, `DMCreateColoring()`
255: E*/
256: typedef enum {
257: IS_COLORING_GLOBAL,
258: IS_COLORING_LOCAL
259: } ISColoringType;
261: PETSC_EXTERN const char *const ISColoringTypes[];
263: /*M
264: ISColoringValue - unsigned integral type used to indicate a coloring
266: Level: beginner
268: Note:
269: The unsigned integral type is determined at `./configure` time with the option `--with-is-color-value-type=(char|short)` which results
270: in either `unsigned char` or `unsigned short`.
272: .seealso: `ISColoringCreate()`
273: M*/
274: typedef unsigned PETSC_IS_COLORING_VALUE_TYPE ISColoringValue;
276: #define IS_COLORING_MAX PETSC_IS_COLORING_MAX
277: #define MPIU_COLORING_VALUE PETSC_MPIU_IS_COLORING_VALUE_TYPE
278: PETSC_EXTERN PetscErrorCode ISAllGatherColors(MPI_Comm, PetscInt, ISColoringValue *, PetscInt *, ISColoringValue *[]);
280: /*@
281: ISColoringValueCast - casts an integer a `ISColoringValue` (which may be 1-bits in size), generates an
282: error if the value is too large
284: Not Collective; No Fortran Support
286: Input Parameter:
287: . a - the `PetscCount` value
289: Output Parameter:
290: . b - the resulting `ISColoringValue` value, optional, pass `NULL` if not needed
292: Level: advanced
294: Note:
295: Errors if the integer is negative
297: .seealso: `ISColoringValue`, `ISColoringCreate()`, `PetscBLASInt`, `PetscMPIInt`, `PetscInt`, `PetscMPIIntCast()`, `PetscIntCast()`
298: @*/
299: static inline PetscErrorCode ISColoringValueCast(PetscCount a, ISColoringValue *b)
300: {
301: PetscFunctionBegin;
302: if (b) *b = 0;
303: PetscCheck(a >= 0, PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Passing negative integer not supported");
304: PetscCheck(a < PETSC_IS_COLORING_MAX, PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Integer too large to convert");
305: if (b) *b = (ISColoringValue)a;
306: PetscFunctionReturn(PETSC_SUCCESS);
307: }
309: PETSC_EXTERN PetscErrorCode ISColoringCreate(MPI_Comm, PetscInt, PetscInt, const ISColoringValue[], PetscCopyMode, ISColoring *);
310: PETSC_EXTERN PetscErrorCode ISColoringDestroy(ISColoring *);
311: PETSC_EXTERN PetscErrorCode ISColoringView(ISColoring, PetscViewer);
312: PETSC_EXTERN PetscErrorCode ISColoringViewFromOptions(ISColoring, PetscObject, const char[]);
313: PETSC_EXTERN PetscErrorCode ISColoringGetIS(ISColoring, PetscCopyMode, PetscInt *, IS *[]);
314: PETSC_EXTERN PetscErrorCode ISColoringRestoreIS(ISColoring, PetscCopyMode, IS *[]);
315: PETSC_EXTERN PetscErrorCode ISColoringReference(ISColoring);
316: PETSC_EXTERN PetscErrorCode ISColoringSetType(ISColoring, ISColoringType);
317: PETSC_EXTERN PetscErrorCode ISColoringGetType(ISColoring, ISColoringType *);
318: PETSC_EXTERN PetscErrorCode ISColoringGetColors(ISColoring, PetscInt *, PetscInt *, const ISColoringValue *[]);
320: PETSC_EXTERN PetscErrorCode ISBuildTwoSided(IS, IS, IS *);
321: PETSC_EXTERN PetscErrorCode ISPartitioningToNumbering(IS, IS *);
322: PETSC_EXTERN PetscErrorCode ISPartitioningCount(IS, PetscInt, PetscInt[]);
324: PETSC_EXTERN PetscErrorCode ISCompressIndicesGeneral(PetscInt, PetscInt, PetscInt, PetscInt, const IS[], IS[]);
325: PETSC_DEPRECATED_FUNCTION(3, 19, 0, "ISCompressIndicesGeneral()", ) static inline PetscErrorCode ISCompressIndicesSorted(PetscInt n, PetscInt bs, PetscInt imax, const IS is_in[], IS is_out[])
326: {
327: return ISCompressIndicesGeneral(n, bs, n, imax, is_in, is_out);
328: }
329: PETSC_EXTERN PetscErrorCode ISExpandIndicesGeneral(PetscInt, PetscInt, PetscInt, PetscInt, const IS[], IS[]);
331: struct _n_PetscLayout {
332: MPI_Comm comm;
333: PetscMPIInt size;
334: PetscInt n, N; /* local, global vector size */
335: PetscInt rstart, rend; /* local start, local end + 1 */
336: PetscInt *range; /* the offset of each processor */
337: PetscBool range_alloc; /* should range be freed in Destroy? */
338: PetscInt bs; /* number of elements in each block (generally for multi-component problems) */
339: PetscInt refcnt; /* MPI Vecs obtained with VecDuplicate() and from MatCreateVecs() reuse map of input object */
340: ISLocalToGlobalMapping mapping; /* mapping used in Vec/MatSetValuesLocal() */
341: PetscBool setupcalled; /* Forbid setup more than once */
342: PetscInt oldn, oldN; /* Checking if setup is allowed */
343: PetscInt oldbs; /* And again */
344: };
346: PETSC_EXTERN PetscErrorCode PetscLayoutCreate(MPI_Comm, PetscLayout *);
347: PETSC_EXTERN PetscErrorCode PetscLayoutFindOwner(PetscLayout, PetscInt, PetscMPIInt *);
348: PETSC_EXTERN PetscErrorCode PetscLayoutFindOwnerIndex(PetscLayout, PetscInt, PetscMPIInt *, PetscInt *);
349: PETSC_EXTERN PetscErrorCode PetscLayoutCreateFromSizes(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscLayout *);
350: PETSC_EXTERN PetscErrorCode PetscLayoutCreateFromRanges(MPI_Comm, const PetscInt[], PetscCopyMode, PetscInt, PetscLayout *);
351: PETSC_EXTERN PetscErrorCode PetscLayoutSetUp(PetscLayout);
352: PETSC_EXTERN PetscErrorCode PetscLayoutDestroy(PetscLayout *);
353: PETSC_EXTERN PetscErrorCode PetscLayoutDuplicate(PetscLayout, PetscLayout *);
354: PETSC_EXTERN PetscErrorCode PetscLayoutReference(PetscLayout, PetscLayout *);
355: PETSC_EXTERN PetscErrorCode PetscLayoutGetComm(PetscLayout, MPI_Comm *);
356: PETSC_EXTERN PetscErrorCode PetscLayoutSetLocalSize(PetscLayout, PetscInt);
357: PETSC_EXTERN PetscErrorCode PetscLayoutGetLocalSize(PetscLayout, PetscInt *);
358: PETSC_EXTERN PetscErrorCode PetscLayoutSetSize(PetscLayout, PetscInt);
359: PETSC_EXTERN PetscErrorCode PetscLayoutGetSize(PetscLayout, PetscInt *);
360: PETSC_EXTERN PetscErrorCode PetscLayoutSetBlockSize(PetscLayout, PetscInt);
361: PETSC_EXTERN PetscErrorCode PetscLayoutGetBlockSize(PetscLayout, PetscInt *);
362: PETSC_EXTERN PetscErrorCode PetscLayoutGetRange(PetscLayout, PetscInt *, PetscInt *);
363: PETSC_EXTERN PetscErrorCode PetscLayoutGetRanges(PetscLayout, const PetscInt *[]);
364: PETSC_EXTERN PetscErrorCode PetscLayoutCompare(PetscLayout, PetscLayout, PetscBool *);
365: PETSC_EXTERN PetscErrorCode PetscLayoutSetISLocalToGlobalMapping(PetscLayout, ISLocalToGlobalMapping);
366: PETSC_EXTERN PetscErrorCode PetscLayoutMapLocal(PetscLayout, PetscInt, const PetscInt[], PetscInt *, PetscInt *[], PetscInt *[]);
368: PETSC_EXTERN PetscErrorCode PetscParallelSortInt(PetscLayout, PetscLayout, PetscInt *, PetscInt *);
370: /*S
371: PetscKDTree - Implementation of KDTree for efficiently querying spatial points
373: Level: advanced
375: Note:
376: See <https://en.wikipedia.org/wiki/K-d_tree> for a description of K-d trees
378: .seealso: `PetscKDTreeCreate()`, `PetscKDTreeDestroy()`, `PetscKDTreeView()`, `PetscKDTreeQueryPointsNearestNeighbor()`
379: S*/
380: typedef struct _n_PetscKDTree *PetscKDTree;
382: PETSC_EXTERN PetscErrorCode PetscKDTreeCreate(PetscCount, PetscInt, const PetscReal[], PetscCopyMode, PetscInt, PetscKDTree *);
383: PETSC_EXTERN PetscErrorCode PetscKDTreeDestroy(PetscKDTree *);
384: PETSC_EXTERN PetscErrorCode PetscKDTreeView(PetscKDTree, PetscViewer);
385: PETSC_EXTERN PetscErrorCode PetscKDTreeQueryPointsNearestNeighbor(PetscKDTree, PetscCount, const PetscReal[], PetscReal, PetscCount[], PetscReal[]);
387: PETSC_EXTERN PetscErrorCode ISGetLayout(IS, PetscLayout *);
388: PETSC_EXTERN PetscErrorCode ISSetLayout(IS, PetscLayout);