1 #if !defined(__PETSCDMDA_H) 2 #define __PETSCDMDA_H 3 4 #include <petscdm.h> 5 #include <petscdmdatypes.h> 6 #include <petscpf.h> 7 #include <petscao.h> 8 9 /*MC 10 DMDA_STENCIL_STAR - "Star"-type stencil. In logical grid coordinates, only (i,j,k), (i+s,j,k), (i,j+s,k), 11 (i,j,k+s) are in the stencil NOT, for example, (i+s,j+s,k) 12 13 Level: beginner 14 15 .seealso: DMDA_STENCIL_BOX, DMDAStencilType, DMDASetStencilType() 16 M*/ 17 18 /*MC 19 DMDA_STENCIL_BOX - "Box"-type stencil. In logical grid coordinates, any of (i,j,k), (i+s,j+r,k+t) may 20 be in the stencil. 21 22 Level: beginner 23 24 .seealso: DMDA_STENCIL_STAR, DMDAStencilType, DMDASetStencilType() 25 M*/ 26 27 PETSC_EXTERN const char *const DMDABoundaryTypes[]; 28 29 PETSC_EXTERN PetscErrorCode DMDASetInterpolationType(DM,DMDAInterpolationType); 30 PETSC_EXTERN PetscErrorCode DMDAGetInterpolationType(DM,DMDAInterpolationType*); 31 32 PETSC_EXTERN PetscErrorCode DMDASetElementType(DM,DMDAElementType); 33 PETSC_EXTERN PetscErrorCode DMDAGetElementType(DM,DMDAElementType*); 34 PETSC_EXTERN PetscErrorCode DMDAGetElements(DM,PetscInt *,PetscInt *,const PetscInt*[]); 35 PETSC_EXTERN PetscErrorCode DMDARestoreElements(DM,PetscInt *,PetscInt *,const PetscInt*[]); 36 37 typedef enum { DMDA_X,DMDA_Y,DMDA_Z } DMDADirection; 38 39 #define MATSEQUSFFT "sequsfft" 40 41 PETSC_EXTERN PetscErrorCode DMDACreate(MPI_Comm,DM*); 42 PETSC_EXTERN PetscErrorCode DMDASetDim(DM,PetscInt); 43 PETSC_EXTERN PetscErrorCode DMDASetSizes(DM,PetscInt,PetscInt,PetscInt); 44 PETSC_EXTERN PetscErrorCode DMDACreate1d(MPI_Comm,DMDABoundaryType,PetscInt,PetscInt,PetscInt,const PetscInt[],DM *); 45 PETSC_EXTERN PetscErrorCode DMDACreate2d(MPI_Comm,DMDABoundaryType,DMDABoundaryType,DMDAStencilType,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],DM*); 46 PETSC_EXTERN PetscErrorCode DMDACreate3d(MPI_Comm,DMDABoundaryType,DMDABoundaryType,DMDABoundaryType,DMDAStencilType,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscInt[],DM*); 47 48 PETSC_EXTERN PetscErrorCode DMDAGlobalToNaturalBegin(DM,Vec,InsertMode,Vec); 49 PETSC_EXTERN PetscErrorCode DMDAGlobalToNaturalEnd(DM,Vec,InsertMode,Vec); 50 PETSC_EXTERN PetscErrorCode DMDANaturalToGlobalBegin(DM,Vec,InsertMode,Vec); 51 PETSC_EXTERN PetscErrorCode DMDANaturalToGlobalEnd(DM,Vec,InsertMode,Vec); 52 PETSC_EXTERN PetscErrorCode DMDALocalToLocalBegin(DM,Vec,InsertMode,Vec); 53 PETSC_EXTERN PetscErrorCode DMDALocalToLocalEnd(DM,Vec,InsertMode,Vec); 54 PETSC_EXTERN PetscErrorCode DMDACreateNaturalVector(DM,Vec *); 55 56 PETSC_EXTERN PetscErrorCode DMDAGetCorners(DM,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*); 57 PETSC_EXTERN PetscErrorCode DMDAGetGhostCorners(DM,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*); 58 PETSC_EXTERN PetscErrorCode DMDAGetInfo(DM,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,DMDABoundaryType*,DMDABoundaryType*,DMDABoundaryType*,DMDAStencilType*); 59 PETSC_EXTERN PetscErrorCode DMDAGetProcessorSubset(DM,DMDADirection,PetscInt,MPI_Comm*); 60 PETSC_EXTERN PetscErrorCode DMDAGetProcessorSubsets(DM,DMDADirection,MPI_Comm*); 61 PETSC_EXTERN PetscErrorCode DMDAGetRay(DM,DMDADirection,PetscInt,Vec*,VecScatter*); 62 63 PETSC_EXTERN PetscErrorCode DMDAGlobalToNaturalAllCreate(DM,VecScatter*); 64 PETSC_EXTERN PetscErrorCode DMDANaturalAllToGlobalCreate(DM,VecScatter*); 65 66 PETSC_EXTERN PetscErrorCode DMDAGetGlobalIndices(DM,PetscInt*,PetscInt**); 67 68 PETSC_EXTERN PetscErrorCode DMDAGetScatter(DM,VecScatter*,VecScatter*,VecScatter*); 69 PETSC_EXTERN PetscErrorCode DMDAGetNeighbors(DM,const PetscMPIInt**); 70 71 PETSC_EXTERN PetscErrorCode DMDAGetAO(DM,AO*); 72 PETSC_EXTERN PetscErrorCode DMDASetUniformCoordinates(DM,PetscReal,PetscReal,PetscReal,PetscReal,PetscReal,PetscReal); 73 PETSC_EXTERN PetscErrorCode DMDAGetBoundingBox(DM,PetscReal[],PetscReal[]); 74 PETSC_EXTERN PetscErrorCode DMDAGetLocalBoundingBox(DM,PetscReal[],PetscReal[]); 75 PETSC_EXTERN PetscErrorCode DMDAGetLogicalCoordinate(DM,PetscScalar,PetscScalar,PetscScalar,PetscInt*,PetscInt*,PetscInt*,PetscScalar*,PetscScalar*,PetscScalar*); 76 /* function to wrap coordinates around boundary */ 77 PETSC_EXTERN PetscErrorCode DMDAMapCoordsToPeriodicDomain(DM,PetscScalar*,PetscScalar*); 78 79 PETSC_EXTERN PetscErrorCode DMDAGetReducedDMDA(DM,PetscInt,DM*); 80 81 PETSC_EXTERN PetscErrorCode DMDASetFieldName(DM,PetscInt,const char[]); 82 PETSC_EXTERN PetscErrorCode DMDAGetFieldName(DM,PetscInt,const char**); 83 PETSC_EXTERN PetscErrorCode DMDASetCoordinateName(DM,PetscInt,const char[]); 84 PETSC_EXTERN PetscErrorCode DMDAGetCoordinateName(DM,PetscInt,const char**); 85 86 PETSC_EXTERN PetscErrorCode DMDASetBoundaryType(DM,DMDABoundaryType,DMDABoundaryType,DMDABoundaryType); 87 PETSC_EXTERN PetscErrorCode DMDASetDof(DM, PetscInt); 88 PETSC_EXTERN PetscErrorCode DMDASetOverlap(DM,PetscInt,PetscInt,PetscInt); 89 PETSC_EXTERN PetscErrorCode DMDAGetOverlap(DM,PetscInt*,PetscInt*,PetscInt*); 90 PETSC_EXTERN PetscErrorCode DMDAGetOffset(DM,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*); 91 PETSC_EXTERN PetscErrorCode DMDASetOffset(DM,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt); 92 PETSC_EXTERN PetscErrorCode DMDASetStencilWidth(DM, PetscInt); 93 PETSC_EXTERN PetscErrorCode DMDASetOwnershipRanges(DM,const PetscInt[],const PetscInt[],const PetscInt[]); 94 PETSC_EXTERN PetscErrorCode DMDAGetOwnershipRanges(DM,const PetscInt**,const PetscInt**,const PetscInt**); 95 PETSC_EXTERN PetscErrorCode DMDASetNumProcs(DM, PetscInt, PetscInt, PetscInt); 96 PETSC_EXTERN PetscErrorCode DMDASetStencilType(DM, DMDAStencilType); 97 98 PETSC_EXTERN PetscErrorCode DMDAVecGetArray(DM,Vec,void *); 99 PETSC_EXTERN PetscErrorCode DMDAVecRestoreArray(DM,Vec,void *); 100 101 PETSC_EXTERN PetscErrorCode DMDAVecGetArrayDOF(DM,Vec,void *); 102 PETSC_EXTERN PetscErrorCode DMDAVecRestoreArrayDOF(DM,Vec,void *); 103 104 PETSC_EXTERN PetscErrorCode DMDASplitComm2d(MPI_Comm,PetscInt,PetscInt,PetscInt,MPI_Comm*); 105 106 PETSC_EXTERN PetscErrorCode DMDACreatePatchIS(DM,MatStencil*,MatStencil*,IS*); 107 108 109 /*MC 110 DMDACoor2d - Structure for holding 2d (x and y) coordinates. 111 112 Level: intermediate 113 114 Sample Usage: 115 DMDACoor2d **coors; 116 Vec vcoors; 117 DM cda; 118 119 DMGetCoordinates(da,&vcoors); 120 DMDAGetCoordinateDA(da,&cda); 121 DMDAVecGetArray(cda,vcoors,&coors); 122 DMDAGetCorners(cda,&mstart,&nstart,0,&m,&n,0) 123 for (i=mstart; i<mstart+m; i++) { 124 for (j=nstart; j<nstart+n; j++) { 125 x = coors[j][i].x; 126 y = coors[j][i].y; 127 ...... 128 } 129 } 130 DMDAVecRestoreArray(dac,vcoors,&coors); 131 132 .seealso: DMDACoor3d, DMDAForEachPointBegin(), DMDAGetCoordinateDA(), DMGetCoordinates(), DMDAGetGhostCoordinates() 133 M*/ 134 typedef struct {PetscScalar x,y;} DMDACoor2d; 135 136 /*MC 137 DMDACoor3d - Structure for holding 3d (x, y and z) coordinates. 138 139 Level: intermediate 140 141 Sample Usage: 142 DMDACoor3d ***coors; 143 Vec vcoors; 144 DM cda; 145 146 DMGetCoordinates(da,&vcoors); 147 DMDAGetCoordinateDA(da,&cda); 148 DMDAVecGetArray(cda,vcoors,&coors); 149 DMDAGetCorners(cda,&mstart,&nstart,&pstart,&m,&n,&p) 150 for (i=mstart; i<mstart+m; i++) { 151 for (j=nstart; j<nstart+n; j++) { 152 for (k=pstart; k<pstart+p; k++) { 153 x = coors[k][j][i].x; 154 y = coors[k][j][i].y; 155 z = coors[k][j][i].z; 156 ...... 157 } 158 } 159 DMDAVecRestoreArray(dac,vcoors,&coors); 160 161 .seealso: DMDACoor2d, DMDAForEachPointBegin(), DMDAGetCoordinateDA(), DMGetCoordinates(), DMDAGetGhostCoordinates() 162 M*/ 163 typedef struct {PetscScalar x,y,z;} DMDACoor3d; 164 165 PETSC_EXTERN PetscErrorCode DMDAGetLocalInfo(DM,DMDALocalInfo*); 166 167 PETSC_EXTERN PetscErrorCode MatRegisterDAAD(void); 168 PETSC_EXTERN PetscErrorCode MatCreateDAAD(DM,Mat*); 169 PETSC_EXTERN PetscErrorCode MatCreateSeqUSFFT(Vec,DM,Mat*); 170 171 PETSC_EXTERN PetscErrorCode DMDASetGetMatrix(DM,PetscErrorCode (*)(DM, MatType,Mat *)); 172 PETSC_EXTERN PetscErrorCode DMDASetBlockFills(DM,const PetscInt*,const PetscInt*); 173 PETSC_EXTERN PetscErrorCode DMDASetRefinementFactor(DM,PetscInt,PetscInt,PetscInt); 174 PETSC_EXTERN PetscErrorCode DMDAGetRefinementFactor(DM,PetscInt*,PetscInt*,PetscInt*); 175 176 PETSC_EXTERN PetscErrorCode DMDAGetArray(DM,PetscBool ,void*); 177 PETSC_EXTERN PetscErrorCode DMDARestoreArray(DM,PetscBool ,void*); 178 179 PETSC_EXTERN PetscErrorCode DMDACreatePF(DM,PF*); 180 181 PETSC_EXTERN PetscErrorCode DMDAGetNumCells(DM, PetscInt *); 182 PETSC_EXTERN PetscErrorCode DMDAGetNumVertices(DM, PetscInt *, PetscInt *, PetscInt *, PetscInt *); 183 PETSC_EXTERN PetscErrorCode DMDAGetNumFaces(DM, PetscInt *, PetscInt *, PetscInt *, PetscInt *, PetscInt *, PetscInt *); 184 PETSC_EXTERN PetscErrorCode DMDAGetHeightStratum(DM, PetscInt, PetscInt *, PetscInt *); 185 PETSC_EXTERN PetscErrorCode DMDACreateSection(DM, PetscInt[], PetscInt[], PetscInt[], PetscInt[]); 186 PETSC_EXTERN PetscErrorCode DMDAComputeCellGeometry(DM, PetscInt, PetscQuadrature *, PetscReal [], PetscReal [], PetscReal [], PetscReal []); 187 PETSC_EXTERN PetscErrorCode DMDAVecGetClosure(DM, PetscSection, Vec, PetscInt, const PetscScalar **); 188 PETSC_EXTERN PetscErrorCode DMDAVecSetClosure(DM, PetscSection, Vec, PetscInt, const PetscScalar *, InsertMode); 189 PETSC_EXTERN PetscErrorCode DMDAGetClosure(DM,PetscSection,PetscInt,PetscInt*,const PetscInt**); 190 PETSC_EXTERN PetscErrorCode DMDARestoreClosure(DM,PetscSection,PetscInt,PetscInt*,const PetscInt**); 191 PETSC_EXTERN PetscErrorCode DMDAGetClosureScalar(DM,PetscSection,PetscInt,PetscScalar*,const PetscScalar**); 192 PETSC_EXTERN PetscErrorCode DMDARestoreClosureScalar(DM,PetscSection,PetscInt,PetscScalar*,const PetscScalar**); 193 PETSC_EXTERN PetscErrorCode DMDASetClosureScalar(DM,PetscSection,PetscInt,PetscScalar*,const PetscScalar*,InsertMode); 194 PETSC_EXTERN PetscErrorCode DMDAConvertToCell(DM, MatStencil, PetscInt *); 195 196 #endif 197