Actual source code: isimpl.h

  1: /*
  2:     Index sets for scatter-gather type operations in vectors
  3: and matrices.

  5: */

  7: #ifndef _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 {
 49:   IS_INFO_UNKNOWN = 0,
 50:   IS_INFO_FALSE   = 1,
 51:   IS_INFO_TRUE    = 2
 52: } ISInfoBool;

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

 66: PETSC_EXTERN PetscErrorCode ISView_Binary(IS, PetscViewer);
 67: PETSC_EXTERN PetscErrorCode ISLoad_Binary(IS, PetscViewer);
 68: PETSC_EXTERN PetscErrorCode ISLoad_Default(IS, PetscViewer);

 70: struct _ISLocalToGlobalMappingOps {
 71:   PetscErrorCode (*globaltolocalmappingsetup)(ISLocalToGlobalMapping);
 72:   PetscErrorCode (*globaltolocalmappingapply)(ISLocalToGlobalMapping, ISGlobalToLocalMappingMode, PetscInt, const PetscInt[], PetscInt *, PetscInt[]);
 73:   PetscErrorCode (*globaltolocalmappingapplyblock)(ISLocalToGlobalMapping, ISGlobalToLocalMappingMode, PetscInt, const PetscInt[], PetscInt *, PetscInt[]);
 74:   PetscErrorCode (*destroy)(ISLocalToGlobalMapping);
 75: };

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

 96: struct _n_ISColoring {
 97:   PetscInt         refct;
 98:   PetscInt         n;  /* number of colors */
 99:   IS              *is; /* for each color indicates columns */
100:   MPI_Comm         comm;
101:   ISColoringValue *colors; /* for each column indicates color */
102:   PetscInt         N;      /* number of columns */
103:   ISColoringType   ctype;
104:   PetscBool        allocated;
105: };

107: #endif