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 #if !defined(PETSCIS_H) 6 #define PETSCIS_H 7 #include <petscsys.h> 8 #include <petscsftypes.h> 9 #include <petscistypes.h> /*I "petscis.h" I*/ 10 11 #define IS_FILE_CLASSID 1211218 12 PETSC_EXTERN PetscClassId IS_CLASSID; 13 14 PETSC_EXTERN PetscErrorCode ISInitializePackage(void); 15 16 /*J 17 ISType - String with the name of a PETSc index set type 18 19 Level: beginner 20 21 .seealso: ISSetType(), IS, ISCreate(), ISRegister() 22 J*/ 23 typedef const char* ISType; 24 #define ISGENERAL "general" 25 #define ISSTRIDE "stride" 26 #define ISBLOCK "block" 27 28 /* Dynamic creation and loading functions */ 29 PETSC_EXTERN PetscFunctionList ISList; 30 PETSC_EXTERN PetscErrorCode ISSetType(IS, ISType); 31 PETSC_EXTERN PetscErrorCode ISGetType(IS, ISType *); 32 PETSC_EXTERN PetscErrorCode ISRegister(const char[],PetscErrorCode (*)(IS)); 33 PETSC_EXTERN PetscErrorCode ISCreate(MPI_Comm,IS*); 34 35 /* 36 Default index set data structures that PETSc provides. 37 */ 38 PETSC_EXTERN PetscErrorCode ISCreateGeneral(MPI_Comm,PetscInt,const PetscInt[],PetscCopyMode,IS *); 39 PETSC_EXTERN PetscErrorCode ISGeneralSetIndices(IS,PetscInt,const PetscInt[],PetscCopyMode); 40 PETSC_EXTERN PetscErrorCode ISCreateBlock(MPI_Comm,PetscInt,PetscInt,const PetscInt[],PetscCopyMode,IS *); 41 PETSC_EXTERN PetscErrorCode ISBlockSetIndices(IS,PetscInt,PetscInt,const PetscInt[],PetscCopyMode); 42 PETSC_EXTERN PetscErrorCode ISCreateStride(MPI_Comm,PetscInt,PetscInt,PetscInt,IS *); 43 PETSC_EXTERN PetscErrorCode ISStrideSetStride(IS,PetscInt,PetscInt,PetscInt); 44 45 PETSC_EXTERN PetscErrorCode ISDestroy(IS*); 46 PETSC_EXTERN PetscErrorCode ISSetPermutation(IS); 47 PETSC_EXTERN PetscErrorCode ISPermutation(IS,PetscBool *); 48 PETSC_EXTERN PetscErrorCode ISSetIdentity(IS); 49 PETSC_EXTERN PetscErrorCode ISIdentity(IS,PetscBool *); 50 PETSC_EXTERN PetscErrorCode ISContiguousLocal(IS,PetscInt,PetscInt,PetscInt*,PetscBool*); 51 52 PETSC_EXTERN PetscErrorCode ISGetIndices(IS,const PetscInt *[]); 53 PETSC_EXTERN PetscErrorCode ISRestoreIndices(IS,const PetscInt *[]); 54 PETSC_EXTERN PetscErrorCode ISGetTotalIndices(IS,const PetscInt *[]); 55 PETSC_EXTERN PetscErrorCode ISRestoreTotalIndices(IS,const PetscInt *[]); 56 PETSC_EXTERN PetscErrorCode ISGetNonlocalIndices(IS,const PetscInt *[]); 57 PETSC_EXTERN PetscErrorCode ISRestoreNonlocalIndices(IS,const PetscInt *[]); 58 PETSC_EXTERN PetscErrorCode ISGetNonlocalIS(IS, IS *is); 59 PETSC_EXTERN PetscErrorCode ISRestoreNonlocalIS(IS, IS *is); 60 PETSC_EXTERN PetscErrorCode ISGetSize(IS,PetscInt *); 61 PETSC_EXTERN PetscErrorCode ISGetLocalSize(IS,PetscInt *); 62 PETSC_EXTERN PetscErrorCode ISInvertPermutation(IS,PetscInt,IS*); 63 PETSC_EXTERN PetscErrorCode ISView(IS,PetscViewer); 64 PETSC_STATIC_INLINE PetscErrorCode ISViewFromOptions(IS A,PetscObject obj,const char name[]) {return PetscObjectViewFromOptions((PetscObject)A,obj,name);} 65 PETSC_EXTERN PetscErrorCode ISLoad(IS,PetscViewer); 66 PETSC_EXTERN PetscErrorCode ISEqual(IS,IS,PetscBool *); 67 PETSC_EXTERN PetscErrorCode ISEqualUnsorted(IS,IS,PetscBool *); 68 PETSC_EXTERN PetscErrorCode ISSort(IS); 69 PETSC_EXTERN PetscErrorCode ISSortRemoveDups(IS); 70 PETSC_EXTERN PetscErrorCode ISSorted(IS,PetscBool *); 71 PETSC_EXTERN PetscErrorCode ISDifference(IS,IS,IS*); 72 PETSC_EXTERN PetscErrorCode ISSum(IS,IS,IS*); 73 PETSC_EXTERN PetscErrorCode ISExpand(IS,IS,IS*); 74 PETSC_EXTERN PetscErrorCode ISIntersect(IS,IS,IS*); 75 PETSC_EXTERN PetscErrorCode ISGetMinMax(IS,PetscInt*,PetscInt*); 76 77 PETSC_EXTERN PetscErrorCode ISLocate(IS,PetscInt,PetscInt*); 78 PETSC_EXTERN PetscErrorCode ISGetPointRange(IS,PetscInt*,PetscInt*,const PetscInt**); 79 PETSC_EXTERN PetscErrorCode ISRestorePointRange(IS,PetscInt*,PetscInt*,const PetscInt**); 80 PETSC_EXTERN PetscErrorCode ISGetPointSubrange(IS,PetscInt,PetscInt,const PetscInt*); 81 82 PETSC_EXTERN PetscErrorCode ISBlockGetIndices(IS,const PetscInt *[]); 83 PETSC_EXTERN PetscErrorCode ISBlockRestoreIndices(IS,const PetscInt *[]); 84 PETSC_EXTERN PetscErrorCode ISBlockGetLocalSize(IS,PetscInt *); 85 PETSC_EXTERN PetscErrorCode ISBlockGetSize(IS,PetscInt *); 86 PETSC_EXTERN PetscErrorCode ISGetBlockSize(IS,PetscInt*); 87 PETSC_EXTERN PetscErrorCode ISSetBlockSize(IS,PetscInt); 88 89 PETSC_EXTERN PetscErrorCode ISStrideGetInfo(IS,PetscInt *,PetscInt*); 90 91 PETSC_EXTERN PetscErrorCode ISToGeneral(IS); 92 93 PETSC_EXTERN PetscErrorCode ISDuplicate(IS,IS*); 94 PETSC_EXTERN PetscErrorCode ISCopy(IS,IS); 95 PETSC_EXTERN PetscErrorCode ISAllGather(IS,IS*); 96 PETSC_EXTERN PetscErrorCode ISComplement(IS,PetscInt,PetscInt,IS*); 97 PETSC_EXTERN PetscErrorCode ISConcatenate(MPI_Comm,PetscInt,const IS[],IS*); 98 PETSC_EXTERN PetscErrorCode ISListToPair(MPI_Comm,PetscInt, IS[],IS*,IS*); 99 PETSC_EXTERN PetscErrorCode ISPairToList(IS,IS,PetscInt*, IS *[]); 100 PETSC_EXTERN PetscErrorCode ISEmbed(IS,IS,PetscBool,IS*); 101 PETSC_EXTERN PetscErrorCode ISSortPermutation(IS,PetscBool,IS*); 102 PETSC_EXTERN PetscErrorCode ISOnComm(IS,MPI_Comm,PetscCopyMode,IS*); 103 PETSC_EXTERN PetscErrorCode ISRenumber(IS,IS,PetscInt*,IS*); 104 PETSC_EXTERN PetscErrorCode ISCreateSubIS(IS,IS,IS*); 105 106 PETSC_EXTERN PetscErrorCode ISGeneralFilter(IS,PetscInt,PetscInt); 107 108 /* --------------------------------------------------------------------------*/ 109 PETSC_EXTERN PetscClassId IS_LTOGM_CLASSID; 110 111 /*E 112 ISGlobalToLocalMappingMode - Indicates if missing global indices are 113 114 IS_GTOLM_MASK - missing global indices are replaced with -1 115 IS_GTOLM_DROP - missing global indices are dropped 116 117 Level: beginner 118 119 .seealso: ISGlobalToLocalMappingApplyBlock(), ISGlobalToLocalMappingApply() 120 121 E*/ 122 typedef enum {IS_GTOLM_MASK,IS_GTOLM_DROP} ISGlobalToLocalMappingMode; 123 124 /*J 125 ISLocalToGlobalMappingType - String with the name of a mapping method 126 127 Level: beginner 128 129 .seealso: ISLocalToGlobalMappingSetType(), ISLocalToGlobalSetFromOptions() 130 J*/ 131 typedef const char* ISLocalToGlobalMappingType; 132 #define ISLOCALTOGLOBALMAPPINGBASIC "basic" 133 #define ISLOCALTOGLOBALMAPPINGHASH "hash" 134 135 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingSetType(ISLocalToGlobalMapping,ISLocalToGlobalMappingType); 136 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingRegister(const char[],PetscErrorCode (*)(ISLocalToGlobalMapping)); 137 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingRegisterAll(void); 138 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingCreate(MPI_Comm,PetscInt,PetscInt,const PetscInt[],PetscCopyMode,ISLocalToGlobalMapping*); 139 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingCreateIS(IS,ISLocalToGlobalMapping *); 140 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingCreateSF(PetscSF,PetscInt,ISLocalToGlobalMapping*); 141 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingSetFromOptions(ISLocalToGlobalMapping); 142 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingSetUp(ISLocalToGlobalMapping); 143 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingView(ISLocalToGlobalMapping,PetscViewer); 144 PETSC_STATIC_INLINE PetscErrorCode ISLocalToGlobalMappingViewFromOptions(ISLocalToGlobalMapping A,PetscObject B,const char name[]) {return PetscObjectViewFromOptions((PetscObject)A,B,name);} 145 146 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingDestroy(ISLocalToGlobalMapping*); 147 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingApply(ISLocalToGlobalMapping,PetscInt,const PetscInt[],PetscInt[]); 148 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingApplyBlock(ISLocalToGlobalMapping,PetscInt,const PetscInt[],PetscInt[]); 149 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingApplyIS(ISLocalToGlobalMapping,IS,IS*); 150 PETSC_EXTERN PetscErrorCode ISGlobalToLocalMappingApply(ISLocalToGlobalMapping,ISGlobalToLocalMappingMode,PetscInt,const PetscInt[],PetscInt*,PetscInt[]); 151 PETSC_EXTERN PetscErrorCode ISGlobalToLocalMappingApplyBlock(ISLocalToGlobalMapping,ISGlobalToLocalMappingMode,PetscInt,const PetscInt[],PetscInt*,PetscInt[]); 152 PETSC_EXTERN PetscErrorCode ISGlobalToLocalMappingApplyIS(ISLocalToGlobalMapping,ISGlobalToLocalMappingMode,IS,IS*); 153 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingGetSize(ISLocalToGlobalMapping,PetscInt*); 154 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingGetNodeInfo(ISLocalToGlobalMapping,PetscInt*,PetscInt*[],PetscInt**[]); 155 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingRestoreNodeInfo(ISLocalToGlobalMapping,PetscInt*,PetscInt*[],PetscInt**[]); 156 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingGetInfo(ISLocalToGlobalMapping,PetscInt*,PetscInt*[],PetscInt*[],PetscInt**[]); 157 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingRestoreInfo(ISLocalToGlobalMapping,PetscInt*,PetscInt*[],PetscInt*[],PetscInt**[]); 158 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingGetBlockInfo(ISLocalToGlobalMapping,PetscInt*,PetscInt*[],PetscInt*[],PetscInt**[]); 159 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingRestoreBlockInfo(ISLocalToGlobalMapping,PetscInt*,PetscInt*[],PetscInt*[],PetscInt**[]); 160 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingGetIndices(ISLocalToGlobalMapping,const PetscInt**); 161 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingRestoreIndices(ISLocalToGlobalMapping,const PetscInt**); 162 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingGetBlockIndices(ISLocalToGlobalMapping,const PetscInt**); 163 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingRestoreBlockIndices(ISLocalToGlobalMapping,const PetscInt**); 164 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingConcatenate(MPI_Comm,PetscInt,const ISLocalToGlobalMapping[],ISLocalToGlobalMapping*); 165 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingGetBlockSize(ISLocalToGlobalMapping,PetscInt*); 166 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingSetBlockSize(ISLocalToGlobalMapping,PetscInt); 167 PETSC_EXTERN PetscErrorCode ISLocalToGlobalMappingDuplicate(ISLocalToGlobalMapping,ISLocalToGlobalMapping*); 168 169 170 /* --------------------------------------------------------------------------*/ 171 /*E 172 ISColoringType - determines if the coloring is for the entire parallel grid/graph/matrix 173 or for just the local ghosted portion 174 175 Level: beginner 176 177 $ IS_COLORING_GLOBAL - does not include the colors for ghost points, this is used when the function 178 $ is called synchronously in parallel. This requires generating a "parallel coloring". 179 $ IS_COLORING_LOCAL - includes colors for ghost points, this is used when the function can be called 180 $ separately on individual processes with the ghost points already filled in. Does not 181 $ require a "parallel coloring", rather each process colors its local + ghost part. 182 $ Using this can result in much less parallel communication. Currently only works 183 $ with DMDA and if you call MatFDColoringSetFunction() with the local function. 184 185 .seealso: DMCreateColoring() 186 E*/ 187 typedef enum {IS_COLORING_GLOBAL,IS_COLORING_LOCAL} ISColoringType; 188 PETSC_EXTERN const char *const ISColoringTypes[]; 189 typedef unsigned PETSC_IS_COLOR_VALUE_TYPE ISColoringValue; 190 PETSC_EXTERN PetscErrorCode ISAllGatherColors(MPI_Comm,PetscInt,ISColoringValue*,PetscInt*,ISColoringValue*[]); 191 192 PETSC_EXTERN PetscErrorCode ISColoringCreate(MPI_Comm,PetscInt,PetscInt,const ISColoringValue[],PetscCopyMode,ISColoring*); 193 PETSC_EXTERN PetscErrorCode ISColoringDestroy(ISColoring*); 194 PETSC_EXTERN PetscErrorCode ISColoringView(ISColoring,PetscViewer); 195 PETSC_EXTERN PetscErrorCode ISColoringViewFromOptions(ISColoring,PetscObject,const char[]); 196 PETSC_EXTERN PetscErrorCode ISColoringGetIS(ISColoring,PetscCopyMode,PetscInt*,IS*[]); 197 PETSC_EXTERN PetscErrorCode ISColoringRestoreIS(ISColoring,PetscCopyMode,IS*[]); 198 PETSC_EXTERN PetscErrorCode ISColoringReference(ISColoring); 199 PETSC_EXTERN PetscErrorCode ISColoringSetType(ISColoring,ISColoringType); 200 PETSC_EXTERN PetscErrorCode ISColoringGetType(ISColoring,ISColoringType*); 201 PETSC_EXTERN PetscErrorCode ISColoringGetColors(ISColoring,PetscInt*,PetscInt*,const ISColoringValue**); 202 203 /* --------------------------------------------------------------------------*/ 204 PETSC_EXTERN PetscErrorCode ISBuildTwoSided(IS,IS,IS*); 205 PETSC_EXTERN PetscErrorCode ISPartitioningToNumbering(IS,IS*); 206 PETSC_EXTERN PetscErrorCode ISPartitioningCount(IS,PetscInt,PetscInt[]); 207 208 PETSC_EXTERN PetscErrorCode ISCompressIndicesGeneral(PetscInt,PetscInt,PetscInt,PetscInt,const IS[],IS[]); 209 PETSC_EXTERN PetscErrorCode ISCompressIndicesSorted(PetscInt,PetscInt,PetscInt,const IS[],IS[]); 210 PETSC_EXTERN PetscErrorCode ISExpandIndicesGeneral(PetscInt,PetscInt,PetscInt,PetscInt,const IS[],IS[]); 211 212 213 struct _n_PetscLayout{ 214 MPI_Comm comm; 215 PetscInt n,N; /* local, global vector size */ 216 PetscInt rstart,rend; /* local start, local end + 1 */ 217 PetscInt *range; /* the offset of each processor */ 218 PetscBool range_alloc; /* should range be freed in Destroy? */ 219 PetscInt bs; /* number of elements in each block (generally for multi-component 220 * problems). Defaults to -1 and can be arbitrarily lazy so always use 221 * PetscAbs(map->bs) when accessing directly and expecting result to be 222 * positive. Do NOT multiply above numbers by bs */ 223 PetscInt refcnt; /* MPI Vecs obtained with VecDuplicate() and from MatCreateVecs() reuse map of input object */ 224 ISLocalToGlobalMapping mapping; /* mapping used in Vec/MatSetValuesLocal() */ 225 PetscBool setupcalled; /* Forbid setup more than once */ 226 PetscInt oldn,oldN; /* Checking if setup is allowed */ 227 PetscInt oldbs; /* And again */ 228 }; 229 230 /*@C 231 PetscLayoutFindOwner - Find the owning rank for a global index 232 233 Not Collective 234 235 Input Parameters: 236 + map - the layout 237 - idx - global index to find the owner of 238 239 Output Parameter: 240 . owner - the owning rank 241 242 Level: developer 243 244 Fortran Notes: 245 Not available from Fortran 246 247 @*/ 248 PETSC_STATIC_INLINE PetscErrorCode PetscLayoutFindOwner(PetscLayout map,PetscInt idx,PetscInt *owner) 249 { 250 PetscErrorCode ierr; 251 PetscMPIInt lo = 0,hi,t; 252 253 PetscFunctionBegin; 254 *owner = -1; /* GCC erroneously issues warning about possibly uninitialized use when error condition */ 255 if (!((map->n >= 0) && (map->N >= 0) && (map->range))) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONGSTATE,"PetscLayoutSetUp() must be called first"); 256 if (idx < 0 || idx > map->N) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Index %D is out of range",idx); 257 ierr = MPI_Comm_size(map->comm,&hi);CHKERRQ(ierr); 258 while (hi - lo > 1) { 259 t = lo + (hi - lo) / 2; 260 if (idx < map->range[t]) hi = t; 261 else lo = t; 262 } 263 *owner = lo; 264 PetscFunctionReturn(0); 265 } 266 267 /*@C 268 PetscLayoutFindOwnerIndex - Find the owning rank and the local index for a global index 269 270 Not Collective 271 272 Input Parameters: 273 + map - the layout 274 - idx - global index to find the owner of 275 276 Output Parameter: 277 + owner - the owning rank 278 - lidx - local index used by the owner for idx 279 280 Level: developer 281 282 Fortran Notes: 283 Not available from Fortran 284 285 @*/ 286 PETSC_STATIC_INLINE PetscErrorCode PetscLayoutFindOwnerIndex(PetscLayout map,PetscInt idx,PetscInt *owner, PetscInt *lidx) 287 { 288 PetscErrorCode ierr; 289 PetscMPIInt lo = 0,hi,t; 290 291 PetscFunctionBegin; 292 if (!((map->n >= 0) && (map->N >= 0) && (map->range))) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONGSTATE,"PetscLayoutSetUp() must be called first"); 293 if (idx < 0 || idx > map->N) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Index %D is out of range",idx); 294 ierr = MPI_Comm_size(map->comm,&hi);CHKERRQ(ierr); 295 while (hi - lo > 1) { 296 t = lo + (hi - lo) / 2; 297 if (idx < map->range[t]) hi = t; 298 else lo = t; 299 } 300 if (owner) *owner = lo; 301 if (lidx) *lidx = idx-map->range[lo]; 302 PetscFunctionReturn(0); 303 } 304 305 PETSC_EXTERN PetscErrorCode PetscLayoutCreate(MPI_Comm,PetscLayout*); 306 PETSC_EXTERN PetscErrorCode PetscLayoutCreateFromSizes(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscLayout*); 307 PETSC_EXTERN PetscErrorCode PetscLayoutCreateFromRanges(MPI_Comm,const PetscInt[],PetscCopyMode,PetscInt,PetscLayout*); 308 PETSC_EXTERN PetscErrorCode PetscLayoutSetUp(PetscLayout); 309 PETSC_EXTERN PetscErrorCode PetscLayoutDestroy(PetscLayout*); 310 PETSC_EXTERN PetscErrorCode PetscLayoutDuplicate(PetscLayout,PetscLayout*); 311 PETSC_EXTERN PetscErrorCode PetscLayoutReference(PetscLayout,PetscLayout*); 312 PETSC_EXTERN PetscErrorCode PetscLayoutSetLocalSize(PetscLayout,PetscInt); 313 PETSC_EXTERN PetscErrorCode PetscLayoutGetLocalSize(PetscLayout,PetscInt *); 314 PETSC_EXTERN PetscErrorCode PetscLayoutSetSize(PetscLayout,PetscInt); 315 PETSC_EXTERN PetscErrorCode PetscLayoutGetSize(PetscLayout,PetscInt *); 316 PETSC_EXTERN PetscErrorCode PetscLayoutSetBlockSize(PetscLayout,PetscInt); 317 PETSC_EXTERN PetscErrorCode PetscLayoutGetBlockSize(PetscLayout,PetscInt*); 318 PETSC_EXTERN PetscErrorCode PetscLayoutGetRange(PetscLayout,PetscInt *,PetscInt *); 319 PETSC_EXTERN PetscErrorCode PetscLayoutGetRanges(PetscLayout,const PetscInt *[]); 320 PETSC_EXTERN PetscErrorCode PetscLayoutCompare(PetscLayout,PetscLayout,PetscBool*); 321 PETSC_EXTERN PetscErrorCode PetscLayoutSetISLocalToGlobalMapping(PetscLayout,ISLocalToGlobalMapping); 322 PETSC_EXTERN PetscErrorCode PetscLayoutMapLocal(PetscLayout,PetscInt,const PetscInt[],PetscInt*,PetscInt**,PetscInt**); 323 PETSC_EXTERN PetscErrorCode PetscSFSetGraphLayout(PetscSF,PetscLayout,PetscInt,const PetscInt*,PetscCopyMode,const PetscInt*); 324 325 326 PETSC_EXTERN PetscClassId PETSC_SECTION_CLASSID; 327 328 PETSC_EXTERN PetscErrorCode PetscSectionCreate(MPI_Comm,PetscSection*); 329 PETSC_EXTERN PetscErrorCode PetscSectionClone(PetscSection, PetscSection*); 330 PETSC_EXTERN PetscErrorCode PetscSectionSetFromOptions(PetscSection); 331 PETSC_EXTERN PetscErrorCode PetscSectionCopy(PetscSection, PetscSection); 332 PETSC_EXTERN PetscErrorCode PetscSectionCompare(PetscSection, PetscSection, PetscBool*); 333 PETSC_EXTERN PetscErrorCode PetscSectionGetNumFields(PetscSection, PetscInt *); 334 PETSC_EXTERN PetscErrorCode PetscSectionSetNumFields(PetscSection, PetscInt); 335 PETSC_EXTERN PetscErrorCode PetscSectionGetFieldName(PetscSection, PetscInt, const char *[]); 336 PETSC_EXTERN PetscErrorCode PetscSectionSetFieldName(PetscSection, PetscInt, const char []); 337 PETSC_EXTERN PetscErrorCode PetscSectionGetFieldComponents(PetscSection, PetscInt, PetscInt *); 338 PETSC_EXTERN PetscErrorCode PetscSectionSetFieldComponents(PetscSection, PetscInt, PetscInt); 339 PETSC_EXTERN PetscErrorCode PetscSectionGetChart(PetscSection, PetscInt *, PetscInt *); 340 PETSC_EXTERN PetscErrorCode PetscSectionSetChart(PetscSection, PetscInt, PetscInt); 341 PETSC_EXTERN PetscErrorCode PetscSectionGetPermutation(PetscSection, IS *); 342 PETSC_EXTERN PetscErrorCode PetscSectionSetPermutation(PetscSection, IS); 343 PETSC_EXTERN PetscErrorCode PetscSectionGetPointMajor(PetscSection, PetscBool *); 344 PETSC_EXTERN PetscErrorCode PetscSectionSetPointMajor(PetscSection, PetscBool); 345 PETSC_EXTERN PetscErrorCode PetscSectionGetDof(PetscSection, PetscInt, PetscInt*); 346 PETSC_EXTERN PetscErrorCode PetscSectionSetDof(PetscSection, PetscInt, PetscInt); 347 PETSC_EXTERN PetscErrorCode PetscSectionAddDof(PetscSection, PetscInt, PetscInt); 348 PETSC_EXTERN PetscErrorCode PetscSectionGetFieldDof(PetscSection, PetscInt, PetscInt, PetscInt*); 349 PETSC_EXTERN PetscErrorCode PetscSectionSetFieldDof(PetscSection, PetscInt, PetscInt, PetscInt); 350 PETSC_EXTERN PetscErrorCode PetscSectionAddFieldDof(PetscSection, PetscInt, PetscInt, PetscInt); 351 PETSC_EXTERN PetscErrorCode PetscSectionHasConstraints(PetscSection, PetscBool *); 352 PETSC_EXTERN PetscErrorCode PetscSectionGetConstraintDof(PetscSection, PetscInt, PetscInt*); 353 PETSC_EXTERN PetscErrorCode PetscSectionSetConstraintDof(PetscSection, PetscInt, PetscInt); 354 PETSC_EXTERN PetscErrorCode PetscSectionAddConstraintDof(PetscSection, PetscInt, PetscInt); 355 PETSC_EXTERN PetscErrorCode PetscSectionGetFieldConstraintDof(PetscSection, PetscInt, PetscInt, PetscInt*); 356 PETSC_EXTERN PetscErrorCode PetscSectionSetFieldConstraintDof(PetscSection, PetscInt, PetscInt, PetscInt); 357 PETSC_EXTERN PetscErrorCode PetscSectionAddFieldConstraintDof(PetscSection, PetscInt, PetscInt, PetscInt); 358 PETSC_EXTERN PetscErrorCode PetscSectionGetConstraintIndices(PetscSection, PetscInt, const PetscInt**); 359 PETSC_EXTERN PetscErrorCode PetscSectionSetConstraintIndices(PetscSection, PetscInt, const PetscInt*); 360 PETSC_EXTERN PetscErrorCode PetscSectionGetFieldConstraintIndices(PetscSection, PetscInt, PetscInt, const PetscInt**); 361 PETSC_EXTERN PetscErrorCode PetscSectionSetFieldConstraintIndices(PetscSection, PetscInt, PetscInt, const PetscInt*); 362 PETSC_EXTERN PetscErrorCode PetscSectionSetUpBC(PetscSection); 363 PETSC_EXTERN PetscErrorCode PetscSectionSetUp(PetscSection); 364 PETSC_EXTERN PetscErrorCode PetscSectionGetMaxDof(PetscSection, PetscInt*); 365 PETSC_EXTERN PetscErrorCode PetscSectionGetStorageSize(PetscSection, PetscInt*); 366 PETSC_EXTERN PetscErrorCode PetscSectionGetConstrainedStorageSize(PetscSection, PetscInt*); 367 PETSC_EXTERN PetscErrorCode PetscSectionGetOffset(PetscSection, PetscInt, PetscInt*); 368 PETSC_EXTERN PetscErrorCode PetscSectionSetOffset(PetscSection, PetscInt, PetscInt); 369 PETSC_EXTERN PetscErrorCode PetscSectionGetFieldOffset(PetscSection, PetscInt, PetscInt, PetscInt*); 370 PETSC_EXTERN PetscErrorCode PetscSectionSetFieldOffset(PetscSection, PetscInt, PetscInt, PetscInt); 371 PETSC_EXTERN PetscErrorCode PetscSectionGetFieldPointOffset(PetscSection, PetscInt, PetscInt, PetscInt*); 372 PETSC_EXTERN PetscErrorCode PetscSectionGetOffsetRange(PetscSection, PetscInt *, PetscInt *); 373 PETSC_EXTERN PetscErrorCode PetscSectionView(PetscSection, PetscViewer); 374 PETSC_STATIC_INLINE PetscErrorCode PetscSectionViewFromOptions(PetscSection A,PetscObject obj,const char name[]) {return PetscObjectViewFromOptions((PetscObject)A,obj,name);} 375 PETSC_EXTERN PetscErrorCode PetscSectionReset(PetscSection); 376 PETSC_EXTERN PetscErrorCode PetscSectionDestroy(PetscSection*); 377 PETSC_EXTERN PetscErrorCode PetscSectionCreateGlobalSection(PetscSection, PetscSF, PetscBool, PetscBool, PetscSection *); 378 PETSC_EXTERN PetscErrorCode PetscSectionCreateGlobalSectionCensored(PetscSection, PetscSF, PetscBool, PetscInt, const PetscInt [], PetscSection *); 379 PETSC_EXTERN PetscErrorCode PetscSectionCreateSubsection(PetscSection, PetscInt, const PetscInt [], PetscSection *); 380 PETSC_EXTERN PetscErrorCode PetscSectionCreateSupersection(PetscSection[], PetscInt, PetscSection *); 381 PETSC_EXTERN PetscErrorCode PetscSectionCreateSubmeshSection(PetscSection, IS, PetscSection *); 382 PETSC_EXTERN PetscErrorCode PetscSectionGetPointLayout(MPI_Comm, PetscSection, PetscLayout *); 383 PETSC_EXTERN PetscErrorCode PetscSectionGetValueLayout(MPI_Comm, PetscSection, PetscLayout *); 384 PETSC_EXTERN PetscErrorCode PetscSectionPermute(PetscSection, IS, PetscSection *); 385 PETSC_EXTERN PetscErrorCode PetscSectionGetField(PetscSection, PetscInt, PetscSection *); 386 PETSC_EXTERN PetscErrorCode PetscSectionSetUseFieldOffsets(PetscSection, PetscBool); 387 PETSC_EXTERN PetscErrorCode PetscSectionGetUseFieldOffsets(PetscSection, PetscBool *); 388 PETSC_EXTERN PetscErrorCode PetscSectionExtractDofsFromArray(PetscSection, MPI_Datatype, const void *, IS, PetscSection *, void *[]); 389 390 PETSC_EXTERN PetscErrorCode PetscSectionSetClosureIndex(PetscSection, PetscObject, PetscSection, IS); 391 PETSC_EXTERN PetscErrorCode PetscSectionGetClosureIndex(PetscSection, PetscObject, PetscSection *, IS *); 392 PETSC_EXTERN PetscErrorCode PetscSectionSetClosurePermutation(PetscSection, PetscObject, IS); 393 PETSC_EXTERN PetscErrorCode PetscSectionGetClosurePermutation(PetscSection, PetscObject, IS *); 394 PETSC_EXTERN PetscErrorCode PetscSectionGetClosureInversePermutation(PetscSection, PetscObject, IS *); 395 396 PETSC_EXTERN PetscClassId PETSC_SECTION_SYM_CLASSID; 397 398 /*J 399 PetscSectionSymType - String with the name of a PetscSectionSym type. 400 401 Level: developer 402 403 Notes: 404 PetscSectionSym has no default implementation, but is used by DM in PetscSectionSymCreateLabel(). 405 406 .seealso: PetscSectionSymSetType(), PetscSectionSym, PetscSectionSymCreate(), PetscSectionSymRegister() 407 J*/ 408 typedef const char *PetscSectionSymType; 409 410 PETSC_EXTERN PetscFunctionList PetscSectionSymList; 411 PETSC_EXTERN PetscErrorCode PetscSectionSymSetType(PetscSectionSym, PetscSectionSymType); 412 PETSC_EXTERN PetscErrorCode PetscSectionSymGetType(PetscSectionSym, PetscSectionSymType*); 413 PETSC_EXTERN PetscErrorCode PetscSectionSymRegister(const char[],PetscErrorCode (*)(PetscSectionSym)); 414 415 PETSC_EXTERN PetscErrorCode PetscSectionSymCreate(MPI_Comm, PetscSectionSym*); 416 PETSC_EXTERN PetscErrorCode PetscSectionSymDestroy(PetscSectionSym*); 417 PETSC_EXTERN PetscErrorCode PetscSectionSymView(PetscSectionSym,PetscViewer); 418 419 PETSC_EXTERN PetscErrorCode PetscSectionSetSym(PetscSection, PetscSectionSym); 420 PETSC_EXTERN PetscErrorCode PetscSectionGetSym(PetscSection, PetscSectionSym*); 421 PETSC_EXTERN PetscErrorCode PetscSectionSetFieldSym(PetscSection, PetscInt, PetscSectionSym); 422 PETSC_EXTERN PetscErrorCode PetscSectionGetFieldSym(PetscSection, PetscInt, PetscSectionSym*); 423 424 PETSC_EXTERN PetscErrorCode PetscSectionGetPointSyms(PetscSection, PetscInt, const PetscInt *, const PetscInt ***, const PetscScalar ***); 425 PETSC_EXTERN PetscErrorCode PetscSectionRestorePointSyms(PetscSection, PetscInt, const PetscInt *, const PetscInt ***, const PetscScalar ***); 426 PETSC_EXTERN PetscErrorCode PetscSectionGetFieldPointSyms(PetscSection, PetscInt, PetscInt, const PetscInt *, const PetscInt ***, const PetscScalar ***); 427 PETSC_EXTERN PetscErrorCode PetscSectionRestoreFieldPointSyms(PetscSection, PetscInt, PetscInt, const PetscInt *, const PetscInt ***, const PetscScalar ***); 428 429 430 /* PetscSF support */ 431 PETSC_EXTERN PetscErrorCode PetscSFConvertPartition(PetscSF, PetscSection, IS, ISLocalToGlobalMapping *, PetscSF *); 432 PETSC_EXTERN PetscErrorCode PetscSFCreateRemoteOffsets(PetscSF, PetscSection, PetscSection, PetscInt **); 433 PETSC_EXTERN PetscErrorCode PetscSFDistributeSection(PetscSF, PetscSection, PetscInt **, PetscSection); 434 PETSC_EXTERN PetscErrorCode PetscSFCreateSectionSF(PetscSF, PetscSection, PetscInt [], PetscSection, PetscSF *); 435 436 #endif 437