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