Actual source code: petscdmstag.h

  1: #pragma once

  3: #include <petscdm.h>
  4: #include <petscdmproduct.h>

  6: /* SUBMANSEC = DMStag */

  8: /*E
  9:   DMStagStencilLocation - enumerated type denoting a location relative to an element in a `DMSTAG` grid

 11:   The interpretation of these values is dimension-dependent.

 13:   Level: beginner

 15:   Developer Note:
 16:   The order of the enum entries is significant, as it corresponds to the canonical numbering
 17:   of DOFs, and the fact that the numbering starts at 0 may also be used by the implementation.

 19:   Fortran Note:
 20:   Currently there is no Fortran support, it could be easily added.

 22: .seealso: [](ch_stag), `DMSTAG`, `DMDA`, `DMStagStencil`, `DMStagGetLocationSlot()`, `DMStagStencilType`
 23: E*/
 24: typedef enum {
 25:   DMSTAG_NULL_LOCATION = 0,
 26:   DMSTAG_BACK_DOWN_LEFT,
 27:   DMSTAG_BACK_DOWN,
 28:   DMSTAG_BACK_DOWN_RIGHT,
 29:   DMSTAG_BACK_LEFT,
 30:   DMSTAG_BACK,
 31:   DMSTAG_BACK_RIGHT,
 32:   DMSTAG_BACK_UP_LEFT,
 33:   DMSTAG_BACK_UP,
 34:   DMSTAG_BACK_UP_RIGHT,
 35:   DMSTAG_DOWN_LEFT,
 36:   DMSTAG_DOWN,
 37:   DMSTAG_DOWN_RIGHT,
 38:   DMSTAG_LEFT,
 39:   DMSTAG_ELEMENT,
 40:   DMSTAG_RIGHT,
 41:   DMSTAG_UP_LEFT,
 42:   DMSTAG_UP,
 43:   DMSTAG_UP_RIGHT,
 44:   DMSTAG_FRONT_DOWN_LEFT,
 45:   DMSTAG_FRONT_DOWN,
 46:   DMSTAG_FRONT_DOWN_RIGHT,
 47:   DMSTAG_FRONT_LEFT,
 48:   DMSTAG_FRONT,
 49:   DMSTAG_FRONT_RIGHT,
 50:   DMSTAG_FRONT_UP_LEFT,
 51:   DMSTAG_FRONT_UP,
 52:   DMSTAG_FRONT_UP_RIGHT
 53: } DMStagStencilLocation;
 54: PETSC_EXTERN const char *const DMStagStencilLocations[]; /* Corresponding strings (see stagstencil.c) */

 56: /*S
 57:   DMStagStencil - data structure representing a degree of freedom on a `DMSTAG` grid

 59:   Data structure (C struct), analogous to describing a degree of freedom associated with a `DMSTAG` object,
 60:   in terms of a global element index in each of up to three directions, a "location" as defined by `DMStagStencilLocation`,
 61:   and a component number. Primarily for use with `DMStagMatSetValuesStencil()` (compare with use of `MatStencil` with `MatSetValuesStencil()`).

 63:   Level: beginner

 65:   Notes:
 66:   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).

 68:   This is a struct, not a `PetscObject`.

 70: .seealso: [](ch_stag), `DMSTAG`, `DMDA`, `DMStagMatSetValuesStencil()`, `DMStagVecSetValuesStencil()`, `DMStagStencilLocation`, `DMStagSetStencilWidth()`,
 71:           `DMStagSetStencilType()`, `DMStagVecGetValuesStencil()`, `DMStagStencilLocation`
 72: S*/
 73: typedef struct {
 74:   DMStagStencilLocation loc;
 75:   PetscInt              i, j, k, c;
 76: } DMStagStencil;

 78: /*E
 79:   DMStagStencilType - Elementwise stencil type, determining which neighbors participate in communication

 81:   Level: beginner

 83: .seealso: [](ch_stag), `DMSTAG`, `DMDA`, `DMStagCreate1d()`, `DMStagCreate2d()`, `DMStagCreate3d()`, `DMStagStencil`, `DMDAStencilType`, `DMStagStencilLocation`,
 84:           `DMDAStencilType`
 85: E*/

 87: typedef enum {
 88:   DMSTAG_STENCIL_NONE = 0,
 89:   DMSTAG_STENCIL_STAR,
 90:   DMSTAG_STENCIL_BOX
 91: } DMStagStencilType;
 92: PETSC_EXTERN const char *const DMStagStencilTypes[]; /* Corresponding strings (see stagstencil.c) */

 94: PETSC_EXTERN PetscErrorCode DMCreate_Stag(DM);
 95: PETSC_EXTERN PetscErrorCode DMStagCreate1d(MPI_Comm, DMBoundaryType, PetscInt, PetscInt, PetscInt, DMStagStencilType, PetscInt, const PetscInt[], DM *);
 96: PETSC_EXTERN PetscErrorCode DMStagCreate2d(MPI_Comm, DMBoundaryType, DMBoundaryType, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, DMStagStencilType, PetscInt, const PetscInt[], const PetscInt[], DM *);
 97: 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 *);
 98: PETSC_EXTERN PetscErrorCode DMStagCreateCompatibleDMStag(DM, PetscInt, PetscInt, PetscInt, PetscInt, DM *);
 99: PETSC_EXTERN PetscErrorCode DMStagCreateISFromStencils(DM, PetscInt, DMStagStencil *, IS *);
100: PETSC_EXTERN PetscErrorCode DMStagGetBoundaryTypes(DM, DMBoundaryType *, DMBoundaryType *, DMBoundaryType *);
101: PETSC_EXTERN PetscErrorCode DMStagGetCorners(DM, PetscInt *, PetscInt *, PetscInt *, PetscInt *, PetscInt *, PetscInt *, PetscInt *, PetscInt *, PetscInt *);
102: PETSC_EXTERN PetscErrorCode DMStagGetDOF(DM, PetscInt *, PetscInt *, PetscInt *, PetscInt *);
103: PETSC_EXTERN PetscErrorCode DMStagGetEntries(DM, PetscInt *);
104: PETSC_EXTERN PetscErrorCode DMStagGetEntriesLocal(DM, PetscInt *);
105: PETSC_EXTERN PetscErrorCode DMStagGetEntriesPerElement(DM, PetscInt *);
106: PETSC_EXTERN PetscErrorCode DMStagGetGhostCorners(DM, PetscInt *, PetscInt *, PetscInt *, PetscInt *, PetscInt *, PetscInt *);
107: PETSC_EXTERN PetscErrorCode DMStagGetGlobalSizes(DM, PetscInt *, PetscInt *, PetscInt *);
108: PETSC_EXTERN PetscErrorCode DMStagGetIsFirstRank(DM, PetscBool *, PetscBool *, PetscBool *);
109: PETSC_EXTERN PetscErrorCode DMStagGetIsLastRank(DM, PetscBool *, PetscBool *, PetscBool *);
110: PETSC_EXTERN PetscErrorCode DMStagGetLocalSizes(DM, PetscInt *, PetscInt *, PetscInt *);
111: PETSC_EXTERN PetscErrorCode DMStagGetLocationDOF(DM, DMStagStencilLocation, PetscInt *);
112: PETSC_EXTERN PetscErrorCode DMStagGetLocationSlot(DM, DMStagStencilLocation, PetscInt, PetscInt *);
113: PETSC_EXTERN PetscErrorCode DMStagGetNumRanks(DM, PetscInt *, PetscInt *, PetscInt *);
114: PETSC_EXTERN PetscErrorCode DMStagGetOwnershipRanges(DM, const PetscInt **, const PetscInt **, const PetscInt **);
115: PETSC_EXTERN PetscErrorCode DMStagGetProductCoordinateArrays(DM, void *, void *, void *);
116: PETSC_EXTERN PetscErrorCode DMStagGetProductCoordinateArraysRead(DM, void *, void *, void *);
117: PETSC_EXTERN PetscErrorCode DMStagGetProductCoordinateLocationSlot(DM, DMStagStencilLocation, PetscInt *);
118: PETSC_EXTERN PetscErrorCode DMStagGetStencilType(DM, DMStagStencilType *);
119: PETSC_EXTERN PetscErrorCode DMStagGetStencilWidth(DM, PetscInt *);
120: PETSC_EXTERN PetscErrorCode DMStagGetRefinementFactor(DM, PetscInt *, PetscInt *, PetscInt *);
121: PETSC_EXTERN PetscErrorCode DMStagMatGetValuesStencil(DM, Mat, PetscInt, const DMStagStencil *, PetscInt, const DMStagStencil *, PetscScalar *);
122: PETSC_EXTERN PetscErrorCode DMStagMatSetValuesStencil(DM, Mat, PetscInt, const DMStagStencil *, PetscInt, const DMStagStencil *, const PetscScalar *, InsertMode);
123: PETSC_EXTERN PetscErrorCode DMStagMigrateVec(DM, Vec, DM, Vec);
124: PETSC_EXTERN PetscErrorCode DMStagPopulateLocalToGlobalInjective(DM);
125: PETSC_EXTERN PetscErrorCode DMStagRestoreProductCoordinateArrays(DM, void *, void *, void *);
126: PETSC_EXTERN PetscErrorCode DMStagRestoreProductCoordinateArraysRead(DM, void *, void *, void *);
127: PETSC_EXTERN PetscErrorCode DMStagRestrictSimple(DM, Vec, DM, Vec);
128: PETSC_EXTERN PetscErrorCode DMStagSetBoundaryTypes(DM, DMBoundaryType, DMBoundaryType, DMBoundaryType);
129: PETSC_EXTERN PetscErrorCode DMStagSetCoordinateDMType(DM, DMType);
130: PETSC_EXTERN PetscErrorCode DMStagSetDOF(DM, PetscInt, PetscInt, PetscInt, PetscInt);
131: PETSC_EXTERN PetscErrorCode DMStagSetGlobalSizes(DM, PetscInt, PetscInt, PetscInt);
132: PETSC_EXTERN PetscErrorCode DMStagSetNumRanks(DM, PetscInt, PetscInt, PetscInt);
133: PETSC_EXTERN PetscErrorCode DMStagSetOwnershipRanges(DM, PetscInt const *, PetscInt const *, PetscInt const *);
134: PETSC_EXTERN PetscErrorCode DMStagSetStencilType(DM, DMStagStencilType);
135: PETSC_EXTERN PetscErrorCode DMStagSetStencilWidth(DM, PetscInt);
136: PETSC_EXTERN PetscErrorCode DMStagSetRefinementFactor(DM, PetscInt, PetscInt, PetscInt);
137: PETSC_EXTERN PetscErrorCode DMStagSetUniformCoordinates(DM, PetscReal, PetscReal, PetscReal, PetscReal, PetscReal, PetscReal);
138: PETSC_EXTERN PetscErrorCode DMStagSetUniformCoordinatesExplicit(DM, PetscReal, PetscReal, PetscReal, PetscReal, PetscReal, PetscReal);
139: PETSC_EXTERN PetscErrorCode DMStagSetUniformCoordinatesProduct(DM, PetscReal, PetscReal, PetscReal, PetscReal, PetscReal, PetscReal);
140: PETSC_EXTERN PetscErrorCode DMStagStencilToIndexLocal(DM, PetscInt, PetscInt, const DMStagStencil *, PetscInt *);
141: PETSC_EXTERN PetscErrorCode DMStagVecGetArray(DM, Vec, void *);
142: PETSC_EXTERN PetscErrorCode DMStagVecGetArrayRead(DM, Vec, void *);
143: PETSC_EXTERN PetscErrorCode DMStagVecGetValuesStencil(DM, Vec, PetscInt, const DMStagStencil *, PetscScalar *);
144: PETSC_EXTERN PetscErrorCode DMStagVecRestoreArray(DM, Vec, void *);
145: PETSC_EXTERN PetscErrorCode DMStagVecRestoreArrayRead(DM, Vec, void *);
146: PETSC_EXTERN PetscErrorCode DMStagVecSetValuesStencil(DM, Vec, PetscInt, const DMStagStencil *, const PetscScalar *, InsertMode);
147: PETSC_EXTERN PetscErrorCode DMStagVecSplitToDMDA(DM, Vec, DMStagStencilLocation, PetscInt, DM *, Vec *);

149: PETSC_DEPRECATED_FUNCTION(3, 13, 0, "DMStagGetProductCoordinateArraysRead()", ) static inline PetscErrorCode DMStagGet1dCoordinateArraysDOFRead(DM dm, void *ax, void *ay, void *az)
150: {
151:   return DMStagGetProductCoordinateArraysRead(dm, ax, ay, az);
152: }
153: PETSC_DEPRECATED_FUNCTION(3, 13, 0, "DMStagGetProductCoordinateLocationSlot()", ) static inline PetscErrorCode DMStagGet1dCoordinateLocationSlot(DM dm, DMStagStencilLocation loc, PetscInt *s)
154: {
155:   return DMStagGetProductCoordinateLocationSlot(dm, loc, s);
156: }
157: PETSC_DEPRECATED_FUNCTION(3, 11, 0, "DMStagGetStencilType()", ) static inline PetscErrorCode DMStagGetGhostType(DM dm, DMStagStencilType *s)
158: {
159:   return DMStagGetStencilType(dm, s);
160: }
161: PETSC_DEPRECATED_FUNCTION(3, 13, 0, "DMStagRestoreProductCoordinateArraysRead()", ) static inline PetscErrorCode DMStagRestore1dCoordinateArraysDOFRead(DM dm, void *ax, void *ay, void *az)
162: {
163:   return DMStagRestoreProductCoordinateArraysRead(dm, ax, ay, az);
164: }
165: PETSC_DEPRECATED_FUNCTION(3, 11, 0, "DMStagSetStencilType()", ) static inline PetscErrorCode DMStagSetGhostType(DM dm, DMStagStencilType *s)
166: {
167:   return DMStagGetStencilType(dm, s);
168: }
169: PETSC_DEPRECATED_FUNCTION(3, 13, 0, "DMStagVecGetArray()", ) static inline PetscErrorCode DMStagVecGetArrayDOF(DM dm, Vec v, void *a)
170: {
171:   return DMStagVecGetArray(dm, v, a);
172: }
173: PETSC_DEPRECATED_FUNCTION(3, 13, 0, "DMStagVecGetArrayRead()", ) static inline PetscErrorCode DMStagVecGetArrayDOFRead(DM dm, Vec v, void *a)
174: {
175:   return DMStagVecGetArrayRead(dm, v, a);
176: }
177: PETSC_DEPRECATED_FUNCTION(3, 13, 0, "DMStagVecRestoreArray()", ) static inline PetscErrorCode DMStagVecRestoreArrayDOF(DM dm, Vec v, void *a)
178: {
179:   return DMStagVecRestoreArray(dm, v, a);
180: }
181: PETSC_DEPRECATED_FUNCTION(3, 13, 0, "DMStagVecRestoreArrayRead()", ) static inline PetscErrorCode DMStagVecRestoreArrayDOFRead(DM dm, Vec v, void *a)
182: {
183:   return DMStagVecRestoreArrayRead(dm, v, a);
184: }