Actual source code: isimpl.h

petsc-master 2020-01-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: /* events */
 18: PETSC_EXTERN PetscLogEvent IS_Load;

 20: struct _ISOps {
 21:   PetscErrorCode (*getindices)(IS,const PetscInt*[]);
 22:   PetscErrorCode (*restoreindices)(IS,const PetscInt*[]);
 23:   PetscErrorCode (*invertpermutation)(IS,PetscInt,IS*);
 24:   PetscErrorCode (*sort)(IS);
 25:   PetscErrorCode (*sortremovedups)(IS);
 26:   PetscErrorCode (*sorted)(IS,PetscBool*);
 27:   PetscErrorCode (*duplicate)(IS,IS*);
 28:   PetscErrorCode (*destroy)(IS);
 29:   PetscErrorCode (*view)(IS,PetscViewer);
 30:   PetscErrorCode (*load)(IS,PetscViewer);
 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:   PetscErrorCode (*sortedlocal)(IS,PetscBool*);
 38:   PetscErrorCode (*sortedglobal)(IS,PetscBool*);
 39:   PetscErrorCode (*uniquelocal)(IS,PetscBool*);
 40:   PetscErrorCode (*uniqueglobal)(IS,PetscBool*);
 41:   PetscErrorCode (*permlocal)(IS,PetscBool*);
 42:   PetscErrorCode (*permglobal)(IS,PetscBool*);
 43:   PetscErrorCode (*intervallocal)(IS,PetscBool*);
 44:   PetscErrorCode (*intervalglobal)(IS,PetscBool*);
 45: };

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

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

 61: extern PetscErrorCode ISLoad_Default(IS, PetscViewer);

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

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

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

 99: #endif