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: /*E
 23:     DAStencilType - Determines if the stencil extends only along the coordinate directions, or also
 24:       to the northeast, northwest etc

 26:    Level: beginner

 28: .seealso: DACreate1d(), DACreate2d(), DACreate3d(), DA, DACreate()
 29: E*/
 30: typedef enum { DA_STENCIL_STAR,DA_STENCIL_BOX } DAStencilType;

 32: /*MC
 33:      DA_STENCIL_STAR - "Star"-type stencil. In logical grid coordinates, only (i,j,k), (i+s,j,k), (i,j+s,k),
 34:                        (i,j,k+s) are in the stencil  NOT, for example, (i+s,j+s,k)

 36:      Level: beginner

 38: .seealso: DA_STENCIL_BOX, DAStencilType
 39: M*/

 41: /*MC
 42:      DA_STENCIL_Box - "Box"-type stencil. In logical grid coordinates, any of (i,j,k), (i+s,j+r,k+t) may 
 43:                       be in the stencil.

 45:      Level: beginner

 47: .seealso: DA_STENCIL_STAR, DAStencilType
 48: M*/

 50: /*E
 51:     DAPeriodicType - Is the domain periodic in one or more directions

 53:    Level: beginner

 55:    DA_XYZGHOSTED means that ghost points are put around all the physical boundaries
 56:    in the local representation of the Vec (i.e. DACreate/GetLocalVector().

 58: .seealso: DACreate1d(), DACreate2d(), DACreate3d(), DA, DACreate()
 59: E*/
 60: typedef enum { DA_NONPERIODIC,DA_XPERIODIC,DA_YPERIODIC,DA_XYPERIODIC,
 61:                DA_XYZPERIODIC,DA_XZPERIODIC,DA_YZPERIODIC,DA_ZPERIODIC,DA_XYZGHOSTED} DAPeriodicType;

 64: /*E
 65:     DAInterpolationType - Defines the type of interpolation that will be returned by 
 66:        DAGetInterpolation.

 68:    Level: beginner

 70: .seealso: DACreate1d(), DACreate2d(), DACreate3d(), DA, DAGetInterpolation(), DASetInterpolationType(), DACreate()
 71: E*/
 72: typedef enum { DA_Q0, DA_Q1 } DAInterpolationType;

 74: EXTERN PetscErrorCode   DASetInterpolationType(DA,DAInterpolationType);

 76: /*E
 77:     DAElementType - Defines the type of elements that will be returned by 
 78:        DAGetElements.

 80:    Level: beginner

 82: .seealso: DACreate1d(), DACreate2d(), DACreate3d(), DA, DAGetInterpolation(), DASetInterpolationType(), 
 83:           DASetElementType(), DAGetElements(), DARestoreElements(), DACreate()
 84: E*/
 85: typedef enum { DA_ELEMENT_P1, DA_ELEMENT_Q1 } DAElementType;

 87: EXTERN PetscErrorCode   DASetElementType(DA,DAElementType);
 88: /*MC
 89:    DAGetElements - same as DMGetElements()
 90:    uses DA instead of DM as input
 91: M*/
 92: #define DAGetElements(da,a,b)      DMGetElements((DM)da,a,b)
 93: /*MC
 94:    DARestoreElements - same as DMRestoreElements()
 95:    uses DA instead of DM as input
 96: M*/
 97: #define DARestoreElements(da,a,b)  DMRestoreElements((DM)da,a,b)


100: #define DAXPeriodic(pt) ((pt)==DA_XPERIODIC||(pt)==DA_XYPERIODIC||(pt)==DA_XZPERIODIC||(pt)==DA_XYZPERIODIC)
101: #define DAYPeriodic(pt) ((pt)==DA_YPERIODIC||(pt)==DA_XYPERIODIC||(pt)==DA_YZPERIODIC||(pt)==DA_XYZPERIODIC)
102: #define DAZPeriodic(pt) ((pt)==DA_ZPERIODIC||(pt)==DA_XZPERIODIC||(pt)==DA_YZPERIODIC||(pt)==DA_XYZPERIODIC)

104: typedef enum { DA_X,DA_Y,DA_Z } DADirection;


108: #define MATSEQUSFFT        "sequsfft"

110: EXTERN PetscErrorCode     DACreate1d(MPI_Comm,DAPeriodicType,PetscInt,PetscInt,PetscInt,const PetscInt[],DA *);
111: EXTERN PetscErrorCode     DACreate2d(MPI_Comm,DAPeriodicType,DAStencilType,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],DA *);
112: EXTERN PetscErrorCode     DACreate3d(MPI_Comm,DAPeriodicType,DAStencilType,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscInt[],DA*);
113: EXTERN PetscErrorCode     DACreate(MPI_Comm,PetscInt,DAPeriodicType,DAStencilType,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscInt[],DA*);
114: EXTERN PetscErrorCode     DADestroy(DA);
115: EXTERN PetscErrorCode     DAView(DA,PetscViewer);

117: EXTERN PetscErrorCode     DAGlobalToLocalBegin(DA,Vec,InsertMode,Vec);
118: EXTERN PetscErrorCode     DAGlobalToLocalEnd(DA,Vec,InsertMode,Vec);
119: EXTERN PetscErrorCode     DAGlobalToNaturalBegin(DA,Vec,InsertMode,Vec);
120: EXTERN PetscErrorCode     DAGlobalToNaturalEnd(DA,Vec,InsertMode,Vec);
121: EXTERN PetscErrorCode     DANaturalToGlobalBegin(DA,Vec,InsertMode,Vec);
122: EXTERN PetscErrorCode     DANaturalToGlobalEnd(DA,Vec,InsertMode,Vec);
123: EXTERN PetscErrorCode     DALocalToLocalBegin(DA,Vec,InsertMode,Vec);
124: EXTERN PetscErrorCode     DALocalToLocalEnd(DA,Vec,InsertMode,Vec);
125: EXTERN PetscErrorCode     DALocalToGlobal(DA,Vec,InsertMode,Vec);
126: EXTERN PetscErrorCode     DALocalToGlobalBegin(DA,Vec,Vec);
127: EXTERN PetscErrorCode     DALocalToGlobalEnd(DA,Vec,Vec);
128: EXTERN PetscErrorCode     DAGetOwnershipRanges(DA,const PetscInt*[],const PetscInt*[],const PetscInt*[]);
129: EXTERN PetscErrorCode     DACreateGlobalVector(DA,Vec *);
130: EXTERN PetscErrorCode     DACreateLocalVector(DA,Vec *);
131: EXTERN PetscErrorCode     DACreateNaturalVector(DA,Vec *);
132: #define  DAGetLocalVector(da,v)      DMGetLocalVector((DM)da,v)
133: #define  DARestoreLocalVector(da,v)  DMRestoreLocalVector((DM)da,v)
134: #define  DAGetGlobalVector(da,v)     DMGetGlobalVector((DM)da,v)
135: #define  DARestoreGlobalVector(da,v) DMRestoreGlobalVector((DM)da,v)
136: EXTERN PetscErrorCode     DALoad(PetscViewer,PetscInt,PetscInt,PetscInt,DA *);
137: EXTERN PetscErrorCode     DAGetCorners(DA,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*);
138: EXTERN PetscErrorCode     DAGetGhostCorners(DA,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*);
139: EXTERN PetscErrorCode     DAGetInfo(DA,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,DAPeriodicType*,DAStencilType*);
140: EXTERN PetscErrorCode     DAGetProcessorSubset(DA,DADirection,PetscInt,MPI_Comm*);
141: EXTERN PetscErrorCode     DARefine(DA,MPI_Comm,DA*);
142: EXTERN PetscErrorCode     DACoarsen(DA,MPI_Comm,DA*);

144: EXTERN PetscErrorCode     DAGlobalToNaturalAllCreate(DA,VecScatter*);
145: EXTERN PetscErrorCode     DANaturalAllToGlobalCreate(DA,VecScatter*);

147: EXTERN PetscErrorCode     DAGetGlobalIndices(DA,PetscInt*,PetscInt**);
148: EXTERN PetscErrorCode     DAGetISLocalToGlobalMapping(DA,ISLocalToGlobalMapping*);
149: EXTERN PetscErrorCode     DAGetISLocalToGlobalMappingBlck(DA,ISLocalToGlobalMapping*);

151: EXTERN PetscErrorCode     DAGetScatter(DA,VecScatter*,VecScatter*,VecScatter*);
152: EXTERN PetscErrorCode     DAGetNeighbors(DA,const PetscMPIInt**);

154: EXTERN PetscErrorCode     DAGetAO(DA,AO*);
155: EXTERN PetscErrorCode     DASetCoordinates(DA,Vec);
156: EXTERN PetscErrorCode     DAGetCoordinates(DA,Vec *);
157: EXTERN PetscErrorCode     DAGetGhostedCoordinates(DA,Vec *);
158: EXTERN PetscErrorCode     DAGetCoordinateDA(DA,DA *);
159: EXTERN PetscErrorCode     DASetUniformCoordinates(DA,PetscReal,PetscReal,PetscReal,PetscReal,PetscReal,PetscReal);
160: EXTERN PetscErrorCode     DASetFieldName(DA,PetscInt,const char[]);
161: EXTERN PetscErrorCode     DAGetFieldName(DA,PetscInt,char **);

163: EXTERN PetscErrorCode     DAVecGetArray(DA,Vec,void *);
164: EXTERN PetscErrorCode     DAVecRestoreArray(DA,Vec,void *);

166: EXTERN PetscErrorCode     DAVecGetArrayDOF(DA,Vec,void *);
167: EXTERN PetscErrorCode     DAVecRestoreArrayDOF(DA,Vec,void *);

169: EXTERN PetscErrorCode     DASplitComm2d(MPI_Comm,PetscInt,PetscInt,PetscInt,MPI_Comm*);

171: /*S
172:      SDA - This provides a simplified interface to the DA distributed
173:            array object in PETSc. This is intended for people who are
174:            NOT using PETSc vectors or objects but just want to distribute
175:            simple rectangular arrays amoung a number of procesors and have
176:            PETSc handle moving the ghost-values when needed.

178:           In certain applications this can serve as a replacement for 
179:           BlockComm (which is apparently being phased out?).


182:    Level: beginner

184:   Concepts: simplified distributed array

186: .seealso:  SDACreate1d(), SDACreate2d(), SDACreate3d(), SDADestroy(), DA, SDALocalToLocalBegin(),
187:            SDALocalToLocalEnd(), SDAGetCorners(), SDAGetGhostCorners()
188: S*/
189: typedef struct _n_SDA* SDA;

191: EXTERN PetscErrorCode     SDACreate3d(MPI_Comm,DAPeriodicType,DAStencilType,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscInt[],SDA*);
192: EXTERN PetscErrorCode     SDACreate2d(MPI_Comm,DAPeriodicType,DAStencilType,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],SDA*);
193: EXTERN PetscErrorCode     SDACreate1d(MPI_Comm,DAPeriodicType,PetscInt,PetscInt,PetscInt,const PetscInt[],SDA*);
194: EXTERN PetscErrorCode     SDADestroy(SDA);
195: EXTERN PetscErrorCode     SDALocalToLocalBegin(SDA,PetscScalar*,InsertMode,PetscScalar*);
196: EXTERN PetscErrorCode     SDALocalToLocalEnd(SDA,PetscScalar*,InsertMode,PetscScalar*);
197: EXTERN PetscErrorCode     SDAGetCorners(SDA,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*);
198: EXTERN PetscErrorCode     SDAGetGhostCorners(SDA,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*);
199: EXTERN PetscErrorCode     SDAArrayView(SDA,PetscScalar*,PetscViewer);

201: EXTERN PetscErrorCode     MatRegisterDAAD(void);
202: EXTERN PetscErrorCode     MatCreateDAAD(DA,Mat*);
203: EXTERN PetscErrorCode    MatCreateSeqUSFFT(DA, DA,Mat*);

205: /*S
206:      DALocalInfo - C struct that contains information about a structured grid and a processors logical
207:               location in it.

209:    Level: beginner

211:   Concepts: distributed array

213:   Developer note: Then entries in this struct are int instead of PetscInt so that the elements may
214:                   be extracted in Fortran as if from an integer array

216: .seealso:  DACreate1d(), DACreate2d(), DACreate3d(), DADestroy(), DA, DAGetLocalInfo(), DAGetInfo()
217: S*/
218: typedef struct {
219:   PetscInt       dim,dof,sw;
220:   PetscInt       mx,my,mz;    /* global number of grid points in each direction */
221:   PetscInt       xs,ys,zs;    /* starting pointd of this processor, excluding ghosts */
222:   PetscInt       xm,ym,zm;    /* number of grid points on this processor, excluding ghosts */
223:   PetscInt       gxs,gys,gzs;    /* starting point of this processor including ghosts */
224:   PetscInt       gxm,gym,gzm;    /* number of grid points on this processor including ghosts */
225:   DAPeriodicType pt;
226:   DAStencilType  st;
227:   DA             da;
228: } DALocalInfo;

230: /*MC
231:       DAForEachPointBegin2d - Starts a loop over the local part of a two dimensional DA

233:    Synopsis:
234:    void  DAForEachPointBegin2d(DALocalInfo *info,PetscInt i,PetscInt j);
235:    
236:    Level: intermediate

238: .seealso: DAForEachPointEnd2d(), DAVecGetArray()
239: M*/
240: #define DAForEachPointBegin2d(info,i,j) {\
241:   PetscInt _xints = info->xs,_xinte = info->xs+info->xm,_yints = info->ys,_yinte = info->ys+info->ym;\
242:   for (j=_yints; j<_yinte; j++) {\
243:     for (i=_xints; i<_xinte; i++) {\

245: /*MC
246:       DAForEachPointEnd2d - Ends a loop over the local part of a two dimensional DA

248:    Synopsis:
249:    void  DAForEachPointEnd2d;
250:    
251:    Level: intermediate

253: .seealso: DAForEachPointBegin2d(), DAVecGetArray()
254: M*/
255: #define DAForEachPointEnd2d }}}

257: /*MC
258:       DACoor2d - Structure for holding 2d (x and y) coordinates.

260:     Level: intermediate

262:     Sample Usage:
263:       DACoor2d **coors;
264:       Vec      vcoors;
265:       DA       cda;     

267:       DAGetCoordinates(da,&vcoors); 
268:       DAGetCoordinateDA(da,&cda);
269:       DAVecGetArray(cda,vcoors,&coors);
270:       DAGetCorners(cda,&mstart,&nstart,0,&m,&n,0)
271:       for (i=mstart; i<mstart+m; i++) {
272:         for (j=nstart; j<nstart+n; j++) {
273:           x = coors[j][i].x;
274:           y = coors[j][i].y;
275:           ......
276:         }
277:       }
278:       DAVecRestoreArray(dac,vcoors,&coors);

280: .seealso: DACoor3d, DAForEachPointBegin(), DAGetCoordinateDA(), DAGetCoordinates(), DAGetGhostCoordinates()
281: M*/
282: typedef struct {PetscScalar x,y;} DACoor2d;

284: /*MC
285:       DACoor3d - Structure for holding 3d (x, y and z) coordinates.

287:     Level: intermediate

289:     Sample Usage:
290:       DACoor3d ***coors;
291:       Vec      vcoors;
292:       DA       cda;     

294:       DAGetCoordinates(da,&vcoors); 
295:       DAGetCoordinateDA(da,&cda);
296:       DAVecGetArray(cda,vcoors,&coors);
297:       DAGetCorners(cda,&mstart,&nstart,&pstart,&m,&n,&p)
298:       for (i=mstart; i<mstart+m; i++) {
299:         for (j=nstart; j<nstart+n; j++) {
300:           for (k=pstart; k<pstart+p; k++) {
301:             x = coors[k][j][i].x;
302:             y = coors[k][j][i].y;
303:             z = coors[k][j][i].z;
304:           ......
305:         }
306:       }
307:       DAVecRestoreArray(dac,vcoors,&coors);

309: .seealso: DACoor2d, DAForEachPointBegin(), DAGetCoordinateDA(), DAGetCoordinates(), DAGetGhostCoordinates()
310: M*/
311: typedef struct {PetscScalar x,y,z;} DACoor3d;
312: 
313: EXTERN PetscErrorCode   DAGetLocalInfo(DA,DALocalInfo*);
314: typedef PetscErrorCode (*DALocalFunction1)(DALocalInfo*,void*,void*,void*);
315: EXTERN PetscErrorCode   DAFormFunctionLocal(DA, DALocalFunction1, Vec, Vec, void *);
316: EXTERN PetscErrorCode   DAFormFunctionLocalGhost(DA, DALocalFunction1, Vec, Vec, void *);
317: EXTERN PetscErrorCode   DAFormJacobianLocal(DA, DALocalFunction1, Vec, Mat, void *);
318: EXTERN PetscErrorCode   DAFormFunction1(DA,Vec,Vec,void*);
319: EXTERN PetscErrorCode   DAFormFunction(DA,PetscErrorCode (*)(void),Vec,Vec,void*);
320: EXTERN PetscErrorCode   DAFormFunctioni1(DA,PetscInt,Vec,PetscScalar*,void*);
321: EXTERN PetscErrorCode   DAFormFunctionib1(DA,PetscInt,Vec,PetscScalar*,void*);
322: EXTERN PetscErrorCode   DAComputeJacobian1WithAdic(DA,Vec,Mat,void*);
323: EXTERN PetscErrorCode   DAComputeJacobian1WithAdifor(DA,Vec,Mat,void*);
324: EXTERN PetscErrorCode   DAMultiplyByJacobian1WithAdic(DA,Vec,Vec,Vec,void*);
325: EXTERN PetscErrorCode   DAMultiplyByJacobian1WithAdifor(DA,Vec,Vec,Vec,void*);
326: EXTERN PetscErrorCode   DAMultiplyByJacobian1WithAD(DA,Vec,Vec,Vec,void*);
327: EXTERN PetscErrorCode   DAComputeJacobian1(DA,Vec,Mat,void*);
328: EXTERN PetscErrorCode   DAGetLocalFunction(DA,DALocalFunction1*);
329: EXTERN PetscErrorCode   DASetLocalFunction(DA,DALocalFunction1);
330: EXTERN PetscErrorCode   DASetLocalFunctioni(DA,PetscErrorCode (*)(DALocalInfo*,MatStencil*,void*,PetscScalar*,void*));
331: EXTERN PetscErrorCode   DASetLocalFunctionib(DA,PetscErrorCode (*)(DALocalInfo*,MatStencil*,void*,PetscScalar*,void*));
332: EXTERN PetscErrorCode   DAGetLocalJacobian(DA,DALocalFunction1*);
333: EXTERN PetscErrorCode   DASetLocalJacobian(DA,DALocalFunction1);
334: EXTERN PetscErrorCode   DASetLocalAdicFunction_Private(DA,DALocalFunction1);

336: /*MC
337:        DASetLocalAdicFunction - Caches in a DA a local function computed by ADIC/ADIFOR

339:    Collective on DA

341:    Synopsis:
342:    PetscErrorCode DASetLocalAdicFunction(DA da,DALocalFunction1 ad_lf)
343:    
344:    Input Parameter:
345: +  da - initial distributed array
346: -  ad_lf - the local function as computed by ADIC/ADIFOR

348:    Level: intermediate

350: .keywords:  distributed array, refine

352: .seealso: DACreate1d(), DACreate2d(), DACreate3d(), DADestroy(), DAGetLocalFunction(), DASetLocalFunction(),
353:           DASetLocalJacobian()
354: M*/
355: #if defined(PETSC_HAVE_ADIC)
356: #  define DASetLocalAdicFunction(a,d) DASetLocalAdicFunction_Private(a,(DALocalFunction1)d)
357: #else
358: #  define DASetLocalAdicFunction(a,d) DASetLocalAdicFunction_Private(a,0)
359: #endif

361: EXTERN PetscErrorCode   DASetLocalAdicMFFunction_Private(DA,DALocalFunction1);
362: #if defined(PETSC_HAVE_ADIC)
363: #  define DASetLocalAdicMFFunction(a,d) DASetLocalAdicMFFunction_Private(a,(DALocalFunction1)d)
364: #else
365: #  define DASetLocalAdicMFFunction(a,d) DASetLocalAdicMFFunction_Private(a,0)
366: #endif
367: EXTERN PetscErrorCode   DASetLocalAdicFunctioni_Private(DA,PetscErrorCode (*)(DALocalInfo*,MatStencil*,void*,void*,void*));
368: #if defined(PETSC_HAVE_ADIC)
369: #  define DASetLocalAdicFunctioni(a,d) DASetLocalAdicFunctioni_Private(a,(PetscErrorCode (*)(DALocalInfo*,MatStencil*,void*,void*,void*))d)
370: #else
371: #  define DASetLocalAdicFunctioni(a,d) DASetLocalAdicFunctioni_Private(a,0)
372: #endif
373: EXTERN PetscErrorCode   DASetLocalAdicMFFunctioni_Private(DA,PetscErrorCode (*)(DALocalInfo*,MatStencil*,void*,void*,void*));
374: #if defined(PETSC_HAVE_ADIC)
375: #  define DASetLocalAdicMFFunctioni(a,d) DASetLocalAdicMFFunctioni_Private(a,(PetscErrorCode (*)(DALocalInfo*,MatStencil*,void*,void*,void*))d)
376: #else
377: #  define DASetLocalAdicMFFunctioni(a,d) DASetLocalAdicMFFunctioni_Private(a,0)
378: #endif

380: EXTERN PetscErrorCode   DASetLocalAdicFunctionib_Private(DA,PetscErrorCode (*)(DALocalInfo*,MatStencil*,void*,void*,void*));
381: #if defined(PETSC_HAVE_ADIC)
382: #  define DASetLocalAdicFunctionib(a,d) DASetLocalAdicFunctionib_Private(a,(PetscErrorCode (*)(DALocalInfo*,MatStencil*,void*,void*,void*))d)
383: #else
384: #  define DASetLocalAdicFunctionib(a,d) DASetLocalAdicFunctionib_Private(a,0)
385: #endif
386: EXTERN PetscErrorCode   DASetLocalAdicMFFunctionib_Private(DA,PetscErrorCode (*)(DALocalInfo*,MatStencil*,void*,void*,void*));
387: #if defined(PETSC_HAVE_ADIC)
388: #  define DASetLocalAdicMFFunctionib(a,d) DASetLocalAdicMFFunctionib_Private(a,(PetscErrorCode (*)(DALocalInfo*,MatStencil*,void*,void*,void*))d)
389: #else
390: #  define DASetLocalAdicMFFunctionib(a,d) DASetLocalAdicMFFunctionib_Private(a,0)
391: #endif

393: EXTERN PetscErrorCode   DAFormFunctioniTest1(DA,void*);

395:  #include petscmat.h

397: /*S
398:      DM - Abstract PETSc object that manages an abstract grid object
399:           
400:    Level: intermediate

402:   Concepts: grids, grid refinement

404:    Notes: The DA object and the DMComposite object are examples of DMs

406:           Though the DA objects require the petscsnes.h include files the DM library is
407:     NOT dependent on the SNES or KSP library. In fact, the KSP and SNES libraries depend on
408:     DM. (This is not great design, but not trivial to fix).

410: .seealso:  DMCompositeCreate(), DA, DMComposite
411: S*/
412: typedef struct _p_DM* DM;

414: EXTERN PetscErrorCode   DMView(DM,PetscViewer);
415: EXTERN PetscErrorCode   DMDestroy(DM);
416: EXTERN PetscErrorCode   DMCreateGlobalVector(DM,Vec*);
417: EXTERN PetscErrorCode   DMCreateLocalVector(DM,Vec*);
418: EXTERN PetscErrorCode   DMGetLocalVector(DM,Vec *);
419: EXTERN PetscErrorCode   DMRestoreLocalVector(DM,Vec *);
420: EXTERN PetscErrorCode   DMGetGlobalVector(DM,Vec *);
421: EXTERN PetscErrorCode   DMRestoreGlobalVector(DM,Vec *);
422: EXTERN PetscErrorCode   DMGetColoring(DM,ISColoringType,ISColoring*);
423: EXTERN PetscErrorCode   DMGetMatrix(DM, const MatType,Mat*);
424: EXTERN PetscErrorCode   DMGetInterpolation(DM,DM,Mat*,Vec*);
425: EXTERN PetscErrorCode   DMGetInjection(DM,DM,VecScatter*);
426: EXTERN PetscErrorCode   DMRefine(DM,MPI_Comm,DM*);
427: EXTERN PetscErrorCode   DMCoarsen(DM,MPI_Comm,DM*);
428: EXTERN PetscErrorCode   DMRefineHierarchy(DM,PetscInt,DM**);
429: EXTERN PetscErrorCode   DMCoarsenHierarchy(DM,PetscInt,DM**);
430: EXTERN PetscErrorCode   DMGetInterpolationScale(DM,DM,Mat,Vec*);
431: EXTERN PetscErrorCode   DMGetAggregates(DM,DM,Mat*);
432: EXTERN PetscErrorCode   DMGlobalToLocalBegin(DM,Vec,InsertMode,Vec);
433: EXTERN PetscErrorCode   DMGlobalToLocalEnd(DM,Vec,InsertMode,Vec);
434: EXTERN PetscErrorCode   DMLocalToGlobal(DM,Vec,InsertMode,Vec);
435: EXTERN PetscErrorCode   DMGetElements(DM,PetscInt *,const PetscInt*[]);
436: EXTERN PetscErrorCode   DMRestoreElements(DM,PetscInt *,const PetscInt*[]);
437: EXTERN PetscErrorCode   DMFinalizePackage(void);

439: EXTERN PetscErrorCode   DAGetColoring(DA,ISColoringType,ISColoring *);
440: EXTERN PetscErrorCode   DAGetMatrix(DA, const MatType,Mat *);
441: EXTERN PetscErrorCode   DASetGetMatrix(DA,PetscErrorCode (*)(DA, const MatType,Mat *));
442: EXTERN PetscErrorCode   DAGetInterpolation(DA,DA,Mat*,Vec*);
443: EXTERN PetscErrorCode   DAGetAggregates(DA,DA,Mat*);
444: EXTERN PetscErrorCode   DAGetInjection(DA,DA,VecScatter*);
445: EXTERN PetscErrorCode   DASetBlockFills(DA,PetscInt*,PetscInt*);
446: EXTERN PetscErrorCode   DASetMatPreallocateOnly(DA,PetscTruth);
447: EXTERN PetscErrorCode   DASetRefinementFactor(DA,PetscInt,PetscInt,PetscInt);
448: EXTERN PetscErrorCode   DAGetRefinementFactor(DA,PetscInt*,PetscInt*,PetscInt*);

450: EXTERN PetscErrorCode   DAGetAdicArray(DA,PetscTruth,void**,void**,PetscInt*);
451: EXTERN PetscErrorCode   DARestoreAdicArray(DA,PetscTruth,void**,void**,PetscInt*);
452: EXTERN PetscErrorCode   DAGetAdicMFArray(DA,PetscTruth,void**,void**,PetscInt*);
453: EXTERN PetscErrorCode   DAGetAdicMFArray4(DA,PetscTruth,void**,void**,PetscInt*);
454: EXTERN PetscErrorCode   DAGetAdicMFArray9(DA,PetscTruth,void**,void**,PetscInt*);
455: EXTERN PetscErrorCode   DAGetAdicMFArrayb(DA,PetscTruth,void**,void**,PetscInt*);
456: EXTERN PetscErrorCode   DARestoreAdicMFArray(DA,PetscTruth,void**,void**,PetscInt*);
457: EXTERN PetscErrorCode   DAGetArray(DA,PetscTruth,void**);
458: EXTERN PetscErrorCode   DARestoreArray(DA,PetscTruth,void**);
459: EXTERN PetscErrorCode   ad_DAGetArray(DA,PetscTruth,void**);
460: EXTERN PetscErrorCode   ad_DARestoreArray(DA,PetscTruth,void**);
461: EXTERN PetscErrorCode   admf_DAGetArray(DA,PetscTruth,void**);
462: EXTERN PetscErrorCode   admf_DARestoreArray(DA,PetscTruth,void**);

464:  #include petscpf.h
465: EXTERN PetscErrorCode   DACreatePF(DA,PF*);

467: /*S
468:      DMComposite - Abstract PETSc object that manages treating several distinct vectors as if they
469:         were one.   The DMComposite routines allow one to manage a nonlinear solver that works on a
470:         vector that consists of several distinct parts. This is mostly used for LNKS solvers, 
471:         that is design optimization problems that are written as a nonlinear system

473:    Level: beginner

475:   Concepts: multi-component, LNKS solvers

477: .seealso:  DMCompositeCreate(), DMCompositeDestroy(), DM
478: S*/
479: typedef struct _p_DMComposite* DMComposite;

481: EXTERN PetscErrorCode   DMCompositeCreate(MPI_Comm,DMComposite*);
482: EXTERN PetscErrorCode   DMCompositeDestroy(DMComposite);
483: EXTERN PetscErrorCode   DMCompositeAddArray(DMComposite,PetscMPIInt,PetscInt);
484: EXTERN PetscErrorCode   DMCompositeAddDM(DMComposite,DM);
485: EXTERN PetscErrorCode   DMCompositeSetCoupling(DMComposite,PetscErrorCode (*)(DMComposite,Mat,PetscInt*,PetscInt*,PetscInt,PetscInt,PetscInt,PetscInt));
486: EXTERN PetscErrorCode   DMCompositeSetContext(DMComposite,void*);
487: EXTERN PetscErrorCode   DMCompositeGetContext(DMComposite,void**);
488: EXTERN PetscErrorCode   DMCompositeAddVecScatter(DMComposite,VecScatter);
489: EXTERN PetscErrorCode   DMCompositeScatter(DMComposite,Vec,...);
490: EXTERN PetscErrorCode   DMCompositeGather(DMComposite,Vec,...);
491: EXTERN PetscErrorCode   DMCompositeGetAccess(DMComposite,Vec,...);
492: EXTERN PetscErrorCode   DMCompositeGetNumberDM(DMComposite,PetscInt*);
493: EXTERN PetscErrorCode   DMCompositeRestoreAccess(DMComposite,Vec,...);
494: EXTERN PetscErrorCode   DMCompositeGetLocalVectors(DMComposite,...);
495: EXTERN PetscErrorCode   DMCompositeGetEntries(DMComposite,...);
496: EXTERN PetscErrorCode   DMCompositeRestoreLocalVectors(DMComposite,...);
497: EXTERN PetscErrorCode   DMCompositeCreateGlobalVector(DMComposite,Vec*);
498: EXTERN PetscErrorCode   DMCompositeCreateLocalVector(DMComposite,Vec*);
499: EXTERN PetscErrorCode   DMCompositeGetLocalISs(DMComposite,IS*[]);
500: EXTERN PetscErrorCode   DMCompositeGetGlobalISs(DMComposite,IS*[]);
501: EXTERN PetscErrorCode   DMCompositeRefine(DMComposite,MPI_Comm,DMComposite*);
502: EXTERN PetscErrorCode   DMCompositeGetInterpolation(DMComposite,DMComposite,Mat*,Vec*);
503: EXTERN PetscErrorCode   DMCompositeGetMatrix(DMComposite,const MatType,Mat*);
504: EXTERN PetscErrorCode   DMCompositeGetColoring(DMComposite,ISColoringType,ISColoring*);
505: EXTERN PetscErrorCode   DMCompositeGlobalToLocalBegin(DMComposite,Vec,InsertMode,Vec);
506: EXTERN PetscErrorCode   DMCompositeGlobalToLocalEnd(DMComposite,Vec,InsertMode,Vec);

508: /*S
509:      Slice - Abstract PETSc object that manages distributed field data for a simple unstructured matrix

511:    Level: beginner

513:   Concepts: distributed array

515: .seealso:  DACreate1d(), DACreate2d(), DACreate3d(), DADestroy(), VecScatter, DACreate(), DMCompositeCreate(), DMComposite
516: S*/
517: typedef struct _p_Sliced* Sliced;

519: EXTERN PetscErrorCode   SlicedView(Sliced,PetscViewer);
520: EXTERN PetscErrorCode   SlicedCreate(MPI_Comm,Sliced*);
521: EXTERN PetscErrorCode   SlicedDestroy(Sliced);
522: EXTERN PetscErrorCode   SlicedCreateGlobalVector(Sliced,Vec*);
523: EXTERN PetscErrorCode   SlicedCreateLocalVector(Sliced,Vec*);
524: EXTERN PetscErrorCode   SlicedGetMatrix(Sliced, const MatType,Mat*);
525: EXTERN PetscErrorCode   SlicedGetGlobalIndices(Sliced,PetscInt*[]);
526: EXTERN PetscErrorCode   SlicedSetPreallocation(Sliced,PetscInt,const PetscInt[],PetscInt,const PetscInt[]);
527: EXTERN PetscErrorCode   SlicedSetGhosts(Sliced,PetscInt,PetscInt,PetscInt,const PetscInt[]);
528: EXTERN PetscErrorCode   SlicedGlobalToLocalBegin(Sliced,Vec,InsertMode,Vec);
529: EXTERN PetscErrorCode   SlicedGlobalToLocalEnd(Sliced,Vec,InsertMode,Vec);


532: typedef struct NLF_DAAD* NLF;

534: #include <petscbag.h>

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, DA);


543: /*S
544:   ADDA - Abstract PETSc object that manages distributed field data for a single structured grid
545:          These are for any number of dimensions.

547:   Level: advanced. 

549:   Concepts: distributed array
550: .seealso: DA, DACreate(), ADDACreate()
551: S*/
552: typedef struct _p_ADDA* ADDA;


556: PetscErrorCode  ADDACreate(MPI_Comm,PetscInt,PetscInt*,PetscInt*,PetscInt,PetscTruth*,ADDA*);
557: PetscErrorCode  ADDADestroy(ADDA);

559: /* DM interface functions */
560: PetscErrorCode  ADDAView(ADDA,PetscViewer);
561: PetscErrorCode  ADDACreateGlobalVector(ADDA,Vec*);
562: PetscErrorCode  ADDAGetColoring(ADDA,ISColoringType,ISColoring*);
563: PetscErrorCode  ADDAGetMatrix(ADDA,const MatType, Mat*);
564: PetscErrorCode  ADDAGetInterpolation(ADDA,ADDA,Mat*,Vec*);
565: PetscErrorCode  ADDARefine(ADDA, MPI_Comm,ADDA *);
566: PetscErrorCode  ADDACoarsen(ADDA, MPI_Comm, ADDA*);
567: PetscErrorCode  ADDAGetInjection(ADDA, ADDA, VecScatter*);
568: PetscErrorCode  ADDAGetAggregates(ADDA, ADDA, Mat *);

570: /* functions only supported by ADDA */
571: PetscErrorCode  ADDASetRefinement(ADDA, PetscInt *,PetscInt);
572: PetscErrorCode  ADDAGetCorners(ADDA, PetscInt **, PetscInt **);
573: PetscErrorCode  ADDAGetGhostCorners(ADDA, PetscInt **, PetscInt **);
574: PetscErrorCode  ADDAGetMatrixNS(ADDA, ADDA, const MatType , Mat *);

576: /* functions to set values in vectors and matrices */
577: struct _ADDAIdx_s {
578:   PetscInt     *x;               /* the coordinates, user has to make sure it is the correct size! */
579:   PetscInt     d;                /* indexes the dof */
580: };
581: typedef struct _ADDAIdx_s ADDAIdx;

583: PetscErrorCode  ADDAMatSetValues(Mat, ADDA, PetscInt, const ADDAIdx[], ADDA, PetscInt,
584:                                                   const ADDAIdx[], const PetscScalar[], InsertMode);

586: PetscTruth ADDAHCiterStartup(const PetscInt, const PetscInt *const, const PetscInt *const, PetscInt *const);
587: PetscTruth ADDAHCiter(const PetscInt, const PetscInt *const, const PetscInt *const, PetscInt *const);

590: #endif