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