Actual source code: isimpl.h

petsc-master 2020-05-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 PetscBool ISLocalToGlobalMappingRegisterAllCalled;
 15: PETSC_EXTERN PetscErrorCode ISRegisterAll(void);

 17: /* events */
 18: PETSC_EXTERN PetscLogEvent IS_View;
 19: PETSC_EXTERN PetscLogEvent IS_Load;

 21: struct _ISOps {
 22:   PetscErrorCode (*getindices)(IS,const PetscInt*[]);
 23:   PetscErrorCode (*restoreindices)(IS,const PetscInt*[]);
 24:   PetscErrorCode (*invertpermutation)(IS,PetscInt,IS*);
 25:   PetscErrorCode (*sort)(IS);
 26:   PetscErrorCode (*sortremovedups)(IS);
 27:   PetscErrorCode (*sorted)(IS,PetscBool*);
 28:   PetscErrorCode (*duplicate)(IS,IS*);
 29:   PetscErrorCode (*destroy)(IS);
 30:   PetscErrorCode (*view)(IS,PetscViewer);
 31:   PetscErrorCode (*load)(IS,PetscViewer);
 32:   PetscErrorCode (*copy)(IS,IS);
 33:   PetscErrorCode (*togeneral)(IS);
 34:   PetscErrorCode (*oncomm)(IS,MPI_Comm,PetscCopyMode,IS*);
 35:   PetscErrorCode (*setblocksize)(IS,PetscInt);
 36:   PetscErrorCode (*contiguous)(IS,PetscInt,PetscInt,PetscInt*,PetscBool*);
 37:   PetscErrorCode (*locate)(IS,PetscInt,PetscInt *);
 38:   PetscErrorCode (*sortedlocal)(IS,PetscBool*);
 39:   PetscErrorCode (*sortedglobal)(IS,PetscBool*);
 40:   PetscErrorCode (*uniquelocal)(IS,PetscBool*);
 41:   PetscErrorCode (*uniqueglobal)(IS,PetscBool*);
 42:   PetscErrorCode (*permlocal)(IS,PetscBool*);
 43:   PetscErrorCode (*permglobal)(IS,PetscBool*);
 44:   PetscErrorCode (*intervallocal)(IS,PetscBool*);
 45:   PetscErrorCode (*intervalglobal)(IS,PetscBool*);
 46: };

 48: typedef enum {IS_INFO_UNKNOWN=0, IS_INFO_FALSE=1, IS_INFO_TRUE=2} ISInfoBool;

 50: struct _p_IS {
 51:   PETSCHEADER(struct _ISOps);
 52:   PetscLayout  map;
 53:   PetscInt     max,min;         /* range of possible values */
 54:   void         *data;
 55:   PetscInt     *total, *nonlocal;   /* local representation of ALL indices across the comm as well as the nonlocal part. */
 56:   PetscInt     local_offset;        /* offset to the local part within the total index set */
 57:   IS           complement;          /* IS wrapping nonlocal indices. */
 58:   PetscBool    info_permanent[2][IS_INFO_MAX]; /* whether local / global properties are permanent */
 59:   ISInfoBool   info[2][IS_INFO_MAX];         /* local / global properties */
 60: };

 62: PETSC_EXTERN PetscErrorCode ISView_Binary(IS, PetscViewer);
 63: PETSC_EXTERN PetscErrorCode ISLoad_Binary(IS, PetscViewer);
 64: PETSC_EXTERN PetscErrorCode ISLoad_Default(IS, PetscViewer);

 66: struct _ISLocalToGlobalMappingOps {
 67:   PetscErrorCode (*globaltolocalmappingsetup)(ISLocalToGlobalMapping);
 68:   PetscErrorCode (*globaltolocalmappingapply)(ISLocalToGlobalMapping,ISGlobalToLocalMappingMode,PetscInt,const PetscInt[],PetscInt*,PetscInt[]);
 69:   PetscErrorCode (*globaltolocalmappingapplyblock)(ISLocalToGlobalMapping,ISGlobalToLocalMappingMode,PetscInt,const PetscInt[],PetscInt*,PetscInt[]);
 70:   PetscErrorCode (*destroy)(ISLocalToGlobalMapping);
 71: };

 73: struct _p_ISLocalToGlobalMapping{
 74:   PETSCHEADER(struct _ISLocalToGlobalMappingOps);
 75:   PetscInt     n;               /* number of local indices */
 76:   PetscInt     bs;              /* blocksize; there is one index per block */
 77:   PetscInt    *indices;         /* global index of each local index */
 78:   PetscInt     globalstart;     /* first global referenced in indices */
 79:   PetscInt     globalend;       /* last + 1 global referenced in indices */
 80:   PetscBool    info_cached;     /* reuse GetInfo */
 81:   PetscBool    info_free;
 82:   PetscInt     info_nproc;
 83:   PetscInt    *info_procs;
 84:   PetscInt    *info_numprocs;
 85:   PetscInt   **info_indices;
 86:   PetscInt    *info_nodec;
 87:   PetscInt   **info_nodei;
 88:   void        *data;            /* type specific data is stored here */
 89: };

 91: struct _n_ISColoring {
 92:   PetscInt        refct;
 93:   PetscInt        n;                /* number of colors */
 94:   IS              *is;              /* for each color indicates columns */
 95:   MPI_Comm        comm;
 96:   ISColoringValue *colors;          /* for each column indicates color */
 97:   PetscInt        N;                /* number of columns */
 98:   ISColoringType  ctype;
 99:   PetscBool       allocated;
100: };

102: #endif