12eac72dbSBarry Smith /* 2f8256253SLois Curfman McInnes An index set is a generalization of a subset of integers. Index sets 3f8256253SLois Curfman McInnes are used for defining scatters and gathers. 42eac72dbSBarry Smith */ 526bd1501SBarry Smith #if !defined(PETSCIS_H) 626bd1501SBarry Smith #define PETSCIS_H 72c8e378dSBarry Smith #include <petscsys.h> 80c312b8eSJed Brown #include <petscsftypes.h> 94914ba2bSBarry Smith #include <petscistypes.h> /*I "petscis.h" I*/ 102eac72dbSBarry Smith 1197b48c8fSBarry Smith #define IS_FILE_CLASSID 1211218 12014dd563SJed Brown PETSC_EXTERN PetscClassId IS_CLASSID; 13f0479e8cSBarry Smith 14607a6623SBarry Smith PETSC_EXTERN PetscErrorCode ISInitializePackage(void); 152b6de112SBarry Smith 1676bdecfbSBarry Smith /*J 178f6c3df8SBarry Smith ISType - String with the name of a PETSc index set type 1827bdab1eSBarry Smith 1927bdab1eSBarry Smith Level: beginner 2027bdab1eSBarry Smith 218f6c3df8SBarry Smith .seealso: ISSetType(), IS, ISCreate(), ISRegister() 2276bdecfbSBarry Smith J*/ 2319fd82e9SBarry Smith typedef const char* ISType; 2427bdab1eSBarry Smith #define ISGENERAL "general" 2527bdab1eSBarry Smith #define ISSTRIDE "stride" 2627bdab1eSBarry Smith #define ISBLOCK "block" 2727bdab1eSBarry Smith 2827bdab1eSBarry Smith /* Dynamic creation and loading functions */ 29140e18c1SBarry Smith PETSC_EXTERN PetscFunctionList ISList; 3019fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode ISSetType(IS, ISType); 3119fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode ISGetType(IS, ISType *); 32bdf89e91SBarry Smith PETSC_EXTERN PetscErrorCode ISRegister(const char[],PetscErrorCode (*)(IS)); 33014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISCreate(MPI_Comm,IS*); 3427bdab1eSBarry Smith 35639f9d9dSBarry Smith /* 36639f9d9dSBarry Smith Default index set data structures that PETSc provides. 37639f9d9dSBarry Smith */ 38014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISCreateGeneral(MPI_Comm,PetscInt,const PetscInt[],PetscCopyMode,IS *); 39014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISGeneralSetIndices(IS,PetscInt,const PetscInt[],PetscCopyMode); 40014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISCreateBlock(MPI_Comm,PetscInt,PetscInt,const PetscInt[],PetscCopyMode,IS *); 41014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISBlockSetIndices(IS,PetscInt,PetscInt,const PetscInt[],PetscCopyMode); 42014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISCreateStride(MPI_Comm,PetscInt,PetscInt,PetscInt,IS *); 43014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISStrideSetStride(IS,PetscInt,PetscInt,PetscInt); 444b0e389bSBarry Smith 45014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISDestroy(IS*); 46014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISSetPermutation(IS); 47014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISPermutation(IS,PetscBool *); 48014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISSetIdentity(IS); 49014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISIdentity(IS,PetscBool *); 50014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISContiguousLocal(IS,PetscInt,PetscInt,PetscInt*,PetscBool*); 5108480c60SBarry Smith 52014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISGetIndices(IS,const PetscInt *[]); 53014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISRestoreIndices(IS,const PetscInt *[]); 54014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISGetTotalIndices(IS,const PetscInt *[]); 55014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISRestoreTotalIndices(IS,const PetscInt *[]); 56014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISGetNonlocalIndices(IS,const PetscInt *[]); 57014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISRestoreNonlocalIndices(IS,const PetscInt *[]); 58014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISGetNonlocalIS(IS, IS *is); 59014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISRestoreNonlocalIS(IS, IS *is); 60014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISGetSize(IS,PetscInt *); 61014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISGetLocalSize(IS,PetscInt *); 62014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISInvertPermutation(IS,PetscInt,IS*); 63014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISView(IS,PetscViewer); 64685405a1SBarry Smith PETSC_STATIC_INLINE PetscErrorCode ISViewFromOptions(IS A,PetscObject obj,const char name[]) {return PetscObjectViewFromOptions((PetscObject)A,obj,name);} 65235f7792SMatthew G. Knepley PETSC_EXTERN PetscErrorCode ISLoad(IS,PetscViewer); 66014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISEqual(IS,IS,PetscBool *); 67e8386968SVaclav Hapla PETSC_EXTERN PetscErrorCode ISEqualUnsorted(IS,IS,PetscBool *); 68014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISSort(IS); 69b080c0f9SMatthew G. Knepley PETSC_EXTERN PetscErrorCode ISSortRemoveDups(IS); 70014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISSorted(IS,PetscBool *); 71014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISDifference(IS,IS,IS*); 72014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISSum(IS,IS,IS*); 73014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISExpand(IS,IS,IS*); 743daafeecSToby Isaac PETSC_EXTERN PetscErrorCode ISIntersect(IS,IS,IS*); 75132da990SBarry Smith PETSC_EXTERN PetscErrorCode ISGetMinMax(IS,PetscInt*,PetscInt*); 76612dd529SBarry Smith 77c3c3c9f4SToby Isaac PETSC_EXTERN PetscErrorCode ISLocate(IS,PetscInt,PetscInt*); 789305a4c7SMatthew G. Knepley PETSC_EXTERN PetscErrorCode ISGetPointRange(IS,PetscInt*,PetscInt*,const PetscInt**); 799305a4c7SMatthew G. Knepley PETSC_EXTERN PetscErrorCode ISRestorePointRange(IS,PetscInt*,PetscInt*,const PetscInt**); 809305a4c7SMatthew G. Knepley PETSC_EXTERN PetscErrorCode ISGetPointSubrange(IS,PetscInt,PetscInt,const PetscInt*); 81c3c3c9f4SToby Isaac 82014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISBlockGetIndices(IS,const PetscInt *[]); 83014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISBlockRestoreIndices(IS,const PetscInt *[]); 84014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISBlockGetLocalSize(IS,PetscInt *); 85014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISBlockGetSize(IS,PetscInt *); 86014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISGetBlockSize(IS,PetscInt*); 87014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISSetBlockSize(IS,PetscInt); 88c16cb8f2SBarry Smith 89014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISStrideGetInfo(IS,PetscInt *,PetscInt*); 90c16cb8f2SBarry Smith 91014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISToGeneral(IS); 9238f40f24SLois Curfman McInnes 93014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISDuplicate(IS,IS*); 94014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISCopy(IS,IS); 95014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISAllGather(IS,IS*); 96014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISComplement(IS,PetscInt,PetscInt,IS*); 97014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISConcatenate(MPI_Comm,PetscInt,const IS[],IS*); 98bb74729cSDmitry Karpeev PETSC_EXTERN PetscErrorCode ISListToPair(MPI_Comm,PetscInt, IS[],IS*,IS*); 99bb74729cSDmitry Karpeev PETSC_EXTERN PetscErrorCode ISPairToList(IS,IS,PetscInt*, IS *[]); 100bb74729cSDmitry Karpeev PETSC_EXTERN PetscErrorCode ISEmbed(IS,IS,PetscBool,IS*); 1015ea6c424SDmitry Karpeev PETSC_EXTERN PetscErrorCode ISSortPermutation(IS,PetscBool,IS*); 102014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISOnComm(IS,MPI_Comm,PetscCopyMode,IS*); 1036583bcc1SStefano Zampini PETSC_EXTERN PetscErrorCode ISRenumber(IS,IS,PetscInt*,IS*); 1046c04a3c5SFande Kong PETSC_EXTERN PetscErrorCode ISCreateSubIS(IS,IS,IS*); 105d64ed03dSBarry Smith 10656cd22aeSBarry Smith /* --------------------------------------------------------------------------*/ 107014dd563SJed Brown PETSC_EXTERN PetscClassId IS_LTOGM_CLASSID; 10856cd22aeSBarry Smith 1095c20da3cSBarry Smith /*E 110413f72f0SBarry Smith ISGlobalToLocalMappingMode - Indicates if missing global indices are 1115c20da3cSBarry Smith 1125c20da3cSBarry Smith IS_GTOLM_MASK - missing global indices are replaced with -1 1135c20da3cSBarry Smith IS_GTOLM_DROP - missing global indices are dropped 1145c20da3cSBarry Smith 1155c20da3cSBarry Smith Level: beginner 1165c20da3cSBarry Smith 117413f72f0SBarry Smith .seealso: ISGlobalToLocalMappingApplyBlock(), ISGlobalToLocalMappingApply() 1185c20da3cSBarry Smith 1195c20da3cSBarry Smith E*/ 120413f72f0SBarry Smith typedef enum {IS_GTOLM_MASK,IS_GTOLM_DROP} ISGlobalToLocalMappingMode; 12190f02eecSBarry Smith 122413f72f0SBarry Smith /*J 123413f72f0SBarry Smith ISLocalToGlobalMappingType - String with the name of a mapping method 124413f72f0SBarry Smith 125413f72f0SBarry Smith Level: beginner 126413f72f0SBarry Smith 127413f72f0SBarry Smith .seealso: ISLocalToGlobalMappingSetType(), ISLocalToGlobalSetFromOptions() 128413f72f0SBarry Smith J*/ 129413f72f0SBarry Smith typedef const char* ISLocalToGlobalMappingType; 130413f72f0SBarry Smith #define ISLOCALTOGLOBALMAPPINGBASIC "basic" 131413f72f0SBarry Smith #define ISLOCALTOGLOBALMAPPINGHASH "hash" 132413f72f0SBarry Smith 133413f72f0SBarry Smith PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingSetType(ISLocalToGlobalMapping,ISLocalToGlobalMappingType); 1341d36bdfdSBarry Smith PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingRegister(const char[],PetscErrorCode (*)(ISLocalToGlobalMapping)); 135413f72f0SBarry Smith PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingRegisterAll(void); 136f0413b6fSBarry Smith PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingCreate(MPI_Comm,PetscInt,PetscInt,const PetscInt[],PetscCopyMode,ISLocalToGlobalMapping*); 137014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingCreateIS(IS,ISLocalToGlobalMapping *); 138014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingCreateSF(PetscSF,PetscInt,ISLocalToGlobalMapping*); 1397e99dc12SLawrence Mitchell PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingSetFromOptions(ISLocalToGlobalMapping); 140413f72f0SBarry Smith PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingSetUp(ISLocalToGlobalMapping); 141014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingView(ISLocalToGlobalMapping,PetscViewer); 142662df134SStefano Zampini PETSC_STATIC_INLINE PetscErrorCode ISLocalToGlobalMappingViewFromOptions(ISLocalToGlobalMapping A,PetscObject B,const char name[]) {return PetscObjectViewFromOptions((PetscObject)A,B,name);} 143662df134SStefano Zampini 144014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingDestroy(ISLocalToGlobalMapping*); 14504a59952SBarry Smith PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingApply(ISLocalToGlobalMapping,PetscInt,const PetscInt[],PetscInt[]); 14645b6f7e9SBarry Smith PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingApplyBlock(ISLocalToGlobalMapping,PetscInt,const PetscInt[],PetscInt[]); 147014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingApplyIS(ISLocalToGlobalMapping,IS,IS*); 148413f72f0SBarry Smith PETSC_EXTERN PetscErrorCode ISGlobalToLocalMappingApply(ISLocalToGlobalMapping,ISGlobalToLocalMappingMode,PetscInt,const PetscInt[],PetscInt*,PetscInt[]); 149413f72f0SBarry Smith PETSC_EXTERN PetscErrorCode ISGlobalToLocalMappingApplyBlock(ISLocalToGlobalMapping,ISGlobalToLocalMappingMode,PetscInt,const PetscInt[],PetscInt*,PetscInt[]); 150413f72f0SBarry Smith PETSC_EXTERN PetscErrorCode ISGlobalToLocalMappingApplyIS(ISLocalToGlobalMapping,ISGlobalToLocalMappingMode,IS,IS*); 151014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingGetSize(ISLocalToGlobalMapping,PetscInt*); 1521bd0b88eSStefano Zampini PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingGetNodeInfo(ISLocalToGlobalMapping,PetscInt*,PetscInt*[],PetscInt**[]); 1531bd0b88eSStefano Zampini PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingRestoreNodeInfo(ISLocalToGlobalMapping,PetscInt*,PetscInt*[],PetscInt**[]); 154014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingGetInfo(ISLocalToGlobalMapping,PetscInt*,PetscInt*[],PetscInt*[],PetscInt**[]); 155014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingRestoreInfo(ISLocalToGlobalMapping,PetscInt*,PetscInt*[],PetscInt*[],PetscInt**[]); 1566a818285SBarry Smith PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingGetBlockInfo(ISLocalToGlobalMapping,PetscInt*,PetscInt*[],PetscInt*[],PetscInt**[]); 1576a818285SBarry Smith PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingRestoreBlockInfo(ISLocalToGlobalMapping,PetscInt*,PetscInt*[],PetscInt*[],PetscInt**[]); 158014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingGetIndices(ISLocalToGlobalMapping,const PetscInt**); 159014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingRestoreIndices(ISLocalToGlobalMapping,const PetscInt**); 16045b6f7e9SBarry Smith PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingGetBlockIndices(ISLocalToGlobalMapping,const PetscInt**); 16145b6f7e9SBarry Smith PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingRestoreBlockIndices(ISLocalToGlobalMapping,const PetscInt**); 162014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingConcatenate(MPI_Comm,PetscInt,const ISLocalToGlobalMapping[],ISLocalToGlobalMapping*); 16345b6f7e9SBarry Smith PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingGetBlockSize(ISLocalToGlobalMapping,PetscInt*); 16463fa5c83Sstefano_zampini PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingSetBlockSize(ISLocalToGlobalMapping,PetscInt); 1656658fb44Sstefano_zampini PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingDuplicate(ISLocalToGlobalMapping,ISLocalToGlobalMapping*); 16645b6f7e9SBarry Smith 16774637425SBarry Smith 16856cd22aeSBarry Smith /* --------------------------------------------------------------------------*/ 169b9617806SBarry Smith /*E 170b9617806SBarry Smith ISColoringType - determines if the coloring is for the entire parallel grid/graph/matrix 171b9617806SBarry Smith or for just the local ghosted portion 172b9617806SBarry Smith 173b9617806SBarry Smith Level: beginner 174b9617806SBarry Smith 1758ee2e534SBarry Smith $ IS_COLORING_GLOBAL - does not include the colors for ghost points, this is used when the function 1768ee2e534SBarry Smith $ is called synchronously in parallel. This requires generating a "parallel coloring". 1775bdb020cSBarry Smith $ IS_COLORING_LOCAL - includes colors for ghost points, this is used when the function can be called 178bebe2cf6SSatish Balay $ separately on individual processes with the ghost points already filled in. Does not 1798ee2e534SBarry Smith $ require a "parallel coloring", rather each process colors its local + ghost part. 1805bdb020cSBarry Smith $ Using this can result in much less parallel communication. Currently only works 1815bdb020cSBarry Smith $ with DMDA and if you call MatFDColoringSetFunction() with the local function. 18273d7d85fSBarry Smith 183e727c939SJed Brown .seealso: DMCreateColoring() 184b9617806SBarry Smith E*/ 1855bdb020cSBarry Smith typedef enum {IS_COLORING_GLOBAL,IS_COLORING_LOCAL} ISColoringType; 1866a6fc655SJed Brown PETSC_EXTERN const char *const ISColoringTypes[]; 1876c09f170SSatish Balay typedef unsigned PETSC_IS_COLOR_VALUE_TYPE ISColoringValue; 188014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISAllGatherColors(MPI_Comm,PetscInt,ISColoringValue*,PetscInt*,ISColoringValue*[]); 189dde82324SBarry Smith 190aaf3ff59SMatthew G. Knepley PETSC_EXTERN PetscErrorCode ISColoringCreate(MPI_Comm,PetscInt,PetscInt,const ISColoringValue[],PetscCopyMode,ISColoring*); 191014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISColoringDestroy(ISColoring*); 192014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISColoringView(ISColoring,PetscViewer); 1938aec7d55SBarry Smith PETSC_EXTERN PetscErrorCode ISColoringViewFromOptions(ISColoring,PetscObject,const char[]); 194071fcb05SBarry Smith PETSC_EXTERN PetscErrorCode ISColoringGetIS(ISColoring,PetscCopyMode,PetscInt*,IS*[]); 195071fcb05SBarry Smith PETSC_EXTERN PetscErrorCode ISColoringRestoreIS(ISColoring,PetscCopyMode,IS*[]); 19649b734d2SBarry Smith PETSC_EXTERN PetscErrorCode ISColoringReference(ISColoring); 19749b734d2SBarry Smith PETSC_EXTERN PetscErrorCode ISColoringSetType(ISColoring,ISColoringType); 198*bdaf1daeSBarry Smith PETSC_EXTERN PetscErrorCode ISColoringGetType(ISColoring,ISColoringType*); 199*bdaf1daeSBarry Smith PETSC_EXTERN PetscErrorCode ISColoringGetColors(ISColoring,PetscInt*,PetscInt*,const ISColoringValue**); 2003a7fca6bSBarry Smith 201dbef8a1cSBarry Smith /* --------------------------------------------------------------------------*/ 20294f0491fSFande Kong PETSC_EXTERN PetscErrorCode ISBuildTwoSided(IS,IS,IS*); 203014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISPartitioningToNumbering(IS,IS*); 204014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISPartitioningCount(IS,PetscInt,PetscInt[]); 205dbef8a1cSBarry Smith 206014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISCompressIndicesGeneral(PetscInt,PetscInt,PetscInt,PetscInt,const IS[],IS[]); 207014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISCompressIndicesSorted(PetscInt,PetscInt,PetscInt,const IS[],IS[]); 208014dd563SJed Brown PETSC_EXTERN PetscErrorCode ISExpandIndicesGeneral(PetscInt,PetscInt,PetscInt,PetscInt,const IS[],IS[]); 209d9489beaSHong Zhang 21069ce434fSBarry Smith 21169ce434fSBarry Smith struct _n_PetscLayout{ 21269ce434fSBarry Smith MPI_Comm comm; 21369ce434fSBarry Smith PetscInt n,N; /* local, global vector size */ 21469ce434fSBarry Smith PetscInt rstart,rend; /* local start, local end + 1 */ 21569ce434fSBarry Smith PetscInt *range; /* the offset of each processor */ 21633d57670SJed Brown PetscInt bs; /* number of elements in each block (generally for multi-component 21733d57670SJed Brown * problems). Defaults to -1 and can be arbitrarily lazy so always use 21833d57670SJed Brown * PetscAbs(map->bs) when accessing directly and expecting result to be 21933d57670SJed Brown * positive. Do NOT multiply above numbers by bs */ 2202a7a6963SBarry Smith PetscInt refcnt; /* MPI Vecs obtained with VecDuplicate() and from MatCreateVecs() reuse map of input object */ 22169ce434fSBarry Smith ISLocalToGlobalMapping mapping; /* mapping used in Vec/MatSetValuesLocal() */ 22269ce434fSBarry Smith }; 22369ce434fSBarry Smith 2247e3c27c9SBarry Smith /*@C 22569ce434fSBarry Smith PetscLayoutFindOwner - Find the owning rank for a global index 22669ce434fSBarry Smith 22769ce434fSBarry Smith Not Collective 22869ce434fSBarry Smith 22969ce434fSBarry Smith Input Parameters: 23069ce434fSBarry Smith + map - the layout 23169ce434fSBarry Smith - idx - global index to find the owner of 23269ce434fSBarry Smith 23369ce434fSBarry Smith Output Parameter: 23469ce434fSBarry Smith . owner - the owning rank 23569ce434fSBarry Smith 23669ce434fSBarry Smith Level: developer 23769ce434fSBarry Smith 23869ce434fSBarry Smith Fortran Notes: 23969ce434fSBarry Smith Not available from Fortran 24069ce434fSBarry Smith 24169ce434fSBarry Smith @*/ 24269ce434fSBarry Smith PETSC_STATIC_INLINE PetscErrorCode PetscLayoutFindOwner(PetscLayout map,PetscInt idx,PetscInt *owner) 24369ce434fSBarry Smith { 24469ce434fSBarry Smith PetscErrorCode ierr; 24569ce434fSBarry Smith PetscMPIInt lo = 0,hi,t; 24669ce434fSBarry Smith 24769ce434fSBarry Smith PetscFunctionBegin; 24869ce434fSBarry Smith *owner = -1; /* GCC erroneously issues warning about possibly uninitialized use when error condition */ 24969ce434fSBarry Smith if (!((map->n >= 0) && (map->N >= 0) && (map->range))) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONGSTATE,"PetscLayoutSetUp() must be called first"); 25069ce434fSBarry Smith if (idx < 0 || idx > map->N) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Index %D is out of range",idx); 25169ce434fSBarry Smith ierr = MPI_Comm_size(map->comm,&hi);CHKERRQ(ierr); 25269ce434fSBarry Smith while (hi - lo > 1) { 25369ce434fSBarry Smith t = lo + (hi - lo) / 2; 25469ce434fSBarry Smith if (idx < map->range[t]) hi = t; 25569ce434fSBarry Smith else lo = t; 25669ce434fSBarry Smith } 25769ce434fSBarry Smith *owner = lo; 25869ce434fSBarry Smith PetscFunctionReturn(0); 25969ce434fSBarry Smith } 26069ce434fSBarry Smith 26169ce434fSBarry Smith /*@C 26269ce434fSBarry Smith PetscLayoutFindOwnerIndex - Find the owning rank and the local index for a global index 26369ce434fSBarry Smith 26469ce434fSBarry Smith Not Collective 26569ce434fSBarry Smith 26669ce434fSBarry Smith Input Parameters: 26769ce434fSBarry Smith + map - the layout 26869ce434fSBarry Smith - idx - global index to find the owner of 26969ce434fSBarry Smith 27069ce434fSBarry Smith Output Parameter: 27169ce434fSBarry Smith + owner - the owning rank 27269ce434fSBarry Smith - lidx - local index used by the owner for idx 27369ce434fSBarry Smith 27469ce434fSBarry Smith Level: developer 27569ce434fSBarry Smith 27669ce434fSBarry Smith Fortran Notes: 27769ce434fSBarry Smith Not available from Fortran 27869ce434fSBarry Smith 27969ce434fSBarry Smith @*/ 28069ce434fSBarry Smith PETSC_STATIC_INLINE PetscErrorCode PetscLayoutFindOwnerIndex(PetscLayout map,PetscInt idx,PetscInt *owner, PetscInt *lidx) 28169ce434fSBarry Smith { 28269ce434fSBarry Smith PetscErrorCode ierr; 28369ce434fSBarry Smith PetscMPIInt lo = 0,hi,t; 28469ce434fSBarry Smith 28569ce434fSBarry Smith PetscFunctionBegin; 28669ce434fSBarry Smith if (!((map->n >= 0) && (map->N >= 0) && (map->range))) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONGSTATE,"PetscLayoutSetUp() must be called first"); 28769ce434fSBarry Smith if (idx < 0 || idx > map->N) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Index %D is out of range",idx); 28869ce434fSBarry Smith ierr = MPI_Comm_size(map->comm,&hi);CHKERRQ(ierr); 28969ce434fSBarry Smith while (hi - lo > 1) { 29069ce434fSBarry Smith t = lo + (hi - lo) / 2; 29169ce434fSBarry Smith if (idx < map->range[t]) hi = t; 29269ce434fSBarry Smith else lo = t; 29369ce434fSBarry Smith } 29404799504SMark Adams if (owner) *owner = lo; 29504799504SMark Adams if (lidx) *lidx = idx-map->range[lo]; 29669ce434fSBarry Smith PetscFunctionReturn(0); 29769ce434fSBarry Smith } 2989e03d832SJed Brown 29901e13f73SMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscLayoutCreate(MPI_Comm,PetscLayout*); 30001e13f73SMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscLayoutSetUp(PetscLayout); 30101e13f73SMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscLayoutDestroy(PetscLayout*); 30201e13f73SMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscLayoutDuplicate(PetscLayout,PetscLayout*); 30301e13f73SMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscLayoutReference(PetscLayout,PetscLayout*); 30401e13f73SMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscLayoutSetLocalSize(PetscLayout,PetscInt); 30501e13f73SMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscLayoutGetLocalSize(PetscLayout,PetscInt *); 30601e13f73SMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscLayoutSetSize(PetscLayout,PetscInt); 30701e13f73SMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscLayoutGetSize(PetscLayout,PetscInt *); 30801e13f73SMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscLayoutSetBlockSize(PetscLayout,PetscInt); 30901e13f73SMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscLayoutGetBlockSize(PetscLayout,PetscInt*); 31001e13f73SMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscLayoutGetRange(PetscLayout,PetscInt *,PetscInt *); 31101e13f73SMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscLayoutGetRanges(PetscLayout,const PetscInt *[]); 312f92d6284SStefano Zampini PETSC_EXTERN PetscErrorCode PetscLayoutCompare(PetscLayout,PetscLayout,PetscBool*); 31301e13f73SMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscLayoutSetISLocalToGlobalMapping(PetscLayout,ISLocalToGlobalMapping); 31407acc2aeSBarry Smith PETSC_EXTERN PetscErrorCode PetscLayoutMapLocal(PetscLayout,PetscInt,const PetscInt[],PetscInt*,PetscInt**,PetscInt**); 31501e13f73SMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscSFSetGraphLayout(PetscSF,PetscLayout,PetscInt,const PetscInt*,PetscCopyMode,const PetscInt*); 31601e13f73SMatthew G. Knepley 3174e97f8ebSVaclav Hapla 3181d799100SJed Brown PETSC_EXTERN PetscClassId PETSC_SECTION_CLASSID; 3191d799100SJed Brown 320d53a3d6fSBarry Smith PETSC_EXTERN PetscErrorCode PetscSectionCreate(MPI_Comm,PetscSection*); 321d53a3d6fSBarry Smith PETSC_EXTERN PetscErrorCode PetscSectionClone(PetscSection, PetscSection*); 3229d054d3dSMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscSectionSetFromOptions(PetscSection); 323d902297bSMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscSectionCopy(PetscSection, PetscSection); 3249e436492SVaclav Hapla PETSC_EXTERN PetscErrorCode PetscSectionCompare(PetscSection, PetscSection, PetscBool*); 325d53a3d6fSBarry Smith PETSC_EXTERN PetscErrorCode PetscSectionGetNumFields(PetscSection, PetscInt *); 326d53a3d6fSBarry Smith PETSC_EXTERN PetscErrorCode PetscSectionSetNumFields(PetscSection, PetscInt); 327d53a3d6fSBarry Smith PETSC_EXTERN PetscErrorCode PetscSectionGetFieldName(PetscSection, PetscInt, const char *[]); 328d53a3d6fSBarry Smith PETSC_EXTERN PetscErrorCode PetscSectionSetFieldName(PetscSection, PetscInt, const char []); 329d53a3d6fSBarry Smith PETSC_EXTERN PetscErrorCode PetscSectionGetFieldComponents(PetscSection, PetscInt, PetscInt *); 330d53a3d6fSBarry Smith PETSC_EXTERN PetscErrorCode PetscSectionSetFieldComponents(PetscSection, PetscInt, PetscInt); 331d53a3d6fSBarry Smith PETSC_EXTERN PetscErrorCode PetscSectionGetChart(PetscSection, PetscInt *, PetscInt *); 332d53a3d6fSBarry Smith PETSC_EXTERN PetscErrorCode PetscSectionSetChart(PetscSection, PetscInt, PetscInt); 3334c0d72c2SMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscSectionGetPermutation(PetscSection, IS *); 3344c0d72c2SMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscSectionSetPermutation(PetscSection, IS); 3358530cb24SMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscSectionGetPointMajor(PetscSection, PetscBool *); 3368530cb24SMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscSectionSetPointMajor(PetscSection, PetscBool); 337d53a3d6fSBarry Smith PETSC_EXTERN PetscErrorCode PetscSectionGetDof(PetscSection, PetscInt, PetscInt*); 338d53a3d6fSBarry Smith PETSC_EXTERN PetscErrorCode PetscSectionSetDof(PetscSection, PetscInt, PetscInt); 339d53a3d6fSBarry Smith PETSC_EXTERN PetscErrorCode PetscSectionAddDof(PetscSection, PetscInt, PetscInt); 340d53a3d6fSBarry Smith PETSC_EXTERN PetscErrorCode PetscSectionGetFieldDof(PetscSection, PetscInt, PetscInt, PetscInt*); 341d53a3d6fSBarry Smith PETSC_EXTERN PetscErrorCode PetscSectionSetFieldDof(PetscSection, PetscInt, PetscInt, PetscInt); 342d53a3d6fSBarry Smith PETSC_EXTERN PetscErrorCode PetscSectionAddFieldDof(PetscSection, PetscInt, PetscInt, PetscInt); 3437ba4506dSMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscSectionHasConstraints(PetscSection, PetscBool *); 344d53a3d6fSBarry Smith PETSC_EXTERN PetscErrorCode PetscSectionGetConstraintDof(PetscSection, PetscInt, PetscInt*); 345d53a3d6fSBarry Smith PETSC_EXTERN PetscErrorCode PetscSectionSetConstraintDof(PetscSection, PetscInt, PetscInt); 346d53a3d6fSBarry Smith PETSC_EXTERN PetscErrorCode PetscSectionAddConstraintDof(PetscSection, PetscInt, PetscInt); 347d53a3d6fSBarry Smith PETSC_EXTERN PetscErrorCode PetscSectionGetFieldConstraintDof(PetscSection, PetscInt, PetscInt, PetscInt*); 348d53a3d6fSBarry Smith PETSC_EXTERN PetscErrorCode PetscSectionSetFieldConstraintDof(PetscSection, PetscInt, PetscInt, PetscInt); 349d53a3d6fSBarry Smith PETSC_EXTERN PetscErrorCode PetscSectionAddFieldConstraintDof(PetscSection, PetscInt, PetscInt, PetscInt); 350d53a3d6fSBarry Smith PETSC_EXTERN PetscErrorCode PetscSectionGetConstraintIndices(PetscSection, PetscInt, const PetscInt**); 351d53a3d6fSBarry Smith PETSC_EXTERN PetscErrorCode PetscSectionSetConstraintIndices(PetscSection, PetscInt, const PetscInt*); 352d53a3d6fSBarry Smith PETSC_EXTERN PetscErrorCode PetscSectionGetFieldConstraintIndices(PetscSection, PetscInt, PetscInt, const PetscInt**); 353d53a3d6fSBarry Smith PETSC_EXTERN PetscErrorCode PetscSectionSetFieldConstraintIndices(PetscSection, PetscInt, PetscInt, const PetscInt*); 354d53a3d6fSBarry Smith PETSC_EXTERN PetscErrorCode PetscSectionSetUpBC(PetscSection); 355d53a3d6fSBarry Smith PETSC_EXTERN PetscErrorCode PetscSectionSetUp(PetscSection); 356d53a3d6fSBarry Smith PETSC_EXTERN PetscErrorCode PetscSectionGetMaxDof(PetscSection, PetscInt*); 357d53a3d6fSBarry Smith PETSC_EXTERN PetscErrorCode PetscSectionGetStorageSize(PetscSection, PetscInt*); 358d53a3d6fSBarry Smith PETSC_EXTERN PetscErrorCode PetscSectionGetConstrainedStorageSize(PetscSection, PetscInt*); 359d53a3d6fSBarry Smith PETSC_EXTERN PetscErrorCode PetscSectionGetOffset(PetscSection, PetscInt, PetscInt*); 360d53a3d6fSBarry Smith PETSC_EXTERN PetscErrorCode PetscSectionSetOffset(PetscSection, PetscInt, PetscInt); 361d53a3d6fSBarry Smith PETSC_EXTERN PetscErrorCode PetscSectionGetFieldOffset(PetscSection, PetscInt, PetscInt, PetscInt*); 362d53a3d6fSBarry Smith PETSC_EXTERN PetscErrorCode PetscSectionSetFieldOffset(PetscSection, PetscInt, PetscInt, PetscInt); 363d53a3d6fSBarry Smith PETSC_EXTERN PetscErrorCode PetscSectionGetOffsetRange(PetscSection, PetscInt *, PetscInt *); 364d53a3d6fSBarry Smith PETSC_EXTERN PetscErrorCode PetscSectionView(PetscSection, PetscViewer); 365685405a1SBarry Smith PETSC_STATIC_INLINE PetscErrorCode PetscSectionViewFromOptions(PetscSection A,PetscObject obj,const char name[]) {return PetscObjectViewFromOptions((PetscObject)A,obj,name);} 366d53a3d6fSBarry Smith PETSC_EXTERN PetscErrorCode PetscSectionReset(PetscSection); 367d53a3d6fSBarry Smith PETSC_EXTERN PetscErrorCode PetscSectionDestroy(PetscSection*); 368c5e4d11fSDmitry Karpeev PETSC_EXTERN PetscErrorCode PetscSectionCreateGlobalSection(PetscSection, PetscSF, PetscBool, PetscBool, PetscSection *); 369d53a3d6fSBarry Smith PETSC_EXTERN PetscErrorCode PetscSectionCreateGlobalSectionCensored(PetscSection, PetscSF, PetscBool, PetscInt, const PetscInt [], PetscSection *); 370276c5506SMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscSectionCreateSubsection(PetscSection, PetscInt, const PetscInt [], PetscSection *); 3710f7a5dcfSMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscSectionCreateSupersection(PetscSection[], PetscInt, PetscSection *); 372d53a3d6fSBarry Smith PETSC_EXTERN PetscErrorCode PetscSectionCreateSubmeshSection(PetscSection, IS, PetscSection *); 373d53a3d6fSBarry Smith PETSC_EXTERN PetscErrorCode PetscSectionGetPointLayout(MPI_Comm, PetscSection, PetscLayout *); 374d53a3d6fSBarry Smith PETSC_EXTERN PetscErrorCode PetscSectionGetValueLayout(MPI_Comm, PetscSection, PetscLayout *); 375b348688eSMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscSectionPermute(PetscSection, IS, PetscSection *); 376a7c23f90SMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscSectionGetField(PetscSection, PetscInt, PetscSection *); 37716ac2964SMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscSectionSetUseFieldOffsets(PetscSection, PetscBool); 37816ac2964SMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscSectionGetUseFieldOffsets(PetscSection, PetscBool *); 379d5f5d44eSVaclav Hapla PETSC_EXTERN PetscErrorCode PetscSectionExtractDofsFromArray(PetscSection, MPI_Datatype, const void *, IS, PetscSection *, void *[]); 380d53a3d6fSBarry Smith 38105eca2e3SMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscSectionSetClosureIndex(PetscSection, PetscObject, PetscSection, IS); 38205eca2e3SMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscSectionGetClosureIndex(PetscSection, PetscObject, PetscSection *, IS *); 3831fdd32a2SMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscSectionSetClosurePermutation(PetscSection, PetscObject, IS); 3841fdd32a2SMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscSectionGetClosurePermutation(PetscSection, PetscObject, IS *); 3851fdd32a2SMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscSectionGetClosureInversePermutation(PetscSection, PetscObject, IS *); 386d53a3d6fSBarry Smith 387b5a418daSToby Isaac PETSC_EXTERN PetscClassId PETSC_SECTION_SYM_CLASSID; 388b5a418daSToby Isaac 389b5a418daSToby Isaac /*J 390b5a418daSToby Isaac PetscSectionSymType - String with the name of a PetscSectionSym type. 391b5a418daSToby Isaac 392b5a418daSToby Isaac Level: developer 393b5a418daSToby Isaac 39495452b02SPatrick Sanan Notes: 39595452b02SPatrick Sanan PetscSectionSym has no default implementation, but is used by DM in PetscSectionSymCreateLabel(). 396b5a418daSToby Isaac 397b5a418daSToby Isaac .seealso: PetscSectionSymSetType(), PetscSectionSym, PetscSectionSymCreate(), PetscSectionSymRegister() 398b5a418daSToby Isaac J*/ 399b5a418daSToby Isaac typedef const char *PetscSectionSymType; 400b5a418daSToby Isaac 401b5a418daSToby Isaac PETSC_EXTERN PetscFunctionList PetscSectionSymList; 402b5a418daSToby Isaac PETSC_EXTERN PetscErrorCode PetscSectionSymSetType(PetscSectionSym, PetscSectionSymType); 403b5a418daSToby Isaac PETSC_EXTERN PetscErrorCode PetscSectionSymGetType(PetscSectionSym, PetscSectionSymType*); 404b5a418daSToby Isaac PETSC_EXTERN PetscErrorCode PetscSectionSymRegister(const char[],PetscErrorCode (*)(PetscSectionSym)); 405b5a418daSToby Isaac 406b5a418daSToby Isaac PETSC_EXTERN PetscErrorCode PetscSectionSymCreate(MPI_Comm, PetscSectionSym*); 407b5a418daSToby Isaac PETSC_EXTERN PetscErrorCode PetscSectionSymDestroy(PetscSectionSym*); 408b5a418daSToby Isaac PETSC_EXTERN PetscErrorCode PetscSectionSymView(PetscSectionSym,PetscViewer); 409b5a418daSToby Isaac 410b5a418daSToby Isaac PETSC_EXTERN PetscErrorCode PetscSectionSetSym(PetscSection, PetscSectionSym); 411b5a418daSToby Isaac PETSC_EXTERN PetscErrorCode PetscSectionGetSym(PetscSection, PetscSectionSym*); 412b5a418daSToby Isaac PETSC_EXTERN PetscErrorCode PetscSectionSetFieldSym(PetscSection, PetscInt, PetscSectionSym); 413b5a418daSToby Isaac PETSC_EXTERN PetscErrorCode PetscSectionGetFieldSym(PetscSection, PetscInt, PetscSectionSym*); 414b5a418daSToby Isaac 415b5a418daSToby Isaac PETSC_EXTERN PetscErrorCode PetscSectionGetPointSyms(PetscSection, PetscInt, const PetscInt *, const PetscInt ***, const PetscScalar ***); 416b5a418daSToby Isaac PETSC_EXTERN PetscErrorCode PetscSectionRestorePointSyms(PetscSection, PetscInt, const PetscInt *, const PetscInt ***, const PetscScalar ***); 417b5a418daSToby Isaac PETSC_EXTERN PetscErrorCode PetscSectionGetFieldPointSyms(PetscSection, PetscInt, PetscInt, const PetscInt *, const PetscInt ***, const PetscScalar ***); 418b5a418daSToby Isaac PETSC_EXTERN PetscErrorCode PetscSectionRestoreFieldPointSyms(PetscSection, PetscInt, PetscInt, const PetscInt *, const PetscInt ***, const PetscScalar ***); 419b5a418daSToby Isaac 420b5a418daSToby Isaac 421d53a3d6fSBarry Smith /* PetscSF support */ 422d53a3d6fSBarry Smith PETSC_EXTERN PetscErrorCode PetscSFConvertPartition(PetscSF, PetscSection, IS, ISLocalToGlobalMapping *, PetscSF *); 423d53a3d6fSBarry Smith PETSC_EXTERN PetscErrorCode PetscSFCreateRemoteOffsets(PetscSF, PetscSection, PetscSection, PetscInt **); 424d53a3d6fSBarry Smith PETSC_EXTERN PetscErrorCode PetscSFDistributeSection(PetscSF, PetscSection, PetscInt **, PetscSection); 425d53a3d6fSBarry Smith PETSC_EXTERN PetscErrorCode PetscSFCreateSectionSF(PetscSF, PetscSection, PetscInt [], PetscSection, PetscSF *); 426d53a3d6fSBarry Smith 427a2ce50c7SBarry Smith #endif 428