Actual source code: stag.c
1: /*
2: Implementation of DMStag, defining dimension-independent functions in the
3: DM API. stag1d.c, stag2d.c, and stag3d.c may include dimension-specific
4: implementations of DM API functions, and other files here contain additional
5: DMStag-specific API functions, as well as internal functions.
6: */
7: #include <petsc/private/dmstagimpl.h>
8: #include <petscsf.h>
10: static PetscErrorCode DMClone_Stag(DM dm,DM *newdm)
11: {
15: /* Destroy the DM created by generic logic in DMClone() */
16: if (*newdm) {
17: DMDestroy(newdm);
18: }
19: DMStagDuplicateWithoutSetup(dm,PetscObjectComm((PetscObject)dm),newdm);
20: DMSetUp(*newdm);
21: return(0);
22: }
24: static PetscErrorCode DMDestroy_Stag(DM dm)
25: {
27: DM_Stag *stag;
28: PetscInt i;
31: stag = (DM_Stag*)dm->data;
32: for (i=0; i<DMSTAG_MAX_DIM; ++i) {
33: PetscFree(stag->l[i]);
34: }
35: VecScatterDestroy(&stag->gtol);
36: VecScatterDestroy(&stag->ltog_injective);
37: PetscFree(stag->neighbors);
38: PetscFree(stag->locationOffsets);
39: PetscFree(stag->coordinateDMType);
40: PetscFree(stag);
41: return(0);
42: }
44: static PetscErrorCode DMCreateGlobalVector_Stag(DM dm,Vec *vec)
45: {
46: PetscErrorCode ierr;
47: DM_Stag * const stag = (DM_Stag*)dm->data;
50: VecCreateMPI(PetscObjectComm((PetscObject)dm),stag->entries,PETSC_DECIDE,vec);
51: VecSetDM(*vec,dm);
52: /* Could set some ops, as DMDA does */
53: VecSetLocalToGlobalMapping(*vec,dm->ltogmap);
54: return(0);
55: }
57: static PetscErrorCode DMCreateLocalVector_Stag(DM dm,Vec *vec)
58: {
59: PetscErrorCode ierr;
60: DM_Stag * const stag = (DM_Stag*)dm->data;
63: VecCreateSeq(PETSC_COMM_SELF,stag->entriesGhost,vec);
64: VecSetBlockSize(*vec,stag->entriesPerElement);
65: VecSetDM(*vec,dm);
66: return(0);
67: }
69: static PetscErrorCode DMCreateMatrix_Stag(DM dm,Mat *mat)
70: {
71: PetscErrorCode ierr;
72: MatType matType;
73: PetscBool isaij,isshell;
74: PetscInt entries,width,nNeighbors,dim,dof[DMSTAG_MAX_STRATA],stencilWidth;
75: DMStagStencilType stencilType;
76: ISLocalToGlobalMapping ltogmap;
79: DMGetDimension(dm,&dim);
80: DMGetMatType(dm,&matType);
81: PetscStrcmp(matType,MATAIJ,&isaij);
82: PetscStrcmp(matType,MATSHELL,&isshell);
83: DMStagGetEntries(dm,&entries);
84: DMStagGetDOF(dm,&dof[0],&dof[1],&dof[2],&dof[3]);
85: DMStagGetStencilWidth(dm,&stencilWidth);
86: DMStagGetStencilType(dm,&stencilType);
88: if (isaij) {
89: /* This implementation gives a very dense stencil, which is likely unsuitable for
90: real applications. */
91: switch (stencilType) {
92: case DMSTAG_STENCIL_NONE:
93: nNeighbors = 1;
94: break;
95: case DMSTAG_STENCIL_STAR:
96: switch (dim) {
97: case 1 :
98: nNeighbors = 2*stencilWidth + 1;
99: break;
100: case 2 :
101: nNeighbors = 4*stencilWidth + 3;
102: break;
103: case 3 :
104: nNeighbors = 6*stencilWidth + 5;
105: break;
106: default : SETERRQ1(PetscObjectComm((PetscObject)dm),PETSC_ERR_ARG_OUTOFRANGE,"Unsupported dimension %d",dim);
107: }
108: break;
109: case DMSTAG_STENCIL_BOX:
110: switch (dim) {
111: case 1 :
112: nNeighbors = (2*stencilWidth + 1);
113: break;
114: case 2 :
115: nNeighbors = (2*stencilWidth + 1) * (2*stencilWidth + 1);
116: break;
117: case 3 :
118: nNeighbors = (2*stencilWidth + 1) * (2*stencilWidth + 1) * (2*stencilWidth + 1);
119: break;
120: default : SETERRQ1(PetscObjectComm((PetscObject)dm),PETSC_ERR_ARG_OUTOFRANGE,"Unsupported dimension %d",dim);
121: }
122: break;
123: default : SETERRQ(PetscObjectComm((PetscObject)dm),PETSC_ERR_ARG_OUTOFRANGE,"Unsupported stencil");
124: }
125: width = (dof[0] + dof[1] + dof[2] + dof[3]) * nNeighbors;
126: MatCreateAIJ(PetscObjectComm((PetscObject)dm),entries,entries,PETSC_DETERMINE,PETSC_DETERMINE,width,NULL,width,NULL,mat);
127: } else if (isshell) {
128: MatCreate(PetscObjectComm((PetscObject)dm),mat);
129: MatSetSizes(*mat,entries,entries,PETSC_DETERMINE,PETSC_DETERMINE);
130: MatSetType(*mat,MATSHELL);
131: MatSetUp(*mat);
132: } else SETERRQ1(PetscObjectComm((PetscObject)dm),PETSC_ERR_SUP,"Not implemented for Mattype %s",matType);
134: DMGetLocalToGlobalMapping(dm,<ogmap);
135: MatSetLocalToGlobalMapping(*mat,ltogmap,ltogmap);
136: MatSetDM(*mat,dm);
137: return(0);
138: }
140: static PetscErrorCode DMGetCompatibility_Stag(DM dm,DM dm2,PetscBool *compatible,PetscBool *set)
141: {
142: PetscErrorCode ierr;
143: const DM_Stag * const stag = (DM_Stag*)dm->data;
144: const DM_Stag * const stag2 = (DM_Stag*)dm2->data;
145: PetscInt dim,dim2,i;
146: MPI_Comm comm;
147: PetscMPIInt sameComm;
148: DMType type2;
149: PetscBool sameType;
152: DMGetType(dm2,&type2);
153: PetscStrcmp(DMSTAG,type2,&sameType);
154: if (!sameType) {
155: PetscInfo1((PetscObject)dm,"DMStag compatibility check not implemented with DM of type %s\n",type2);
156: *set = PETSC_FALSE;
157: return(0);
158: }
160: PetscObjectGetComm((PetscObject)dm,&comm);
161: MPI_Comm_compare(comm,PetscObjectComm((PetscObject)dm2),&sameComm);
162: if (sameComm != MPI_IDENT) {
163: PetscInfo2((PetscObject)dm,"DMStag objects have different communicators: %d != %d\n",comm,PetscObjectComm((PetscObject)dm2));
164: *set = PETSC_FALSE;
165: return(0);
166: }
167: DMGetDimension(dm ,&dim);
168: DMGetDimension(dm2,&dim2);
169: if (dim != dim2) {
170: PetscInfo((PetscObject)dm,"DMStag objects have different dimensions");
171: *set = PETSC_TRUE;
172: *compatible = PETSC_FALSE;
173: return(0);
174: }
175: for (i=0; i<dim; ++i) {
176: if (stag->N[i] != stag2->N[i]) {
177: PetscInfo3((PetscObject)dm,"DMStag objects have different global numbers of elements in dimension %D: %D != %D\n",i,stag->n[i],stag2->n[i]);
178: *set = PETSC_TRUE;
179: *compatible = PETSC_FALSE;
180: return(0);
181: }
182: if (stag->n[i] != stag2->n[i]) {
183: PetscInfo3((PetscObject)dm,"DMStag objects have different local numbers of elements in dimension %D: %D != %D\n",i,stag->n[i],stag2->n[i]);
184: *set = PETSC_TRUE;
185: *compatible = PETSC_FALSE;
186: return(0);
187: }
188: if (stag->boundaryType[i] != stag2->boundaryType[i]) {
189: PetscInfo3((PetscObject)dm,"DMStag objects have different boundary types in dimension %d: %s != %s\n",i,stag->boundaryType[i],stag2->boundaryType[i]);
190: *set = PETSC_TRUE;
191: *compatible = PETSC_FALSE;
192: return(0);
193: }
194: }
195: /* Note: we include stencil type and width in the notion of compatibility, as this affects
196: the "atlas" (local subdomains). This might be irritating in legitimate cases
197: of wanting to transfer between two other-wise compatible DMs with different
198: stencil characteristics. */
199: if (stag->stencilType != stag2->stencilType) {
200: PetscInfo2((PetscObject)dm,"DMStag objects have different ghost stencil types: %s != %s\n",DMStagStencilTypes[stag->stencilType],DMStagStencilTypes[stag2->stencilType]);
201: *set = PETSC_TRUE;
202: *compatible = PETSC_FALSE;
203: return(0);
204: }
205: if (stag->stencilWidth != stag2->stencilWidth) {
206: PetscInfo2((PetscObject)dm,"DMStag objects have different ghost stencil widths: %D != %D\n",stag->stencilWidth,stag->stencilWidth);
207: *set = PETSC_TRUE;
208: *compatible = PETSC_FALSE;
209: return(0);
210: }
211: *set = PETSC_TRUE;
212: *compatible = PETSC_TRUE;
213: return(0);
214: }
216: /*
217: Note there are several orderings in play here.
218: In all cases, non-element dof are associated with the element that they are below/left/behind, and the order in 2D proceeds vertex/bottom edge/left edge/element (with all dof on each together).
219: Also in all cases, only subdomains which are the last in their dimension have partial elements.
221: 1) "Natural" Ordering (not used). Number adding each full or partial (on the right or top) element, starting at the bottom left (i=0,j=0) and proceeding across the entire domain, row by row to get a global numbering.
222: 2) Global ("PETSc") ordering. The same as natural, but restricted to each domain. So, traverse all elements (again starting at the bottom left and going row-by-row) on rank 0, then continue numbering with rank 1, and so on.
223: 3) Local ordering. Including ghost elements (both interior and on the right/top/front to complete partial elements), use the same convention to create a local numbering.
224: */
226: static PetscErrorCode DMLocalToGlobalBegin_Stag(DM dm,Vec l,InsertMode mode,Vec g)
227: {
228: PetscErrorCode ierr;
229: DM_Stag * const stag = (DM_Stag*)dm->data;
232: if (mode == ADD_VALUES) {
233: VecScatterBegin(stag->gtol,l,g,mode,SCATTER_REVERSE);
234: } else if (mode == INSERT_VALUES) {
235: if (stag->ltog_injective) {
236: VecScatterBegin(stag->ltog_injective,l,g,mode,SCATTER_FORWARD);
237: } else {
238: VecScatterBegin(stag->gtol,l,g,mode,SCATTER_REVERSE_LOCAL);
239: }
240: } else SETERRQ(PetscObjectComm((PetscObject)dm),PETSC_ERR_SUP,"Unsupported InsertMode");
241: return(0);
242: }
244: static PetscErrorCode DMLocalToGlobalEnd_Stag(DM dm,Vec l,InsertMode mode,Vec g)
245: {
246: PetscErrorCode ierr;
247: DM_Stag * const stag = (DM_Stag*)dm->data;
250: if (mode == ADD_VALUES) {
251: VecScatterEnd(stag->gtol,l,g,mode,SCATTER_REVERSE);
252: } else if (mode == INSERT_VALUES) {
253: if (stag->ltog_injective) {
254: VecScatterEnd(stag->ltog_injective,l,g,mode,SCATTER_FORWARD);
255: } else {
256: VecScatterEnd(stag->gtol,l,g,mode,SCATTER_REVERSE_LOCAL);
257: }
258: } else SETERRQ(PetscObjectComm((PetscObject)dm),PETSC_ERR_SUP,"Unsupported InsertMode");
259: return(0);
260: }
262: static PetscErrorCode DMGlobalToLocalBegin_Stag(DM dm,Vec g,InsertMode mode,Vec l)
263: {
264: PetscErrorCode ierr;
265: DM_Stag * const stag = (DM_Stag*)dm->data;
268: VecScatterBegin(stag->gtol,g,l,mode,SCATTER_FORWARD);
269: return(0);
270: }
272: static PetscErrorCode DMGlobalToLocalEnd_Stag(DM dm,Vec g,InsertMode mode,Vec l)
273: {
274: PetscErrorCode ierr;
275: DM_Stag * const stag = (DM_Stag*)dm->data;
278: VecScatterEnd(stag->gtol,g,l,mode,SCATTER_FORWARD);
279: return(0);
280: }
282: /*
283: If a stratum is active (non-zero dof), make it active in the coordinate DM.
284: */
285: static PetscErrorCode DMCreateCoordinateDM_Stag(DM dm,DM *dmc)
286: {
287: PetscErrorCode ierr;
288: DM_Stag * const stag = (DM_Stag*)dm->data;
289: PetscInt dim;
290: PetscBool isstag,isproduct;
294: if (!stag->coordinateDMType) SETERRQ(PetscObjectComm((PetscObject)dm),PETSC_ERR_ARG_OUTOFRANGE,"Before creating a coordinate DM, a type must be specified with DMStagSetCoordinateDMType()");
296: DMGetDimension(dm,&dim);
297: PetscStrcmp(stag->coordinateDMType,DMSTAG,&isstag);
298: PetscStrcmp(stag->coordinateDMType,DMPRODUCT,&isproduct);
299: if (isstag) {
300: DMStagCreateCompatibleDMStag(dm,
301: stag->dof[0] > 0 ? dim : 0,
302: stag->dof[1] > 0 ? dim : 0,
303: stag->dof[2] > 0 ? dim : 0,
304: stag->dof[3] > 0 ? dim : 0,
305: dmc);
306: } else if (isproduct) {
307: DMCreate(PETSC_COMM_WORLD,dmc);
308: DMSetType(*dmc,DMPRODUCT);
309: DMSetDimension(*dmc,dim);
310: } else SETERRQ1(PetscObjectComm((PetscObject)dm),PETSC_ERR_SUP,"Unsupported coordinate DM type %s",stag->coordinateDMType);
311: return(0);
312: }
314: static PetscErrorCode DMGetNeighbors_Stag(DM dm,PetscInt *nRanks,const PetscMPIInt *ranks[])
315: {
316: PetscErrorCode ierr;
317: DM_Stag * const stag = (DM_Stag*)dm->data;
318: PetscInt dim;
321: DMGetDimension(dm,&dim);
322: switch (dim) {
323: case 1: *nRanks = 3; break;
324: case 2: *nRanks = 9; break;
325: case 3: *nRanks = 27; break;
326: default : SETERRQ1(PetscObjectComm((PetscObject)dm),PETSC_ERR_SUP,"Get neighbors not implemented for dim = %D",dim);
327: }
328: *ranks = stag->neighbors;
329: return(0);
330: }
332: static PetscErrorCode DMView_Stag(DM dm,PetscViewer viewer)
333: {
334: PetscErrorCode ierr;
335: DM_Stag * const stag = (DM_Stag*)dm->data;
336: PetscBool isascii,viewAllRanks;
337: PetscMPIInt rank,size;
338: PetscInt dim,maxRanksToView,i;
341: MPI_Comm_rank(PetscObjectComm((PetscObject)dm),&rank);
342: MPI_Comm_size(PetscObjectComm((PetscObject)dm),&size);
343: DMGetDimension(dm,&dim);
344: PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
345: if (isascii) {
346: PetscViewerASCIIPrintf(viewer,"Dimension: %D\n",dim);
347: switch (dim) {
348: case 1:
349: PetscViewerASCIIPrintf(viewer,"Global size: %D\n",stag->N[0]);
350: break;
351: case 2:
352: PetscViewerASCIIPrintf(viewer,"Global sizes: %D x %D\n",stag->N[0],stag->N[1]);
353: PetscViewerASCIIPrintf(viewer,"Parallel decomposition: %D x %D ranks\n",stag->nRanks[0],stag->nRanks[1]);
354: break;
355: case 3:
356: PetscViewerASCIIPrintf(viewer,"Global sizes: %D x %D x %D\n",stag->N[0],stag->N[1],stag->N[2]);
357: PetscViewerASCIIPrintf(viewer,"Parallel decomposition: %D x %D x %D ranks\n",stag->nRanks[0],stag->nRanks[1],stag->nRanks[2]);
358: break;
359: default: SETERRQ1(PetscObjectComm((PetscObject)dm),PETSC_ERR_SUP,"not implemented for dim==%D",dim);
360: }
361: PetscViewerASCIIPrintf(viewer,"Boundary ghosting:");
362: for (i=0; i<dim; ++i) {
363: PetscViewerASCIIPrintf(viewer," %s",DMBoundaryTypes[stag->boundaryType[i]]);
364: }
365: PetscViewerASCIIPrintf(viewer,"\n");
366: PetscViewerASCIIPrintf(viewer,"Elementwise ghost stencil: %s, width %D\n",DMStagStencilTypes[stag->stencilType],stag->stencilWidth);
367: PetscViewerASCIIPrintf(viewer,"Stratum dof:");
368: for (i=0; i<dim+1; ++i) {
369: PetscViewerASCIIPrintf(viewer," %D:%D",i,stag->dof[i]);
370: }
371: PetscViewerASCIIPrintf(viewer,"\n");
372: if (dm->coordinateDM) {
373: PetscViewerASCIIPrintf(viewer,"Has coordinate DM\n");
374: }
375: maxRanksToView = 16;
376: viewAllRanks = (PetscBool)(size <= maxRanksToView);
377: if (viewAllRanks) {
378: PetscViewerASCIIPushSynchronized(viewer);
379: switch (dim) {
380: case 1:
381: PetscViewerASCIISynchronizedPrintf(viewer,"[%d] Local elements : %D (%D with ghosts)\n",rank,stag->n[0],stag->nGhost[0]);
382: break;
383: case 2:
384: PetscViewerASCIISynchronizedPrintf(viewer,"[%d] Rank coordinates (%d,%d)\n",rank,stag->rank[0],stag->rank[1]);
385: PetscViewerASCIISynchronizedPrintf(viewer,"[%d] Local elements : %D x %D (%D x %D with ghosts)\n",rank,stag->n[0],stag->n[1],stag->nGhost[0],stag->nGhost[1]);
386: break;
387: case 3:
388: PetscViewerASCIISynchronizedPrintf(viewer,"[%d] Rank coordinates (%d,%d,%d)\n",rank,stag->rank[0],stag->rank[1],stag->rank[2]);
389: PetscViewerASCIISynchronizedPrintf(viewer,"[%d] Local elements : %D x %D x %D (%D x %D x %D with ghosts)\n",rank,stag->n[0],stag->n[1],stag->n[2],stag->nGhost[0],stag->nGhost[1],stag->nGhost[2]);
390: break;
391: default: SETERRQ1(PetscObjectComm((PetscObject)dm),PETSC_ERR_SUP,"not implemented for dim==%D",dim);
392: }
393: PetscViewerASCIISynchronizedPrintf(viewer,"[%d] Local native entries: %d\n",rank,stag->entries);
394: PetscViewerASCIISynchronizedPrintf(viewer,"[%d] Local entries total : %d\n",rank,stag->entriesGhost);
395: PetscViewerFlush(viewer);
396: PetscViewerASCIIPopSynchronized(viewer);
397: } else {
398: PetscViewerASCIIPrintf(viewer,"(Per-rank information omitted since >%D ranks used)\n",maxRanksToView);
399: }
400: }
401: return(0);
402: }
404: static PetscErrorCode DMSetFromOptions_Stag(PetscOptionItems *PetscOptionsObject,DM dm)
405: {
406: PetscErrorCode ierr;
407: DM_Stag * const stag = (DM_Stag*)dm->data;
408: PetscInt dim;
411: DMGetDimension(dm,&dim);
412: PetscOptionsHead(PetscOptionsObject,"DMStag Options");
413: PetscOptionsInt("-stag_grid_x","Number of grid points in x direction","DMStagSetGlobalSizes",stag->N[0],&stag->N[0],NULL);
414: if (dim > 1) { PetscOptionsInt("-stag_grid_y","Number of grid points in y direction","DMStagSetGlobalSizes",stag->N[1],&stag->N[1],NULL); }
415: if (dim > 2) { PetscOptionsInt("-stag_grid_z","Number of grid points in z direction","DMStagSetGlobalSizes",stag->N[2],&stag->N[2],NULL); }
416: PetscOptionsInt("-stag_ranks_x","Number of ranks in x direction","DMStagSetNumRanks",stag->nRanks[0],&stag->nRanks[0],NULL);
417: if (dim > 1) { PetscOptionsInt("-stag_ranks_y","Number of ranks in y direction","DMStagSetNumRanks",stag->nRanks[1],&stag->nRanks[1],NULL); }
418: if (dim > 2) { PetscOptionsInt("-stag_ranks_z","Number of ranks in z direction","DMStagSetNumRanks",stag->nRanks[2],&stag->nRanks[2],NULL); }
419: PetscOptionsInt("-stag_stencil_width","Elementwise stencil width","DMStagSetStencilWidth",stag->stencilWidth,&stag->stencilWidth,NULL);
420: PetscOptionsEnum("-stag_stencil_type","Elementwise stencil stype","DMStagSetStencilType",DMStagStencilTypes,(PetscEnum)stag->stencilType,(PetscEnum*)&stag->stencilType,NULL);
421: PetscOptionsEnum("-stag_boundary_type_x","Treatment of (physical) boundaries in x direction","DMStagSetBoundaryTypes",DMBoundaryTypes,(PetscEnum)stag->boundaryType[0],(PetscEnum*)&stag->boundaryType[0],NULL);
422: PetscOptionsEnum("-stag_boundary_type_y","Treatment of (physical) boundaries in y direction","DMStagSetBoundaryTypes",DMBoundaryTypes,(PetscEnum)stag->boundaryType[1],(PetscEnum*)&stag->boundaryType[1],NULL);
423: PetscOptionsEnum("-stag_boundary_type_z","Treatment of (physical) boundaries in z direction","DMStagSetBoundaryTypes",DMBoundaryTypes,(PetscEnum)stag->boundaryType[2],(PetscEnum*)&stag->boundaryType[2],NULL);
424: PetscOptionsInt("-stag_dof_0","Number of dof per 0-cell (vertex/corner)","DMStagSetDOF",stag->dof[0],&stag->dof[0],NULL);
425: PetscOptionsInt("-stag_dof_1","Number of dof per 1-cell (edge)", "DMStagSetDOF",stag->dof[1],&stag->dof[1],NULL);
426: PetscOptionsInt("-stag_dof_2","Number of dof per 2-cell (face)", "DMStagSetDOF",stag->dof[2],&stag->dof[2],NULL);
427: PetscOptionsInt("-stag_dof_3","Number of dof per 3-cell (hexahedron)", "DMStagSetDOF",stag->dof[3],&stag->dof[3],NULL);
428: PetscOptionsTail();
429: return(0);
430: }
432: /*MC
433: DMSTAG = "stag" - A DM object representing a "staggered grid" or a structured cell complex.
435: This implementation parallels the DMDA implementation in many ways, but allows degrees of freedom
436: to be associated with all "strata" in a logically-rectangular grid: vertices, edges, faces, and elements.
438: Level: beginner
440: .seealso: DM, DMPRODUCT, DMDA, DMPLEX, DMStagCreate1d(), DMStagCreate2d(), DMStagCreate3d(), DMType, DMCreate(), DMSetType()
441: M*/
443: PETSC_EXTERN PetscErrorCode DMCreate_Stag(DM dm)
444: {
446: DM_Stag *stag;
447: PetscInt i,dim;
451: PetscNewLog(dm,&stag);
452: dm->data = stag;
454: stag->gtol = NULL;
455: stag->ltog_injective = NULL;
456: for (i=0; i<DMSTAG_MAX_STRATA; ++i) stag->dof[i] = 0;
457: for (i=0; i<DMSTAG_MAX_DIM; ++i) stag->l[i] = NULL;
458: stag->stencilType = DMSTAG_STENCIL_NONE;
459: stag->stencilWidth = 0;
460: for (i=0; i<DMSTAG_MAX_DIM; ++i) stag->nRanks[i] = -1;
461: stag->coordinateDMType = NULL;
463: DMGetDimension(dm,&dim);
464: if (dim != 1 && dim != 2 && dim != 3) SETERRQ(PetscObjectComm((PetscObject)dm),PETSC_ERR_ARG_WRONGSTATE,"DMSetDimension() must be called to set a dimension with value 1, 2, or 3");
466: PetscMemzero(dm->ops,sizeof(*(dm->ops)));
467: dm->ops->createcoordinatedm = DMCreateCoordinateDM_Stag;
468: dm->ops->createglobalvector = DMCreateGlobalVector_Stag;
469: dm->ops->createinterpolation = NULL;
470: dm->ops->createlocalvector = DMCreateLocalVector_Stag;
471: dm->ops->creatematrix = DMCreateMatrix_Stag;
472: dm->ops->destroy = DMDestroy_Stag;
473: dm->ops->getneighbors = DMGetNeighbors_Stag;
474: dm->ops->globaltolocalbegin = DMGlobalToLocalBegin_Stag;
475: dm->ops->globaltolocalend = DMGlobalToLocalEnd_Stag;
476: dm->ops->localtoglobalbegin = DMLocalToGlobalBegin_Stag;
477: dm->ops->localtoglobalend = DMLocalToGlobalEnd_Stag;
478: dm->ops->setfromoptions = DMSetFromOptions_Stag;
479: switch (dim) {
480: case 1: dm->ops->setup = DMSetUp_Stag_1d; break;
481: case 2: dm->ops->setup = DMSetUp_Stag_2d; break;
482: case 3: dm->ops->setup = DMSetUp_Stag_3d; break;
483: default : SETERRQ1(PetscObjectComm((PetscObject)dm),PETSC_ERR_ARG_OUTOFRANGE,"Unsupported dimension %d",dim);
484: }
485: dm->ops->clone = DMClone_Stag;
486: dm->ops->view = DMView_Stag;
487: dm->ops->getcompatibility = DMGetCompatibility_Stag;
488: return(0);
489: }