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:   PetscBool   compressOutput;                 /* flag to compress output */
 58: };

 60: PETSC_INTERN PetscErrorCode ISView_Binary(IS, PetscViewer);
 61: PETSC_INTERN 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:   PetscBool  dealloc_indices; /* should indices be deallocated? */
 76:   PetscInt   globalstart;     /* first global referenced in indices */
 77:   PetscInt   globalend;       /* last + 1 global referenced in indices */
 78:   PetscInt   info_nproc;
 79:   PetscInt  *info_procs;
 80:   PetscInt  *info_numprocs;
 81:   PetscInt **info_indices;
 82:   PetscInt  *info_nodec;
 83:   PetscInt **info_nodei;
 84:   PetscSF    multileaves_sf; /* SF to communicate from local block indices to multi-leaves */
 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: };