1 #ifndef PETSC_DMSTAG_H 2 #define PETSC_DMSTAG_H 3 4 #include <petscdm.h> 5 #include <petscdmproduct.h> 6 7 /* SUBMANSEC = DMStag */ 8 9 /*E 10 DMStagStencilLocation - enumerated type denoted a location relative to an element in a `DMSTAG` grid 11 12 The interpretation of these values is dimension-dependent. 13 14 Level: beginner 15 16 .seealso: `DMSTAG`, `DMStagStencil`, `DMStagGetLocationSlot()` 17 E*/ 18 19 /* The order of these entries is significant, as it corresponds to the canonical numbering 20 of DOFs, and the fact the the numbering starts at 0 may also be used by the implementation */ 21 typedef enum { 22 DMSTAG_NULL_LOCATION = 0, 23 DMSTAG_BACK_DOWN_LEFT, 24 DMSTAG_BACK_DOWN, 25 DMSTAG_BACK_DOWN_RIGHT, 26 DMSTAG_BACK_LEFT, 27 DMSTAG_BACK, 28 DMSTAG_BACK_RIGHT, 29 DMSTAG_BACK_UP_LEFT, 30 DMSTAG_BACK_UP, 31 DMSTAG_BACK_UP_RIGHT, 32 DMSTAG_DOWN_LEFT, 33 DMSTAG_DOWN, 34 DMSTAG_DOWN_RIGHT, 35 DMSTAG_LEFT, 36 DMSTAG_ELEMENT, 37 DMSTAG_RIGHT, 38 DMSTAG_UP_LEFT, 39 DMSTAG_UP, 40 DMSTAG_UP_RIGHT, 41 DMSTAG_FRONT_DOWN_LEFT, 42 DMSTAG_FRONT_DOWN, 43 DMSTAG_FRONT_DOWN_RIGHT, 44 DMSTAG_FRONT_LEFT, 45 DMSTAG_FRONT, 46 DMSTAG_FRONT_RIGHT, 47 DMSTAG_FRONT_UP_LEFT, 48 DMSTAG_FRONT_UP, 49 DMSTAG_FRONT_UP_RIGHT 50 } DMStagStencilLocation; 51 PETSC_EXTERN const char *const DMStagStencilLocations[]; /* Corresponding strings (see stagstencil.c) */ 52 53 /*S 54 DMStagStencil - data structure representing a degree of freedom on a `DMSTAG` grid 55 56 Data structure (C struct), analogous to describing a degree of freedom associated with a `DMSTAG` object, 57 in terms of a global element index in each of up to three directions, a "location" as defined by `DMStagStencilLocation`, 58 and a component number. Primarily for use with `DMStagMatSetValuesStencil()` (compare with use of `MatStencil` with `MatSetValuesStencil()`). 59 60 Note: 61 The component (c) field must always be set, even if there is a single component at a given location (in which case c should be set to 0). 62 63 Level: beginner 64 65 .seealso: `DMSTAG`, `DMStagMatSetValuesStencil()`, `DMStagVecSetValuesStencil()`, `DMStagStencilLocation`, `DMStagSetStencilWidth()`, `DMStagSetStencilType()`, `DMStagVecGetValuesStencil()` 66 S*/ 67 typedef struct { 68 DMStagStencilLocation loc; 69 PetscInt i, j, k, c; 70 } DMStagStencil; 71 72 /*E 73 DMStagStencilType - Elementwise stencil type, determining which neighbors participate in communication 74 75 Level: beginner 76 77 .seealso: `DMSTAG`, `DMStagCreate1d()`, `DMStagCreate2d()`, `DMStagCreate3d()`, `DMStagStencil`, `DMDAStencilType` 78 E*/ 79 80 typedef enum { 81 DMSTAG_STENCIL_NONE = 0, 82 DMSTAG_STENCIL_STAR, 83 DMSTAG_STENCIL_BOX 84 } DMStagStencilType; 85 PETSC_EXTERN const char *const DMStagStencilTypes[]; /* Corresponding strings (see stagstencil.c) */ 86 87 PETSC_EXTERN PetscErrorCode DMCreate_Stag(DM); 88 PETSC_EXTERN PetscErrorCode DMStagCreate1d(MPI_Comm, DMBoundaryType, PetscInt, PetscInt, PetscInt, DMStagStencilType, PetscInt, const PetscInt[], DM *); 89 PETSC_EXTERN PetscErrorCode DMStagCreate2d(MPI_Comm, DMBoundaryType, DMBoundaryType, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, DMStagStencilType, PetscInt, const PetscInt[], const PetscInt[], DM *); 90 PETSC_EXTERN PetscErrorCode DMStagCreate3d(MPI_Comm, DMBoundaryType, DMBoundaryType, DMBoundaryType, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, DMStagStencilType, PetscInt, const PetscInt[], const PetscInt[], const PetscInt[], DM *); 91 PETSC_EXTERN PetscErrorCode DMStagCreateCompatibleDMStag(DM, PetscInt, PetscInt, PetscInt, PetscInt, DM *); 92 PETSC_EXTERN PetscErrorCode DMStagCreateISFromStencils(DM, PetscInt, DMStagStencil *, IS *); 93 PETSC_EXTERN PetscErrorCode DMStagGetBoundaryTypes(DM, DMBoundaryType *, DMBoundaryType *, DMBoundaryType *); 94 PETSC_EXTERN PetscErrorCode DMStagGetCorners(DM, PetscInt *, PetscInt *, PetscInt *, PetscInt *, PetscInt *, PetscInt *, PetscInt *, PetscInt *, PetscInt *); 95 PETSC_EXTERN PetscErrorCode DMStagGetDOF(DM, PetscInt *, PetscInt *, PetscInt *, PetscInt *); 96 PETSC_EXTERN PetscErrorCode DMStagGetEntries(DM, PetscInt *); 97 PETSC_EXTERN PetscErrorCode DMStagGetEntriesLocal(DM, PetscInt *); 98 PETSC_EXTERN PetscErrorCode DMStagGetEntriesPerElement(DM, PetscInt *); 99 PETSC_EXTERN PetscErrorCode DMStagGetGhostCorners(DM, PetscInt *, PetscInt *, PetscInt *, PetscInt *, PetscInt *, PetscInt *); 100 PETSC_EXTERN PetscErrorCode DMStagGetGlobalSizes(DM, PetscInt *, PetscInt *, PetscInt *); 101 PETSC_EXTERN PetscErrorCode DMStagGetIsFirstRank(DM, PetscBool *, PetscBool *, PetscBool *); 102 PETSC_EXTERN PetscErrorCode DMStagGetIsLastRank(DM, PetscBool *, PetscBool *, PetscBool *); 103 PETSC_EXTERN PetscErrorCode DMStagGetLocalSizes(DM, PetscInt *, PetscInt *, PetscInt *); 104 PETSC_EXTERN PetscErrorCode DMStagGetLocationDOF(DM, DMStagStencilLocation, PetscInt *); 105 PETSC_EXTERN PetscErrorCode DMStagGetLocationSlot(DM, DMStagStencilLocation, PetscInt, PetscInt *); 106 PETSC_EXTERN PetscErrorCode DMStagGetNumRanks(DM, PetscInt *, PetscInt *, PetscInt *); 107 PETSC_EXTERN PetscErrorCode DMStagGetOwnershipRanges(DM, const PetscInt **, const PetscInt **, const PetscInt **); 108 PETSC_EXTERN PetscErrorCode DMStagGetProductCoordinateArrays(DM, void *, void *, void *); 109 PETSC_EXTERN PetscErrorCode DMStagGetProductCoordinateArraysRead(DM, void *, void *, void *); 110 PETSC_EXTERN PetscErrorCode DMStagGetProductCoordinateLocationSlot(DM, DMStagStencilLocation, PetscInt *); 111 PETSC_EXTERN PetscErrorCode DMStagGetStencilType(DM, DMStagStencilType *); 112 PETSC_EXTERN PetscErrorCode DMStagGetStencilWidth(DM, PetscInt *); 113 PETSC_EXTERN PetscErrorCode DMStagMatGetValuesStencil(DM, Mat, PetscInt, const DMStagStencil *, PetscInt, const DMStagStencil *, PetscScalar *); 114 PETSC_EXTERN PetscErrorCode DMStagMatSetValuesStencil(DM, Mat, PetscInt, const DMStagStencil *, PetscInt, const DMStagStencil *, const PetscScalar *, InsertMode); 115 PETSC_EXTERN PetscErrorCode DMStagMigrateVec(DM, Vec, DM, Vec); 116 PETSC_EXTERN PetscErrorCode DMStagPopulateLocalToGlobalInjective(DM); 117 PETSC_EXTERN PetscErrorCode DMStagRestoreProductCoordinateArrays(DM, void *, void *, void *); 118 PETSC_EXTERN PetscErrorCode DMStagRestoreProductCoordinateArraysRead(DM, void *, void *, void *); 119 PETSC_EXTERN PetscErrorCode DMStagRestrictSimple(DM, Vec, DM, Vec); 120 PETSC_EXTERN PetscErrorCode DMStagSetBoundaryTypes(DM, DMBoundaryType, DMBoundaryType, DMBoundaryType); 121 PETSC_EXTERN PetscErrorCode DMStagSetCoordinateDMType(DM, DMType); 122 PETSC_EXTERN PetscErrorCode DMStagSetDOF(DM, PetscInt, PetscInt, PetscInt, PetscInt); 123 PETSC_EXTERN PetscErrorCode DMStagSetGlobalSizes(DM, PetscInt, PetscInt, PetscInt); 124 PETSC_EXTERN PetscErrorCode DMStagSetNumRanks(DM, PetscInt, PetscInt, PetscInt); 125 PETSC_EXTERN PetscErrorCode DMStagSetOwnershipRanges(DM, PetscInt const *, PetscInt const *, PetscInt const *); 126 PETSC_EXTERN PetscErrorCode DMStagSetStencilType(DM, DMStagStencilType); 127 PETSC_EXTERN PetscErrorCode DMStagSetStencilWidth(DM, PetscInt); 128 PETSC_EXTERN PetscErrorCode DMStagSetUniformCoordinates(DM, PetscReal, PetscReal, PetscReal, PetscReal, PetscReal, PetscReal); 129 PETSC_EXTERN PetscErrorCode DMStagSetUniformCoordinatesExplicit(DM, PetscReal, PetscReal, PetscReal, PetscReal, PetscReal, PetscReal); 130 PETSC_EXTERN PetscErrorCode DMStagSetUniformCoordinatesProduct(DM, PetscReal, PetscReal, PetscReal, PetscReal, PetscReal, PetscReal); 131 PETSC_EXTERN PetscErrorCode DMStagStencilToIndexLocal(DM, PetscInt, PetscInt, const DMStagStencil *, PetscInt *); 132 PETSC_EXTERN PetscErrorCode DMStagVecGetArray(DM, Vec, void *); 133 PETSC_EXTERN PetscErrorCode DMStagVecGetArrayRead(DM, Vec, void *); 134 PETSC_EXTERN PetscErrorCode DMStagVecGetValuesStencil(DM, Vec, PetscInt, const DMStagStencil *, PetscScalar *); 135 PETSC_EXTERN PetscErrorCode DMStagVecRestoreArray(DM, Vec, void *); 136 PETSC_EXTERN PetscErrorCode DMStagVecRestoreArrayRead(DM, Vec, void *); 137 PETSC_EXTERN PetscErrorCode DMStagVecSetValuesStencil(DM, Vec, PetscInt, const DMStagStencil *, const PetscScalar *, InsertMode); 138 PETSC_EXTERN PetscErrorCode DMStagVecSplitToDMDA(DM, Vec, DMStagStencilLocation, PetscInt, DM *, Vec *); 139 140 PETSC_DEPRECATED_FUNCTION("Use DMStagGetProductCoordinateArraysRead() (since version 3.13") static inline PetscErrorCode DMStagGet1dCoordinateArraysDOFRead(DM dm, void *ax, void *ay, void *az) 141 { 142 return DMStagGetProductCoordinateArraysRead(dm, ax, ay, az); 143 } 144 PETSC_DEPRECATED_FUNCTION("Use DMStagGetProductCoordinateLocationSlot() (since version 3.13") static inline PetscErrorCode DMStagGet1dCoordinateLocationSlot(DM dm, DMStagStencilLocation loc, PetscInt *s) 145 { 146 return DMStagGetProductCoordinateLocationSlot(dm, loc, s); 147 } 148 PETSC_DEPRECATED_FUNCTION("Use DMStagGetStencilType() (since version 3.11)") static inline PetscErrorCode DMStagGetGhostType(DM dm, DMStagStencilType *s) 149 { 150 return DMStagGetStencilType(dm, s); 151 } 152 PETSC_DEPRECATED_FUNCTION("Use DMStagRestoreProductCoordinateArraysRead() (since version 3.13") static inline PetscErrorCode DMStagRestore1dCoordinateArraysDOFRead(DM dm, void *ax, void *ay, void *az) 153 { 154 return DMStagRestoreProductCoordinateArraysRead(dm, ax, ay, az); 155 } 156 PETSC_DEPRECATED_FUNCTION("Use DMStagSetStencilType() (since version 3.11)") static inline PetscErrorCode DMStagSetGhostType(DM dm, DMStagStencilType *s) 157 { 158 return DMStagGetStencilType(dm, s); 159 } 160 PETSC_DEPRECATED_FUNCTION("Use DMStagVecGetArray() (since version 3.13") static inline PetscErrorCode DMStagVecGetArrayDOF(DM dm, Vec v, void *a) 161 { 162 return DMStagVecGetArray(dm, v, a); 163 } 164 PETSC_DEPRECATED_FUNCTION("Use DMStagVecGetArrayRead() (since version 3.13") static inline PetscErrorCode DMStagVecGetArrayDOFRead(DM dm, Vec v, void *a) 165 { 166 return DMStagVecGetArrayRead(dm, v, a); 167 } 168 PETSC_DEPRECATED_FUNCTION("Use DMStagVecRestoreArray() (since version 3.13") static inline PetscErrorCode DMStagVecRestoreArrayDOF(DM dm, Vec v, void *a) 169 { 170 return DMStagVecRestoreArray(dm, v, a); 171 } 172 PETSC_DEPRECATED_FUNCTION("Use DMStagVecRestoreArrayRead() (since version 3.13") static inline PetscErrorCode DMStagVecRestoreArrayDOFRead(DM dm, Vec v, void *a) 173 { 174 return DMStagVecRestoreArrayRead(dm, v, a); 175 } 176 177 #endif // PETSC_DMSTAG_H 178