1 #pragma once 2 3 /* Index sets for scatter-gather type operations in vectors and matrices. */ 4 5 #include <petscis.h> 6 #include <petsc/private/petscimpl.h> 7 8 PETSC_INTERN PetscBool ISRegisterAllCalled; 9 PETSC_INTERN PetscBool ISLocalToGlobalMappingRegisterAllCalled; 10 11 PETSC_EXTERN PetscLogEvent IS_View; 12 PETSC_EXTERN PetscLogEvent IS_Load; 13 14 PETSC_EXTERN PetscLogEvent PetscKDTree_Build; 15 PETSC_EXTERN PetscLogEvent PetscKDTree_Query; 16 17 struct _ISOps { 18 PetscErrorCode (*getindices)(IS, const PetscInt *[]); 19 PetscErrorCode (*restoreindices)(IS, const PetscInt *[]); 20 PetscErrorCode (*invertpermutation)(IS, PetscInt, IS *); 21 PetscErrorCode (*sort)(IS); 22 PetscErrorCode (*sortremovedups)(IS); 23 PetscErrorCode (*sorted)(IS, PetscBool *); 24 PetscErrorCode (*duplicate)(IS, IS *); 25 PetscErrorCode (*destroy)(IS); 26 PetscErrorCode (*view)(IS, PetscViewer); 27 PetscErrorCode (*load)(IS, PetscViewer); 28 PetscErrorCode (*copy)(IS, IS); 29 PetscErrorCode (*togeneral)(IS); 30 PetscErrorCode (*oncomm)(IS, MPI_Comm, PetscCopyMode, IS *); 31 PetscErrorCode (*setblocksize)(IS, PetscInt); 32 PetscErrorCode (*contiguous)(IS, PetscInt, PetscInt, PetscInt *, PetscBool *); 33 PetscErrorCode (*locate)(IS, PetscInt, PetscInt *); 34 PetscErrorCode (*sortedlocal)(IS, PetscBool *); 35 PetscErrorCode (*sortedglobal)(IS, PetscBool *); 36 PetscErrorCode (*uniquelocal)(IS, PetscBool *); 37 PetscErrorCode (*uniqueglobal)(IS, PetscBool *); 38 PetscErrorCode (*permlocal)(IS, PetscBool *); 39 PetscErrorCode (*permglobal)(IS, PetscBool *); 40 PetscErrorCode (*intervallocal)(IS, PetscBool *); 41 PetscErrorCode (*intervalglobal)(IS, PetscBool *); 42 }; 43 44 typedef enum { 45 IS_INFO_UNKNOWN = 0, 46 IS_INFO_FALSE = 1, 47 IS_INFO_TRUE = 2 48 } ISInfoBool; 49 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 PetscBool compressOutput; /* flag to compress output */ 61 }; 62 63 PETSC_INTERN PetscErrorCode ISView_Binary(IS, PetscViewer); 64 PETSC_INTERN PetscErrorCode ISLoad_Default(IS, PetscViewer); 65 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 }; 72 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 PetscBool dealloc_indices; /* should indices be deallocated? */ 79 PetscInt globalstart; /* first global referenced in indices */ 80 PetscInt globalend; /* last + 1 global referenced in indices */ 81 PetscInt info_nproc; 82 PetscInt *info_procs; 83 PetscInt *info_numprocs; 84 PetscInt **info_indices; 85 PetscInt *info_nodec; 86 PetscInt **info_nodei; 87 PetscSF multileaves_sf; /* SF to communicate from local block indices to multi-leaves */ 88 void *data; /* type specific data is stored here */ 89 }; 90 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 }; 101