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(char *name, char *path, 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: Level: intermediate
320: .seealso: DAForEachPointEnd2d(), DAVecGetArray()
321: M*/
322: #define DAForEachPointBegin2d(info,i,j) {\
323: PetscInt _xints = info->xs,_xinte = info->xs+info->xm,_yints = info->ys,_yinte = info->ys+info->ym;\
324: for (j=_yints; j<_yinte; j++) {\
325: for (i=_xints; i<_xinte; i++) {\
327: /*MC
328: DAForEachPointEnd2d - Ends a loop over the local part of a two dimensional DA
330: Synopsis:
331: void DAForEachPointEnd2d;
332:
333: Level: intermediate
335: .seealso: DAForEachPointBegin2d(), DAVecGetArray()
336: M*/
337: #define DAForEachPointEnd2d }}}
339: /*MC
340: DACoor2d - Structure for holding 2d (x and y) coordinates.
342: Level: intermediate
344: Sample Usage:
345: DACoor2d **coors;
346: Vec vcoors;
347: DA cda;
349: DAGetCoordinates(da,&vcoors);
350: DAGetCoordinateDA(da,&cda);
351: DAVecGetArray(cda,vcoors,&coors);
352: DAGetCorners(cda,&mstart,&nstart,0,&m,&n,0)
353: for (i=mstart; i<mstart+m; i++) {
354: for (j=nstart; j<nstart+n; j++) {
355: x = coors[j][i].x;
356: y = coors[j][i].y;
357: ......
358: }
359: }
360: DAVecRestoreArray(dac,vcoors,&coors);
362: .seealso: DACoor3d, DAForEachPointBegin(), DAGetCoordinateDA(), DAGetCoordinates(), DAGetGhostCoordinates()
363: M*/
364: typedef struct {PetscScalar x,y;} DACoor2d;
366: /*MC
367: DACoor3d - Structure for holding 3d (x, y and z) coordinates.
369: Level: intermediate
371: Sample Usage:
372: DACoor3d ***coors;
373: Vec vcoors;
374: DA cda;
376: DAGetCoordinates(da,&vcoors);
377: DAGetCoordinateDA(da,&cda);
378: DAVecGetArray(cda,vcoors,&coors);
379: DAGetCorners(cda,&mstart,&nstart,&pstart,&m,&n,&p)
380: for (i=mstart; i<mstart+m; i++) {
381: for (j=nstart; j<nstart+n; j++) {
382: for (k=pstart; k<pstart+p; k++) {
383: x = coors[k][j][i].x;
384: y = coors[k][j][i].y;
385: z = coors[k][j][i].z;
386: ......
387: }
388: }
389: DAVecRestoreArray(dac,vcoors,&coors);
391: .seealso: DACoor2d, DAForEachPointBegin(), DAGetCoordinateDA(), DAGetCoordinates(), DAGetGhostCoordinates()
392: M*/
393: typedef struct {PetscScalar x,y,z;} DACoor3d;
394:
395: EXTERN PetscErrorCode DAGetLocalInfo(DA,DALocalInfo*);
396: typedef PetscErrorCode (*DALocalFunction1)(DALocalInfo*,void*,void*,void*);
397: EXTERN PetscErrorCode DAFormFunctionLocal(DA, DALocalFunction1, Vec, Vec, void *);
398: EXTERN PetscErrorCode DAFormFunctionLocalGhost(DA, DALocalFunction1, Vec, Vec, void *);
399: EXTERN PetscErrorCode DAFormJacobianLocal(DA, DALocalFunction1, Vec, Mat, void *);
400: EXTERN PetscErrorCode DAFormFunction1(DA,Vec,Vec,void*);
401: EXTERN PetscErrorCode DAFormFunction(DA,PetscErrorCode (*)(void),Vec,Vec,void*);
402: EXTERN PetscErrorCode DAFormFunctioni1(DA,PetscInt,Vec,PetscScalar*,void*);
403: EXTERN PetscErrorCode DAFormFunctionib1(DA,PetscInt,Vec,PetscScalar*,void*);
404: EXTERN PetscErrorCode DAComputeJacobian1WithAdic(DA,Vec,Mat,void*);
405: EXTERN PetscErrorCode DAComputeJacobian1WithAdifor(DA,Vec,Mat,void*);
406: EXTERN PetscErrorCode DAMultiplyByJacobian1WithAdic(DA,Vec,Vec,Vec,void*);
407: EXTERN PetscErrorCode DAMultiplyByJacobian1WithAdifor(DA,Vec,Vec,Vec,void*);
408: EXTERN PetscErrorCode DAMultiplyByJacobian1WithAD(DA,Vec,Vec,Vec,void*);
409: EXTERN PetscErrorCode DAComputeJacobian1(DA,Vec,Mat,void*);
410: EXTERN PetscErrorCode DAGetLocalFunction(DA,DALocalFunction1*);
411: EXTERN PetscErrorCode DASetLocalFunction(DA,DALocalFunction1);
412: EXTERN PetscErrorCode DASetLocalFunctioni(DA,PetscErrorCode (*)(DALocalInfo*,MatStencil*,void*,PetscScalar*,void*));
413: EXTERN PetscErrorCode DASetLocalFunctionib(DA,PetscErrorCode (*)(DALocalInfo*,MatStencil*,void*,PetscScalar*,void*));
414: EXTERN PetscErrorCode DAGetLocalJacobian(DA,DALocalFunction1*);
415: EXTERN PetscErrorCode DASetLocalJacobian(DA,DALocalFunction1);
416: EXTERN PetscErrorCode DASetLocalAdicFunction_Private(DA,DALocalFunction1);
418: EXTERN PetscErrorCode MatSetDA(Mat,DA);
420: /*MC
421: DASetLocalAdicFunction - Caches in a DA a local function computed by ADIC/ADIFOR
423: Collective on DA
425: Synopsis:
426: PetscErrorCode DASetLocalAdicFunction(DA da,DALocalFunction1 ad_lf)
427:
428: Input Parameter:
429: + da - initial distributed array
430: - ad_lf - the local function as computed by ADIC/ADIFOR
432: Level: intermediate
434: .keywords: distributed array, refine
436: .seealso: DACreate1d(), DACreate2d(), DACreate3d(), DADestroy(), DAGetLocalFunction(), DASetLocalFunction(),
437: DASetLocalJacobian()
438: M*/
439: #if defined(PETSC_HAVE_ADIC)
440: # define DASetLocalAdicFunction(a,d) DASetLocalAdicFunction_Private(a,(DALocalFunction1)d)
441: #else
442: # define DASetLocalAdicFunction(a,d) DASetLocalAdicFunction_Private(a,0)
443: #endif
445: EXTERN PetscErrorCode DASetLocalAdicMFFunction_Private(DA,DALocalFunction1);
446: #if defined(PETSC_HAVE_ADIC)
447: # define DASetLocalAdicMFFunction(a,d) DASetLocalAdicMFFunction_Private(a,(DALocalFunction1)d)
448: #else
449: # define DASetLocalAdicMFFunction(a,d) DASetLocalAdicMFFunction_Private(a,0)
450: #endif
451: EXTERN PetscErrorCode DASetLocalAdicFunctioni_Private(DA,PetscErrorCode (*)(DALocalInfo*,MatStencil*,void*,void*,void*));
452: #if defined(PETSC_HAVE_ADIC)
453: # define DASetLocalAdicFunctioni(a,d) DASetLocalAdicFunctioni_Private(a,(PetscErrorCode (*)(DALocalInfo*,MatStencil*,void*,void*,void*))d)
454: #else
455: # define DASetLocalAdicFunctioni(a,d) DASetLocalAdicFunctioni_Private(a,0)
456: #endif
457: EXTERN PetscErrorCode DASetLocalAdicMFFunctioni_Private(DA,PetscErrorCode (*)(DALocalInfo*,MatStencil*,void*,void*,void*));
458: #if defined(PETSC_HAVE_ADIC)
459: # define DASetLocalAdicMFFunctioni(a,d) DASetLocalAdicMFFunctioni_Private(a,(PetscErrorCode (*)(DALocalInfo*,MatStencil*,void*,void*,void*))d)
460: #else
461: # define DASetLocalAdicMFFunctioni(a,d) DASetLocalAdicMFFunctioni_Private(a,0)
462: #endif
464: EXTERN PetscErrorCode DASetLocalAdicFunctionib_Private(DA,PetscErrorCode (*)(DALocalInfo*,MatStencil*,void*,void*,void*));
465: #if defined(PETSC_HAVE_ADIC)
466: # define DASetLocalAdicFunctionib(a,d) DASetLocalAdicFunctionib_Private(a,(PetscErrorCode (*)(DALocalInfo*,MatStencil*,void*,void*,void*))d)
467: #else
468: # define DASetLocalAdicFunctionib(a,d) DASetLocalAdicFunctionib_Private(a,0)
469: #endif
470: EXTERN PetscErrorCode DASetLocalAdicMFFunctionib_Private(DA,PetscErrorCode (*)(DALocalInfo*,MatStencil*,void*,void*,void*));
471: #if defined(PETSC_HAVE_ADIC)
472: # define DASetLocalAdicMFFunctionib(a,d) DASetLocalAdicMFFunctionib_Private(a,(PetscErrorCode (*)(DALocalInfo*,MatStencil*,void*,void*,void*))d)
473: #else
474: # define DASetLocalAdicMFFunctionib(a,d) DASetLocalAdicMFFunctionib_Private(a,0)
475: #endif
477: EXTERN PetscErrorCode DAFormFunctioniTest1(DA,void*);
479: #include petscmat.h
481: /*S
482: DM - Abstract PETSc object that manages an abstract grid object
483:
484: Level: intermediate
486: Concepts: grids, grid refinement
488: Notes: The DA object and the DMComposite object are examples of DMs
490: Though the DA objects require the petscsnes.h include files the DM library is
491: NOT dependent on the SNES or KSP library. In fact, the KSP and SNES libraries depend on
492: DM. (This is not great design, but not trivial to fix).
494: .seealso: DMCompositeCreate(), DA, DMComposite
495: S*/
496: typedef struct _p_DM* DM;
498: EXTERN PetscErrorCode DMView(DM,PetscViewer);
499: EXTERN PetscErrorCode DMDestroy(DM);
500: EXTERN PetscErrorCode DMCreateGlobalVector(DM,Vec*);
501: EXTERN PetscErrorCode DMCreateLocalVector(DM,Vec*);
502: EXTERN PetscErrorCode DMGetLocalVector(DM,Vec *);
503: EXTERN PetscErrorCode DMRestoreLocalVector(DM,Vec *);
504: EXTERN PetscErrorCode DMGetGlobalVector(DM,Vec *);
505: EXTERN PetscErrorCode DMRestoreGlobalVector(DM,Vec *);
506: EXTERN PetscErrorCode DMGetColoring(DM,ISColoringType,const MatType,ISColoring*);
507: EXTERN PetscErrorCode DMGetMatrix(DM, const MatType,Mat*);
508: EXTERN PetscErrorCode DMGetInterpolation(DM,DM,Mat*,Vec*);
509: EXTERN PetscErrorCode DMGetInjection(DM,DM,VecScatter*);
510: EXTERN PetscErrorCode DMRefine(DM,MPI_Comm,DM*);
511: EXTERN PetscErrorCode DMCoarsen(DM,MPI_Comm,DM*);
512: EXTERN PetscErrorCode DMRefineHierarchy(DM,PetscInt,DM[]);
513: EXTERN PetscErrorCode DMCoarsenHierarchy(DM,PetscInt,DM[]);
514: EXTERN PetscErrorCode DMGetInterpolationScale(DM,DM,Mat,Vec*);
515: EXTERN PetscErrorCode DMGetAggregates(DM,DM,Mat*);
516: EXTERN PetscErrorCode DMGlobalToLocalBegin(DM,Vec,InsertMode,Vec);
517: EXTERN PetscErrorCode DMGlobalToLocalEnd(DM,Vec,InsertMode,Vec);
518: EXTERN PetscErrorCode DMLocalToGlobal(DM,Vec,InsertMode,Vec);
519: EXTERN PetscErrorCode DMGetElements(DM,PetscInt *,const PetscInt*[]);
520: EXTERN PetscErrorCode DMRestoreElements(DM,PetscInt *,const PetscInt*[]);
521: EXTERN PetscErrorCode DMFinalizePackage(void);
523: EXTERN PetscErrorCode DAGetColoring(DA,ISColoringType,const MatType,ISColoring *);
524: EXTERN PetscErrorCode DAGetMatrix(DA, const MatType,Mat *);
525: EXTERN PetscErrorCode DASetGetMatrix(DA,PetscErrorCode (*)(DA, const MatType,Mat *));
526: EXTERN PetscErrorCode DAGetInterpolation(DA,DA,Mat*,Vec*);
527: EXTERN PetscErrorCode DAGetAggregates(DA,DA,Mat*);
528: EXTERN PetscErrorCode DAGetInjection(DA,DA,VecScatter*);
529: EXTERN PetscErrorCode DASetBlockFills(DA,PetscInt*,PetscInt*);
530: EXTERN PetscErrorCode DASetMatPreallocateOnly(DA,PetscTruth);
531: EXTERN PetscErrorCode DASetRefinementFactor(DA,PetscInt,PetscInt,PetscInt);
532: EXTERN PetscErrorCode DAGetRefinementFactor(DA,PetscInt*,PetscInt*,PetscInt*);
534: EXTERN PetscErrorCode DAGetAdicArray(DA,PetscTruth,void**,void**,PetscInt*);
535: EXTERN PetscErrorCode DARestoreAdicArray(DA,PetscTruth,void**,void**,PetscInt*);
536: EXTERN PetscErrorCode DAGetAdicMFArray(DA,PetscTruth,void**,void**,PetscInt*);
537: EXTERN PetscErrorCode DAGetAdicMFArray4(DA,PetscTruth,void**,void**,PetscInt*);
538: EXTERN PetscErrorCode DAGetAdicMFArray9(DA,PetscTruth,void**,void**,PetscInt*);
539: EXTERN PetscErrorCode DAGetAdicMFArrayb(DA,PetscTruth,void**,void**,PetscInt*);
540: EXTERN PetscErrorCode DARestoreAdicMFArray(DA,PetscTruth,void**,void**,PetscInt*);
541: EXTERN PetscErrorCode DAGetArray(DA,PetscTruth,void**);
542: EXTERN PetscErrorCode DARestoreArray(DA,PetscTruth,void**);
543: EXTERN PetscErrorCode ad_DAGetArray(DA,PetscTruth,void**);
544: EXTERN PetscErrorCode ad_DARestoreArray(DA,PetscTruth,void**);
545: EXTERN PetscErrorCode admf_DAGetArray(DA,PetscTruth,void**);
546: EXTERN PetscErrorCode admf_DARestoreArray(DA,PetscTruth,void**);
548: #include petscpf.h
549: EXTERN PetscErrorCode DACreatePF(DA,PF*);
551: /*S
552: DMComposite - Abstract PETSc object that manages treating several distinct vectors as if they
553: were one. The DMComposite routines allow one to manage a nonlinear solver that works on a
554: vector that consists of several distinct parts. This is mostly used for LNKS solvers,
555: that is design optimization problems that are written as a nonlinear system
557: Level: beginner
559: Concepts: multi-component, LNKS solvers
561: .seealso: DMCompositeCreate(), DMCompositeDestroy(), DM
562: S*/
563: typedef struct _p_DMComposite* DMComposite;
565: EXTERN PetscErrorCode DMCompositeCreate(MPI_Comm,DMComposite*);
566: EXTERN PetscErrorCode DMCompositeDestroy(DMComposite);
567: EXTERN PetscErrorCode DMCompositeView(DMComposite,PetscViewer);
568: EXTERN PetscErrorCode DMCompositeAddArray(DMComposite,PetscMPIInt,PetscInt);
569: EXTERN PetscErrorCode DMCompositeAddDM(DMComposite,DM);
570: EXTERN PetscErrorCode DMCompositeSetCoupling(DMComposite,PetscErrorCode (*)(DMComposite,Mat,PetscInt*,PetscInt*,PetscInt,PetscInt,PetscInt,PetscInt));
571: EXTERN PetscErrorCode DMCompositeSetContext(DMComposite,void*);
572: EXTERN PetscErrorCode DMCompositeGetContext(DMComposite,void**);
573: EXTERN PetscErrorCode DMCompositeAddVecScatter(DMComposite,VecScatter);
574: EXTERN PetscErrorCode DMCompositeScatter(DMComposite,Vec,...);
575: EXTERN PetscErrorCode DMCompositeGather(DMComposite,Vec,...);
576: EXTERN PetscErrorCode DMCompositeGetAccess(DMComposite,Vec,...);
577: EXTERN PetscErrorCode DMCompositeGetNumberDM(DMComposite,PetscInt*);
578: EXTERN PetscErrorCode DMCompositeRestoreAccess(DMComposite,Vec,...);
579: EXTERN PetscErrorCode DMCompositeGetLocalVectors(DMComposite,...);
580: EXTERN PetscErrorCode DMCompositeGetEntries(DMComposite,...);
581: EXTERN PetscErrorCode DMCompositeRestoreLocalVectors(DMComposite,...);
582: EXTERN PetscErrorCode DMCompositeCreateGlobalVector(DMComposite,Vec*);
583: EXTERN PetscErrorCode DMCompositeCreateLocalVector(DMComposite,Vec*);
584: EXTERN PetscErrorCode DMCompositeGetLocalISs(DMComposite,IS*[]);
585: EXTERN PetscErrorCode DMCompositeGetGlobalISs(DMComposite,IS*[]);
586: EXTERN PetscErrorCode DMCompositeRefine(DMComposite,MPI_Comm,DMComposite*);
587: EXTERN PetscErrorCode DMCompositeGetInterpolation(DMComposite,DMComposite,Mat*,Vec*);
588: EXTERN PetscErrorCode DMCompositeGetMatrix(DMComposite,const MatType,Mat*);
589: EXTERN PetscErrorCode DMCompositeGetColoring(DMComposite,ISColoringType,const MatType,ISColoring*);
590: EXTERN PetscErrorCode DMCompositeGlobalToLocalBegin(DMComposite,Vec,InsertMode,Vec);
591: EXTERN PetscErrorCode DMCompositeGlobalToLocalEnd(DMComposite,Vec,InsertMode,Vec);
593: /*S
594: Slice - Abstract PETSc object that manages distributed field data for a simple unstructured matrix
596: Level: beginner
598: Concepts: distributed array
600: .seealso: DACreate1d(), DACreate2d(), DACreate3d(), DADestroy(), VecScatter, DACreate(), DMCompositeCreate(), DMComposite
601: S*/
602: typedef struct _p_Sliced* Sliced;
604: EXTERN PetscErrorCode SlicedView(Sliced,PetscViewer);
605: EXTERN PetscErrorCode SlicedCreate(MPI_Comm,Sliced*);
606: EXTERN PetscErrorCode SlicedDestroy(Sliced);
607: EXTERN PetscErrorCode SlicedCreateGlobalVector(Sliced,Vec*);
608: EXTERN PetscErrorCode SlicedGetMatrix(Sliced, const MatType,Mat*);
609: EXTERN PetscErrorCode SlicedGetGlobalIndices(Sliced,PetscInt*[]);
610: EXTERN PetscErrorCode SlicedSetPreallocation(Sliced,PetscInt,const PetscInt[],PetscInt,const PetscInt[]);
611: EXTERN PetscErrorCode SlicedSetBlockFills(Sliced,const PetscInt*,const PetscInt*);
612: EXTERN PetscErrorCode SlicedSetGhosts(Sliced,PetscInt,PetscInt,PetscInt,const PetscInt[]);
615: typedef struct NLF_DAAD* NLF;
617: #include <petscbag.h>
619: EXTERN PetscErrorCode PetscViewerBinaryMatlabOpen(MPI_Comm, const char [], PetscViewer*);
620: EXTERN PetscErrorCode PetscViewerBinaryMatlabDestroy(PetscViewer);
621: EXTERN PetscErrorCode PetscViewerBinaryMatlabOutputBag(PetscViewer, const char [], PetscBag);
622: EXTERN PetscErrorCode PetscViewerBinaryMatlabOutputVec(PetscViewer, const char [], Vec);
623: EXTERN PetscErrorCode PetscViewerBinaryMatlabOutputVecDA(PetscViewer, const char [], Vec, DA);
626: /*S
627: ADDA - Abstract PETSc object that manages distributed field data for a single structured grid
628: These are for any number of dimensions.
630: Level: advanced.
632: Concepts: distributed array
633: .seealso: DA, DACreate(), ADDACreate()
634: S*/
635: typedef struct _p_ADDA* ADDA;
639: PetscErrorCode ADDACreate(MPI_Comm,PetscInt,PetscInt*,PetscInt*,PetscInt,PetscTruth*,ADDA*);
640: PetscErrorCode ADDADestroy(ADDA);
642: /* DM interface functions */
643: PetscErrorCode ADDAView(ADDA,PetscViewer);
644: PetscErrorCode ADDACreateGlobalVector(ADDA,Vec*);
645: PetscErrorCode ADDAGetColoring(ADDA,ISColoringType,const MatType,ISColoring*);
646: PetscErrorCode ADDAGetMatrix(ADDA,const MatType, Mat*);
647: PetscErrorCode ADDAGetInterpolation(ADDA,ADDA,Mat*,Vec*);
648: PetscErrorCode ADDARefine(ADDA, MPI_Comm,ADDA *);
649: PetscErrorCode ADDACoarsen(ADDA, MPI_Comm, ADDA*);
650: PetscErrorCode ADDAGetInjection(ADDA, ADDA, VecScatter*);
651: PetscErrorCode ADDAGetAggregates(ADDA, ADDA, Mat *);
653: /* functions only supported by ADDA */
654: PetscErrorCode ADDASetRefinement(ADDA, PetscInt *,PetscInt);
655: PetscErrorCode ADDAGetCorners(ADDA, PetscInt **, PetscInt **);
656: PetscErrorCode ADDAGetGhostCorners(ADDA, PetscInt **, PetscInt **);
657: PetscErrorCode ADDAGetMatrixNS(ADDA, ADDA, const MatType , Mat *);
659: /* functions to set values in vectors and matrices */
660: struct _ADDAIdx_s {
661: PetscInt *x; /* the coordinates, user has to make sure it is the correct size! */
662: PetscInt d; /* indexes the dof */
663: };
664: typedef struct _ADDAIdx_s ADDAIdx;
666: PetscErrorCode ADDAMatSetValues(Mat, ADDA, PetscInt, const ADDAIdx[], ADDA, PetscInt,
667: const ADDAIdx[], const PetscScalar[], InsertMode);
669: PetscTruth ADDAHCiterStartup(const PetscInt, const PetscInt *const, const PetscInt *const, PetscInt *const);
670: PetscTruth ADDAHCiter(const PetscInt, const PetscInt *const, const PetscInt *const, PetscInt *const);
673: #endif