1 /* 2 Objects to manage the interactions between the mesh data structures and the algebraic objects 3 */ 4 #if !defined(__PETSCDA_H) 5 #define __PETSCDA_H 6 #include "petscvec.h" 7 #include "petscao.h" 8 PETSC_EXTERN_CXX_BEGIN 9 10 extern PetscErrorCode PETSCDM_DLLEXPORT DMInitializePackage(const char[]); 11 12 /*S 13 DM - Abstract PETSc object that manages an abstract grid object 14 15 Level: intermediate 16 17 Concepts: grids, grid refinement 18 19 Notes: The DMDACreate() based object and the DMCompositeCreate() based object are examples of DMs 20 21 Though the DM objects require the petscsnes.h include files the DM library is 22 NOT dependent on the SNES or KSP library. In fact, the KSP and SNES libraries depend on 23 DM. (This is not great design, but not trivial to fix). 24 25 .seealso: DMCompositeCreate(), DMDACreate() 26 S*/ 27 typedef struct _p_DM* DM; 28 29 /*E 30 DMDAStencilType - Determines if the stencil extends only along the coordinate directions, or also 31 to the northeast, northwest etc 32 33 Level: beginner 34 35 .seealso: DMDACreate1d(), DMDACreate2d(), DMDACreate3d(), DMDACreate() 36 E*/ 37 typedef enum { DMDA_STENCIL_STAR,DMDA_STENCIL_BOX } DMDAStencilType; 38 39 /*MC 40 DMDA_STENCIL_STAR - "Star"-type stencil. In logical grid coordinates, only (i,j,k), (i+s,j,k), (i,j+s,k), 41 (i,j,k+s) are in the stencil NOT, for example, (i+s,j+s,k) 42 43 Level: beginner 44 45 .seealso: DMDA_STENCIL_BOX, DMDAStencilType 46 M*/ 47 48 /*MC 49 DMDA_STENCIL_BOX - "Box"-type stencil. In logical grid coordinates, any of (i,j,k), (i+s,j+r,k+t) may 50 be in the stencil. 51 52 Level: beginner 53 54 .seealso: DMDA_STENCIL_STAR, DMDAStencilType 55 M*/ 56 57 /*E 58 DMDAPeriodicType - Is the domain periodic in one or more directions 59 60 Level: beginner 61 62 DMDA_XYZGHOSTED means that ghost points are put around all the physical boundaries 63 in the local representation of the Vec (i.e. DMDACreate/GetLocalVector(). 64 65 .seealso: DMDACreate1d(), DMDACreate2d(), DMDACreate3d(), DMDACreate() 66 E*/ 67 typedef enum { DMDA_NONPERIODIC,DMDA_XPERIODIC,DMDA_YPERIODIC,DMDA_XYPERIODIC, 68 DMDA_XYZPERIODIC,DMDA_XZPERIODIC,DMDA_YZPERIODIC,DMDA_ZPERIODIC,DMDA_XYZGHOSTED} DMDAPeriodicType; 69 extern const char *DMDAPeriodicTypes[]; 70 71 /*E 72 DMDAInterpolationType - Defines the type of interpolation that will be returned by 73 DMGetInterpolation. 74 75 Level: beginner 76 77 .seealso: DMDACreate1d(), DMDACreate2d(), DMDACreate3d(), DMGetInterpolation(), DMDASetInterpolationType(), DMDACreate() 78 E*/ 79 typedef enum { DMDA_Q0, DMDA_Q1 } DMDAInterpolationType; 80 81 extern PetscErrorCode PETSCDM_DLLEXPORT DMDASetInterpolationType(DM,DMDAInterpolationType); 82 83 /*E 84 DMDAElementType - Defines the type of elements that will be returned by 85 DMGetElements() 86 87 Level: beginner 88 89 .seealso: DMDACreate1d(), DMDACreate2d(), DMDACreate3d(), DMGetInterpolation(), DMDASetInterpolationType(), 90 DMDASetElementType(), DMGetElements(), DMRestoreElements(), DMDACreate() 91 E*/ 92 typedef enum { DMDA_ELEMENT_P1, DMDA_ELEMENT_Q1 } DMDAElementType; 93 94 extern PetscErrorCode PETSCDM_DLLEXPORT DMDASetElementType(DM,DMDAElementType); 95 extern PetscErrorCode PETSCDM_DLLEXPORT DMDAGetElementType(DM,DMDAElementType*); 96 97 #define DMDAXPeriodic(pt) ((pt)==DMDA_XPERIODIC||(pt)==DMDA_XYPERIODIC||(pt)==DMDA_XZPERIODIC||(pt)==DMDA_XYZPERIODIC) 98 #define DMDAYPeriodic(pt) ((pt)==DMDA_YPERIODIC||(pt)==DMDA_XYPERIODIC||(pt)==DMDA_YZPERIODIC||(pt)==DMDA_XYZPERIODIC) 99 #define DMDAZPeriodic(pt) ((pt)==DMDA_ZPERIODIC||(pt)==DMDA_XZPERIODIC||(pt)==DMDA_YZPERIODIC||(pt)==DMDA_XYZPERIODIC) 100 101 typedef enum { DMDA_X,DMDA_Y,DMDA_Z } DMDADirection; 102 103 extern PetscClassId PETSCDM_DLLEXPORT DM_CLASSID; 104 105 #define MATSEQUSFFT "sequsfft" 106 107 extern PetscErrorCode PETSCDM_DLLEXPORT DMDACreate(MPI_Comm,DM*); 108 extern PetscErrorCode PETSCDM_DLLEXPORT DMDASetDim(DM,PetscInt); 109 extern PetscErrorCode PETSCDM_DLLEXPORT DMDASetSizes(DM,PetscInt,PetscInt,PetscInt); 110 extern PetscErrorCode PETSCDM_DLLEXPORT DMDACreate1d(MPI_Comm,DMDAPeriodicType,PetscInt,PetscInt,PetscInt,const PetscInt[],DM *); 111 extern PetscErrorCode PETSCDM_DLLEXPORT DMDACreate2d(MPI_Comm,DMDAPeriodicType,DMDAStencilType,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],DM*); 112 extern PetscErrorCode PETSCDM_DLLEXPORT DMDACreate3d(MPI_Comm,DMDAPeriodicType,DMDAStencilType,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscInt[],DM*); 113 extern PetscErrorCode PETSCDM_DLLEXPORT DMSetOptionsPrefix(DM,const char []); 114 extern PetscErrorCode PETSCDM_DLLEXPORT DMSetVecType(DM,const VecType); 115 116 extern PetscErrorCode PETSCDM_DLLEXPORT DMDAGlobalToNaturalBegin(DM,Vec,InsertMode,Vec); 117 extern PetscErrorCode PETSCDM_DLLEXPORT DMDAGlobalToNaturalEnd(DM,Vec,InsertMode,Vec); 118 extern PetscErrorCode PETSCDM_DLLEXPORT DMDANaturalToGlobalBegin(DM,Vec,InsertMode,Vec); 119 extern PetscErrorCode PETSCDM_DLLEXPORT DMDANaturalToGlobalEnd(DM,Vec,InsertMode,Vec); 120 extern PetscErrorCode PETSCDM_DLLEXPORT DMDALocalToLocalBegin(DM,Vec,InsertMode,Vec); 121 extern PetscErrorCode PETSCDM_DLLEXPORT DMDALocalToLocalEnd(DM,Vec,InsertMode,Vec); 122 extern PetscErrorCode PETSCDM_DLLEXPORT DMDACreateNaturalVector(DM,Vec *); 123 124 extern PetscErrorCode PETSCDM_DLLEXPORT DMDALoad(PetscViewer,PetscInt,PetscInt,PetscInt,DM *); 125 extern PetscErrorCode PETSCDM_DLLEXPORT DMDAGetCorners(DM,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*); 126 extern PetscErrorCode PETSCDM_DLLEXPORT DMDAGetGhostCorners(DM,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*); 127 extern PetscErrorCode PETSCDM_DLLEXPORT DMDAGetInfo(DM,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,DMDAPeriodicType*,DMDAStencilType*); 128 extern PetscErrorCode PETSCDM_DLLEXPORT DMDAGetProcessorSubset(DM,DMDADirection,PetscInt,MPI_Comm*); 129 extern PetscErrorCode PETSCDM_DLLEXPORT DMDAGetProcessorSubsets(DM,DMDADirection,MPI_Comm*); 130 131 extern PetscErrorCode PETSCDM_DLLEXPORT DMDAGlobalToNaturalAllCreate(DM,VecScatter*); 132 extern PetscErrorCode PETSCDM_DLLEXPORT DMDANaturalAllToGlobalCreate(DM,VecScatter*); 133 134 extern PetscErrorCode PETSCDM_DLLEXPORT DMDAGetGlobalIndices(DM,PetscInt*,PetscInt**); 135 136 extern PetscErrorCode PETSCDM_DLLEXPORT DMDAGetScatter(DM,VecScatter*,VecScatter*,VecScatter*); 137 extern PetscErrorCode PETSCDM_DLLEXPORT DMDAGetNeighbors(DM,const PetscMPIInt**); 138 139 extern PetscErrorCode PETSCDM_DLLEXPORT DMDAGetAO(DM,AO*); 140 extern PetscErrorCode PETSCDM_DLLEXPORT DMDASetCoordinates(DM,Vec); 141 extern PetscErrorCode PETSCDM_DLLEXPORT DMDAGetCoordinates(DM,Vec *); 142 extern PetscErrorCode PETSCDM_DLLEXPORT DMDAGetGhostedCoordinates(DM,Vec *); 143 extern PetscErrorCode PETSCDM_DLLEXPORT DMDAGetCoordinateDA(DM,DM *); 144 extern PetscErrorCode PETSCDM_DLLEXPORT DMDASetUniformCoordinates(DM,PetscReal,PetscReal,PetscReal,PetscReal,PetscReal,PetscReal); 145 extern PetscErrorCode PETSCDM_DLLEXPORT DMDAGetBoundingBox(DM,PetscReal[],PetscReal[]); 146 extern PetscErrorCode PETSCDM_DLLEXPORT DMDAGetLocalBoundingBox(DM,PetscReal[],PetscReal[]); 147 extern PetscErrorCode PETSCDM_DLLEXPORT DMDASetFieldName(DM,PetscInt,const char[]); 148 extern PetscErrorCode PETSCDM_DLLEXPORT DMDAGetFieldName(DM,PetscInt,const char**); 149 150 extern PetscErrorCode PETSCDM_DLLEXPORT DMDASetPeriodicity(DM, DMDAPeriodicType); 151 extern PetscErrorCode PETSCDM_DLLEXPORT DMDASetDof(DM, int); 152 extern PetscErrorCode PETSCDM_DLLEXPORT DMDASetStencilWidth(DM, PetscInt); 153 extern PetscErrorCode PETSCDM_DLLEXPORT DMDASetOwnershipRanges(DM,const PetscInt[],const PetscInt[],const PetscInt[]); 154 extern PetscErrorCode PETSCDM_DLLEXPORT DMDAGetOwnershipRanges(DM,const PetscInt**,const PetscInt**,const PetscInt**); 155 extern PetscErrorCode PETSCDM_DLLEXPORT DMDASetNumProcs(DM, PetscInt, PetscInt, PetscInt); 156 extern PetscErrorCode PETSCDM_DLLEXPORT DMDASetStencilType(DM, DMDAStencilType); 157 158 extern PetscErrorCode PETSCDM_DLLEXPORT DMDAVecGetArray(DM,Vec,void *); 159 extern PetscErrorCode PETSCDM_DLLEXPORT DMDAVecRestoreArray(DM,Vec,void *); 160 161 extern PetscErrorCode PETSCDM_DLLEXPORT DMDAVecGetArrayDOF(DM,Vec,void *); 162 extern PetscErrorCode PETSCDM_DLLEXPORT DMDAVecRestoreArrayDOF(DM,Vec,void *); 163 164 extern PetscErrorCode PETSCDM_DLLEXPORT DMDASplitComm2d(MPI_Comm,PetscInt,PetscInt,PetscInt,MPI_Comm*); 165 166 /*E 167 DMType - String with the name of a PETSc DM or the creation function 168 with an optional dynamic library name, for example 169 http://www.mcs.anl.gov/petsc/lib.a:myveccreate() 170 171 Level: beginner 172 173 .seealso: DMSetType(), DM 174 E*/ 175 176 #define DMType char* 177 #define DMDA "da" 178 #define DMADDA "adda" 179 #define DMCOMPOSITE "composite" 180 #define DMSLICED "sliced" 181 182 extern PetscFList DMList; 183 extern PetscBool DMRegisterAllCalled; 184 extern PetscErrorCode PETSCDM_DLLEXPORT DMCreate(MPI_Comm,DM*); 185 extern PetscErrorCode PETSCDM_DLLEXPORT DMSetType(DM, const DMType); 186 extern PetscErrorCode PETSCDM_DLLEXPORT DMGetType(DM, const DMType *); 187 extern PetscErrorCode PETSCDM_DLLEXPORT DMRegister(const char[],const char[],const char[],PetscErrorCode (*)(DM)); 188 extern PetscErrorCode PETSCDM_DLLEXPORT DMRegisterAll(const char []); 189 extern PetscErrorCode PETSCDM_DLLEXPORT DMRegisterDestroy(void); 190 191 /*MC 192 DMRegisterDynamic - Adds a new DM component implementation 193 194 Synopsis: 195 PetscErrorCode DMRegisterDynamic(const char *name,const char *path,const char *func_name, PetscErrorCode (*create_func)(DM)) 196 197 Not Collective 198 199 Input Parameters: 200 + name - The name of a new user-defined creation routine 201 . path - The path (either absolute or relative) of the library containing this routine 202 . func_name - The name of routine to create method context 203 - create_func - The creation routine itself 204 205 Notes: 206 DMRegisterDynamic() may be called multiple times to add several user-defined DMs 207 208 If dynamic libraries are used, then the fourth input argument (routine_create) is ignored. 209 210 Sample usage: 211 .vb 212 DMRegisterDynamic("my_da","/home/username/my_lib/lib/libO/solaris/libmy.a", "MyDMCreate", MyDMCreate); 213 .ve 214 215 Then, your DM type can be chosen with the procedural interface via 216 .vb 217 DMCreate(MPI_Comm, DM *); 218 DMSetType(DM,"my_da_name"); 219 .ve 220 or at runtime via the option 221 .vb 222 -da_type my_da_name 223 .ve 224 225 Notes: $PETSC_ARCH occuring in pathname will be replaced with appropriate values. 226 If your function is not being put into a shared library then use DMRegister() instead 227 228 Level: advanced 229 230 .keywords: DM, register 231 .seealso: DMRegisterAll(), DMRegisterDestroy(), DMRegister() 232 M*/ 233 #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 234 #define DMRegisterDynamic(a,b,c,d) DMRegister(a,b,c,0) 235 #else 236 #define DMRegisterDynamic(a,b,c,d) DMRegister(a,b,c,d) 237 #endif 238 239 extern PetscErrorCode PETSCDM_DLLEXPORT MatRegisterDAAD(void); 240 extern PetscErrorCode PETSCDM_DLLEXPORT MatCreateDAAD(DM,Mat*); 241 extern PetscErrorCode PETSCMAT_DLLEXPORT MatCreateSeqUSFFT(Vec, DM,Mat*); 242 243 /*S 244 DMDALocalInfo - C struct that contains information about a structured grid and a processors logical 245 location in it. 246 247 Level: beginner 248 249 Concepts: distributed array 250 251 Developer note: Then entries in this struct are int instead of PetscInt so that the elements may 252 be extracted in Fortran as if from an integer array 253 254 .seealso: DMDACreate1d(), DMDACreate2d(), DMDACreate3d(), DMDestroy(), DM, DMDAGetLocalInfo(), DMDAGetInfo() 255 S*/ 256 typedef struct { 257 PetscInt dim,dof,sw; 258 PetscInt mx,my,mz; /* global number of grid points in each direction */ 259 PetscInt xs,ys,zs; /* starting pointd of this processor, excluding ghosts */ 260 PetscInt xm,ym,zm; /* number of grid points on this processor, excluding ghosts */ 261 PetscInt gxs,gys,gzs; /* starting point of this processor including ghosts */ 262 PetscInt gxm,gym,gzm; /* number of grid points on this processor including ghosts */ 263 DMDAPeriodicType pt; 264 DMDAStencilType st; 265 DM da; 266 } DMDALocalInfo; 267 268 /*MC 269 DMDAForEachPointBegin2d - Starts a loop over the local part of a two dimensional DMDA 270 271 Synopsis: 272 void DMDAForEachPointBegin2d(DALocalInfo *info,PetscInt i,PetscInt j); 273 274 Not Collective 275 276 Level: intermediate 277 278 .seealso: DMDAForEachPointEnd2d(), DMDAVecGetArray() 279 M*/ 280 #define DMDAForEachPointBegin2d(info,i,j) {\ 281 PetscInt _xints = info->xs,_xinte = info->xs+info->xm,_yints = info->ys,_yinte = info->ys+info->ym;\ 282 for (j=_yints; j<_yinte; j++) {\ 283 for (i=_xints; i<_xinte; i++) {\ 284 285 /*MC 286 DMDAForEachPointEnd2d - Ends a loop over the local part of a two dimensional DMDA 287 288 Synopsis: 289 void DMDAForEachPointEnd2d; 290 291 Not Collective 292 293 Level: intermediate 294 295 .seealso: DMDAForEachPointBegin2d(), DMDAVecGetArray() 296 M*/ 297 #define DMDAForEachPointEnd2d }}} 298 299 /*MC 300 DMDACoor2d - Structure for holding 2d (x and y) coordinates. 301 302 Level: intermediate 303 304 Sample Usage: 305 DMDACoor2d **coors; 306 Vec vcoors; 307 DM cda; 308 309 DMDAGetCoordinates(da,&vcoors); 310 DMDAGetCoordinateDA(da,&cda); 311 DMDAVecGetArray(cda,vcoors,&coors); 312 DMDAGetCorners(cda,&mstart,&nstart,0,&m,&n,0) 313 for (i=mstart; i<mstart+m; i++) { 314 for (j=nstart; j<nstart+n; j++) { 315 x = coors[j][i].x; 316 y = coors[j][i].y; 317 ...... 318 } 319 } 320 DMDAVecRestoreArray(dac,vcoors,&coors); 321 322 .seealso: DMDACoor3d, DMDAForEachPointBegin(), DMDAGetCoordinateDA(), DMDAGetCoordinates(), DMDAGetGhostCoordinates() 323 M*/ 324 typedef struct {PetscScalar x,y;} DMDACoor2d; 325 326 /*MC 327 DMDACoor3d - Structure for holding 3d (x, y and z) coordinates. 328 329 Level: intermediate 330 331 Sample Usage: 332 DMDACoor3d ***coors; 333 Vec vcoors; 334 DM cda; 335 336 DMDAGetCoordinates(da,&vcoors); 337 DMDAGetCoordinateDA(da,&cda); 338 DMDAVecGetArray(cda,vcoors,&coors); 339 DMDAGetCorners(cda,&mstart,&nstart,&pstart,&m,&n,&p) 340 for (i=mstart; i<mstart+m; i++) { 341 for (j=nstart; j<nstart+n; j++) { 342 for (k=pstart; k<pstart+p; k++) { 343 x = coors[k][j][i].x; 344 y = coors[k][j][i].y; 345 z = coors[k][j][i].z; 346 ...... 347 } 348 } 349 DMDAVecRestoreArray(dac,vcoors,&coors); 350 351 .seealso: DMDACoor2d, DMDAForEachPointBegin(), DMDAGetCoordinateDA(), DMDAGetCoordinates(), DMDAGetGhostCoordinates() 352 M*/ 353 typedef struct {PetscScalar x,y,z;} DMDACoor3d; 354 355 extern PetscErrorCode PETSCDM_DLLEXPORT DMDAGetLocalInfo(DM,DMDALocalInfo*); 356 typedef PetscErrorCode (*DMDALocalFunction1)(DMDALocalInfo*,void*,void*,void*); 357 extern PetscErrorCode PETSCDM_DLLEXPORT DMDAFormFunctionLocal(DM, DMDALocalFunction1, Vec, Vec, void *); 358 extern PetscErrorCode PETSCDM_DLLEXPORT DMDAFormFunctionLocalGhost(DM, DMDALocalFunction1, Vec, Vec, void *); 359 extern PetscErrorCode PETSCDM_DLLEXPORT DMDAFormJacobianLocal(DM, DMDALocalFunction1, Vec, Mat, void *); 360 extern PetscErrorCode PETSCDM_DLLEXPORT DMDAFormFunction1(DM,Vec,Vec,void*); 361 extern PetscErrorCode PETSCDM_DLLEXPORT DMDAFormFunction(DM,PetscErrorCode (*)(void),Vec,Vec,void*); 362 extern PetscErrorCode PETSCDM_DLLEXPORT DMDAFormFunctioni1(DM,PetscInt,Vec,PetscScalar*,void*); 363 extern PetscErrorCode PETSCDM_DLLEXPORT DMDAFormFunctionib1(DM,PetscInt,Vec,PetscScalar*,void*); 364 extern PetscErrorCode PETSCDM_DLLEXPORT DMDAComputeJacobian1WithAdic(DM,Vec,Mat,void*); 365 extern PetscErrorCode PETSCDM_DLLEXPORT DMDAComputeJacobian1WithAdifor(DM,Vec,Mat,void*); 366 extern PetscErrorCode PETSCDM_DLLEXPORT DMDAMultiplyByJacobian1WithAdic(DM,Vec,Vec,Vec,void*); 367 extern PetscErrorCode PETSCDM_DLLEXPORT DMDAMultiplyByJacobian1WithAdifor(DM,Vec,Vec,Vec,void*); 368 extern PetscErrorCode PETSCDM_DLLEXPORT DMDAMultiplyByJacobian1WithAD(DM,Vec,Vec,Vec,void*); 369 extern PetscErrorCode PETSCDM_DLLEXPORT DMDAComputeJacobian1(DM,Vec,Mat,void*); 370 extern PetscErrorCode PETSCDM_DLLEXPORT DMDAGetLocalFunction(DM,DMDALocalFunction1*); 371 extern PetscErrorCode PETSCDM_DLLEXPORT DMDASetLocalFunction(DM,DMDALocalFunction1); 372 extern PetscErrorCode PETSCDM_DLLEXPORT DMDASetLocalFunctioni(DM,PetscErrorCode (*)(DMDALocalInfo*,MatStencil*,void*,PetscScalar*,void*)); 373 extern PetscErrorCode PETSCDM_DLLEXPORT DMDASetLocalFunctionib(DM,PetscErrorCode (*)(DMDALocalInfo*,MatStencil*,void*,PetscScalar*,void*)); 374 extern PetscErrorCode PETSCDM_DLLEXPORT DMDAGetLocalJacobian(DM,DMDALocalFunction1*); 375 extern PetscErrorCode PETSCDM_DLLEXPORT DMDASetLocalJacobian(DM,DMDALocalFunction1); 376 extern PetscErrorCode PETSCDM_DLLEXPORT DMDASetLocalAdicFunction_Private(DM,DMDALocalFunction1); 377 378 extern PetscErrorCode PETSCDM_DLLEXPORT MatSetDA(Mat,DM); 379 380 /*MC 381 DMDASetLocalAdicFunction - Caches in a DM a local function computed by ADIC/ADIFOR 382 383 Synopsis: 384 PetscErrorCode DMDASetLocalAdicFunction(DM da,DMDALocalFunction1 ad_lf) 385 386 Logically Collective on DM 387 388 Input Parameter: 389 + da - initial distributed array 390 - ad_lf - the local function as computed by ADIC/ADIFOR 391 392 Level: intermediate 393 394 .keywords: distributed array, refine 395 396 .seealso: DMDACreate1d(), DMDACreate2d(), DMDACreate3d(), DMDestroy(), DMDAGetLocalFunction(), DMDASetLocalFunction(), 397 DMDASetLocalJacobian() 398 M*/ 399 #if defined(PETSC_HAVE_ADIC) 400 # define DMDASetLocalAdicFunction(a,d) DMDASetLocalAdicFunction_Private(a,(DMDALocalFunction1)d) 401 #else 402 # define DMDASetLocalAdicFunction(a,d) DMDASetLocalAdicFunction_Private(a,0) 403 #endif 404 405 extern PetscErrorCode PETSCDM_DLLEXPORT DMDASetLocalAdicMFFunction_Private(DM,DMDALocalFunction1); 406 #if defined(PETSC_HAVE_ADIC) 407 # define DMDASetLocalAdicMFFunction(a,d) DMDASetLocalAdicMFFunction_Private(a,(DMDALocalFunction1)d) 408 #else 409 # define DMDASetLocalAdicMFFunction(a,d) DMDASetLocalAdicMFFunction_Private(a,0) 410 #endif 411 extern PetscErrorCode PETSCDM_DLLEXPORT DMDASetLocalAdicFunctioni_Private(DM,PetscErrorCode (*)(DMDALocalInfo*,MatStencil*,void*,void*,void*)); 412 #if defined(PETSC_HAVE_ADIC) 413 # define DMDASetLocalAdicFunctioni(a,d) DMDASetLocalAdicFunctioni_Private(a,(PetscErrorCode (*)(DMDALocalInfo*,MatStencil*,void*,void*,void*))d) 414 #else 415 # define DMDASetLocalAdicFunctioni(a,d) DMDASetLocalAdicFunctioni_Private(a,0) 416 #endif 417 extern PetscErrorCode PETSCDM_DLLEXPORT DMDASetLocalAdicMFFunctioni_Private(DM,PetscErrorCode (*)(DMDALocalInfo*,MatStencil*,void*,void*,void*)); 418 #if defined(PETSC_HAVE_ADIC) 419 # define DMDASetLocalAdicMFFunctioni(a,d) DMDASetLocalAdicMFFunctioni_Private(a,(PetscErrorCode (*)(DMDALocalInfo*,MatStencil*,void*,void*,void*))d) 420 #else 421 # define DMDASetLocalAdicMFFunctioni(a,d) DMDASetLocalAdicMFFunctioni_Private(a,0) 422 #endif 423 424 extern PetscErrorCode PETSCDM_DLLEXPORT DMDASetLocalAdicFunctionib_Private(DM,PetscErrorCode (*)(DMDALocalInfo*,MatStencil*,void*,void*,void*)); 425 #if defined(PETSC_HAVE_ADIC) 426 # define DMDASetLocalAdicFunctionib(a,d) DMDASetLocalAdicFunctionib_Private(a,(PetscErrorCode (*)(DMDALocalInfo*,MatStencil*,void*,void*,void*))d) 427 #else 428 # define DMDASetLocalAdicFunctionib(a,d) DMDASetLocalAdicFunctionib_Private(a,0) 429 #endif 430 extern PetscErrorCode PETSCDM_DLLEXPORT DMDASetLocalAdicMFFunctionib_Private(DM,PetscErrorCode (*)(DMDALocalInfo*,MatStencil*,void*,void*,void*)); 431 #if defined(PETSC_HAVE_ADIC) 432 # define DMDASetLocalAdicMFFunctionib(a,d) DMDASetLocalAdicMFFunctionib_Private(a,(PetscErrorCode (*)(DMDALocalInfo*,MatStencil*,void*,void*,void*))d) 433 #else 434 # define DMDASetLocalAdicMFFunctionib(a,d) DMDASetLocalAdicMFFunctionib_Private(a,0) 435 #endif 436 437 extern PetscErrorCode PETSCDM_DLLEXPORT DMDAFormFunctioniTest1(DM,void*); 438 439 #include "petscmat.h" 440 441 442 extern PetscErrorCode PETSCDM_DLLEXPORT DMView(DM,PetscViewer); 443 extern PetscErrorCode PETSCDM_DLLEXPORT DMDestroy(DM); 444 extern PetscErrorCode PETSCDM_DLLEXPORT DMCreateGlobalVector(DM,Vec*); 445 extern PetscErrorCode PETSCDM_DLLEXPORT DMCreateLocalVector(DM,Vec*); 446 extern PetscErrorCode PETSCDM_DLLEXPORT DMGetLocalVector(DM,Vec *); 447 extern PetscErrorCode PETSCDM_DLLEXPORT DMRestoreLocalVector(DM,Vec *); 448 extern PetscErrorCode PETSCDM_DLLEXPORT DMGetGlobalVector(DM,Vec *); 449 extern PetscErrorCode PETSCDM_DLLEXPORT DMRestoreGlobalVector(DM,Vec *); 450 extern PetscErrorCode PETSCDM_DLLEXPORT DMGetLocalToGlobalMapping(DM,ISLocalToGlobalMapping*); 451 extern PetscErrorCode PETSCDM_DLLEXPORT DMGetLocalToGlobalMappingBlock(DM,ISLocalToGlobalMapping*); 452 extern PetscErrorCode PETSCDM_DLLEXPORT DMGetBlockSize(DM,PetscInt*); 453 extern PetscErrorCode PETSCDM_DLLEXPORT DMGetColoring(DM,ISColoringType,const MatType,ISColoring*); 454 extern PetscErrorCode PETSCDM_DLLEXPORT DMGetMatrix(DM, const MatType,Mat*); 455 extern PetscErrorCode PETSCDM_DLLEXPORT DMGetInterpolation(DM,DM,Mat*,Vec*); 456 extern PetscErrorCode PETSCDM_DLLEXPORT DMGetInjection(DM,DM,VecScatter*); 457 extern PetscErrorCode PETSCDM_DLLEXPORT DMRefine(DM,MPI_Comm,DM*); 458 extern PetscErrorCode PETSCDM_DLLEXPORT DMCoarsen(DM,MPI_Comm,DM*); 459 extern PetscErrorCode PETSCDM_DLLEXPORT DMRefineHierarchy(DM,PetscInt,DM[]); 460 extern PetscErrorCode PETSCDM_DLLEXPORT DMCoarsenHierarchy(DM,PetscInt,DM[]); 461 extern PetscErrorCode PETSCDM_DLLEXPORT DMSetFromOptions(DM); 462 extern PetscErrorCode PETSCDM_DLLEXPORT DMSetUp(DM); 463 extern PetscErrorCode PETSCDM_DLLEXPORT DMGetInterpolationScale(DM,DM,Mat,Vec*); 464 extern PetscErrorCode PETSCDM_DLLEXPORT DMGetAggregates(DM,DM,Mat*); 465 extern PetscErrorCode PETSCDM_DLLEXPORT DMGlobalToLocalBegin(DM,Vec,InsertMode,Vec); 466 extern PetscErrorCode PETSCDM_DLLEXPORT DMGlobalToLocalEnd(DM,Vec,InsertMode,Vec); 467 extern PetscErrorCode PETSCDM_DLLEXPORT DMLocalToGlobalBegin(DM,Vec,InsertMode,Vec); 468 extern PetscErrorCode PETSCDM_DLLEXPORT DMLocalToGlobalEnd(DM,Vec,InsertMode,Vec); 469 extern PetscErrorCode PETSCDM_DLLEXPORT DMGetElements(DM,PetscInt *,PetscInt *,const PetscInt*[]); 470 extern PetscErrorCode PETSCDM_DLLEXPORT DMRestoreElements(DM,PetscInt *,PetscInt *,const PetscInt*[]); 471 472 extern PetscErrorCode PETSCDM_DLLEXPORT DMSetContext(DM,void*); 473 extern PetscErrorCode PETSCDM_DLLEXPORT DMGetContext(DM,void**); 474 extern PetscErrorCode PETSCDM_DLLEXPORT DMSetInitialGuess(DM,PetscErrorCode (*)(DM,Vec)); 475 extern PetscErrorCode PETSCDM_DLLEXPORT DMSetFunction(DM,PetscErrorCode (*)(DM,Vec,Vec)); 476 extern PetscErrorCode PETSCDM_DLLEXPORT DMSetJacobian(DM,PetscErrorCode (*)(DM,Vec,Mat,Mat,MatStructure *)); 477 extern PetscErrorCode PETSCDM_DLLEXPORT DMHasInitialGuess(DM,PetscBool *); 478 extern PetscErrorCode PETSCDM_DLLEXPORT DMHasFunction(DM,PetscBool *); 479 extern PetscErrorCode PETSCDM_DLLEXPORT DMHasJacobian(DM,PetscBool *); 480 extern PetscErrorCode PETSCDM_DLLEXPORT DMComputeInitialGuess(DM,Vec); 481 extern PetscErrorCode PETSCDM_DLLEXPORT DMComputeFunction(DM,Vec,Vec); 482 extern PetscErrorCode PETSCDM_DLLEXPORT DMComputeJacobian(DM,Vec,Mat,Mat,MatStructure *); 483 extern PetscErrorCode PETSCDM_DLLEXPORT DMComputeJacobianDefault(DM,Vec,Mat,Mat,MatStructure *); 484 extern PetscErrorCode PETSCDM_DLLEXPORT DMFinalizePackage(void); 485 486 extern PetscErrorCode PETSCDM_DLLEXPORT DMDASetGetMatrix(DM,PetscErrorCode (*)(DM, const MatType,Mat *)); 487 extern PetscErrorCode PETSCDM_DLLEXPORT DMDASetBlockFills(DM,PetscInt*,PetscInt*); 488 extern PetscErrorCode PETSCDM_DLLEXPORT DMDASetMatPreallocateOnly(DM,PetscBool ); 489 extern PetscErrorCode PETSCDM_DLLEXPORT DMDASetRefinementFactor(DM,PetscInt,PetscInt,PetscInt); 490 extern PetscErrorCode PETSCDM_DLLEXPORT DMDAGetRefinementFactor(DM,PetscInt*,PetscInt*,PetscInt*); 491 492 extern PetscErrorCode PETSCDM_DLLEXPORT DMDAGetAdicArray(DM,PetscBool ,void*,void*,PetscInt*); 493 extern PetscErrorCode PETSCDM_DLLEXPORT DMDARestoreAdicArray(DM,PetscBool ,void*,void*,PetscInt*); 494 extern PetscErrorCode PETSCDM_DLLEXPORT DMDAGetAdicMFArray(DM,PetscBool ,void*,void*,PetscInt*); 495 extern PetscErrorCode PETSCDM_DLLEXPORT DMDAGetAdicMFArray4(DM,PetscBool ,void*,void*,PetscInt*); 496 extern PetscErrorCode PETSCDM_DLLEXPORT DMDAGetAdicMFArray9(DM,PetscBool ,void*,void*,PetscInt*); 497 extern PetscErrorCode PETSCDM_DLLEXPORT DMDAGetAdicMFArrayb(DM,PetscBool ,void*,void*,PetscInt*); 498 extern PetscErrorCode PETSCDM_DLLEXPORT DMDARestoreAdicMFArray(DM,PetscBool ,void*,void*,PetscInt*); 499 extern PetscErrorCode PETSCDM_DLLEXPORT DMDAGetArray(DM,PetscBool ,void*); 500 extern PetscErrorCode PETSCDM_DLLEXPORT DMDARestoreArray(DM,PetscBool ,void*); 501 extern PetscErrorCode PETSCDM_DLLEXPORT ad_DAGetArray(DM,PetscBool ,void*); 502 extern PetscErrorCode PETSCDM_DLLEXPORT ad_DARestoreArray(DM,PetscBool ,void*); 503 extern PetscErrorCode PETSCDM_DLLEXPORT admf_DAGetArray(DM,PetscBool ,void*); 504 extern PetscErrorCode PETSCDM_DLLEXPORT admf_DARestoreArray(DM,PetscBool ,void*); 505 506 #include "petscpf.h" 507 extern PetscErrorCode PETSCDM_DLLEXPORT DMDACreatePF(DM,PF*); 508 509 extern PetscErrorCode PETSCDM_DLLEXPORT DMCompositeCreate(MPI_Comm,DM*); 510 extern PetscErrorCode PETSCDM_DLLEXPORT DMCompositeAddArray(DM,PetscMPIInt,PetscInt); 511 extern PetscErrorCode PETSCDM_DLLEXPORT DMCompositeAddDM(DM,DM); 512 extern PetscErrorCode PETSCDM_DLLEXPORT DMCompositeSetCoupling(DM,PetscErrorCode (*)(DM,Mat,PetscInt*,PetscInt*,PetscInt,PetscInt,PetscInt,PetscInt)); 513 extern PetscErrorCode PETSCDM_DLLEXPORT DMCompositeSetContext(DM,void*); 514 extern PetscErrorCode PETSCDM_DLLEXPORT DMCompositeGetContext(DM,void**); 515 extern PetscErrorCode PETSCDM_DLLEXPORT DMCompositeAddVecScatter(DM,VecScatter); 516 extern PetscErrorCode PETSCDM_DLLEXPORT DMCompositeScatter(DM,Vec,...); 517 extern PetscErrorCode PETSCDM_DLLEXPORT DMCompositeGather(DM,Vec,InsertMode,...); 518 extern PetscErrorCode PETSCDM_DLLEXPORT DMCompositeGetAccess(DM,Vec,...); 519 extern PetscErrorCode PETSCDM_DLLEXPORT DMCompositeGetNumberDM(DM,PetscInt*); 520 extern PetscErrorCode PETSCDM_DLLEXPORT DMCompositeRestoreAccess(DM,Vec,...); 521 extern PetscErrorCode PETSCDM_DLLEXPORT DMCompositeGetLocalVectors(DM,...); 522 extern PetscErrorCode PETSCDM_DLLEXPORT DMCompositeGetEntries(DM,...); 523 extern PetscErrorCode PETSCDM_DLLEXPORT DMCompositeRestoreLocalVectors(DM,...); 524 extern PetscErrorCode PETSCDM_DLLEXPORT DMCompositeGetGlobalISs(DM,IS*[]); 525 extern PetscErrorCode PETSCDM_DLLEXPORT DMCompositeGetLocalISs(DM,IS**); 526 extern PetscErrorCode PETSCDM_DLLEXPORT DMCompositeGetISLocalToGlobalMappings(DM,ISLocalToGlobalMapping**); 527 528 extern PetscErrorCode PETSCDM_DLLEXPORT DMSlicedCreate(MPI_Comm,DM*); 529 extern PetscErrorCode PETSCDM_DLLEXPORT DMSlicedGetGlobalIndices(DM,PetscInt*[]); 530 extern PetscErrorCode PETSCDM_DLLEXPORT DMSlicedSetPreallocation(DM,PetscInt,const PetscInt[],PetscInt,const PetscInt[]); 531 extern PetscErrorCode PETSCDM_DLLEXPORT DMSlicedSetBlockFills(DM,const PetscInt*,const PetscInt*); 532 extern PetscErrorCode PETSCDM_DLLEXPORT DMSlicedSetGhosts(DM,PetscInt,PetscInt,PetscInt,const PetscInt[]); 533 534 535 typedef struct NLF_DAAD* NLF; 536 537 #include <petscbag.h> 538 539 extern PetscErrorCode PETSCSYS_DLLEXPORT PetscViewerBinaryMatlabOpen(MPI_Comm, const char [], PetscViewer*); 540 extern PetscErrorCode PETSCSYS_DLLEXPORT PetscViewerBinaryMatlabDestroy(PetscViewer); 541 extern PetscErrorCode PETSCSYS_DLLEXPORT PetscViewerBinaryMatlabOutputBag(PetscViewer, const char [], PetscBag); 542 extern PetscErrorCode PETSCSYS_DLLEXPORT PetscViewerBinaryMatlabOutputVec(PetscViewer, const char [], Vec); 543 extern PetscErrorCode PETSCSYS_DLLEXPORT PetscViewerBinaryMatlabOutputVecDA(PetscViewer, const char [], Vec, DM); 544 545 546 PetscErrorCode PETSCDM_DLLEXPORT DMADDACreate(MPI_Comm,PetscInt,PetscInt*,PetscInt*,PetscInt,PetscBool *,DM*); 547 PetscErrorCode PETSCDM_DLLEXPORT DMADDASetParameters(DM,PetscInt,PetscInt*,PetscInt*,PetscInt,PetscBool*); 548 PetscErrorCode PETSCDM_DLLEXPORT DMADDASetRefinement(DM, PetscInt *,PetscInt); 549 PetscErrorCode PETSCDM_DLLEXPORT DMADDAGetCorners(DM, PetscInt **, PetscInt **); 550 PetscErrorCode PETSCDM_DLLEXPORT DMADDAGetGhostCorners(DM, PetscInt **, PetscInt **); 551 PetscErrorCode PETSCDM_DLLEXPORT DMADDAGetMatrixNS(DM, DM, const MatType , Mat *); 552 553 /* functions to set values in vectors and matrices */ 554 struct _ADDAIdx_s { 555 PetscInt *x; /* the coordinates, user has to make sure it is the correct size! */ 556 PetscInt d; /* indexes the dof */ 557 }; 558 typedef struct _ADDAIdx_s ADDAIdx; 559 560 PetscErrorCode PETSCDM_DLLEXPORT DMADDAMatSetValues(Mat, DM, PetscInt, const ADDAIdx[], DM, PetscInt, const ADDAIdx[], const PetscScalar[], InsertMode); 561 PetscBool ADDAHCiterStartup(const PetscInt, const PetscInt *const, const PetscInt *const, PetscInt *const); 562 PetscBool ADDAHCiter(const PetscInt, const PetscInt *const, const PetscInt *const, PetscInt *const); 563 564 PETSC_EXTERN_CXX_END 565 #endif 566