xref: /petsc/include/petscdm.h (revision 62cbcd01bf7444475d5b2b40f2df209719797777)
1e1589f56SBarry Smith /*
2e1589f56SBarry Smith       Objects to manage the interactions between the mesh data structures and the algebraic objects
3e1589f56SBarry Smith */
4e1589f56SBarry Smith #if !defined(__PETSCDA_H)
5e1589f56SBarry Smith #define __PETSCDA_H
6*62cbcd01SMatthew G Knepley #include "petscmat.h"
7e1589f56SBarry Smith #include "petscao.h"
8e1589f56SBarry Smith PETSC_EXTERN_CXX_BEGIN
9e1589f56SBarry Smith 
107087cfbeSBarry Smith extern PetscErrorCode  DMInitializePackage(const char[]);
11e1589f56SBarry Smith /*S
12e1589f56SBarry Smith      DM - Abstract PETSc object that manages an abstract grid object
13e1589f56SBarry Smith 
14e1589f56SBarry Smith    Level: intermediate
15e1589f56SBarry Smith 
16e1589f56SBarry Smith   Concepts: grids, grid refinement
17e1589f56SBarry Smith 
18325fc9f4SBarry Smith    Notes: The DMDACreate() based object and the DMCompositeCreate() based object are examples of DMs
19e1589f56SBarry Smith 
20325fc9f4SBarry Smith           Though the DM objects require the petscsnes.h include files the DM library is
21e1589f56SBarry Smith     NOT dependent on the SNES or KSP library. In fact, the KSP and SNES libraries depend on
22e1589f56SBarry Smith     DM. (This is not great design, but not trivial to fix).
23e1589f56SBarry Smith 
24e1589f56SBarry Smith .seealso:  DMCompositeCreate(), DMDACreate()
25e1589f56SBarry Smith S*/
26e1589f56SBarry Smith typedef struct _p_DM* DM;
27e1589f56SBarry Smith 
28e1589f56SBarry Smith /*E
29e1589f56SBarry Smith     DMDAStencilType - Determines if the stencil extends only along the coordinate directions, or also
30e1589f56SBarry Smith       to the northeast, northwest etc
31e1589f56SBarry Smith 
32e1589f56SBarry Smith    Level: beginner
33e1589f56SBarry Smith 
34e1589f56SBarry Smith .seealso: DMDACreate1d(), DMDACreate2d(), DMDACreate3d(), DMDACreate()
35e1589f56SBarry Smith E*/
36e1589f56SBarry Smith typedef enum { DMDA_STENCIL_STAR,DMDA_STENCIL_BOX } DMDAStencilType;
37e1589f56SBarry Smith 
38e1589f56SBarry Smith /*MC
39e1589f56SBarry Smith      DMDA_STENCIL_STAR - "Star"-type stencil. In logical grid coordinates, only (i,j,k), (i+s,j,k), (i,j+s,k),
40e1589f56SBarry Smith                        (i,j,k+s) are in the stencil  NOT, for example, (i+s,j+s,k)
41e1589f56SBarry Smith 
42e1589f56SBarry Smith      Level: beginner
43e1589f56SBarry Smith 
44e1589f56SBarry Smith .seealso: DMDA_STENCIL_BOX, DMDAStencilType
45e1589f56SBarry Smith M*/
46e1589f56SBarry Smith 
47e1589f56SBarry Smith /*MC
48e1589f56SBarry Smith      DMDA_STENCIL_BOX - "Box"-type stencil. In logical grid coordinates, any of (i,j,k), (i+s,j+r,k+t) may
49e1589f56SBarry Smith                       be in the stencil.
50e1589f56SBarry Smith 
51e1589f56SBarry Smith      Level: beginner
52e1589f56SBarry Smith 
53e1589f56SBarry Smith .seealso: DMDA_STENCIL_STAR, DMDAStencilType
54e1589f56SBarry Smith M*/
55e1589f56SBarry Smith 
56e1589f56SBarry Smith /*E
571321219cSEthan Coon     DMDABoundaryType - Describes the choice for fill of ghost cells on domain boundaries.
58e1589f56SBarry Smith 
59e1589f56SBarry Smith    Level: beginner
60e1589f56SBarry Smith 
611321219cSEthan Coon    A boundary may be of type DMDA_BOUNDARY_NONE (no ghost nodes), DMDA_BOUNDARY_GHOST (ghost nodes
621321219cSEthan Coon    exist but aren't filled), DMDA_BOUNDARY_MIRROR (not yet implemented), or DMDA_BOUNDARY_PERIODIC
631321219cSEthan Coon    (ghost nodes filled by the opposite edge of the domain).
64ce00eea3SSatish Balay 
651321219cSEthan Coon .seealso: DMDASetBoundaryType(), DMDACreate1d(), DMDACreate2d(), DMDACreate3d(), DMDACreate()
66e1589f56SBarry Smith E*/
671321219cSEthan Coon typedef enum { DMDA_BOUNDARY_NONE, DMDA_BOUNDARY_GHOSTED, DMDA_BOUNDARY_MIRROR, DMDA_BOUNDARY_PERIODIC } DMDABoundaryType;
68ce00eea3SSatish Balay 
69db87c5ecSEthan Coon extern const char *DMDABoundaryTypes[];
70e1589f56SBarry Smith 
71e1589f56SBarry Smith /*E
72e1589f56SBarry Smith     DMDAInterpolationType - Defines the type of interpolation that will be returned by
73e1589f56SBarry Smith        DMGetInterpolation.
74e1589f56SBarry Smith 
75e1589f56SBarry Smith    Level: beginner
76e1589f56SBarry Smith 
77e1589f56SBarry Smith .seealso: DMDACreate1d(), DMDACreate2d(), DMDACreate3d(), DMGetInterpolation(), DMDASetInterpolationType(), DMDACreate()
78e1589f56SBarry Smith E*/
79e1589f56SBarry Smith typedef enum { DMDA_Q0, DMDA_Q1 } DMDAInterpolationType;
80e1589f56SBarry Smith 
817087cfbeSBarry Smith extern PetscErrorCode   DMDASetInterpolationType(DM,DMDAInterpolationType);
82e1589f56SBarry Smith 
83e1589f56SBarry Smith /*E
84e1589f56SBarry Smith     DMDAElementType - Defines the type of elements that will be returned by
85e1589f56SBarry Smith        DMGetElements()
86e1589f56SBarry Smith 
87e1589f56SBarry Smith    Level: beginner
88e1589f56SBarry Smith 
89e1589f56SBarry Smith .seealso: DMDACreate1d(), DMDACreate2d(), DMDACreate3d(), DMGetInterpolation(), DMDASetInterpolationType(),
90e1589f56SBarry Smith           DMDASetElementType(), DMGetElements(), DMRestoreElements(), DMDACreate()
91e1589f56SBarry Smith E*/
92e1589f56SBarry Smith typedef enum { DMDA_ELEMENT_P1, DMDA_ELEMENT_Q1 } DMDAElementType;
93e1589f56SBarry Smith 
947087cfbeSBarry Smith extern PetscErrorCode   DMDASetElementType(DM,DMDAElementType);
957087cfbeSBarry Smith extern PetscErrorCode   DMDAGetElementType(DM,DMDAElementType*);
96e1589f56SBarry Smith 
97e1589f56SBarry Smith typedef enum { DMDA_X,DMDA_Y,DMDA_Z } DMDADirection;
98e1589f56SBarry Smith 
997087cfbeSBarry Smith extern PetscClassId  DM_CLASSID;
100e1589f56SBarry Smith 
101e1589f56SBarry Smith #define MATSEQUSFFT        "sequsfft"
102e1589f56SBarry Smith 
1037087cfbeSBarry Smith extern PetscErrorCode  DMDACreate(MPI_Comm,DM*);
1047087cfbeSBarry Smith extern PetscErrorCode  DMDASetDim(DM,PetscInt);
1057087cfbeSBarry Smith extern PetscErrorCode  DMDASetSizes(DM,PetscInt,PetscInt,PetscInt);
106db87c5ecSEthan Coon extern PetscErrorCode     DMDACreate1d(MPI_Comm,DMDABoundaryType,PetscInt,PetscInt,PetscInt,const PetscInt[],DM *);
1071321219cSEthan Coon extern PetscErrorCode     DMDACreate2d(MPI_Comm,DMDABoundaryType,DMDABoundaryType,DMDAStencilType,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],DM*);
1081321219cSEthan Coon extern PetscErrorCode     DMDACreate3d(MPI_Comm,DMDABoundaryType,DMDABoundaryType,DMDABoundaryType,DMDAStencilType,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscInt[],DM*);
1097087cfbeSBarry Smith extern PetscErrorCode  DMSetOptionsPrefix(DM,const char []);
1107087cfbeSBarry Smith extern PetscErrorCode  DMSetVecType(DM,const VecType);
111e1589f56SBarry Smith 
1127087cfbeSBarry Smith extern PetscErrorCode     DMDAGlobalToNaturalBegin(DM,Vec,InsertMode,Vec);
1137087cfbeSBarry Smith extern PetscErrorCode     DMDAGlobalToNaturalEnd(DM,Vec,InsertMode,Vec);
1147087cfbeSBarry Smith extern PetscErrorCode     DMDANaturalToGlobalBegin(DM,Vec,InsertMode,Vec);
1157087cfbeSBarry Smith extern PetscErrorCode     DMDANaturalToGlobalEnd(DM,Vec,InsertMode,Vec);
1167087cfbeSBarry Smith extern PetscErrorCode     DMDALocalToLocalBegin(DM,Vec,InsertMode,Vec);
1177087cfbeSBarry Smith extern PetscErrorCode     DMDALocalToLocalEnd(DM,Vec,InsertMode,Vec);
1187087cfbeSBarry Smith extern PetscErrorCode     DMDACreateNaturalVector(DM,Vec *);
119e1589f56SBarry Smith 
1207087cfbeSBarry Smith extern PetscErrorCode     DMDALoad(PetscViewer,PetscInt,PetscInt,PetscInt,DM *);
1217087cfbeSBarry Smith extern PetscErrorCode     DMDAGetCorners(DM,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*);
1227087cfbeSBarry Smith extern PetscErrorCode     DMDAGetGhostCorners(DM,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*);
1231321219cSEthan Coon extern PetscErrorCode     DMDAGetInfo(DM,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,DMDABoundaryType*,DMDABoundaryType*,DMDABoundaryType*,DMDAStencilType*);
1247087cfbeSBarry Smith extern PetscErrorCode     DMDAGetProcessorSubset(DM,DMDADirection,PetscInt,MPI_Comm*);
1257087cfbeSBarry Smith extern PetscErrorCode     DMDAGetProcessorSubsets(DM,DMDADirection,MPI_Comm*);
126e1589f56SBarry Smith 
1277087cfbeSBarry Smith extern PetscErrorCode     DMDAGlobalToNaturalAllCreate(DM,VecScatter*);
1287087cfbeSBarry Smith extern PetscErrorCode     DMDANaturalAllToGlobalCreate(DM,VecScatter*);
129e1589f56SBarry Smith 
1307087cfbeSBarry Smith extern PetscErrorCode     DMDAGetGlobalIndices(DM,PetscInt*,PetscInt**);
131e1589f56SBarry Smith 
1327087cfbeSBarry Smith extern PetscErrorCode     DMDAGetScatter(DM,VecScatter*,VecScatter*,VecScatter*);
1337087cfbeSBarry Smith extern PetscErrorCode     DMDAGetNeighbors(DM,const PetscMPIInt**);
134e1589f56SBarry Smith 
1357087cfbeSBarry Smith extern PetscErrorCode     DMDAGetAO(DM,AO*);
1367087cfbeSBarry Smith extern PetscErrorCode     DMDASetCoordinates(DM,Vec);
137ce00eea3SSatish Balay extern PetscErrorCode     DMDASetGhostedCoordinates(DM,Vec);
1387087cfbeSBarry Smith extern PetscErrorCode     DMDAGetCoordinates(DM,Vec *);
1397087cfbeSBarry Smith extern PetscErrorCode     DMDAGetGhostedCoordinates(DM,Vec *);
1407087cfbeSBarry Smith extern PetscErrorCode     DMDAGetCoordinateDA(DM,DM *);
1417087cfbeSBarry Smith extern PetscErrorCode     DMDASetUniformCoordinates(DM,PetscReal,PetscReal,PetscReal,PetscReal,PetscReal,PetscReal);
1427087cfbeSBarry Smith extern PetscErrorCode     DMDAGetBoundingBox(DM,PetscReal[],PetscReal[]);
1437087cfbeSBarry Smith extern PetscErrorCode     DMDAGetLocalBoundingBox(DM,PetscReal[],PetscReal[]);
1447087cfbeSBarry Smith extern PetscErrorCode     DMDASetFieldName(DM,PetscInt,const char[]);
1457087cfbeSBarry Smith extern PetscErrorCode     DMDAGetFieldName(DM,PetscInt,const char**);
146e1589f56SBarry Smith 
1471321219cSEthan Coon extern PetscErrorCode  DMDASetBoundaryType(DM,DMDABoundaryType,DMDABoundaryType,DMDABoundaryType);
1487087cfbeSBarry Smith extern PetscErrorCode  DMDASetDof(DM, int);
1497087cfbeSBarry Smith extern PetscErrorCode  DMDASetStencilWidth(DM, PetscInt);
1507087cfbeSBarry Smith extern PetscErrorCode  DMDASetOwnershipRanges(DM,const PetscInt[],const PetscInt[],const PetscInt[]);
1517087cfbeSBarry Smith extern PetscErrorCode  DMDAGetOwnershipRanges(DM,const PetscInt**,const PetscInt**,const PetscInt**);
1527087cfbeSBarry Smith extern PetscErrorCode  DMDASetNumProcs(DM, PetscInt, PetscInt, PetscInt);
1537087cfbeSBarry Smith extern PetscErrorCode  DMDASetStencilType(DM, DMDAStencilType);
154e1589f56SBarry Smith 
1557087cfbeSBarry Smith extern PetscErrorCode     DMDAVecGetArray(DM,Vec,void *);
1567087cfbeSBarry Smith extern PetscErrorCode     DMDAVecRestoreArray(DM,Vec,void *);
157e1589f56SBarry Smith 
1587087cfbeSBarry Smith extern PetscErrorCode     DMDAVecGetArrayDOF(DM,Vec,void *);
1597087cfbeSBarry Smith extern PetscErrorCode     DMDAVecRestoreArrayDOF(DM,Vec,void *);
160e1589f56SBarry Smith 
1617087cfbeSBarry Smith extern PetscErrorCode     DMDASplitComm2d(MPI_Comm,PetscInt,PetscInt,PetscInt,MPI_Comm*);
162e1589f56SBarry Smith 
163e1589f56SBarry Smith /*E
164e1589f56SBarry Smith     DMType - String with the name of a PETSc DM or the creation function
165e1589f56SBarry Smith        with an optional dynamic library name, for example
166e1589f56SBarry Smith        http://www.mcs.anl.gov/petsc/lib.a:myveccreate()
167e1589f56SBarry Smith 
168e1589f56SBarry Smith    Level: beginner
169e1589f56SBarry Smith 
170e1589f56SBarry Smith .seealso: DMSetType(), DM
171e1589f56SBarry Smith E*/
172e1589f56SBarry Smith 
173e1589f56SBarry Smith #define DMType char*
174e1589f56SBarry Smith #define DMDA        "da"
175e1589f56SBarry Smith #define DMADDA      "adda"
176e1589f56SBarry Smith #define DMCOMPOSITE "composite"
177e1589f56SBarry Smith #define DMSLICED    "sliced"
178b30b9b2eSMatthew G Knepley #define DMMESH      "mesh"
179b30b9b2eSMatthew G Knepley #define DMCARTESIAN "cartesian"
180e1589f56SBarry Smith 
181e1589f56SBarry Smith extern PetscFList DMList;
182e1589f56SBarry Smith extern PetscBool  DMRegisterAllCalled;
1837087cfbeSBarry Smith extern PetscErrorCode  DMCreate(MPI_Comm,DM*);
1847087cfbeSBarry Smith extern PetscErrorCode  DMSetType(DM, const DMType);
1857087cfbeSBarry Smith extern PetscErrorCode  DMGetType(DM, const DMType *);
1867087cfbeSBarry Smith extern PetscErrorCode  DMRegister(const char[],const char[],const char[],PetscErrorCode (*)(DM));
1877087cfbeSBarry Smith extern PetscErrorCode  DMRegisterAll(const char []);
1887087cfbeSBarry Smith extern PetscErrorCode  DMRegisterDestroy(void);
189e1589f56SBarry Smith 
190e1589f56SBarry Smith /*MC
191e1589f56SBarry Smith   DMRegisterDynamic - Adds a new DM component implementation
192e1589f56SBarry Smith 
193e1589f56SBarry Smith   Synopsis:
194e1589f56SBarry Smith   PetscErrorCode DMRegisterDynamic(const char *name,const char *path,const char *func_name, PetscErrorCode (*create_func)(DM))
195e1589f56SBarry Smith 
196e1589f56SBarry Smith   Not Collective
197e1589f56SBarry Smith 
198e1589f56SBarry Smith   Input Parameters:
199e1589f56SBarry Smith + name        - The name of a new user-defined creation routine
200e1589f56SBarry Smith . path        - The path (either absolute or relative) of the library containing this routine
201e1589f56SBarry Smith . func_name   - The name of routine to create method context
202e1589f56SBarry Smith - create_func - The creation routine itself
203e1589f56SBarry Smith 
204e1589f56SBarry Smith   Notes:
205e1589f56SBarry Smith   DMRegisterDynamic() may be called multiple times to add several user-defined DMs
206e1589f56SBarry Smith 
207e1589f56SBarry Smith   If dynamic libraries are used, then the fourth input argument (routine_create) is ignored.
208e1589f56SBarry Smith 
209e1589f56SBarry Smith   Sample usage:
210e1589f56SBarry Smith .vb
211e1589f56SBarry Smith     DMRegisterDynamic("my_da","/home/username/my_lib/lib/libO/solaris/libmy.a", "MyDMCreate", MyDMCreate);
212e1589f56SBarry Smith .ve
213e1589f56SBarry Smith 
214e1589f56SBarry Smith   Then, your DM type can be chosen with the procedural interface via
215e1589f56SBarry Smith .vb
216e1589f56SBarry Smith     DMCreate(MPI_Comm, DM *);
217e1589f56SBarry Smith     DMSetType(DM,"my_da_name");
218e1589f56SBarry Smith .ve
219e1589f56SBarry Smith    or at runtime via the option
220e1589f56SBarry Smith .vb
221e1589f56SBarry Smith     -da_type my_da_name
222e1589f56SBarry Smith .ve
223e1589f56SBarry Smith 
224e1589f56SBarry Smith   Notes: $PETSC_ARCH occuring in pathname will be replaced with appropriate values.
225e1589f56SBarry Smith          If your function is not being put into a shared library then use DMRegister() instead
226e1589f56SBarry Smith 
227e1589f56SBarry Smith   Level: advanced
228e1589f56SBarry Smith 
229e1589f56SBarry Smith .keywords: DM, register
230e1589f56SBarry Smith .seealso: DMRegisterAll(), DMRegisterDestroy(), DMRegister()
231e1589f56SBarry Smith M*/
232e1589f56SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
233e1589f56SBarry Smith #define DMRegisterDynamic(a,b,c,d) DMRegister(a,b,c,0)
234e1589f56SBarry Smith #else
235e1589f56SBarry Smith #define DMRegisterDynamic(a,b,c,d) DMRegister(a,b,c,d)
236e1589f56SBarry Smith #endif
237e1589f56SBarry Smith 
2387087cfbeSBarry Smith extern PetscErrorCode     MatRegisterDAAD(void);
2397087cfbeSBarry Smith extern PetscErrorCode     MatCreateDAAD(DM,Mat*);
2407087cfbeSBarry Smith extern PetscErrorCode    MatCreateSeqUSFFT(Vec, DM,Mat*);
241e1589f56SBarry Smith 
242e1589f56SBarry Smith /*S
243e1589f56SBarry Smith      DMDALocalInfo - C struct that contains information about a structured grid and a processors logical
244e1589f56SBarry Smith               location in it.
245e1589f56SBarry Smith 
246e1589f56SBarry Smith    Level: beginner
247e1589f56SBarry Smith 
248e1589f56SBarry Smith   Concepts: distributed array
249e1589f56SBarry Smith 
250e1589f56SBarry Smith   Developer note: Then entries in this struct are int instead of PetscInt so that the elements may
251e1589f56SBarry Smith                   be extracted in Fortran as if from an integer array
252e1589f56SBarry Smith 
253e1589f56SBarry Smith .seealso:  DMDACreate1d(), DMDACreate2d(), DMDACreate3d(), DMDestroy(), DM, DMDAGetLocalInfo(), DMDAGetInfo()
254e1589f56SBarry Smith S*/
255e1589f56SBarry Smith typedef struct {
256e1589f56SBarry Smith   PetscInt       dim,dof,sw;
257e1589f56SBarry Smith   PetscInt       mx,my,mz;    /* global number of grid points in each direction */
258e1589f56SBarry Smith   PetscInt       xs,ys,zs;    /* starting pointd of this processor, excluding ghosts */
259e1589f56SBarry Smith   PetscInt       xm,ym,zm;    /* number of grid points on this processor, excluding ghosts */
260e1589f56SBarry Smith   PetscInt       gxs,gys,gzs;    /* starting point of this processor including ghosts */
261e1589f56SBarry Smith   PetscInt       gxm,gym,gzm;    /* number of grid points on this processor including ghosts */
2621321219cSEthan Coon   DMDABoundaryType bx,by,bz; /* type of ghost nodes at boundary */
263e1589f56SBarry Smith   DMDAStencilType  st;
264e1589f56SBarry Smith   DM             da;
265e1589f56SBarry Smith } DMDALocalInfo;
266e1589f56SBarry Smith 
267e1589f56SBarry Smith /*MC
268e1589f56SBarry Smith       DMDAForEachPointBegin2d - Starts a loop over the local part of a two dimensional DMDA
269e1589f56SBarry Smith 
270e1589f56SBarry Smith    Synopsis:
271e1589f56SBarry Smith    void  DMDAForEachPointBegin2d(DALocalInfo *info,PetscInt i,PetscInt j);
272e1589f56SBarry Smith 
273e1589f56SBarry Smith    Not Collective
274e1589f56SBarry Smith 
275e1589f56SBarry Smith    Level: intermediate
276e1589f56SBarry Smith 
277e1589f56SBarry Smith .seealso: DMDAForEachPointEnd2d(), DMDAVecGetArray()
278e1589f56SBarry Smith M*/
279e1589f56SBarry Smith #define DMDAForEachPointBegin2d(info,i,j) {\
280e1589f56SBarry Smith   PetscInt _xints = info->xs,_xinte = info->xs+info->xm,_yints = info->ys,_yinte = info->ys+info->ym;\
281e1589f56SBarry Smith   for (j=_yints; j<_yinte; j++) {\
282e1589f56SBarry Smith     for (i=_xints; i<_xinte; i++) {\
283e1589f56SBarry Smith 
284e1589f56SBarry Smith /*MC
285e1589f56SBarry Smith       DMDAForEachPointEnd2d - Ends a loop over the local part of a two dimensional DMDA
286e1589f56SBarry Smith 
287e1589f56SBarry Smith    Synopsis:
288e1589f56SBarry Smith    void  DMDAForEachPointEnd2d;
289e1589f56SBarry Smith 
290e1589f56SBarry Smith    Not Collective
291e1589f56SBarry Smith 
292e1589f56SBarry Smith    Level: intermediate
293e1589f56SBarry Smith 
294e1589f56SBarry Smith .seealso: DMDAForEachPointBegin2d(), DMDAVecGetArray()
295e1589f56SBarry Smith M*/
296e1589f56SBarry Smith #define DMDAForEachPointEnd2d }}}
297e1589f56SBarry Smith 
298e1589f56SBarry Smith /*MC
299e1589f56SBarry Smith       DMDACoor2d - Structure for holding 2d (x and y) coordinates.
300e1589f56SBarry Smith 
301e1589f56SBarry Smith     Level: intermediate
302e1589f56SBarry Smith 
303e1589f56SBarry Smith     Sample Usage:
304e1589f56SBarry Smith       DMDACoor2d **coors;
305e1589f56SBarry Smith       Vec      vcoors;
306e1589f56SBarry Smith       DM       cda;
307e1589f56SBarry Smith 
308e1589f56SBarry Smith       DMDAGetCoordinates(da,&vcoors);
309e1589f56SBarry Smith       DMDAGetCoordinateDA(da,&cda);
310e1589f56SBarry Smith       DMDAVecGetArray(cda,vcoors,&coors);
311e1589f56SBarry Smith       DMDAGetCorners(cda,&mstart,&nstart,0,&m,&n,0)
312e1589f56SBarry Smith       for (i=mstart; i<mstart+m; i++) {
313e1589f56SBarry Smith         for (j=nstart; j<nstart+n; j++) {
314e1589f56SBarry Smith           x = coors[j][i].x;
315e1589f56SBarry Smith           y = coors[j][i].y;
316e1589f56SBarry Smith           ......
317e1589f56SBarry Smith         }
318e1589f56SBarry Smith       }
319e1589f56SBarry Smith       DMDAVecRestoreArray(dac,vcoors,&coors);
320e1589f56SBarry Smith 
321e1589f56SBarry Smith .seealso: DMDACoor3d, DMDAForEachPointBegin(), DMDAGetCoordinateDA(), DMDAGetCoordinates(), DMDAGetGhostCoordinates()
322e1589f56SBarry Smith M*/
323e1589f56SBarry Smith typedef struct {PetscScalar x,y;} DMDACoor2d;
324e1589f56SBarry Smith 
325e1589f56SBarry Smith /*MC
326e1589f56SBarry Smith       DMDACoor3d - Structure for holding 3d (x, y and z) coordinates.
327e1589f56SBarry Smith 
328e1589f56SBarry Smith     Level: intermediate
329e1589f56SBarry Smith 
330e1589f56SBarry Smith     Sample Usage:
331e1589f56SBarry Smith       DMDACoor3d ***coors;
332e1589f56SBarry Smith       Vec      vcoors;
333e1589f56SBarry Smith       DM       cda;
334e1589f56SBarry Smith 
335e1589f56SBarry Smith       DMDAGetCoordinates(da,&vcoors);
336e1589f56SBarry Smith       DMDAGetCoordinateDA(da,&cda);
337e1589f56SBarry Smith       DMDAVecGetArray(cda,vcoors,&coors);
338e1589f56SBarry Smith       DMDAGetCorners(cda,&mstart,&nstart,&pstart,&m,&n,&p)
339e1589f56SBarry Smith       for (i=mstart; i<mstart+m; i++) {
340e1589f56SBarry Smith         for (j=nstart; j<nstart+n; j++) {
341e1589f56SBarry Smith           for (k=pstart; k<pstart+p; k++) {
342e1589f56SBarry Smith             x = coors[k][j][i].x;
343e1589f56SBarry Smith             y = coors[k][j][i].y;
344e1589f56SBarry Smith             z = coors[k][j][i].z;
345e1589f56SBarry Smith           ......
346e1589f56SBarry Smith         }
347e1589f56SBarry Smith       }
348e1589f56SBarry Smith       DMDAVecRestoreArray(dac,vcoors,&coors);
349e1589f56SBarry Smith 
350e1589f56SBarry Smith .seealso: DMDACoor2d, DMDAForEachPointBegin(), DMDAGetCoordinateDA(), DMDAGetCoordinates(), DMDAGetGhostCoordinates()
351e1589f56SBarry Smith M*/
352e1589f56SBarry Smith typedef struct {PetscScalar x,y,z;} DMDACoor3d;
353e1589f56SBarry Smith 
3547087cfbeSBarry Smith extern PetscErrorCode   DMDAGetLocalInfo(DM,DMDALocalInfo*);
355e1589f56SBarry Smith typedef PetscErrorCode (*DMDALocalFunction1)(DMDALocalInfo*,void*,void*,void*);
3567087cfbeSBarry Smith extern PetscErrorCode   DMDAFormFunctionLocal(DM, DMDALocalFunction1, Vec, Vec, void *);
3577087cfbeSBarry Smith extern PetscErrorCode   DMDAFormFunctionLocalGhost(DM, DMDALocalFunction1, Vec, Vec, void *);
3587087cfbeSBarry Smith extern PetscErrorCode   DMDAFormJacobianLocal(DM, DMDALocalFunction1, Vec, Mat, void *);
3597087cfbeSBarry Smith extern PetscErrorCode   DMDAFormFunction1(DM,Vec,Vec,void*);
3607087cfbeSBarry Smith extern PetscErrorCode   DMDAFormFunction(DM,PetscErrorCode (*)(void),Vec,Vec,void*);
3617087cfbeSBarry Smith extern PetscErrorCode   DMDAFormFunctioni1(DM,PetscInt,Vec,PetscScalar*,void*);
3627087cfbeSBarry Smith extern PetscErrorCode   DMDAFormFunctionib1(DM,PetscInt,Vec,PetscScalar*,void*);
3637087cfbeSBarry Smith extern PetscErrorCode   DMDAComputeJacobian1WithAdic(DM,Vec,Mat,void*);
3647087cfbeSBarry Smith extern PetscErrorCode   DMDAComputeJacobian1WithAdifor(DM,Vec,Mat,void*);
3657087cfbeSBarry Smith extern PetscErrorCode   DMDAMultiplyByJacobian1WithAdic(DM,Vec,Vec,Vec,void*);
3667087cfbeSBarry Smith extern PetscErrorCode   DMDAMultiplyByJacobian1WithAdifor(DM,Vec,Vec,Vec,void*);
3677087cfbeSBarry Smith extern PetscErrorCode   DMDAMultiplyByJacobian1WithAD(DM,Vec,Vec,Vec,void*);
3687087cfbeSBarry Smith extern PetscErrorCode   DMDAComputeJacobian1(DM,Vec,Mat,void*);
3697087cfbeSBarry Smith extern PetscErrorCode   DMDAGetLocalFunction(DM,DMDALocalFunction1*);
3707087cfbeSBarry Smith extern PetscErrorCode   DMDASetLocalFunction(DM,DMDALocalFunction1);
3717087cfbeSBarry Smith extern PetscErrorCode   DMDASetLocalFunctioni(DM,PetscErrorCode (*)(DMDALocalInfo*,MatStencil*,void*,PetscScalar*,void*));
3727087cfbeSBarry Smith extern PetscErrorCode   DMDASetLocalFunctionib(DM,PetscErrorCode (*)(DMDALocalInfo*,MatStencil*,void*,PetscScalar*,void*));
3737087cfbeSBarry Smith extern PetscErrorCode   DMDAGetLocalJacobian(DM,DMDALocalFunction1*);
3747087cfbeSBarry Smith extern PetscErrorCode   DMDASetLocalJacobian(DM,DMDALocalFunction1);
3757087cfbeSBarry Smith extern PetscErrorCode   DMDASetLocalAdicFunction_Private(DM,DMDALocalFunction1);
376e1589f56SBarry Smith 
3777087cfbeSBarry Smith extern PetscErrorCode   MatSetDA(Mat,DM);
378e1589f56SBarry Smith 
379e1589f56SBarry Smith /*MC
380e1589f56SBarry Smith        DMDASetLocalAdicFunction - Caches in a DM a local function computed by ADIC/ADIFOR
381e1589f56SBarry Smith 
382e1589f56SBarry Smith    Synopsis:
383e1589f56SBarry Smith    PetscErrorCode DMDASetLocalAdicFunction(DM da,DMDALocalFunction1 ad_lf)
384e1589f56SBarry Smith 
385e1589f56SBarry Smith    Logically Collective on DM
386e1589f56SBarry Smith 
387e1589f56SBarry Smith    Input Parameter:
388e1589f56SBarry Smith +  da - initial distributed array
389e1589f56SBarry Smith -  ad_lf - the local function as computed by ADIC/ADIFOR
390e1589f56SBarry Smith 
391e1589f56SBarry Smith    Level: intermediate
392e1589f56SBarry Smith 
393e1589f56SBarry Smith .keywords:  distributed array, refine
394e1589f56SBarry Smith 
395e1589f56SBarry Smith .seealso: DMDACreate1d(), DMDACreate2d(), DMDACreate3d(), DMDestroy(), DMDAGetLocalFunction(), DMDASetLocalFunction(),
396e1589f56SBarry Smith           DMDASetLocalJacobian()
397e1589f56SBarry Smith M*/
398e1589f56SBarry Smith #if defined(PETSC_HAVE_ADIC)
399e1589f56SBarry Smith #  define DMDASetLocalAdicFunction(a,d) DMDASetLocalAdicFunction_Private(a,(DMDALocalFunction1)d)
400e1589f56SBarry Smith #else
401e1589f56SBarry Smith #  define DMDASetLocalAdicFunction(a,d) DMDASetLocalAdicFunction_Private(a,0)
402e1589f56SBarry Smith #endif
403e1589f56SBarry Smith 
4047087cfbeSBarry Smith extern PetscErrorCode   DMDASetLocalAdicMFFunction_Private(DM,DMDALocalFunction1);
405e1589f56SBarry Smith #if defined(PETSC_HAVE_ADIC)
406e1589f56SBarry Smith #  define DMDASetLocalAdicMFFunction(a,d) DMDASetLocalAdicMFFunction_Private(a,(DMDALocalFunction1)d)
407e1589f56SBarry Smith #else
408e1589f56SBarry Smith #  define DMDASetLocalAdicMFFunction(a,d) DMDASetLocalAdicMFFunction_Private(a,0)
409e1589f56SBarry Smith #endif
4107087cfbeSBarry Smith extern PetscErrorCode   DMDASetLocalAdicFunctioni_Private(DM,PetscErrorCode (*)(DMDALocalInfo*,MatStencil*,void*,void*,void*));
411e1589f56SBarry Smith #if defined(PETSC_HAVE_ADIC)
412e1589f56SBarry Smith #  define DMDASetLocalAdicFunctioni(a,d) DMDASetLocalAdicFunctioni_Private(a,(PetscErrorCode (*)(DMDALocalInfo*,MatStencil*,void*,void*,void*))d)
413e1589f56SBarry Smith #else
414e1589f56SBarry Smith #  define DMDASetLocalAdicFunctioni(a,d) DMDASetLocalAdicFunctioni_Private(a,0)
415e1589f56SBarry Smith #endif
4167087cfbeSBarry Smith extern PetscErrorCode   DMDASetLocalAdicMFFunctioni_Private(DM,PetscErrorCode (*)(DMDALocalInfo*,MatStencil*,void*,void*,void*));
417e1589f56SBarry Smith #if defined(PETSC_HAVE_ADIC)
418e1589f56SBarry Smith #  define DMDASetLocalAdicMFFunctioni(a,d) DMDASetLocalAdicMFFunctioni_Private(a,(PetscErrorCode (*)(DMDALocalInfo*,MatStencil*,void*,void*,void*))d)
419e1589f56SBarry Smith #else
420e1589f56SBarry Smith #  define DMDASetLocalAdicMFFunctioni(a,d) DMDASetLocalAdicMFFunctioni_Private(a,0)
421e1589f56SBarry Smith #endif
422e1589f56SBarry Smith 
4237087cfbeSBarry Smith extern PetscErrorCode   DMDASetLocalAdicFunctionib_Private(DM,PetscErrorCode (*)(DMDALocalInfo*,MatStencil*,void*,void*,void*));
424e1589f56SBarry Smith #if defined(PETSC_HAVE_ADIC)
425e1589f56SBarry Smith #  define DMDASetLocalAdicFunctionib(a,d) DMDASetLocalAdicFunctionib_Private(a,(PetscErrorCode (*)(DMDALocalInfo*,MatStencil*,void*,void*,void*))d)
426e1589f56SBarry Smith #else
427e1589f56SBarry Smith #  define DMDASetLocalAdicFunctionib(a,d) DMDASetLocalAdicFunctionib_Private(a,0)
428e1589f56SBarry Smith #endif
4297087cfbeSBarry Smith extern PetscErrorCode   DMDASetLocalAdicMFFunctionib_Private(DM,PetscErrorCode (*)(DMDALocalInfo*,MatStencil*,void*,void*,void*));
430e1589f56SBarry Smith #if defined(PETSC_HAVE_ADIC)
431e1589f56SBarry Smith #  define DMDASetLocalAdicMFFunctionib(a,d) DMDASetLocalAdicMFFunctionib_Private(a,(PetscErrorCode (*)(DMDALocalInfo*,MatStencil*,void*,void*,void*))d)
432e1589f56SBarry Smith #else
433e1589f56SBarry Smith #  define DMDASetLocalAdicMFFunctionib(a,d) DMDASetLocalAdicMFFunctionib_Private(a,0)
434e1589f56SBarry Smith #endif
435e1589f56SBarry Smith 
4367087cfbeSBarry Smith extern PetscErrorCode   DMDAFormFunctioniTest1(DM,void*);
437e1589f56SBarry Smith 
4387087cfbeSBarry Smith extern PetscErrorCode   DMView(DM,PetscViewer);
4397087cfbeSBarry Smith extern PetscErrorCode   DMDestroy(DM);
4407087cfbeSBarry Smith extern PetscErrorCode   DMCreateGlobalVector(DM,Vec*);
4417087cfbeSBarry Smith extern PetscErrorCode   DMCreateLocalVector(DM,Vec*);
4427087cfbeSBarry Smith extern PetscErrorCode   DMGetLocalVector(DM,Vec *);
4437087cfbeSBarry Smith extern PetscErrorCode   DMRestoreLocalVector(DM,Vec *);
4447087cfbeSBarry Smith extern PetscErrorCode   DMGetGlobalVector(DM,Vec *);
4457087cfbeSBarry Smith extern PetscErrorCode   DMRestoreGlobalVector(DM,Vec *);
4467087cfbeSBarry Smith extern PetscErrorCode   DMGetLocalToGlobalMapping(DM,ISLocalToGlobalMapping*);
4477087cfbeSBarry Smith extern PetscErrorCode   DMGetLocalToGlobalMappingBlock(DM,ISLocalToGlobalMapping*);
4487087cfbeSBarry Smith extern PetscErrorCode   DMGetBlockSize(DM,PetscInt*);
4497087cfbeSBarry Smith extern PetscErrorCode   DMGetColoring(DM,ISColoringType,const MatType,ISColoring*);
4507087cfbeSBarry Smith extern PetscErrorCode   DMGetMatrix(DM, const MatType,Mat*);
4517087cfbeSBarry Smith extern PetscErrorCode   DMGetInterpolation(DM,DM,Mat*,Vec*);
4527087cfbeSBarry Smith extern PetscErrorCode   DMGetInjection(DM,DM,VecScatter*);
4537087cfbeSBarry Smith extern PetscErrorCode   DMRefine(DM,MPI_Comm,DM*);
4547087cfbeSBarry Smith extern PetscErrorCode   DMCoarsen(DM,MPI_Comm,DM*);
4557087cfbeSBarry Smith extern PetscErrorCode   DMRefineHierarchy(DM,PetscInt,DM[]);
4567087cfbeSBarry Smith extern PetscErrorCode   DMCoarsenHierarchy(DM,PetscInt,DM[]);
4577087cfbeSBarry Smith extern PetscErrorCode   DMSetFromOptions(DM);
4587087cfbeSBarry Smith extern PetscErrorCode   DMSetUp(DM);
4597087cfbeSBarry Smith extern PetscErrorCode   DMGetInterpolationScale(DM,DM,Mat,Vec*);
4607087cfbeSBarry Smith extern PetscErrorCode   DMGetAggregates(DM,DM,Mat*);
4617087cfbeSBarry Smith extern PetscErrorCode   DMGlobalToLocalBegin(DM,Vec,InsertMode,Vec);
4627087cfbeSBarry Smith extern PetscErrorCode   DMGlobalToLocalEnd(DM,Vec,InsertMode,Vec);
4637087cfbeSBarry Smith extern PetscErrorCode   DMLocalToGlobalBegin(DM,Vec,InsertMode,Vec);
4647087cfbeSBarry Smith extern PetscErrorCode   DMLocalToGlobalEnd(DM,Vec,InsertMode,Vec);
4657087cfbeSBarry Smith extern PetscErrorCode   DMGetElements(DM,PetscInt *,PetscInt *,const PetscInt*[]);
4667087cfbeSBarry Smith extern PetscErrorCode   DMRestoreElements(DM,PetscInt *,PetscInt *,const PetscInt*[]);
467e1589f56SBarry Smith 
4687087cfbeSBarry Smith extern PetscErrorCode   DMSetContext(DM,void*);
4697087cfbeSBarry Smith extern PetscErrorCode   DMGetContext(DM,void**);
4707087cfbeSBarry Smith extern PetscErrorCode   DMSetInitialGuess(DM,PetscErrorCode (*)(DM,Vec));
4717087cfbeSBarry Smith extern PetscErrorCode   DMSetFunction(DM,PetscErrorCode (*)(DM,Vec,Vec));
4727087cfbeSBarry Smith extern PetscErrorCode   DMSetJacobian(DM,PetscErrorCode (*)(DM,Vec,Mat,Mat,MatStructure *));
4737087cfbeSBarry Smith extern PetscErrorCode   DMHasInitialGuess(DM,PetscBool *);
4747087cfbeSBarry Smith extern PetscErrorCode   DMHasFunction(DM,PetscBool *);
4757087cfbeSBarry Smith extern PetscErrorCode   DMHasJacobian(DM,PetscBool *);
4767087cfbeSBarry Smith extern PetscErrorCode   DMComputeInitialGuess(DM,Vec);
4777087cfbeSBarry Smith extern PetscErrorCode   DMComputeFunction(DM,Vec,Vec);
4787087cfbeSBarry Smith extern PetscErrorCode   DMComputeJacobian(DM,Vec,Mat,Mat,MatStructure *);
4797087cfbeSBarry Smith extern PetscErrorCode   DMComputeJacobianDefault(DM,Vec,Mat,Mat,MatStructure *);
4807087cfbeSBarry Smith extern PetscErrorCode   DMFinalizePackage(void);
481e1589f56SBarry Smith 
4827087cfbeSBarry Smith extern PetscErrorCode   DMDASetGetMatrix(DM,PetscErrorCode (*)(DM, const MatType,Mat *));
4837087cfbeSBarry Smith extern PetscErrorCode   DMDASetBlockFills(DM,PetscInt*,PetscInt*);
4847087cfbeSBarry Smith extern PetscErrorCode   DMDASetMatPreallocateOnly(DM,PetscBool );
4857087cfbeSBarry Smith extern PetscErrorCode   DMDASetRefinementFactor(DM,PetscInt,PetscInt,PetscInt);
4867087cfbeSBarry Smith extern PetscErrorCode   DMDAGetRefinementFactor(DM,PetscInt*,PetscInt*,PetscInt*);
487e1589f56SBarry Smith 
4887087cfbeSBarry Smith extern PetscErrorCode   DMDAGetAdicArray(DM,PetscBool ,void*,void*,PetscInt*);
4897087cfbeSBarry Smith extern PetscErrorCode   DMDARestoreAdicArray(DM,PetscBool ,void*,void*,PetscInt*);
4907087cfbeSBarry Smith extern PetscErrorCode   DMDAGetAdicMFArray(DM,PetscBool ,void*,void*,PetscInt*);
4917087cfbeSBarry Smith extern PetscErrorCode   DMDAGetAdicMFArray4(DM,PetscBool ,void*,void*,PetscInt*);
4927087cfbeSBarry Smith extern PetscErrorCode   DMDAGetAdicMFArray9(DM,PetscBool ,void*,void*,PetscInt*);
4937087cfbeSBarry Smith extern PetscErrorCode   DMDAGetAdicMFArrayb(DM,PetscBool ,void*,void*,PetscInt*);
4947087cfbeSBarry Smith extern PetscErrorCode   DMDARestoreAdicMFArray(DM,PetscBool ,void*,void*,PetscInt*);
4957087cfbeSBarry Smith extern PetscErrorCode   DMDAGetArray(DM,PetscBool ,void*);
4967087cfbeSBarry Smith extern PetscErrorCode   DMDARestoreArray(DM,PetscBool ,void*);
4977087cfbeSBarry Smith extern PetscErrorCode   ad_DAGetArray(DM,PetscBool ,void*);
4987087cfbeSBarry Smith extern PetscErrorCode   ad_DARestoreArray(DM,PetscBool ,void*);
4997087cfbeSBarry Smith extern PetscErrorCode   admf_DAGetArray(DM,PetscBool ,void*);
5007087cfbeSBarry Smith extern PetscErrorCode   admf_DARestoreArray(DM,PetscBool ,void*);
501e1589f56SBarry Smith 
502e1589f56SBarry Smith #include "petscpf.h"
5037087cfbeSBarry Smith extern PetscErrorCode   DMDACreatePF(DM,PF*);
504e1589f56SBarry Smith 
5057087cfbeSBarry Smith extern PetscErrorCode   DMCompositeCreate(MPI_Comm,DM*);
5067087cfbeSBarry Smith extern PetscErrorCode   DMCompositeAddArray(DM,PetscMPIInt,PetscInt);
5077087cfbeSBarry Smith extern PetscErrorCode   DMCompositeAddDM(DM,DM);
5087087cfbeSBarry Smith extern PetscErrorCode   DMCompositeSetCoupling(DM,PetscErrorCode (*)(DM,Mat,PetscInt*,PetscInt*,PetscInt,PetscInt,PetscInt,PetscInt));
5097087cfbeSBarry Smith extern PetscErrorCode   DMCompositeSetContext(DM,void*);
5107087cfbeSBarry Smith extern PetscErrorCode   DMCompositeGetContext(DM,void**);
5117087cfbeSBarry Smith extern PetscErrorCode   DMCompositeAddVecScatter(DM,VecScatter);
5127087cfbeSBarry Smith extern PetscErrorCode   DMCompositeScatter(DM,Vec,...);
5137087cfbeSBarry Smith extern PetscErrorCode   DMCompositeGather(DM,Vec,InsertMode,...);
5147087cfbeSBarry Smith extern PetscErrorCode   DMCompositeGetAccess(DM,Vec,...);
5157087cfbeSBarry Smith extern PetscErrorCode   DMCompositeGetNumberDM(DM,PetscInt*);
5167087cfbeSBarry Smith extern PetscErrorCode   DMCompositeRestoreAccess(DM,Vec,...);
5177087cfbeSBarry Smith extern PetscErrorCode   DMCompositeGetLocalVectors(DM,...);
5187087cfbeSBarry Smith extern PetscErrorCode   DMCompositeGetEntries(DM,...);
5197087cfbeSBarry Smith extern PetscErrorCode   DMCompositeRestoreLocalVectors(DM,...);
5207087cfbeSBarry Smith extern PetscErrorCode   DMCompositeGetGlobalISs(DM,IS*[]);
5217087cfbeSBarry Smith extern PetscErrorCode   DMCompositeGetLocalISs(DM,IS**);
5227087cfbeSBarry Smith extern PetscErrorCode   DMCompositeGetISLocalToGlobalMappings(DM,ISLocalToGlobalMapping**);
523e1589f56SBarry Smith 
5247087cfbeSBarry Smith extern PetscErrorCode   DMSlicedCreate(MPI_Comm,DM*);
5257087cfbeSBarry Smith extern PetscErrorCode   DMSlicedGetGlobalIndices(DM,PetscInt*[]);
5267087cfbeSBarry Smith extern PetscErrorCode   DMSlicedSetPreallocation(DM,PetscInt,const PetscInt[],PetscInt,const PetscInt[]);
5277087cfbeSBarry Smith extern PetscErrorCode   DMSlicedSetBlockFills(DM,const PetscInt*,const PetscInt*);
5287087cfbeSBarry Smith extern PetscErrorCode   DMSlicedSetGhosts(DM,PetscInt,PetscInt,PetscInt,const PetscInt[]);
529e1589f56SBarry Smith 
530e1589f56SBarry Smith 
531e1589f56SBarry Smith typedef struct NLF_DAAD* NLF;
532e1589f56SBarry Smith 
533e1589f56SBarry Smith #include <petscbag.h>
534e1589f56SBarry Smith 
5357087cfbeSBarry Smith extern PetscErrorCode  PetscViewerBinaryMatlabOpen(MPI_Comm, const char [], PetscViewer*);
5367087cfbeSBarry Smith extern PetscErrorCode  PetscViewerBinaryMatlabDestroy(PetscViewer);
5377087cfbeSBarry Smith extern PetscErrorCode  PetscViewerBinaryMatlabOutputBag(PetscViewer, const char [], PetscBag);
5387087cfbeSBarry Smith extern PetscErrorCode  PetscViewerBinaryMatlabOutputVec(PetscViewer, const char [], Vec);
5397087cfbeSBarry Smith extern PetscErrorCode  PetscViewerBinaryMatlabOutputVecDA(PetscViewer, const char [], Vec, DM);
540e1589f56SBarry Smith 
541e1589f56SBarry Smith 
5427087cfbeSBarry Smith PetscErrorCode  DMADDACreate(MPI_Comm,PetscInt,PetscInt*,PetscInt*,PetscInt,PetscBool *,DM*);
5437087cfbeSBarry Smith PetscErrorCode  DMADDASetParameters(DM,PetscInt,PetscInt*,PetscInt*,PetscInt,PetscBool*);
5447087cfbeSBarry Smith PetscErrorCode  DMADDASetRefinement(DM, PetscInt *,PetscInt);
5457087cfbeSBarry Smith PetscErrorCode  DMADDAGetCorners(DM, PetscInt **, PetscInt **);
5467087cfbeSBarry Smith PetscErrorCode  DMADDAGetGhostCorners(DM, PetscInt **, PetscInt **);
5477087cfbeSBarry Smith PetscErrorCode  DMADDAGetMatrixNS(DM, DM, const MatType , Mat *);
548e1589f56SBarry Smith 
549e1589f56SBarry Smith /* functions to set values in vectors and matrices */
550e1589f56SBarry Smith struct _ADDAIdx_s {
551e1589f56SBarry Smith   PetscInt     *x;               /* the coordinates, user has to make sure it is the correct size! */
552e1589f56SBarry Smith   PetscInt     d;                /* indexes the dof */
553e1589f56SBarry Smith };
554e1589f56SBarry Smith typedef struct _ADDAIdx_s ADDAIdx;
555e1589f56SBarry Smith 
5567087cfbeSBarry Smith PetscErrorCode  DMADDAMatSetValues(Mat, DM, PetscInt, const ADDAIdx[], DM, PetscInt, const ADDAIdx[], const PetscScalar[], InsertMode);
557e1589f56SBarry Smith PetscBool  ADDAHCiterStartup(const PetscInt, const PetscInt *const, const PetscInt *const, PetscInt *const);
558e1589f56SBarry Smith PetscBool  ADDAHCiter(const PetscInt, const PetscInt *const, const PetscInt *const, PetscInt *const);
559e1589f56SBarry Smith 
560b30b9b2eSMatthew G Knepley /* Mesh Section */
561b30b9b2eSMatthew G Knepley #if defined(PETSC_HAVE_SIEVE) && defined(__cplusplus)
562b30b9b2eSMatthew G Knepley 
563b30b9b2eSMatthew G Knepley #include <sieve/Mesh.hh>
564b30b9b2eSMatthew G Knepley #include <sieve/CartesianSieve.hh>
565b30b9b2eSMatthew G Knepley #include <sieve/Distribution.hh>
566b30b9b2eSMatthew G Knepley #include <sieve/Generator.hh>
567b30b9b2eSMatthew G Knepley 
568b30b9b2eSMatthew G Knepley extern PetscErrorCode DMMeshCreate(MPI_Comm, DM*);
569b30b9b2eSMatthew G Knepley extern PetscErrorCode DMMeshGetMesh(DM, ALE::Obj<PETSC_MESH_TYPE>&);
570b30b9b2eSMatthew G Knepley extern PetscErrorCode DMMeshSetMesh(DM, const ALE::Obj<PETSC_MESH_TYPE>&);
571b30b9b2eSMatthew G Knepley extern PetscErrorCode DMMeshGetGlobalScatter(DM, VecScatter *);
572b30b9b2eSMatthew G Knepley 
573b30b9b2eSMatthew G Knepley extern PetscErrorCode MeshGetLabelSize(DM, const char [], PetscInt *);
574b30b9b2eSMatthew G Knepley extern PetscErrorCode DMMeshGetLabelIds(DM, const char [], PetscInt *);
575b30b9b2eSMatthew G Knepley extern PetscErrorCode DMMeshGetStratumSize(DM, const char [], PetscInt, PetscInt *);
576b30b9b2eSMatthew G Knepley extern PetscErrorCode DMMeshGetStratum(DM, const char [], PetscInt, PetscInt *);
577b30b9b2eSMatthew G Knepley 
578b30b9b2eSMatthew G Knepley extern PetscErrorCode DMCartesianCreate(MPI_Comm, DM *);
579b30b9b2eSMatthew G Knepley 
580b30b9b2eSMatthew G Knepley /*S
581b30b9b2eSMatthew G Knepley   SectionReal - Abstract PETSc object that manages distributed field data over a topology (Sieve).
582b30b9b2eSMatthew G Knepley 
583b30b9b2eSMatthew G Knepley   Level: beginner
584b30b9b2eSMatthew G Knepley 
585b30b9b2eSMatthew G Knepley   Concepts: distributed mesh, field
586b30b9b2eSMatthew G Knepley 
587b30b9b2eSMatthew G Knepley .seealso:  SectionRealCreate(), SectionRealDestroy(), Mesh, MeshCreate()
588b30b9b2eSMatthew G Knepley S*/
589b30b9b2eSMatthew G Knepley typedef struct _p_SectionReal* SectionReal;
590b30b9b2eSMatthew G Knepley 
591b30b9b2eSMatthew G Knepley /* Logging support */
592b30b9b2eSMatthew G Knepley extern PetscClassId  SECTIONREAL_CLASSID;
593b30b9b2eSMatthew G Knepley 
594b30b9b2eSMatthew G Knepley extern PetscErrorCode  SectionRealCreate(MPI_Comm,SectionReal*);
595b30b9b2eSMatthew G Knepley extern PetscErrorCode  SectionRealDestroy(SectionReal);
596b30b9b2eSMatthew G Knepley extern PetscErrorCode  SectionRealView(SectionReal,PetscViewer);
597b30b9b2eSMatthew G Knepley extern PetscErrorCode  SectionRealDuplicate(SectionReal,SectionReal*);
598b30b9b2eSMatthew G Knepley 
599b30b9b2eSMatthew G Knepley extern PetscErrorCode  SectionRealGetSection(SectionReal,ALE::Obj<PETSC_MESH_TYPE::real_section_type>&);
600b30b9b2eSMatthew G Knepley extern PetscErrorCode  SectionRealSetSection(SectionReal,const ALE::Obj<PETSC_MESH_TYPE::real_section_type>&);
601b30b9b2eSMatthew G Knepley extern PetscErrorCode  SectionRealGetBundle(SectionReal,ALE::Obj<PETSC_MESH_TYPE>&);
602b30b9b2eSMatthew G Knepley extern PetscErrorCode  SectionRealSetBundle(SectionReal,const ALE::Obj<PETSC_MESH_TYPE>&);
603b30b9b2eSMatthew G Knepley 
604b30b9b2eSMatthew G Knepley extern PetscErrorCode  SectionRealDistribute(SectionReal, DM, SectionReal *);
605b30b9b2eSMatthew G Knepley extern PetscErrorCode  SectionRealRestrict(SectionReal, PetscInt, PetscScalar *[]);
606b30b9b2eSMatthew G Knepley extern PetscErrorCode  SectionRealUpdate(SectionReal, PetscInt, const PetscScalar [], InsertMode);
607b30b9b2eSMatthew G Knepley extern PetscErrorCode  SectionRealZero(SectionReal);
608b30b9b2eSMatthew G Knepley extern PetscErrorCode  SectionRealCreateLocalVector(SectionReal, Vec*);
609b30b9b2eSMatthew G Knepley extern PetscErrorCode  SectionRealAddSpace(SectionReal);
610b30b9b2eSMatthew G Knepley extern PetscErrorCode  SectionRealGetFibration(SectionReal, const PetscInt, SectionReal *);
611b30b9b2eSMatthew G Knepley extern PetscErrorCode  SectionRealToVec(SectionReal, DM, ScatterMode, Vec);
612b30b9b2eSMatthew G Knepley extern PetscErrorCode  SectionRealToVec(SectionReal, VecScatter, ScatterMode, Vec);
613b30b9b2eSMatthew G Knepley extern PetscErrorCode  SectionRealNorm(SectionReal, DM, NormType, PetscReal *);
614b30b9b2eSMatthew G Knepley extern PetscErrorCode  SectionRealAXPY(SectionReal, DM, PetscScalar, SectionReal);
615b30b9b2eSMatthew G Knepley extern PetscErrorCode  SectionRealComplete(SectionReal);
616b30b9b2eSMatthew G Knepley extern PetscErrorCode  SectionRealSet(SectionReal, PetscReal);
617b30b9b2eSMatthew G Knepley extern PetscErrorCode  SectionRealGetFiberDimension(SectionReal, PetscInt, PetscInt*);
618b30b9b2eSMatthew G Knepley extern PetscErrorCode  SectionRealSetFiberDimension(SectionReal, PetscInt, const PetscInt);
619b30b9b2eSMatthew G Knepley extern PetscErrorCode  SectionRealSetFiberDimensionField(SectionReal, PetscInt, const PetscInt, const PetscInt);
620b30b9b2eSMatthew G Knepley extern PetscErrorCode  SectionRealGetSize(SectionReal, PetscInt *);
621b30b9b2eSMatthew G Knepley extern PetscErrorCode  SectionRealAllocate(SectionReal);
622b30b9b2eSMatthew G Knepley extern PetscErrorCode  SectionRealClear(SectionReal);
623b30b9b2eSMatthew G Knepley 
624b30b9b2eSMatthew G Knepley extern PetscErrorCode  SectionRealRestrictClosure(SectionReal, DM, PetscInt, PetscInt, PetscScalar []);
625b30b9b2eSMatthew G Knepley extern PetscErrorCode  SectionRealRestrictClosure(SectionReal, DM, PetscInt, const PetscScalar *[]);
626b30b9b2eSMatthew G Knepley extern PetscErrorCode  SectionRealUpdateClosure(SectionReal, DM, PetscInt, PetscScalar [], InsertMode);
627b30b9b2eSMatthew G Knepley 
628b30b9b2eSMatthew G Knepley extern PetscErrorCode  DMMeshHasSectionReal(DM, const char [], PetscBool  *);
629b30b9b2eSMatthew G Knepley extern PetscErrorCode  DMMeshGetSectionReal(DM, const char [], SectionReal *);
630b30b9b2eSMatthew G Knepley extern PetscErrorCode  DMMeshSetSectionReal(DM, SectionReal);
631b30b9b2eSMatthew G Knepley 
632b30b9b2eSMatthew G Knepley /*S
633b30b9b2eSMatthew G Knepley   SectionInt - Abstract PETSc object that manages distributed field data over a topology (Sieve).
634b30b9b2eSMatthew G Knepley 
635b30b9b2eSMatthew G Knepley   Level: beginner
636b30b9b2eSMatthew G Knepley 
637b30b9b2eSMatthew G Knepley   Concepts: distributed mesh, field
638b30b9b2eSMatthew G Knepley 
639b30b9b2eSMatthew G Knepley .seealso:  SectionIntCreate(), SectionIntDestroy(), DM, MeshCreate()
640b30b9b2eSMatthew G Knepley S*/
641b30b9b2eSMatthew G Knepley typedef struct _p_SectionInt* SectionInt;
642b30b9b2eSMatthew G Knepley 
643b30b9b2eSMatthew G Knepley /* Logging support */
644b30b9b2eSMatthew G Knepley extern PetscClassId  SECTIONINT_CLASSID;
645b30b9b2eSMatthew G Knepley 
646b30b9b2eSMatthew G Knepley extern PetscErrorCode  SectionIntCreate(MPI_Comm,SectionInt*);
647b30b9b2eSMatthew G Knepley extern PetscErrorCode  SectionIntDestroy(SectionInt);
648b30b9b2eSMatthew G Knepley extern PetscErrorCode  SectionIntView(SectionInt,PetscViewer);
649b30b9b2eSMatthew G Knepley 
650b30b9b2eSMatthew G Knepley extern PetscErrorCode  SectionIntGetSection(SectionInt,ALE::Obj<PETSC_MESH_TYPE::int_section_type>&);
651b30b9b2eSMatthew G Knepley extern PetscErrorCode  SectionIntSetSection(SectionInt,const ALE::Obj<PETSC_MESH_TYPE::int_section_type>&);
652b30b9b2eSMatthew G Knepley extern PetscErrorCode  SectionIntGetBundle(SectionInt,ALE::Obj<PETSC_MESH_TYPE>&);
653b30b9b2eSMatthew G Knepley extern PetscErrorCode  SectionIntSetBundle(SectionInt,const ALE::Obj<PETSC_MESH_TYPE>&);
654b30b9b2eSMatthew G Knepley 
655b30b9b2eSMatthew G Knepley extern PetscErrorCode  SectionIntDistribute(SectionInt, DM, SectionInt *);
656b30b9b2eSMatthew G Knepley extern PetscErrorCode  SectionIntRestrict(SectionInt, PetscInt, PetscInt *[]);
657b30b9b2eSMatthew G Knepley extern PetscErrorCode  SectionIntUpdate(SectionInt, PetscInt, const PetscInt [], InsertMode);
658b30b9b2eSMatthew G Knepley extern PetscErrorCode  SectionIntZero(SectionInt);
659b30b9b2eSMatthew G Knepley extern PetscErrorCode  SectionIntComplete(SectionInt);
660b30b9b2eSMatthew G Knepley extern PetscErrorCode  SectionIntGetFiberDimension(SectionInt, PetscInt, PetscInt*);
661b30b9b2eSMatthew G Knepley extern PetscErrorCode  SectionIntSetFiberDimension(SectionInt, PetscInt, const PetscInt);
662b30b9b2eSMatthew G Knepley extern PetscErrorCode  SectionIntSetFiberDimensionField(SectionInt, PetscInt, const PetscInt, const PetscInt);
663b30b9b2eSMatthew G Knepley extern PetscErrorCode  SectionIntGetSize(SectionInt, PetscInt *);
664b30b9b2eSMatthew G Knepley extern PetscErrorCode  SectionIntAllocate(SectionInt);
665b30b9b2eSMatthew G Knepley extern PetscErrorCode  SectionIntClear(SectionInt);
666b30b9b2eSMatthew G Knepley 
667b30b9b2eSMatthew G Knepley extern PetscErrorCode  SectionIntAddSpace(SectionInt);
668b30b9b2eSMatthew G Knepley extern PetscErrorCode  SectionIntGetFibration(SectionInt, const PetscInt, SectionInt *);
669b30b9b2eSMatthew G Knepley extern PetscErrorCode  SectionIntSet(SectionInt, PetscInt);
670b30b9b2eSMatthew G Knepley 
671b30b9b2eSMatthew G Knepley extern PetscErrorCode  SectionIntRestrictClosure(SectionInt, DM, PetscInt, PetscInt, PetscInt []);
672b30b9b2eSMatthew G Knepley extern PetscErrorCode  SectionIntUpdateClosure(SectionInt, DM, PetscInt, PetscInt [], InsertMode);
673b30b9b2eSMatthew G Knepley 
674b30b9b2eSMatthew G Knepley extern PetscErrorCode  DMMeshHasSectionInt(DM, const char [], PetscBool  *);
675b30b9b2eSMatthew G Knepley extern PetscErrorCode  DMMeshGetSectionInt(DM, const char [], SectionInt *);
676b30b9b2eSMatthew G Knepley extern PetscErrorCode  DMMeshSetSectionInt(DM, SectionInt);
677b30b9b2eSMatthew G Knepley 
678b30b9b2eSMatthew G Knepley typedef PetscErrorCode (*DMMeshLocalFunction1)(DM,SectionReal,SectionReal,void*);
679b30b9b2eSMatthew G Knepley typedef PetscErrorCode (*DMMeshLocalJacobian1)(DM,SectionReal,Mat,void*);
680b30b9b2eSMatthew G Knepley 
681b30b9b2eSMatthew G Knepley /* Misc Mesh functions*/
682b30b9b2eSMatthew G Knepley extern PetscErrorCode DMMeshLoad(PetscViewer, DM);
683b30b9b2eSMatthew G Knepley extern PetscErrorCode DMMeshCreateVector(DM, SectionReal, Vec *);
684b30b9b2eSMatthew G Knepley extern PetscErrorCode DMMeshCreateGlobalScatter(DM, SectionReal, VecScatter *);
685b30b9b2eSMatthew G Knepley extern PetscErrorCode DMMeshSetMaxDof(DM, PetscInt);
686b30b9b2eSMatthew G Knepley 
687b30b9b2eSMatthew G Knepley /* Helper functions for simple distributions */
688b30b9b2eSMatthew G Knepley extern PetscErrorCode DMMeshGetVertexMatrix(DM, MatType, Mat *);
689b30b9b2eSMatthew G Knepley extern PetscErrorCode DMMeshGetVertexSectionReal(DM, const char[], PetscInt, SectionReal *);
690b30b9b2eSMatthew G Knepley PetscPolymorphicSubroutine(DMMeshGetVertexSectionReal,(DM dm, PetscInt fiberDim, SectionReal *section),(dm,"default",fiberDim,section))
691b30b9b2eSMatthew G Knepley extern PetscErrorCode DMMeshGetVertexSectionInt(DM, const char[], PetscInt, SectionInt *);
692b30b9b2eSMatthew G Knepley PetscPolymorphicSubroutine(DMMeshGetVertexSectionInt,(DM dm, PetscInt fiberDim, SectionInt *section),(dm,"default",fiberDim,section))
693b30b9b2eSMatthew G Knepley extern PetscErrorCode DMMeshGetCellMatrix(DM, MatType, Mat *);
694b30b9b2eSMatthew G Knepley extern PetscErrorCode DMMeshGetCellSectionReal(DM, const char[], PetscInt, SectionReal *);
695b30b9b2eSMatthew G Knepley PetscPolymorphicSubroutine(DMMeshGetCellSectionReal,(DM dm, PetscInt fiberDim, SectionReal *section),(dm,"default",fiberDim,section))
696b30b9b2eSMatthew G Knepley extern PetscErrorCode DMMeshGetCellSectionInt(DM, const char[], PetscInt, SectionInt *);
697b30b9b2eSMatthew G Knepley PetscPolymorphicSubroutine(DMMeshGetCellSectionInt,(DM dm, PetscInt fiberDim, SectionInt *section),(dm,"default",fiberDim,section))
698b30b9b2eSMatthew G Knepley 
699b30b9b2eSMatthew G Knepley /* Support for various mesh formats */
700b30b9b2eSMatthew G Knepley extern PetscErrorCode DMMeshCreateExodus(MPI_Comm, const char [], DM *);
701b30b9b2eSMatthew G Knepley extern PetscErrorCode DMMeshExodusGetInfo(DM, PetscInt *, PetscInt *, PetscInt *, PetscInt *, PetscInt *);
702b30b9b2eSMatthew G Knepley 
703b30b9b2eSMatthew G Knepley #endif /* Mesh section */
704b30b9b2eSMatthew G Knepley 
705e1589f56SBarry Smith PETSC_EXTERN_CXX_END
706e1589f56SBarry Smith #endif
707