Actual source code: petscda.h
1: /*
2: Regular array object, for easy parallelism of simple grid
3: problems on regular distributed arrays.
4: */
7: #include petscvec.h
8: #include petscao.h
11: /*S
12: DA - Abstract PETSc object that manages distributed field data for a single structured grid
14: Level: beginner
16: Concepts: distributed array
18: .seealso: DACreate1d(), DACreate2d(), DACreate3d(), DADestroy(), VecScatter, DACreate(), DM, DMComposite
19: S*/
20: typedef struct _p_DA* DA;
22: #define DAType char*
23: #define DA1D "da1d"
24: #define DA2D "da2d"
25: #define DA3D "da3d"
27: /*E
28: DAStencilType - Determines if the stencil extends only along the coordinate directions, or also
29: to the northeast, northwest etc
31: Level: beginner
33: .seealso: DACreate1d(), DACreate2d(), DACreate3d(), DA, DACreate()
34: E*/
35: typedef enum { DA_STENCIL_STAR,DA_STENCIL_BOX } DAStencilType;
37: /*MC
38: DA_STENCIL_STAR - "Star"-type stencil. In logical grid coordinates, only (i,j,k), (i+s,j,k), (i,j+s,k),
39: (i,j,k+s) are in the stencil NOT, for example, (i+s,j+s,k)
41: Level: beginner
43: .seealso: DA_STENCIL_BOX, DAStencilType
44: M*/
46: /*MC
47: DA_STENCIL_BOX - "Box"-type stencil. In logical grid coordinates, any of (i,j,k), (i+s,j+r,k+t) may
48: be in the stencil.
50: Level: beginner
52: .seealso: DA_STENCIL_STAR, DAStencilType
53: M*/
55: /*E
56: DAPeriodicType - Is the domain periodic in one or more directions
58: Level: beginner
60: DA_XYZGHOSTED means that ghost points are put around all the physical boundaries
61: in the local representation of the Vec (i.e. DACreate/GetLocalVector().
63: .seealso: DACreate1d(), DACreate2d(), DACreate3d(), DA, DACreate()
64: E*/
65: typedef enum { DA_NONPERIODIC,DA_XPERIODIC,DA_YPERIODIC,DA_XYPERIODIC,
66: DA_XYZPERIODIC,DA_XZPERIODIC,DA_YZPERIODIC,DA_ZPERIODIC,DA_XYZGHOSTED} DAPeriodicType;
69: /*E
70: DAInterpolationType - Defines the type of interpolation that will be returned by
71: DAGetInterpolation.
73: Level: beginner
75: .seealso: DACreate1d(), DACreate2d(), DACreate3d(), DA, DAGetInterpolation(), DASetInterpolationType(), DACreate()
76: E*/
77: typedef enum { DA_Q0, DA_Q1 } DAInterpolationType;
79: EXTERN PetscErrorCode DASetInterpolationType(DA,DAInterpolationType);
81: /*E
82: DAElementType - Defines the type of elements that will be returned by
83: DAGetElements.
85: Level: beginner
87: .seealso: DACreate1d(), DACreate2d(), DACreate3d(), DA, DAGetInterpolation(), DASetInterpolationType(),
88: DASetElementType(), DAGetElements(), DARestoreElements(), DACreate()
89: E*/
90: typedef enum { DA_ELEMENT_P1, DA_ELEMENT_Q1 } DAElementType;
92: EXTERN PetscErrorCode DASetElementType(DA,DAElementType);
93: /*MC
94: DAGetElements - same as DMGetElements()
95: uses DA instead of DM as input
97: Level: beginner
98: M*/
99: #define DAGetElements(da,a,b) DMGetElements((DM)da,a,b)
100: /*MC
101: DARestoreElements - same as DMRestoreElements()
102: uses DA instead of DM as input
104: Level: beginner
105: M*/
106: #define DARestoreElements(da,a,b) DMRestoreElements((DM)da,a,b)
109: #define DAXPeriodic(pt) ((pt)==DA_XPERIODIC||(pt)==DA_XYPERIODIC||(pt)==DA_XZPERIODIC||(pt)==DA_XYZPERIODIC)
110: #define DAYPeriodic(pt) ((pt)==DA_YPERIODIC||(pt)==DA_XYPERIODIC||(pt)==DA_YZPERIODIC||(pt)==DA_XYZPERIODIC)
111: #define DAZPeriodic(pt) ((pt)==DA_ZPERIODIC||(pt)==DA_XZPERIODIC||(pt)==DA_YZPERIODIC||(pt)==DA_XYZPERIODIC)
113: typedef enum { DA_X,DA_Y,DA_Z } DADirection;
117: #define MATSEQUSFFT "sequsfft"
119: EXTERN PetscErrorCode DACreate(MPI_Comm,DA*);
120: EXTERN PetscErrorCode DASetDim(DA,PetscInt);
121: EXTERN PetscErrorCode DASetSizes(DA,PetscInt,PetscInt,PetscInt);
122: EXTERN PetscErrorCode DACreate1d(MPI_Comm,DAPeriodicType,PetscInt,PetscInt,PetscInt,const PetscInt[],DA *);
123: EXTERN PetscErrorCode DACreate2d(MPI_Comm,DAPeriodicType,DAStencilType,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],DA*);
124: EXTERN PetscErrorCode DACreate3d(MPI_Comm,DAPeriodicType,DAStencilType,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscInt[],DA*);
125: EXTERN PetscErrorCode DASetOptionsPrefix(DA,const char []);
126: EXTERN PetscErrorCode DAViewFromOptions(DA, const char []);
127: EXTERN PetscErrorCode DASetFromOptions(DA);
128: EXTERN PetscErrorCode DADestroy(DA);
129: EXTERN PetscErrorCode DAView(DA,PetscViewer);
131: EXTERN PetscErrorCode DAGlobalToLocalBegin(DA,Vec,InsertMode,Vec);
132: EXTERN PetscErrorCode DAGlobalToLocalEnd(DA,Vec,InsertMode,Vec);
133: EXTERN PetscErrorCode DAGlobalToNaturalBegin(DA,Vec,InsertMode,Vec);
134: EXTERN PetscErrorCode DAGlobalToNaturalEnd(DA,Vec,InsertMode,Vec);
135: EXTERN PetscErrorCode DANaturalToGlobalBegin(DA,Vec,InsertMode,Vec);
136: EXTERN PetscErrorCode DANaturalToGlobalEnd(DA,Vec,InsertMode,Vec);
137: EXTERN PetscErrorCode DALocalToLocalBegin(DA,Vec,InsertMode,Vec);
138: EXTERN PetscErrorCode DALocalToLocalEnd(DA,Vec,InsertMode,Vec);
139: EXTERN PetscErrorCode DALocalToGlobal(DA,Vec,InsertMode,Vec);
140: EXTERN PetscErrorCode DALocalToGlobalBegin(DA,Vec,Vec);
141: EXTERN PetscErrorCode DALocalToGlobalEnd(DA,Vec,Vec);
142: EXTERN PetscErrorCode DAGetOwnershipRanges(DA,const PetscInt*[],const PetscInt*[],const PetscInt*[]);
143: EXTERN PetscErrorCode DACreateGlobalVector(DA,Vec *);
144: EXTERN PetscErrorCode DACreateLocalVector(DA,Vec *);
145: EXTERN PetscErrorCode DACreateNaturalVector(DA,Vec *);
146: #define DAGetLocalVector(da,v) DMGetLocalVector((DM)da,v)
147: #define DARestoreLocalVector(da,v) DMRestoreLocalVector((DM)da,v)
148: #define DAGetGlobalVector(da,v) DMGetGlobalVector((DM)da,v)
149: #define DARestoreGlobalVector(da,v) DMRestoreGlobalVector((DM)da,v)
150: EXTERN PetscErrorCode DALoad(PetscViewer,PetscInt,PetscInt,PetscInt,DA *);
151: EXTERN PetscErrorCode DAGetCorners(DA,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*);
152: EXTERN PetscErrorCode DAGetGhostCorners(DA,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*);
153: EXTERN PetscErrorCode DAGetInfo(DA,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,DAPeriodicType*,DAStencilType*);
154: EXTERN PetscErrorCode DAGetProcessorSubset(DA,DADirection,PetscInt,MPI_Comm*);
155: EXTERN PetscErrorCode DARefine(DA,MPI_Comm,DA*);
156: EXTERN PetscErrorCode DACoarsen(DA,MPI_Comm,DA*);
157: EXTERN PetscErrorCode DARefineHierarchy(DA,PetscInt,DA[]);
158: EXTERN PetscErrorCode DACoarsenHierarchy(DA,PetscInt,DA[]);
160: EXTERN PetscErrorCode DAGlobalToNaturalAllCreate(DA,VecScatter*);
161: EXTERN PetscErrorCode DANaturalAllToGlobalCreate(DA,VecScatter*);
163: EXTERN PetscErrorCode DAGetGlobalIndices(DA,PetscInt*,PetscInt**);
164: EXTERN PetscErrorCode DAGetISLocalToGlobalMapping(DA,ISLocalToGlobalMapping*);
165: EXTERN PetscErrorCode DAGetISLocalToGlobalMappingBlck(DA,ISLocalToGlobalMapping*);
167: EXTERN PetscErrorCode DAGetScatter(DA,VecScatter*,VecScatter*,VecScatter*);
168: EXTERN PetscErrorCode DAGetNeighbors(DA,const PetscMPIInt**);
170: EXTERN PetscErrorCode DAGetAO(DA,AO*);
171: EXTERN PetscErrorCode DASetCoordinates(DA,Vec);
172: EXTERN PetscErrorCode DAGetCoordinates(DA,Vec *);
173: EXTERN PetscErrorCode DAGetGhostedCoordinates(DA,Vec *);
174: EXTERN PetscErrorCode DAGetCoordinateDA(DA,DA *);
175: EXTERN PetscErrorCode DASetUniformCoordinates(DA,PetscReal,PetscReal,PetscReal,PetscReal,PetscReal,PetscReal);
176: EXTERN PetscErrorCode DAGetBoundingBox(DA,PetscReal[],PetscReal[]);
177: EXTERN PetscErrorCode DAGetLocalBoundingBox(DA,PetscReal[],PetscReal[]);
178: EXTERN PetscErrorCode DASetFieldName(DA,PetscInt,const char[]);
179: EXTERN PetscErrorCode DAGetFieldName(DA,PetscInt,char **);
181: EXTERN PetscErrorCode DASetPeriodicity(DA, DAPeriodicType);
182: EXTERN PetscErrorCode DASetDof(DA, int);
183: EXTERN PetscErrorCode DASetStencilWidth(DA, int);
184: EXTERN PetscErrorCode DASetVertexDivision(DA, const PetscInt[], const PetscInt[], const PetscInt[]);
185: EXTERN PetscErrorCode DASetNumProcs(DA, PetscInt, PetscInt, PetscInt);
186: EXTERN PetscErrorCode DASetStencilType(DA, DAStencilType);
188: EXTERN PetscErrorCode DAVecGetArray(DA,Vec,void *);
189: EXTERN PetscErrorCode DAVecRestoreArray(DA,Vec,void *);
191: EXTERN PetscErrorCode DAVecGetArrayDOF(DA,Vec,void *);
192: EXTERN PetscErrorCode DAVecRestoreArrayDOF(DA,Vec,void *);
194: EXTERN PetscErrorCode DASplitComm2d(MPI_Comm,PetscInt,PetscInt,PetscInt,MPI_Comm*);
196: /* Dynamic creation and loading functions */
199: EXTERN PetscErrorCode DASetType(DA, const DAType);
200: EXTERN PetscErrorCode DAGetType(DA, const DAType *);
201: EXTERN PetscErrorCode DARegister(const char[],const char[],const char[],PetscErrorCode (*)(DA));
202: EXTERN PetscErrorCode DARegisterAll(const char []);
203: EXTERN PetscErrorCode DARegisterDestroy(void);
205: /*MC
206: DARegisterDynamic - Adds a new DA component implementation
208: Synopsis:
209: PetscErrorCode DARegisterDynamic(const char *name,const char *path,const char *func_name, PetscErrorCode (*create_func)(DA))
211: Not Collective
213: Input Parameters:
214: + name - The name of a new user-defined creation routine
215: . path - The path (either absolute or relative) of the library containing this routine
216: . func_name - The name of routine to create method context
217: - create_func - The creation routine itself
219: Notes:
220: DARegisterDynamic() may be called multiple times to add several user-defined DAs
222: If dynamic libraries are used, then the fourth input argument (routine_create) is ignored.
224: Sample usage:
225: .vb
226: DARegisterDynamic("my_da","/home/username/my_lib/lib/libO/solaris/libmy.a", "MyDACreate", MyDACreate);
227: .ve
229: Then, your DA type can be chosen with the procedural interface via
230: .vb
231: DACreate(MPI_Comm, DA *);
232: DASetType(DA,"my_da_name");
233: .ve
234: or at runtime via the option
235: .vb
236: -da_type my_da_name
237: .ve
239: Notes: $PETSC_ARCH occuring in pathname will be replaced with appropriate values.
240: If your function is not being put into a shared library then use DARegister() instead
241:
242: Level: advanced
244: .keywords: DA, register
245: .seealso: DARegisterAll(), DARegisterDestroy(), DARegister()
246: M*/
247: #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
248: #define DARegisterDynamic(a,b,c,d) DARegister(a,b,c,0)
249: #else
250: #define DARegisterDynamic(a,b,c,d) DARegister(a,b,c,d)
251: #endif
253: /*S
254: SDA - This provides a simplified interface to the DA distributed
255: array object in PETSc. This is intended for people who are
256: NOT using PETSc vectors or objects but just want to distribute
257: simple rectangular arrays amoung a number of procesors and have
258: PETSc handle moving the ghost-values when needed.
260: In certain applications this can serve as a replacement for
261: BlockComm (which is apparently being phased out?).
264: Level: beginner
266: Concepts: simplified distributed array
268: .seealso: SDACreate1d(), SDACreate2d(), SDACreate3d(), SDADestroy(), DA, SDALocalToLocalBegin(),
269: SDALocalToLocalEnd(), SDAGetCorners(), SDAGetGhostCorners()
270: S*/
271: typedef struct _n_SDA* SDA;
273: EXTERN PetscErrorCode SDACreate3d(MPI_Comm,DAPeriodicType,DAStencilType,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscInt[],SDA*);
274: EXTERN PetscErrorCode SDACreate2d(MPI_Comm,DAPeriodicType,DAStencilType,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],SDA*);
275: EXTERN PetscErrorCode SDACreate1d(MPI_Comm,DAPeriodicType,PetscInt,PetscInt,PetscInt,const PetscInt[],SDA*);
276: EXTERN PetscErrorCode SDADestroy(SDA);
277: EXTERN PetscErrorCode SDALocalToLocalBegin(SDA,PetscScalar*,InsertMode,PetscScalar*);
278: EXTERN PetscErrorCode SDALocalToLocalEnd(SDA,PetscScalar*,InsertMode,PetscScalar*);
279: EXTERN PetscErrorCode SDAGetCorners(SDA,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*);
280: EXTERN PetscErrorCode SDAGetGhostCorners(SDA,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*);
281: EXTERN PetscErrorCode SDAArrayView(SDA,PetscScalar*,PetscViewer);
283: EXTERN PetscErrorCode MatRegisterDAAD(void);
284: EXTERN PetscErrorCode MatCreateDAAD(DA,Mat*);
285: EXTERN PetscErrorCode MatCreateSeqUSFFT(Vec, DA,Mat*);
287: /*S
288: DALocalInfo - C struct that contains information about a structured grid and a processors logical
289: location in it.
291: Level: beginner
293: Concepts: distributed array
295: Developer note: Then entries in this struct are int instead of PetscInt so that the elements may
296: be extracted in Fortran as if from an integer array
298: .seealso: DACreate1d(), DACreate2d(), DACreate3d(), DADestroy(), DA, DAGetLocalInfo(), DAGetInfo()
299: S*/
300: typedef struct {
301: PetscInt dim,dof,sw;
302: PetscInt mx,my,mz; /* global number of grid points in each direction */
303: PetscInt xs,ys,zs; /* starting pointd of this processor, excluding ghosts */
304: PetscInt xm,ym,zm; /* number of grid points on this processor, excluding ghosts */
305: PetscInt gxs,gys,gzs; /* starting point of this processor including ghosts */
306: PetscInt gxm,gym,gzm; /* number of grid points on this processor including ghosts */
307: DAPeriodicType pt;
308: DAStencilType st;
309: DA da;
310: } DALocalInfo;
312: /*MC
313: DAForEachPointBegin2d - Starts a loop over the local part of a two dimensional DA
315: Synopsis:
316: void DAForEachPointBegin2d(DALocalInfo *info,PetscInt i,PetscInt j);
317:
318: Not Collective
320: Level: intermediate
322: .seealso: DAForEachPointEnd2d(), DAVecGetArray()
323: M*/
324: #define DAForEachPointBegin2d(info,i,j) {\
325: PetscInt _xints = info->xs,_xinte = info->xs+info->xm,_yints = info->ys,_yinte = info->ys+info->ym;\
326: for (j=_yints; j<_yinte; j++) {\
327: for (i=_xints; i<_xinte; i++) {\
329: /*MC
330: DAForEachPointEnd2d - Ends a loop over the local part of a two dimensional DA
332: Synopsis:
333: void DAForEachPointEnd2d;
334:
335: Not Collective
337: Level: intermediate
339: .seealso: DAForEachPointBegin2d(), DAVecGetArray()
340: M*/
341: #define DAForEachPointEnd2d }}}
343: /*MC
344: DACoor2d - Structure for holding 2d (x and y) coordinates.
346: Level: intermediate
348: Sample Usage:
349: DACoor2d **coors;
350: Vec vcoors;
351: DA cda;
353: DAGetCoordinates(da,&vcoors);
354: DAGetCoordinateDA(da,&cda);
355: DAVecGetArray(cda,vcoors,&coors);
356: DAGetCorners(cda,&mstart,&nstart,0,&m,&n,0)
357: for (i=mstart; i<mstart+m; i++) {
358: for (j=nstart; j<nstart+n; j++) {
359: x = coors[j][i].x;
360: y = coors[j][i].y;
361: ......
362: }
363: }
364: DAVecRestoreArray(dac,vcoors,&coors);
366: .seealso: DACoor3d, DAForEachPointBegin(), DAGetCoordinateDA(), DAGetCoordinates(), DAGetGhostCoordinates()
367: M*/
368: typedef struct {PetscScalar x,y;} DACoor2d;
370: /*MC
371: DACoor3d - Structure for holding 3d (x, y and z) coordinates.
373: Level: intermediate
375: Sample Usage:
376: DACoor3d ***coors;
377: Vec vcoors;
378: DA cda;
380: DAGetCoordinates(da,&vcoors);
381: DAGetCoordinateDA(da,&cda);
382: DAVecGetArray(cda,vcoors,&coors);
383: DAGetCorners(cda,&mstart,&nstart,&pstart,&m,&n,&p)
384: for (i=mstart; i<mstart+m; i++) {
385: for (j=nstart; j<nstart+n; j++) {
386: for (k=pstart; k<pstart+p; k++) {
387: x = coors[k][j][i].x;
388: y = coors[k][j][i].y;
389: z = coors[k][j][i].z;
390: ......
391: }
392: }
393: DAVecRestoreArray(dac,vcoors,&coors);
395: .seealso: DACoor2d, DAForEachPointBegin(), DAGetCoordinateDA(), DAGetCoordinates(), DAGetGhostCoordinates()
396: M*/
397: typedef struct {PetscScalar x,y,z;} DACoor3d;
398:
399: EXTERN PetscErrorCode DAGetLocalInfo(DA,DALocalInfo*);
400: typedef PetscErrorCode (*DALocalFunction1)(DALocalInfo*,void*,void*,void*);
401: EXTERN PetscErrorCode DAFormFunctionLocal(DA, DALocalFunction1, Vec, Vec, void *);
402: EXTERN PetscErrorCode DAFormFunctionLocalGhost(DA, DALocalFunction1, Vec, Vec, void *);
403: EXTERN PetscErrorCode DAFormJacobianLocal(DA, DALocalFunction1, Vec, Mat, void *);
404: EXTERN PetscErrorCode DAFormFunction1(DA,Vec,Vec,void*);
405: EXTERN PetscErrorCode DAFormFunction(DA,PetscErrorCode (*)(void),Vec,Vec,void*);
406: EXTERN PetscErrorCode DAFormFunctioni1(DA,PetscInt,Vec,PetscScalar*,void*);
407: EXTERN PetscErrorCode DAFormFunctionib1(DA,PetscInt,Vec,PetscScalar*,void*);
408: EXTERN PetscErrorCode DAComputeJacobian1WithAdic(DA,Vec,Mat,void*);
409: EXTERN PetscErrorCode DAComputeJacobian1WithAdifor(DA,Vec,Mat,void*);
410: EXTERN PetscErrorCode DAMultiplyByJacobian1WithAdic(DA,Vec,Vec,Vec,void*);
411: EXTERN PetscErrorCode DAMultiplyByJacobian1WithAdifor(DA,Vec,Vec,Vec,void*);
412: EXTERN PetscErrorCode DAMultiplyByJacobian1WithAD(DA,Vec,Vec,Vec,void*);
413: EXTERN PetscErrorCode DAComputeJacobian1(DA,Vec,Mat,void*);
414: EXTERN PetscErrorCode DAGetLocalFunction(DA,DALocalFunction1*);
415: EXTERN PetscErrorCode DASetLocalFunction(DA,DALocalFunction1);
416: EXTERN PetscErrorCode DASetLocalFunctioni(DA,PetscErrorCode (*)(DALocalInfo*,MatStencil*,void*,PetscScalar*,void*));
417: EXTERN PetscErrorCode DASetLocalFunctionib(DA,PetscErrorCode (*)(DALocalInfo*,MatStencil*,void*,PetscScalar*,void*));
418: EXTERN PetscErrorCode DAGetLocalJacobian(DA,DALocalFunction1*);
419: EXTERN PetscErrorCode DASetLocalJacobian(DA,DALocalFunction1);
420: EXTERN PetscErrorCode DASetLocalAdicFunction_Private(DA,DALocalFunction1);
422: EXTERN PetscErrorCode MatSetDA(Mat,DA);
424: /*MC
425: DASetLocalAdicFunction - Caches in a DA a local function computed by ADIC/ADIFOR
427: Synopsis:
428: PetscErrorCode DASetLocalAdicFunction(DA da,DALocalFunction1 ad_lf)
429:
430: Collective on DA
432: Input Parameter:
433: + da - initial distributed array
434: - ad_lf - the local function as computed by ADIC/ADIFOR
436: Level: intermediate
438: .keywords: distributed array, refine
440: .seealso: DACreate1d(), DACreate2d(), DACreate3d(), DADestroy(), DAGetLocalFunction(), DASetLocalFunction(),
441: DASetLocalJacobian()
442: M*/
443: #if defined(PETSC_HAVE_ADIC)
444: # define DASetLocalAdicFunction(a,d) DASetLocalAdicFunction_Private(a,(DALocalFunction1)d)
445: #else
446: # define DASetLocalAdicFunction(a,d) DASetLocalAdicFunction_Private(a,0)
447: #endif
449: EXTERN PetscErrorCode DASetLocalAdicMFFunction_Private(DA,DALocalFunction1);
450: #if defined(PETSC_HAVE_ADIC)
451: # define DASetLocalAdicMFFunction(a,d) DASetLocalAdicMFFunction_Private(a,(DALocalFunction1)d)
452: #else
453: # define DASetLocalAdicMFFunction(a,d) DASetLocalAdicMFFunction_Private(a,0)
454: #endif
455: EXTERN PetscErrorCode DASetLocalAdicFunctioni_Private(DA,PetscErrorCode (*)(DALocalInfo*,MatStencil*,void*,void*,void*));
456: #if defined(PETSC_HAVE_ADIC)
457: # define DASetLocalAdicFunctioni(a,d) DASetLocalAdicFunctioni_Private(a,(PetscErrorCode (*)(DALocalInfo*,MatStencil*,void*,void*,void*))d)
458: #else
459: # define DASetLocalAdicFunctioni(a,d) DASetLocalAdicFunctioni_Private(a,0)
460: #endif
461: EXTERN PetscErrorCode DASetLocalAdicMFFunctioni_Private(DA,PetscErrorCode (*)(DALocalInfo*,MatStencil*,void*,void*,void*));
462: #if defined(PETSC_HAVE_ADIC)
463: # define DASetLocalAdicMFFunctioni(a,d) DASetLocalAdicMFFunctioni_Private(a,(PetscErrorCode (*)(DALocalInfo*,MatStencil*,void*,void*,void*))d)
464: #else
465: # define DASetLocalAdicMFFunctioni(a,d) DASetLocalAdicMFFunctioni_Private(a,0)
466: #endif
468: EXTERN PetscErrorCode DASetLocalAdicFunctionib_Private(DA,PetscErrorCode (*)(DALocalInfo*,MatStencil*,void*,void*,void*));
469: #if defined(PETSC_HAVE_ADIC)
470: # define DASetLocalAdicFunctionib(a,d) DASetLocalAdicFunctionib_Private(a,(PetscErrorCode (*)(DALocalInfo*,MatStencil*,void*,void*,void*))d)
471: #else
472: # define DASetLocalAdicFunctionib(a,d) DASetLocalAdicFunctionib_Private(a,0)
473: #endif
474: EXTERN PetscErrorCode DASetLocalAdicMFFunctionib_Private(DA,PetscErrorCode (*)(DALocalInfo*,MatStencil*,void*,void*,void*));
475: #if defined(PETSC_HAVE_ADIC)
476: # define DASetLocalAdicMFFunctionib(a,d) DASetLocalAdicMFFunctionib_Private(a,(PetscErrorCode (*)(DALocalInfo*,MatStencil*,void*,void*,void*))d)
477: #else
478: # define DASetLocalAdicMFFunctionib(a,d) DASetLocalAdicMFFunctionib_Private(a,0)
479: #endif
481: EXTERN PetscErrorCode DAFormFunctioniTest1(DA,void*);
483: #include petscmat.h
485: /*S
486: DM - Abstract PETSc object that manages an abstract grid object
487:
488: Level: intermediate
490: Concepts: grids, grid refinement
492: Notes: The DA object and the DMComposite object are examples of DMs
494: Though the DA objects require the petscsnes.h include files the DM library is
495: NOT dependent on the SNES or KSP library. In fact, the KSP and SNES libraries depend on
496: DM. (This is not great design, but not trivial to fix).
498: .seealso: DMCompositeCreate(), DA, DMComposite
499: S*/
500: typedef struct _p_DM* DM;
502: EXTERN PetscErrorCode DMView(DM,PetscViewer);
503: EXTERN PetscErrorCode DMDestroy(DM);
504: EXTERN PetscErrorCode DMCreateGlobalVector(DM,Vec*);
505: EXTERN PetscErrorCode DMCreateLocalVector(DM,Vec*);
506: EXTERN PetscErrorCode DMGetLocalVector(DM,Vec *);
507: EXTERN PetscErrorCode DMRestoreLocalVector(DM,Vec *);
508: EXTERN PetscErrorCode DMGetGlobalVector(DM,Vec *);
509: EXTERN PetscErrorCode DMRestoreGlobalVector(DM,Vec *);
510: EXTERN PetscErrorCode DMGetColoring(DM,ISColoringType,const MatType,ISColoring*);
511: EXTERN PetscErrorCode DMGetMatrix(DM, const MatType,Mat*);
512: EXTERN PetscErrorCode DMGetInterpolation(DM,DM,Mat*,Vec*);
513: EXTERN PetscErrorCode DMGetInjection(DM,DM,VecScatter*);
514: EXTERN PetscErrorCode DMRefine(DM,MPI_Comm,DM*);
515: EXTERN PetscErrorCode DMCoarsen(DM,MPI_Comm,DM*);
516: EXTERN PetscErrorCode DMRefineHierarchy(DM,PetscInt,DM[]);
517: EXTERN PetscErrorCode DMCoarsenHierarchy(DM,PetscInt,DM[]);
518: EXTERN PetscErrorCode DMGetInterpolationScale(DM,DM,Mat,Vec*);
519: EXTERN PetscErrorCode DMGetAggregates(DM,DM,Mat*);
520: EXTERN PetscErrorCode DMGlobalToLocalBegin(DM,Vec,InsertMode,Vec);
521: EXTERN PetscErrorCode DMGlobalToLocalEnd(DM,Vec,InsertMode,Vec);
522: EXTERN PetscErrorCode DMLocalToGlobal(DM,Vec,InsertMode,Vec);
523: EXTERN PetscErrorCode DMGetElements(DM,PetscInt *,const PetscInt*[]);
524: EXTERN PetscErrorCode DMRestoreElements(DM,PetscInt *,const PetscInt*[]);
525: EXTERN PetscErrorCode DMFinalizePackage(void);
527: EXTERN PetscErrorCode DAGetColoring(DA,ISColoringType,const MatType,ISColoring *);
528: EXTERN PetscErrorCode DAGetMatrix(DA, const MatType,Mat *);
529: EXTERN PetscErrorCode DASetGetMatrix(DA,PetscErrorCode (*)(DA, const MatType,Mat *));
530: EXTERN PetscErrorCode DAGetInterpolation(DA,DA,Mat*,Vec*);
531: EXTERN PetscErrorCode DAGetAggregates(DA,DA,Mat*);
532: EXTERN PetscErrorCode DAGetInjection(DA,DA,VecScatter*);
533: EXTERN PetscErrorCode DASetBlockFills(DA,PetscInt*,PetscInt*);
534: EXTERN PetscErrorCode DASetMatPreallocateOnly(DA,PetscTruth);
535: EXTERN PetscErrorCode DASetRefinementFactor(DA,PetscInt,PetscInt,PetscInt);
536: EXTERN PetscErrorCode DAGetRefinementFactor(DA,PetscInt*,PetscInt*,PetscInt*);
538: EXTERN PetscErrorCode DAGetAdicArray(DA,PetscTruth,void**,void**,PetscInt*);
539: EXTERN PetscErrorCode DARestoreAdicArray(DA,PetscTruth,void**,void**,PetscInt*);
540: EXTERN PetscErrorCode DAGetAdicMFArray(DA,PetscTruth,void**,void**,PetscInt*);
541: EXTERN PetscErrorCode DAGetAdicMFArray4(DA,PetscTruth,void**,void**,PetscInt*);
542: EXTERN PetscErrorCode DAGetAdicMFArray9(DA,PetscTruth,void**,void**,PetscInt*);
543: EXTERN PetscErrorCode DAGetAdicMFArrayb(DA,PetscTruth,void**,void**,PetscInt*);
544: EXTERN PetscErrorCode DARestoreAdicMFArray(DA,PetscTruth,void**,void**,PetscInt*);
545: EXTERN PetscErrorCode DAGetArray(DA,PetscTruth,void**);
546: EXTERN PetscErrorCode DARestoreArray(DA,PetscTruth,void**);
547: EXTERN PetscErrorCode ad_DAGetArray(DA,PetscTruth,void**);
548: EXTERN PetscErrorCode ad_DARestoreArray(DA,PetscTruth,void**);
549: EXTERN PetscErrorCode admf_DAGetArray(DA,PetscTruth,void**);
550: EXTERN PetscErrorCode admf_DARestoreArray(DA,PetscTruth,void**);
552: #include petscpf.h
553: EXTERN PetscErrorCode DACreatePF(DA,PF*);
555: /*S
556: DMComposite - Abstract PETSc object that manages treating several distinct vectors as if they
557: were one. The DMComposite routines allow one to manage a nonlinear solver that works on a
558: vector that consists of several distinct parts. This is mostly used for LNKS solvers,
559: that is design optimization problems that are written as a nonlinear system
561: Level: beginner
563: Concepts: multi-component, LNKS solvers
565: .seealso: DMCompositeCreate(), DMCompositeDestroy(), DM
566: S*/
567: typedef struct _p_DMComposite* DMComposite;
569: EXTERN PetscErrorCode DMCompositeCreate(MPI_Comm,DMComposite*);
570: EXTERN PetscErrorCode DMCompositeDestroy(DMComposite);
571: EXTERN PetscErrorCode DMCompositeView(DMComposite,PetscViewer);
572: EXTERN PetscErrorCode DMCompositeAddArray(DMComposite,PetscMPIInt,PetscInt);
573: EXTERN PetscErrorCode DMCompositeAddDM(DMComposite,DM);
574: EXTERN PetscErrorCode DMCompositeSetCoupling(DMComposite,PetscErrorCode (*)(DMComposite,Mat,PetscInt*,PetscInt*,PetscInt,PetscInt,PetscInt,PetscInt));
575: EXTERN PetscErrorCode DMCompositeSetContext(DMComposite,void*);
576: EXTERN PetscErrorCode DMCompositeGetContext(DMComposite,void**);
577: EXTERN PetscErrorCode DMCompositeAddVecScatter(DMComposite,VecScatter);
578: EXTERN PetscErrorCode DMCompositeScatter(DMComposite,Vec,...);
579: EXTERN PetscErrorCode DMCompositeGather(DMComposite,Vec,...);
580: EXTERN PetscErrorCode DMCompositeGetAccess(DMComposite,Vec,...);
581: EXTERN PetscErrorCode DMCompositeGetNumberDM(DMComposite,PetscInt*);
582: EXTERN PetscErrorCode DMCompositeRestoreAccess(DMComposite,Vec,...);
583: EXTERN PetscErrorCode DMCompositeGetLocalVectors(DMComposite,...);
584: EXTERN PetscErrorCode DMCompositeGetEntries(DMComposite,...);
585: EXTERN PetscErrorCode DMCompositeRestoreLocalVectors(DMComposite,...);
586: EXTERN PetscErrorCode DMCompositeCreateGlobalVector(DMComposite,Vec*);
587: EXTERN PetscErrorCode DMCompositeCreateLocalVector(DMComposite,Vec*);
588: EXTERN PetscErrorCode DMCompositeGetLocalISs(DMComposite,IS*[]);
589: EXTERN PetscErrorCode DMCompositeGetGlobalISs(DMComposite,IS*[]);
590: EXTERN PetscErrorCode DMCompositeRefine(DMComposite,MPI_Comm,DMComposite*);
591: EXTERN PetscErrorCode DMCompositeGetInterpolation(DMComposite,DMComposite,Mat*,Vec*);
592: EXTERN PetscErrorCode DMCompositeGetMatrix(DMComposite,const MatType,Mat*);
593: EXTERN PetscErrorCode DMCompositeGetColoring(DMComposite,ISColoringType,const MatType,ISColoring*);
594: EXTERN PetscErrorCode DMCompositeGlobalToLocalBegin(DMComposite,Vec,InsertMode,Vec);
595: EXTERN PetscErrorCode DMCompositeGlobalToLocalEnd(DMComposite,Vec,InsertMode,Vec);
597: /*S
598: Slice - Abstract PETSc object that manages distributed field data for a simple unstructured matrix
600: Level: beginner
602: Concepts: distributed array
604: .seealso: DACreate1d(), DACreate2d(), DACreate3d(), DADestroy(), VecScatter, DACreate(), DMCompositeCreate(), DMComposite
605: S*/
606: typedef struct _p_Sliced* Sliced;
608: EXTERN PetscErrorCode SlicedView(Sliced,PetscViewer);
609: EXTERN PetscErrorCode SlicedCreate(MPI_Comm,Sliced*);
610: EXTERN PetscErrorCode SlicedDestroy(Sliced);
611: EXTERN PetscErrorCode SlicedCreateGlobalVector(Sliced,Vec*);
612: EXTERN PetscErrorCode SlicedGetMatrix(Sliced, const MatType,Mat*);
613: EXTERN PetscErrorCode SlicedGetGlobalIndices(Sliced,PetscInt*[]);
614: EXTERN PetscErrorCode SlicedSetPreallocation(Sliced,PetscInt,const PetscInt[],PetscInt,const PetscInt[]);
615: EXTERN PetscErrorCode SlicedSetBlockFills(Sliced,const PetscInt*,const PetscInt*);
616: EXTERN PetscErrorCode SlicedSetGhosts(Sliced,PetscInt,PetscInt,PetscInt,const PetscInt[]);
619: typedef struct NLF_DAAD* NLF;
621: #include <petscbag.h>
623: EXTERN PetscErrorCode PetscViewerBinaryMatlabOpen(MPI_Comm, const char [], PetscViewer*);
624: EXTERN PetscErrorCode PetscViewerBinaryMatlabDestroy(PetscViewer);
625: EXTERN PetscErrorCode PetscViewerBinaryMatlabOutputBag(PetscViewer, const char [], PetscBag);
626: EXTERN PetscErrorCode PetscViewerBinaryMatlabOutputVec(PetscViewer, const char [], Vec);
627: EXTERN PetscErrorCode PetscViewerBinaryMatlabOutputVecDA(PetscViewer, const char [], Vec, DA);
630: /*S
631: ADDA - Abstract PETSc object that manages distributed field data for a single structured grid
632: These are for any number of dimensions.
634: Level: advanced.
636: Concepts: distributed array
637: .seealso: DA, DACreate(), ADDACreate()
638: S*/
639: typedef struct _p_ADDA* ADDA;
643: PetscErrorCode ADDACreate(MPI_Comm,PetscInt,PetscInt*,PetscInt*,PetscInt,PetscTruth*,ADDA*);
644: PetscErrorCode ADDADestroy(ADDA);
646: /* DM interface functions */
647: PetscErrorCode ADDAView(ADDA,PetscViewer);
648: PetscErrorCode ADDACreateGlobalVector(ADDA,Vec*);
649: PetscErrorCode ADDAGetColoring(ADDA,ISColoringType,const MatType,ISColoring*);
650: PetscErrorCode ADDAGetMatrix(ADDA,const MatType, Mat*);
651: PetscErrorCode ADDAGetInterpolation(ADDA,ADDA,Mat*,Vec*);
652: PetscErrorCode ADDARefine(ADDA, MPI_Comm,ADDA *);
653: PetscErrorCode ADDACoarsen(ADDA, MPI_Comm, ADDA*);
654: PetscErrorCode ADDAGetInjection(ADDA, ADDA, VecScatter*);
655: PetscErrorCode ADDAGetAggregates(ADDA, ADDA, Mat *);
657: /* functions only supported by ADDA */
658: PetscErrorCode ADDASetRefinement(ADDA, PetscInt *,PetscInt);
659: PetscErrorCode ADDAGetCorners(ADDA, PetscInt **, PetscInt **);
660: PetscErrorCode ADDAGetGhostCorners(ADDA, PetscInt **, PetscInt **);
661: PetscErrorCode ADDAGetMatrixNS(ADDA, ADDA, const MatType , Mat *);
663: /* functions to set values in vectors and matrices */
664: struct _ADDAIdx_s {
665: PetscInt *x; /* the coordinates, user has to make sure it is the correct size! */
666: PetscInt d; /* indexes the dof */
667: };
668: typedef struct _ADDAIdx_s ADDAIdx;
670: PetscErrorCode ADDAMatSetValues(Mat, ADDA, PetscInt, const ADDAIdx[], ADDA, PetscInt,
671: const ADDAIdx[], const PetscScalar[], InsertMode);
673: PetscTruth ADDAHCiterStartup(const PetscInt, const PetscInt *const, const PetscInt *const, PetscInt *const);
674: PetscTruth ADDAHCiter(const PetscInt, const PetscInt *const, const PetscInt *const, PetscInt *const);
677: #endif