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