Actual source code: isimpl.h
petsc-3.11.4 2019-09-28
1: /*
2: Index sets for scatter-gather type operations in vectors
3: and matrices.
5: */
7: #if !defined(_IS_H)
8: #define _IS_H
10: #include <petscis.h>
11: #include <petsc/private/petscimpl.h>
13: PETSC_EXTERN PetscBool ISRegisterAllCalled;
14: PETSC_EXTERN PetscBool ISLocalToGlobalMappingRegisterAllCalled;
15: PETSC_EXTERN PetscErrorCode ISRegisterAll(void);
17: struct _ISOps {
18: PetscErrorCode (*getsize)(IS,PetscInt*);
19: PetscErrorCode (*getlocalsize)(IS,PetscInt*);
20: PetscErrorCode (*getindices)(IS,const PetscInt*[]);
21: PetscErrorCode (*restoreindices)(IS,const PetscInt*[]);
22: PetscErrorCode (*invertpermutation)(IS,PetscInt,IS*);
23: PetscErrorCode (*sort)(IS);
24: PetscErrorCode (*sortremovedups)(IS);
25: PetscErrorCode (*sorted)(IS,PetscBool*);
26: PetscErrorCode (*duplicate)(IS,IS*);
27: PetscErrorCode (*destroy)(IS);
28: PetscErrorCode (*view)(IS,PetscViewer);
29: PetscErrorCode (*load)(IS,PetscViewer);
30: PetscErrorCode (*identity)(IS,PetscBool*);
31: PetscErrorCode (*copy)(IS,IS);
32: PetscErrorCode (*togeneral)(IS);
33: PetscErrorCode (*oncomm)(IS,MPI_Comm,PetscCopyMode,IS*);
34: PetscErrorCode (*setblocksize)(IS,PetscInt);
35: PetscErrorCode (*contiguous)(IS,PetscInt,PetscInt,PetscInt*,PetscBool*);
36: PetscErrorCode (*locate)(IS,PetscInt,PetscInt *);
37: };
39: struct _p_IS {
40: PETSCHEADER(struct _ISOps);
41: PetscLayout map;
42: PetscBool isperm; /* if is a permutation */
43: PetscInt max,min; /* range of possible values */
44: void *data;
45: PetscBool isidentity;
46: PetscInt *total, *nonlocal; /* local representation of ALL indices across the comm as well as the nonlocal part. */
47: PetscInt local_offset; /* offset to the local part within the total index set */
48: IS complement; /* IS wrapping nonlocal indices. */
49: };
51: extern PetscErrorCode ISLoad_Default(IS, PetscViewer);
53: struct _ISLocalToGlobalMappingOps {
54: PetscErrorCode (*globaltolocalmappingsetup)(ISLocalToGlobalMapping);
55: PetscErrorCode (*globaltolocalmappingapply)(ISLocalToGlobalMapping,ISGlobalToLocalMappingMode,PetscInt,const PetscInt[],PetscInt*,PetscInt[]);
56: PetscErrorCode (*globaltolocalmappingapplyblock)(ISLocalToGlobalMapping,ISGlobalToLocalMappingMode,PetscInt,const PetscInt[],PetscInt*,PetscInt[]);
57: PetscErrorCode (*destroy)(ISLocalToGlobalMapping);
58: };
60: struct _p_ISLocalToGlobalMapping{
61: PETSCHEADER(struct _ISLocalToGlobalMappingOps);
62: PetscInt n; /* number of local indices */
63: PetscInt bs; /* blocksize; there is one index per block */
64: PetscInt *indices; /* global index of each local index */
65: PetscInt globalstart; /* first global referenced in indices */
66: PetscInt globalend; /* last + 1 global referenced in indices */
67: PetscBool info_cached; /* reuse GetInfo */
68: PetscBool info_free;
69: PetscInt info_nproc;
70: PetscInt *info_procs;
71: PetscInt *info_numprocs;
72: PetscInt **info_indices;
73: PetscInt *info_nodec;
74: PetscInt **info_nodei;
75: void *data; /* type specific data is stored here */
76: };
78: struct _n_ISColoring {
79: PetscInt refct;
80: PetscInt n; /* number of colors */
81: IS *is; /* for each color indicates columns */
82: MPI_Comm comm;
83: ISColoringValue *colors; /* for each column indicates color */
84: PetscInt N; /* number of columns */
85: ISColoringType ctype;
86: PetscBool allocated;
87: };
89: /* ----------------------------------------------------------------------------*/
90: struct _p_PetscSection {
91: PETSCHEADER(int);
92: PetscInt pStart, pEnd; /* The chart: all points are contained in [pStart, pEnd) */
93: IS perm; /* A permutation of [0, pEnd-pStart) */
94: PetscBool pointMajor; /* True if the offsets are point major, otherwise they are fieldMajor */
95: PetscInt *atlasDof; /* Describes layout of storage, point --> # of values */
96: PetscInt *atlasOff; /* Describes layout of storage, point --> offset into storage */
97: PetscInt maxDof; /* Maximum dof on any point */
98: PetscSection bc; /* Describes constraints, point --> # local dofs which are constrained */
99: PetscInt *bcIndices; /* Local indices for constrained dofs */
100: PetscBool setup;
102: PetscInt numFields; /* The number of fields making up the degrees of freedom */
103: char **fieldNames; /* The field names */
104: PetscInt *numFieldComponents; /* The number of components in each field */
105: PetscSection *field; /* A section describing the layout and constraints for each field */
106: PetscBool useFieldOff; /* Use the field offsets directly for the global section, rather than the point offset */
108: PetscObject clObj; /* Key for the closure (right now we only have one) */
109: PetscSection clSection; /* Section giving the number of points in each closure */
110: IS clPoints; /* Points in each closure */
111: PetscInt clSize; /* The size of a dof closure of a cell, when it is uniform */
112: PetscInt *clPerm; /* A permutation of the cell dof closure, of size clSize */
113: PetscInt *clInvPerm; /* The inverse of clPerm */
114: PetscSectionSym sym; /* Symmetries of the data */
115: };
117: PETSC_EXTERN PetscErrorCode PetscSectionSetClosurePermutation_Internal(PetscSection, PetscObject, PetscInt, PetscCopyMode, PetscInt *);
118: PETSC_EXTERN PetscErrorCode PetscSectionGetClosurePermutation_Internal(PetscSection, PetscObject, PetscInt *, const PetscInt *[]);
119: PETSC_EXTERN PetscErrorCode PetscSectionGetClosureInversePermutation_Internal(PetscSection, PetscObject, PetscInt *, const PetscInt *[]);
121: struct _PetscSectionSymOps {
122: PetscErrorCode (*getpoints)(PetscSectionSym,PetscSection,PetscInt,const PetscInt *,const PetscInt **,const PetscScalar **);
123: PetscErrorCode (*destroy)(PetscSectionSym);
124: PetscErrorCode (*view)(PetscSectionSym,PetscViewer);
125: };
127: typedef struct _n_SymWorkLink *SymWorkLink;
129: struct _n_SymWorkLink
130: {
131: SymWorkLink next;
132: const PetscInt **perms;
133: const PetscScalar **rots;
134: PetscInt numPoints;
135: };
137: struct _p_PetscSectionSym {
138: PETSCHEADER(struct _PetscSectionSymOps);
139: void *data;
140: SymWorkLink workin;
141: SymWorkLink workout;
142: };
145: PETSC_EXTERN PetscErrorCode ISIntersect_Caching_Internal(IS, IS, IS *);
146: #endif