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