LCOV - code coverage report
Current view: top level - home/gitlab-runner/builds/q8svuz_Y/0/slepc/petsc/include - petscis.h (source / functions) Hit Total Coverage
Test: SLEPc Lines: 11 13 84.6 %
Date: 2024-05-08 00:46:20 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :    An index set is a generalization of a subset of integers.  Index sets
       3             :    are used for defining scatters and gathers.
       4             : */
       5             : #pragma once
       6             : 
       7             : #include <petscsys.h>
       8             : #include <petscsftypes.h>
       9             : #include <petscsectiontypes.h>
      10             : #include <petscistypes.h> /*I  "petscis.h" I*/
      11             : 
      12             : /* SUBMANSEC = IS */
      13             : 
      14             : #define IS_FILE_CLASSID 1211218
      15             : PETSC_EXTERN PetscClassId IS_CLASSID;
      16             : 
      17             : PETSC_EXTERN PetscErrorCode ISInitializePackage(void);
      18             : PETSC_EXTERN PetscErrorCode ISFinalizePackage(void);
      19             : 
      20             : /*J
      21             :     ISType - String with the name of a PETSc index set type
      22             : 
      23             :    Values:
      24             : +  `ISGENERAL` - the values are stored with an array of indices and generally have no structure
      25             : .  `ISSTRIDE`  - the values have a simple structure of an initial offset and then a step size between values
      26             : -  `ISBLOCK`   - values are an array of indices, each representing a block (of the same common length) of values
      27             : 
      28             :    Level: beginner
      29             : 
      30             : .seealso: `ISSetType()`, `IS`, `ISCreateGeneral()`, `ISCreateStride()`, `ISCreateBlock()`, `ISCreate()`, `ISRegister()`,
      31             :           `VecScatterCreate()`, `MatGetSubMatrices()`
      32             : J*/
      33             : typedef const char *ISType;
      34             : #define ISGENERAL "general"
      35             : #define ISSTRIDE  "stride"
      36             : #define ISBLOCK   "block"
      37             : 
      38             : /* Dynamic creation and loading functions */
      39             : PETSC_EXTERN PetscFunctionList ISList;
      40             : PETSC_EXTERN PetscErrorCode    ISSetType(IS, ISType);
      41             : PETSC_EXTERN PetscErrorCode    ISGetType(IS, ISType *);
      42             : PETSC_EXTERN PetscErrorCode    ISRegister(const char[], PetscErrorCode (*)(IS));
      43             : PETSC_EXTERN PetscErrorCode    ISRegisterAll(void);
      44             : PETSC_EXTERN PetscErrorCode    ISCreate(MPI_Comm, IS *);
      45             : 
      46             : PETSC_EXTERN PetscErrorCode ISDestroy(IS *);
      47             : PETSC_EXTERN PetscErrorCode ISSetPermutation(IS);
      48             : PETSC_EXTERN PetscErrorCode ISPermutation(IS, PetscBool *);
      49             : PETSC_EXTERN PetscErrorCode ISSetIdentity(IS);
      50             : PETSC_EXTERN PetscErrorCode ISIdentity(IS, PetscBool *);
      51             : PETSC_EXTERN PetscErrorCode ISContiguousLocal(IS, PetscInt, PetscInt, PetscInt *, PetscBool *);
      52             : 
      53             : /*E
      54             :    ISInfo - Info that may either be computed or set as known for an index set
      55             : 
      56             :    Level: intermediate
      57             : 
      58             :    Developer Note:
      59             :    Entries that are negative need not be called collectively by all processes.
      60             : 
      61             : .seealso: `IS`, `ISType`, `ISSetInfo()`
      62             : E*/
      63             : typedef enum {
      64             :   IS_INFO_MIN    = -1,
      65             :   IS_SORTED      = 0,
      66             :   IS_UNIQUE      = 1,
      67             :   IS_PERMUTATION = 2,
      68             :   IS_INTERVAL    = 3,
      69             :   IS_IDENTITY    = 4,
      70             :   IS_INFO_MAX    = 5
      71             : } ISInfo;
      72             : 
      73             : typedef enum {
      74             :   IS_LOCAL,
      75             :   IS_GLOBAL
      76             : } ISInfoType;
      77             : 
      78             : PETSC_EXTERN PetscErrorCode ISSetInfo(IS, ISInfo, ISInfoType, PetscBool, PetscBool);
      79             : PETSC_EXTERN PetscErrorCode ISGetInfo(IS, ISInfo, ISInfoType, PetscBool, PetscBool *);
      80             : PETSC_EXTERN PetscErrorCode ISClearInfoCache(IS, PetscBool);
      81             : PETSC_EXTERN PetscErrorCode ISGetIndices(IS, const PetscInt *[]);
      82             : PETSC_EXTERN PetscErrorCode ISRestoreIndices(IS, const PetscInt *[]);
      83             : PETSC_EXTERN PetscErrorCode ISGetTotalIndices(IS, const PetscInt *[]);
      84             : PETSC_EXTERN PetscErrorCode ISRestoreTotalIndices(IS, const PetscInt *[]);
      85             : PETSC_EXTERN PetscErrorCode ISGetNonlocalIndices(IS, const PetscInt *[]);
      86             : PETSC_EXTERN PetscErrorCode ISRestoreNonlocalIndices(IS, const PetscInt *[]);
      87             : PETSC_EXTERN PetscErrorCode ISGetNonlocalIS(IS, IS *);
      88             : PETSC_EXTERN PetscErrorCode ISRestoreNonlocalIS(IS, IS *);
      89             : PETSC_EXTERN PetscErrorCode ISGetSize(IS, PetscInt *);
      90             : PETSC_EXTERN PetscErrorCode ISGetLocalSize(IS, PetscInt *);
      91             : PETSC_EXTERN PetscErrorCode ISInvertPermutation(IS, PetscInt, IS *);
      92             : PETSC_EXTERN PetscErrorCode ISView(IS, PetscViewer);
      93             : PETSC_EXTERN PetscErrorCode ISViewFromOptions(IS, PetscObject, const char[]);
      94             : PETSC_EXTERN PetscErrorCode ISLoad(IS, PetscViewer);
      95             : PETSC_EXTERN PetscErrorCode ISEqual(IS, IS, PetscBool *);
      96             : PETSC_EXTERN PetscErrorCode ISEqualUnsorted(IS, IS, PetscBool *);
      97             : PETSC_EXTERN PetscErrorCode ISSort(IS);
      98             : PETSC_EXTERN PetscErrorCode ISSortRemoveDups(IS);
      99             : PETSC_EXTERN PetscErrorCode ISSorted(IS, PetscBool *);
     100             : PETSC_EXTERN PetscErrorCode ISDifference(IS, IS, IS *);
     101             : PETSC_EXTERN PetscErrorCode ISSum(IS, IS, IS *);
     102             : PETSC_EXTERN PetscErrorCode ISExpand(IS, IS, IS *);
     103             : PETSC_EXTERN PetscErrorCode ISIntersect(IS, IS, IS *);
     104             : PETSC_EXTERN PetscErrorCode ISGetMinMax(IS, PetscInt *, PetscInt *);
     105             : 
     106             : PETSC_EXTERN PetscErrorCode ISLocate(IS, PetscInt, PetscInt *);
     107             : PETSC_EXTERN PetscErrorCode ISGetPointRange(IS, PetscInt *, PetscInt *, const PetscInt **);
     108             : PETSC_EXTERN PetscErrorCode ISRestorePointRange(IS, PetscInt *, PetscInt *, const PetscInt **);
     109             : PETSC_EXTERN PetscErrorCode ISGetPointSubrange(IS, PetscInt, PetscInt, const PetscInt *);
     110             : 
     111             : PETSC_EXTERN PetscErrorCode ISGetBlockSize(IS, PetscInt *);
     112             : PETSC_EXTERN PetscErrorCode ISSetBlockSize(IS, PetscInt);
     113             : 
     114             : PETSC_EXTERN PetscErrorCode ISToGeneral(IS);
     115             : 
     116             : PETSC_EXTERN PetscErrorCode ISDuplicate(IS, IS *);
     117             : PETSC_EXTERN PetscErrorCode ISCopy(IS, IS);
     118             : PETSC_EXTERN PetscErrorCode ISShift(IS, PetscInt, IS);
     119             : PETSC_EXTERN PetscErrorCode ISAllGather(IS, IS *);
     120             : PETSC_EXTERN PetscErrorCode ISComplement(IS, PetscInt, PetscInt, IS *);
     121             : PETSC_EXTERN PetscErrorCode ISConcatenate(MPI_Comm, PetscInt, const IS[], IS *);
     122             : PETSC_EXTERN PetscErrorCode ISListToPair(MPI_Comm, PetscInt, IS[], IS *, IS *);
     123             : PETSC_EXTERN PetscErrorCode ISPairToList(IS, IS, PetscInt *, IS *[]);
     124             : PETSC_EXTERN PetscErrorCode ISEmbed(IS, IS, PetscBool, IS *);
     125             : PETSC_EXTERN PetscErrorCode ISSortPermutation(IS, PetscBool, IS *);
     126             : PETSC_EXTERN PetscErrorCode ISOnComm(IS, MPI_Comm, PetscCopyMode, IS *);
     127             : PETSC_EXTERN PetscErrorCode ISRenumber(IS, IS, PetscInt *, IS *);
     128             : PETSC_EXTERN PetscErrorCode ISCreateSubIS(IS, IS, IS *);
     129             : 
     130             : /* ISGENERAL specific */
     131             : PETSC_EXTERN PetscErrorCode ISCreateGeneral(MPI_Comm, PetscInt, const PetscInt[], PetscCopyMode, IS *);
     132             : PETSC_EXTERN PetscErrorCode ISGeneralSetIndices(IS, PetscInt, const PetscInt[], PetscCopyMode);
     133             : PETSC_EXTERN PetscErrorCode ISGeneralSetIndicesFromMask(IS, PetscInt, PetscInt, const PetscBool[]);
     134             : PETSC_EXTERN PetscErrorCode ISGeneralFilter(IS, PetscInt, PetscInt);
     135             : 
     136             : /* ISBLOCK specific */
     137             : PETSC_EXTERN PetscErrorCode ISCreateBlock(MPI_Comm, PetscInt, PetscInt, const PetscInt[], PetscCopyMode, IS *);
     138             : PETSC_EXTERN PetscErrorCode ISBlockSetIndices(IS, PetscInt, PetscInt, const PetscInt[], PetscCopyMode);
     139             : PETSC_EXTERN PetscErrorCode ISBlockGetIndices(IS, const PetscInt *[]);
     140             : PETSC_EXTERN PetscErrorCode ISBlockRestoreIndices(IS, const PetscInt *[]);
     141             : PETSC_EXTERN PetscErrorCode ISBlockGetLocalSize(IS, PetscInt *);
     142             : PETSC_EXTERN PetscErrorCode ISBlockGetSize(IS, PetscInt *);
     143             : 
     144             : /* ISSTRIDE specific */
     145             : PETSC_EXTERN PetscErrorCode ISCreateStride(MPI_Comm, PetscInt, PetscInt, PetscInt, IS *);
     146             : PETSC_EXTERN PetscErrorCode ISStrideSetStride(IS, PetscInt, PetscInt, PetscInt);
     147             : PETSC_EXTERN PetscErrorCode ISStrideGetInfo(IS, PetscInt *, PetscInt *);
     148             : 
     149             : #define IS_LTOGM_FILE_CLASSID 1211217
     150             : PETSC_EXTERN PetscClassId IS_LTOGM_CLASSID;
     151             : 
     152             : /*E
     153             :    ISGlobalToLocalMappingMode - Indicates mapping behavior if global indices are missing
     154             : 
     155             :    Values:
     156             : +  `IS_GTOLM_MASK` - missing global indices are masked by mapping them to a local index of -1
     157             : -  `IS_GTOLM_DROP` - missing global indices are dropped
     158             : 
     159             :    Level: beginner
     160             : 
     161             : .seealso: `ISGlobalToLocalMappingApplyBlock()`, `ISGlobalToLocalMappingApply()`
     162             : E*/
     163             : typedef enum {
     164             :   IS_GTOLM_MASK,
     165             :   IS_GTOLM_DROP
     166             : } ISGlobalToLocalMappingMode;
     167             : 
     168             : /*J
     169             :    ISLocalToGlobalMappingType - String with the name of a mapping method
     170             : 
     171             :    Values:
     172             : +  `ISLOCALTOGLOBALMAPPINGBASIC` - a non-memory scalable way of storing `ISLocalToGlobalMapping` that allows applying `ISGlobalToLocalMappingApply()` efficiently
     173             : -  `ISLOCALTOGLOBALMAPPINGHASH`  - a memory scalable way of storing `ISLocalToGlobalMapping` that allows applying `ISGlobalToLocalMappingApply()` reasonably efficiently
     174             : 
     175             :    Level: beginner
     176             : 
     177             : .seealso: `ISLocalToGlobalMapping`, `ISLocalToGlobalMappingSetType()`, `ISLocalToGlobalSetFromOptions()`, `ISGlobalToLocalMappingMode`
     178             : J*/
     179             : typedef const char *ISLocalToGlobalMappingType;
     180             : #define ISLOCALTOGLOBALMAPPINGBASIC "basic"
     181             : #define ISLOCALTOGLOBALMAPPINGHASH  "hash"
     182             : 
     183             : PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingSetType(ISLocalToGlobalMapping, ISLocalToGlobalMappingType);
     184             : PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingGetType(ISLocalToGlobalMapping, ISLocalToGlobalMappingType *);
     185             : PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingRegister(const char[], PetscErrorCode (*)(ISLocalToGlobalMapping));
     186             : PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingRegisterAll(void);
     187             : PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingCreate(MPI_Comm, PetscInt, PetscInt, const PetscInt[], PetscCopyMode, ISLocalToGlobalMapping *);
     188             : PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingCreateIS(IS, ISLocalToGlobalMapping *);
     189             : PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingCreateSF(PetscSF, PetscInt, ISLocalToGlobalMapping *);
     190             : PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingSetFromOptions(ISLocalToGlobalMapping);
     191             : PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingSetUp(ISLocalToGlobalMapping);
     192             : PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingView(ISLocalToGlobalMapping, PetscViewer);
     193             : PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingLoad(ISLocalToGlobalMapping, PetscViewer);
     194             : PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingViewFromOptions(ISLocalToGlobalMapping, PetscObject, const char[]);
     195             : PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingConcatenate(MPI_Comm, PetscInt, const ISLocalToGlobalMapping[], ISLocalToGlobalMapping *);
     196             : PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingDuplicate(ISLocalToGlobalMapping, ISLocalToGlobalMapping *);
     197             : PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingDestroy(ISLocalToGlobalMapping *);
     198             : PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingGetSize(ISLocalToGlobalMapping, PetscInt *);
     199             : PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingGetIndices(ISLocalToGlobalMapping, const PetscInt **);
     200             : PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingRestoreIndices(ISLocalToGlobalMapping, const PetscInt **);
     201             : PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingGetBlockIndices(ISLocalToGlobalMapping, const PetscInt **);
     202             : PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingRestoreBlockIndices(ISLocalToGlobalMapping, const PetscInt **);
     203             : PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingGetBlockSize(ISLocalToGlobalMapping, PetscInt *);
     204             : PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingSetBlockSize(ISLocalToGlobalMapping, PetscInt);
     205             : 
     206             : PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingApply(ISLocalToGlobalMapping, PetscInt, const PetscInt[], PetscInt[]);
     207             : PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingApplyBlock(ISLocalToGlobalMapping, PetscInt, const PetscInt[], PetscInt[]);
     208             : PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingApplyIS(ISLocalToGlobalMapping, IS, IS *);
     209             : PETSC_EXTERN PetscErrorCode ISGlobalToLocalMappingApply(ISLocalToGlobalMapping, ISGlobalToLocalMappingMode, PetscInt, const PetscInt[], PetscInt *, PetscInt[]);
     210             : PETSC_EXTERN PetscErrorCode ISGlobalToLocalMappingApplyBlock(ISLocalToGlobalMapping, ISGlobalToLocalMappingMode, PetscInt, const PetscInt[], PetscInt *, PetscInt[]);
     211             : PETSC_EXTERN PetscErrorCode ISGlobalToLocalMappingApplyIS(ISLocalToGlobalMapping, ISGlobalToLocalMappingMode, IS, IS *);
     212             : 
     213             : PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingGetNodeInfo(ISLocalToGlobalMapping, PetscInt *, PetscInt *[], PetscInt **[]);
     214             : PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingRestoreNodeInfo(ISLocalToGlobalMapping, PetscInt *, PetscInt *[], PetscInt **[]);
     215             : PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingGetInfo(ISLocalToGlobalMapping, PetscInt *, PetscInt *[], PetscInt *[], PetscInt **[]);
     216             : PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingRestoreInfo(ISLocalToGlobalMapping, PetscInt *, PetscInt *[], PetscInt *[], PetscInt **[]);
     217             : PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingGetBlockNodeInfo(ISLocalToGlobalMapping, PetscInt *, PetscInt *[], PetscInt **[]);
     218             : PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingRestoreBlockNodeInfo(ISLocalToGlobalMapping, PetscInt *, PetscInt *[], PetscInt **[]);
     219             : PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingGetBlockInfo(ISLocalToGlobalMapping, PetscInt *, PetscInt *[], PetscInt *[], PetscInt **[]);
     220             : PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingRestoreBlockInfo(ISLocalToGlobalMapping, PetscInt *, PetscInt *[], PetscInt *[], PetscInt **[]);
     221             : PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingGetBlockMultiLeavesSF(ISLocalToGlobalMapping, PetscSF *);
     222             : 
     223             : /*E
     224             :    ISColoringType - determines if the coloring is for the entire parallel grid/graph/matrix
     225             :                     or for just the local ghosted portion
     226             : 
     227             :    Values:
     228             : +  `IS_COLORING_GLOBAL` - does not include the colors for ghost points, this is used when the function
     229             :                           is called synchronously in parallel. This requires generating a "parallel coloring".
     230             : -  `IS_COLORING_LOCAL`  - includes colors for ghost points, this is used when the function can be called
     231             :                           separately on individual processes with the ghost points already filled in. Does not
     232             :                           require a "parallel coloring", rather each process colors its local + ghost part.
     233             :                           Using this can result in much less parallel communication. Currently only works
     234             :                           with `DMDA` and if you call `MatFDColoringSetFunction()` with the local function.
     235             : 
     236             :    Level: beginner
     237             : 
     238             : .seealso: `ISColoring`, `ISColoringSetType()`, `ISColoringGetType()`, `DMCreateColoring()`
     239             : E*/
     240             : typedef enum {
     241             :   IS_COLORING_GLOBAL,
     242             :   IS_COLORING_LOCAL
     243             : } ISColoringType;
     244             : 
     245             : PETSC_EXTERN const char *const                ISColoringTypes[];
     246             : typedef unsigned PETSC_IS_COLORING_VALUE_TYPE ISColoringValue;
     247             : #define IS_COLORING_MAX     PETSC_IS_COLORING_MAX
     248             : #define MPIU_COLORING_VALUE PETSC_MPIU_IS_COLORING_VALUE_TYPE
     249             : PETSC_EXTERN PetscErrorCode ISAllGatherColors(MPI_Comm, PetscInt, ISColoringValue *, PetscInt *, ISColoringValue *[]);
     250             : 
     251             : PETSC_EXTERN PetscErrorCode ISColoringCreate(MPI_Comm, PetscInt, PetscInt, const ISColoringValue[], PetscCopyMode, ISColoring *);
     252             : PETSC_EXTERN PetscErrorCode ISColoringDestroy(ISColoring *);
     253             : PETSC_EXTERN PetscErrorCode ISColoringView(ISColoring, PetscViewer);
     254             : PETSC_EXTERN PetscErrorCode ISColoringViewFromOptions(ISColoring, PetscObject, const char[]);
     255             : PETSC_EXTERN PetscErrorCode ISColoringGetIS(ISColoring, PetscCopyMode, PetscInt *, IS *[]);
     256             : PETSC_EXTERN PetscErrorCode ISColoringRestoreIS(ISColoring, PetscCopyMode, IS *[]);
     257             : PETSC_EXTERN PetscErrorCode ISColoringReference(ISColoring);
     258             : PETSC_EXTERN PetscErrorCode ISColoringSetType(ISColoring, ISColoringType);
     259             : PETSC_EXTERN PetscErrorCode ISColoringGetType(ISColoring, ISColoringType *);
     260             : PETSC_EXTERN PetscErrorCode ISColoringGetColors(ISColoring, PetscInt *, PetscInt *, const ISColoringValue **);
     261             : 
     262             : PETSC_EXTERN PetscErrorCode ISBuildTwoSided(IS, IS, IS *);
     263             : PETSC_EXTERN PetscErrorCode ISPartitioningToNumbering(IS, IS *);
     264             : PETSC_EXTERN PetscErrorCode ISPartitioningCount(IS, PetscInt, PetscInt[]);
     265             : 
     266             : PETSC_EXTERN PetscErrorCode ISCompressIndicesGeneral(PetscInt, PetscInt, PetscInt, PetscInt, const IS[], IS[]);
     267             : PETSC_DEPRECATED_FUNCTION(3, 19, 0, "ISCompressIndicesGeneral()", ) static inline PetscErrorCode ISCompressIndicesSorted(PetscInt n, PetscInt bs, PetscInt imax, const IS is_in[], IS is_out[])
     268             : {
     269             :   return ISCompressIndicesGeneral(n, bs, n, imax, is_in, is_out);
     270             : }
     271             : PETSC_EXTERN PetscErrorCode ISExpandIndicesGeneral(PetscInt, PetscInt, PetscInt, PetscInt, const IS[], IS[]);
     272             : 
     273             : struct _n_PetscLayout {
     274             :   MPI_Comm               comm;
     275             :   PetscMPIInt            size;
     276             :   PetscInt               n, N;         /* local, global vector size */
     277             :   PetscInt               rstart, rend; /* local start, local end + 1 */
     278             :   PetscInt              *range;        /* the offset of each processor */
     279             :   PetscBool              range_alloc;  /* should range be freed in Destroy? */
     280             :   PetscInt               bs;           /* number of elements in each block (generally for multi-component
     281             :                                        * problems). Defaults to -1 and can be arbitrarily lazy so always use
     282             :                                        * PetscAbs(map->bs) when accessing directly and expecting result to be
     283             :                                        * positive. Do NOT multiply above numbers by bs */
     284             :   PetscInt               refcnt;       /* MPI Vecs obtained with VecDuplicate() and from MatCreateVecs() reuse map of input object */
     285             :   ISLocalToGlobalMapping mapping;      /* mapping used in Vec/MatSetValuesLocal() */
     286             :   PetscBool              setupcalled;  /* Forbid setup more than once */
     287             :   PetscInt               oldn, oldN;   /* Checking if setup is allowed */
     288             :   PetscInt               oldbs;        /* And again */
     289             : };
     290             : 
     291             : /*@
     292             :    PetscLayoutFindOwner - Find the owning MPI process for a global index
     293             : 
     294             :    Not Collective; No Fortran Support
     295             : 
     296             :    Input Parameters:
     297             : +  map - the layout
     298             : -  idx - global index to find the owner of
     299             : 
     300             :    Output Parameter:
     301             : .  owner - the owning rank
     302             : 
     303             :    Level: developer
     304             : 
     305             : .seealso: `PetscLayout`, `PetscLayoutFindOwnerIndex()`
     306             : @*/
     307          35 : static inline PetscErrorCode PetscLayoutFindOwner(PetscLayout map, PetscInt idx, PetscMPIInt *owner)
     308             : {
     309          35 :   PetscMPIInt lo = 0, hi, t;
     310             : 
     311          35 :   PetscFunctionBegin;
     312          35 :   *owner = -1; /* GCC erroneously issues warning about possibly uninitialized use when error condition */
     313          35 :   PetscAssert((map->n >= 0) && (map->N >= 0) && (map->range), PETSC_COMM_SELF, PETSC_ERR_ARG_WRONGSTATE, "PetscLayoutSetUp() must be called first");
     314          35 :   PetscAssert(idx >= 0 && idx <= map->N, PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Index %" PetscInt_FMT " is out of range", idx);
     315          35 :   hi = map->size;
     316          70 :   while (hi - lo > 1) {
     317           0 :     t = lo + (hi - lo) / 2;
     318           0 :     if (idx < map->range[t]) hi = t;
     319          35 :     else lo = t;
     320             :   }
     321          35 :   *owner = lo;
     322          35 :   PetscFunctionReturn(PETSC_SUCCESS);
     323             : }
     324             : 
     325             : /*@
     326             :     PetscLayoutFindOwnerIndex - Find the owning MPI process and the local index on that process for a global index
     327             : 
     328             :     Not Collective; No Fortran Support
     329             : 
     330             :    Input Parameters:
     331             : +  map   - the layout
     332             : -  idx   - global index to find the owner of
     333             : 
     334             :    Output Parameters:
     335             : +  owner - the owning rank
     336             : -  lidx  - local index used by the owner for `idx`
     337             : 
     338             :    Level: developer
     339             : 
     340             : .seealso: `PetscLayout`, `PetscLayoutFindOwner()`
     341             : @*/
     342             : static inline PetscErrorCode PetscLayoutFindOwnerIndex(PetscLayout map, PetscInt idx, PetscMPIInt *owner, PetscInt *lidx)
     343             : {
     344             :   PetscMPIInt lo = 0, hi, t;
     345             : 
     346             :   PetscFunctionBegin;
     347             :   PetscAssert((map->n >= 0) && (map->N >= 0) && (map->range), PETSC_COMM_SELF, PETSC_ERR_ARG_WRONGSTATE, "PetscLayoutSetUp() must be called first");
     348             :   PetscAssert(idx >= 0 && idx <= map->N, PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Index %" PetscInt_FMT " is out of range", idx);
     349             :   hi = map->size;
     350             :   while (hi - lo > 1) {
     351             :     t = lo + (hi - lo) / 2;
     352             :     if (idx < map->range[t]) hi = t;
     353             :     else lo = t;
     354             :   }
     355             :   if (owner) *owner = lo;
     356             :   if (lidx) *lidx = idx - map->range[lo];
     357             :   PetscFunctionReturn(PETSC_SUCCESS);
     358             : }
     359             : 
     360             : PETSC_EXTERN PetscErrorCode PetscLayoutCreate(MPI_Comm, PetscLayout *);
     361             : PETSC_EXTERN PetscErrorCode PetscLayoutCreateFromSizes(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscLayout *);
     362             : PETSC_EXTERN PetscErrorCode PetscLayoutCreateFromRanges(MPI_Comm, const PetscInt[], PetscCopyMode, PetscInt, PetscLayout *);
     363             : PETSC_EXTERN PetscErrorCode PetscLayoutSetUp(PetscLayout);
     364             : PETSC_EXTERN PetscErrorCode PetscLayoutDestroy(PetscLayout *);
     365             : PETSC_EXTERN PetscErrorCode PetscLayoutDuplicate(PetscLayout, PetscLayout *);
     366             : PETSC_EXTERN PetscErrorCode PetscLayoutReference(PetscLayout, PetscLayout *);
     367             : PETSC_EXTERN PetscErrorCode PetscLayoutSetLocalSize(PetscLayout, PetscInt);
     368             : PETSC_EXTERN PetscErrorCode PetscLayoutGetLocalSize(PetscLayout, PetscInt *);
     369             : PETSC_EXTERN PetscErrorCode PetscLayoutSetSize(PetscLayout, PetscInt);
     370             : PETSC_EXTERN PetscErrorCode PetscLayoutGetSize(PetscLayout, PetscInt *);
     371             : PETSC_EXTERN PetscErrorCode PetscLayoutSetBlockSize(PetscLayout, PetscInt);
     372             : PETSC_EXTERN PetscErrorCode PetscLayoutGetBlockSize(PetscLayout, PetscInt *);
     373             : PETSC_EXTERN PetscErrorCode PetscLayoutGetRange(PetscLayout, PetscInt *, PetscInt *);
     374             : PETSC_EXTERN PetscErrorCode PetscLayoutGetRanges(PetscLayout, const PetscInt *[]);
     375             : PETSC_EXTERN PetscErrorCode PetscLayoutCompare(PetscLayout, PetscLayout, PetscBool *);
     376             : PETSC_EXTERN PetscErrorCode PetscLayoutSetISLocalToGlobalMapping(PetscLayout, ISLocalToGlobalMapping);
     377             : PETSC_EXTERN PetscErrorCode PetscLayoutMapLocal(PetscLayout, PetscInt, const PetscInt[], PetscInt *, PetscInt **, PetscInt **);
     378             : 
     379             : PETSC_EXTERN PetscErrorCode PetscParallelSortInt(PetscLayout, PetscLayout, PetscInt *, PetscInt *);
     380             : 
     381             : PETSC_EXTERN PetscErrorCode ISGetLayout(IS, PetscLayout *);
     382             : PETSC_EXTERN PetscErrorCode ISSetLayout(IS, PetscLayout);

Generated by: LCOV version 1.14