Actual source code: isimpl.h
petsc-3.12.4 2020-02-04
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: 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 (*identity)(IS,PetscBool*);
     29:   PetscErrorCode (*copy)(IS,IS);
     30:   PetscErrorCode (*togeneral)(IS);
     31:   PetscErrorCode (*oncomm)(IS,MPI_Comm,PetscCopyMode,IS*);
     32:   PetscErrorCode (*setblocksize)(IS,PetscInt);
     33:   PetscErrorCode (*contiguous)(IS,PetscInt,PetscInt,PetscInt*,PetscBool*);
     34:   PetscErrorCode (*locate)(IS,PetscInt,PetscInt *);
     35: };

     37: struct _p_IS {
     38:   PETSCHEADER(struct _ISOps);
     39:   PetscLayout  map;
     40:   PetscBool    isperm;          /* if is a permutation */
     41:   PetscInt     max,min;         /* range of possible values */
     42:   void         *data;
     43:   PetscBool    isidentity;
     44:   PetscInt     *total, *nonlocal;   /* local representation of ALL indices across the comm as well as the nonlocal part. */
     45:   PetscInt     local_offset;        /* offset to the local part within the total index set */
     46:   IS           complement;          /* IS wrapping nonlocal indices. */
     47: };

     49: extern PetscErrorCode ISLoad_Default(IS, PetscViewer);

     51: struct _ISLocalToGlobalMappingOps {
     52:   PetscErrorCode (*globaltolocalmappingsetup)(ISLocalToGlobalMapping);
     53:   PetscErrorCode (*globaltolocalmappingapply)(ISLocalToGlobalMapping,ISGlobalToLocalMappingMode,PetscInt,const PetscInt[],PetscInt*,PetscInt[]);
     54:   PetscErrorCode (*globaltolocalmappingapplyblock)(ISLocalToGlobalMapping,ISGlobalToLocalMappingMode,PetscInt,const PetscInt[],PetscInt*,PetscInt[]);
     55:   PetscErrorCode (*destroy)(ISLocalToGlobalMapping);
     56: };

     58: struct _p_ISLocalToGlobalMapping{
     59:   PETSCHEADER(struct _ISLocalToGlobalMappingOps);
     60:   PetscInt     n;               /* number of local indices */
     61:   PetscInt     bs;              /* blocksize; there is one index per block */
     62:   PetscInt    *indices;         /* global index of each local index */
     63:   PetscInt     globalstart;     /* first global referenced in indices */
     64:   PetscInt     globalend;       /* last + 1 global referenced in indices */
     65:   PetscBool    info_cached;     /* reuse GetInfo */
     66:   PetscBool    info_free;
     67:   PetscInt     info_nproc;
     68:   PetscInt    *info_procs;
     69:   PetscInt    *info_numprocs;
     70:   PetscInt   **info_indices;
     71:   PetscInt    *info_nodec;
     72:   PetscInt   **info_nodei;
     73:   void        *data;            /* type specific data is stored here */
     74: };

     76: struct _n_ISColoring {
     77:   PetscInt        refct;
     78:   PetscInt        n;                /* number of colors */
     79:   IS              *is;              /* for each color indicates columns */
     80:   MPI_Comm        comm;
     81:   ISColoringValue *colors;          /* for each column indicates color */
     82:   PetscInt        N;                /* number of columns */
     83:   ISColoringType  ctype;
     84:   PetscBool       allocated;
     85: };

     87: #endif