Actual source code: isimpl.h
petsc-3.7.6 2017-04-24
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: };
37: struct _p_IS {
38: PETSCHEADER(struct _ISOps);
39: PetscLayout map;
40: PetscBool isperm; /* if is a permutation */
41: PetscInt max,min; /* range of possible values */
42: void *data;
43: PetscBool isidentity;
44: PetscInt *total, *nonlocal; /* local representation of ALL indices across the comm as well as the nonlocal part. */
45: PetscInt local_offset; /* offset to the local part within the total index set */
46: IS complement; /* IS wrapping nonlocal indices. */
47: };
49: extern PetscErrorCode ISLoad_Default(IS, PetscViewer);
51: struct _p_ISLocalToGlobalMapping{
52: PETSCHEADER(int);
53: PetscInt n; /* number of local indices */
54: PetscInt bs; /* blocksize; there is one index per block */
55: PetscInt *indices; /* global index of each local index */
56: PetscInt globalstart; /* first global referenced in indices */
57: PetscInt globalend; /* last + 1 global referenced in indices */
58: PetscInt *globals; /* local index for each global index between start and end */
59: PetscBool info_cached; /* reuse GetInfo */
60: PetscBool info_free;
61: PetscInt info_nproc;
62: PetscInt *info_procs;
63: PetscInt *info_numprocs;
64: PetscInt **info_indices;
65: };
67: struct _n_ISColoring {
68: PetscInt refct;
69: PetscInt n; /* number of colors */
70: IS *is; /* for each color indicates columns */
71: MPI_Comm comm;
72: ISColoringValue *colors; /* for each column indicates color */
73: PetscInt N; /* number of columns */
74: ISColoringType ctype;
75: PetscBool allocated;
76: };
78: /* ----------------------------------------------------------------------------*/
79: struct _p_PetscSection {
80: PETSCHEADER(int);
81: PetscInt pStart, pEnd; /* The chart: all points are contained in [pStart, pEnd) */
82: IS perm; /* A permutation of [0, pEnd-pStart) */
83: PetscInt *atlasDof; /* Describes layout of storage, point --> # of values */
84: PetscInt *atlasOff; /* Describes layout of storage, point --> offset into storage */
85: PetscInt maxDof; /* Maximum dof on any point */
86: PetscSection bc; /* Describes constraints, point --> # local dofs which are constrained */
87: PetscInt *bcIndices; /* Local indices for constrained dofs */
88: PetscBool setup;
90: PetscInt numFields; /* The number of fields making up the degrees of freedom */
91: const char **fieldNames; /* The field names */
92: PetscInt *numFieldComponents; /* The number of components in each field */
93: PetscSection *field; /* A section describing the layout and constraints for each field */
95: PetscObject clObj; /* Key for the closure (right now we only have one) */
96: PetscSection clSection; /* Section giving the number of points in each closure */
97: IS clPoints; /* Points in each closure */
98: };
101: #endif