Actual source code: isimpl.h

petsc-3.10.4 2019-02-26
Report Typos and Errors
  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:   PetscInt    *info_nodec;
 73:   PetscInt   **info_nodei;
 74:   void        *data;            /* type specific data is stored here */
 75: };

 77: struct _n_ISColoring {
 78:   PetscInt        refct;
 79:   PetscInt        n;                /* number of colors */
 80:   IS              *is;              /* for each color indicates columns */
 81:   MPI_Comm        comm;
 82:   ISColoringValue *colors;          /* for each column indicates color */
 83:   PetscInt        N;                /* number of columns */
 84:   ISColoringType  ctype;
 85:   PetscBool       allocated;
 86: };

 88: /* ----------------------------------------------------------------------------*/
 89: struct _p_PetscSection {
 90:   PETSCHEADER(int);
 91:   PetscInt                      pStart, pEnd; /* The chart: all points are contained in [pStart, pEnd) */
 92:   IS                            perm;         /* A permutation of [0, pEnd-pStart) */
 93:   PetscInt                     *atlasDof;     /* Describes layout of storage, point --> # of values */
 94:   PetscInt                     *atlasOff;     /* Describes layout of storage, point --> offset into storage */
 95:   PetscInt                      maxDof;       /* Maximum dof on any point */
 96:   PetscSection                  bc;           /* Describes constraints, point --> # local dofs which are constrained */
 97:   PetscInt                     *bcIndices;    /* Local indices for constrained dofs */
 98:   PetscBool                     setup;

100:   PetscInt                      numFields;    /* The number of fields making up the degrees of freedom */
101:   char                        **fieldNames;   /* The field names */
102:   PetscInt                     *numFieldComponents; /* The number of components in each field */
103:   PetscSection                 *field;        /* A section describing the layout and constraints for each field */
104:   PetscBool                     useFieldOff;  /* Use the field offsets directly for the global section, rather than the point offset */

106:   PetscObject                   clObj;        /* Key for the closure (right now we only have one) */
107:   PetscSection                  clSection;    /* Section giving the number of points in each closure */
108:   IS                            clPoints;     /* Points in each closure */
109:   PetscInt                      clSize;       /* The size of a dof closure of a cell, when it is uniform */
110:   PetscInt                     *clPerm;       /* A permutation of the cell dof closure, of size clSize */
111:   PetscInt                     *clInvPerm;    /* The inverse of clPerm */
112:   PetscSectionSym               sym;          /* Symmetries of the data */
113: };

115: PETSC_EXTERN PetscErrorCode PetscSectionSetClosurePermutation_Internal(PetscSection, PetscObject, PetscInt, PetscCopyMode, PetscInt *);
116: PETSC_EXTERN PetscErrorCode PetscSectionGetClosurePermutation_Internal(PetscSection, PetscObject, PetscInt *, const PetscInt *[]);
117: PETSC_EXTERN PetscErrorCode PetscSectionGetClosureInversePermutation_Internal(PetscSection, PetscObject, PetscInt *, const PetscInt *[]);

119: struct _PetscSectionSymOps {
120:   PetscErrorCode (*getpoints)(PetscSectionSym,PetscSection,PetscInt,const PetscInt *,const PetscInt **,const PetscScalar **);
121:   PetscErrorCode (*destroy)(PetscSectionSym);
122:   PetscErrorCode (*view)(PetscSectionSym,PetscViewer);
123: };

125: typedef struct _n_SymWorkLink *SymWorkLink;

127: struct _n_SymWorkLink
128: {
129:   SymWorkLink         next;
130:   const PetscInt    **perms;
131:   const PetscScalar **rots;
132:   PetscInt           numPoints;
133: };

135: struct _p_PetscSectionSym {
136:   PETSCHEADER(struct _PetscSectionSymOps);
137:   void *data;
138:   SymWorkLink workin;
139:   SymWorkLink workout;
140: };


143: PETSC_EXTERN PetscErrorCode ISIntersect_Caching_Internal(IS, IS, IS *);
144: #endif