Actual source code: isimpl.h

  1: #pragma once

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

  5: #include <petscis.h>
  6: #include <petsc/private/petscimpl.h>

  8: PETSC_INTERN PetscBool ISRegisterAllCalled;
  9: PETSC_INTERN PetscBool ISLocalToGlobalMappingRegisterAllCalled;

 11: PETSC_EXTERN PetscLogEvent IS_View;
 12: PETSC_EXTERN PetscLogEvent IS_Load;

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

 41: typedef enum {
 42:   IS_INFO_UNKNOWN = 0,
 43:   IS_INFO_FALSE   = 1,
 44:   IS_INFO_TRUE    = 2
 45: } ISInfoBool;

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

 59: PETSC_INTERN PetscErrorCode ISView_Binary(IS, PetscViewer);
 60: PETSC_INTERN PetscErrorCode ISLoad_Default(IS, PetscViewer);

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

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

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