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