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