Actual source code: isimpl.h
petsc-3.10.5 2019-03-28
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 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:   PetscInt                     *atlasDof;     /* Describes layout of storage, point --> # of values */
     95:   PetscInt                     *atlasOff;     /* Describes layout of storage, point --> offset into storage */
     96:   PetscInt                      maxDof;       /* Maximum dof on any point */
     97:   PetscSection                  bc;           /* Describes constraints, point --> # local dofs which are constrained */
     98:   PetscInt                     *bcIndices;    /* Local indices for constrained dofs */
     99:   PetscBool                     setup;

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

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

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

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

    126: typedef struct _n_SymWorkLink *SymWorkLink;

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

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

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