Actual source code: stag1d.c
1: /*
2: Functions specific to the 1-dimensional implementation of DMStag
3: */
4: #include <petsc/private/dmstagimpl.h>
6: /*@C
7: DMStagCreate1d - Create an object to manage data living on the faces, edges, and vertices of a parallelized regular 1D grid.
9: Collective
11: Input Parameters:
12: + comm - MPI communicator
13: . bndx - boundary type: DM_BOUNDARY_NONE, DM_BOUNDARY_PERIODIC, or DM_BOUNDARY_GHOSTED
14: . M - global number of grid points
15: . dof0 - number of degrees of freedom per vertex/point/node/0-cell
16: . dof1 - number of degrees of freedom per element/edge/1-cell
17: . stencilType - ghost/halo region type: DMSTAG_STENCIL_BOX or DMSTAG_STENCIL_NONE
18: . stencilWidth - width, in elements, of halo/ghost region
19: - lx - array of local sizes, of length equal to the comm size, summing to M
21: Output Parameter:
22: . dm - the new DMStag object
24: Options Database Keys:
25: + -dm_view - calls DMViewFromOptions() a the conclusion of DMSetUp()
26: . -stag_grid_x <nx> - number of elements in the x direction
27: . -stag_ghost_stencil_width - width of ghost region, in elements
28: - -stag_boundary_type_x <none,ghosted,periodic> - DMBoundaryType value
30: Notes:
31: You must call DMSetUp() after this call before using the DM.
32: If you wish to use the options database (see the keys above) to change values in the DMStag, you must call
33: DMSetFromOptions() after this function but before DMSetUp().
35: Level: beginner
37: .seealso: DMSTAG, DMStagCreate2d(), DMStagCreate3d(), DMDestroy(), DMView(), DMCreateGlobalVector(), DMCreateLocalVector(), DMLocalToGlobalBegin(), DMDACreate1d()
38: @*/
39: PETSC_EXTERN PetscErrorCode DMStagCreate1d(MPI_Comm comm,DMBoundaryType bndx,PetscInt M,PetscInt dof0,PetscInt dof1,DMStagStencilType stencilType,PetscInt stencilWidth,const PetscInt lx[],DM* dm)
40: {
42: PetscMPIInt size;
45: MPI_Comm_size(comm,&size);
46: DMCreate(comm,dm);
47: DMSetDimension(*dm,1);
48: DMStagInitialize(bndx,DM_BOUNDARY_NONE,DM_BOUNDARY_NONE,M,0,0,size,0,0,dof0,dof1,0,0,stencilType,stencilWidth,lx,NULL,NULL,*dm);
49: return(0);
50: }
52: PETSC_INTERN PetscErrorCode DMStagSetUniformCoordinatesExplicit_1d(DM dm,PetscReal xmin,PetscReal xmax)
53: {
55: DM_Stag *stagCoord;
56: DM dmCoord;
57: Vec coordLocal;
58: PetscReal h,min;
59: PetscScalar **arr;
60: PetscInt start_ghost,n_ghost,s;
61: PetscInt ileft,ielement;
64: DMGetCoordinateDM(dm, &dmCoord);
65: stagCoord = (DM_Stag*) dmCoord->data;
66: for (s=0; s<2; ++s) {
67: if (stagCoord->dof[s] !=0 && stagCoord->dof[s] != 1) SETERRQ2(PetscObjectComm((PetscObject)dm),PETSC_ERR_PLIB,"Coordinate DM in 1 dimensions must have 0 or 1 dof on each stratum, but stratum %d has %d dof",s,stagCoord->dof[s]);
68: }
69: DMCreateLocalVector(dmCoord,&coordLocal);
71: DMStagVecGetArray(dmCoord,coordLocal,&arr);
72: if (stagCoord->dof[0]) {
73: DMStagGetLocationSlot(dmCoord,DMSTAG_LEFT,0,&ileft);
74: }
75: if (stagCoord->dof[1]) {
76: DMStagGetLocationSlot(dmCoord,DMSTAG_ELEMENT,0,&ielement);
77: }
78: DMStagGetGhostCorners(dmCoord,&start_ghost,NULL,NULL,&n_ghost,NULL,NULL);
80: min = xmin;
81: h = (xmax-xmin)/stagCoord->N[0];
83: for (PetscInt ind=start_ghost; ind<start_ghost + n_ghost; ++ind) {
84: if (stagCoord->dof[0]) {
85: const PetscReal off = 0.0;
86: arr[ind][ileft] = min + ((PetscReal)ind + off) * h;
87: }
88: if (stagCoord->dof[1]) {
89: const PetscReal off = 0.5;
90: arr[ind][ielement] = min + ((PetscReal)ind + off) * h;
91: }
92: }
93: DMStagVecRestoreArray(dmCoord,coordLocal,&arr);
94: DMSetCoordinatesLocal(dm,coordLocal);
95: PetscLogObjectParent((PetscObject)dm,(PetscObject)coordLocal);
96: VecDestroy(&coordLocal);
97: return(0);
98: }
100: /* Helper functions used in DMSetUp_Stag() */
101: static PetscErrorCode DMStagComputeLocationOffsets_1d(DM);
103: PETSC_INTERN PetscErrorCode DMSetUp_Stag_1d(DM dm)
104: {
105: PetscErrorCode ierr;
106: DM_Stag * const stag = (DM_Stag*)dm->data;
107: PetscMPIInt size,rank;
108: MPI_Comm comm;
109: PetscInt j;
112: PetscObjectGetComm((PetscObject)dm,&comm);
113: MPI_Comm_size(comm,&size);
114: MPI_Comm_rank(comm,&rank);
116: /* Check Global size */
117: if (stag->N[0] < 1) SETERRQ1(comm,PETSC_ERR_ARG_OUTOFRANGE,"Global grid size of %D < 1 specified",stag->N[0]);
119: /* Local sizes */
120: if (stag->N[0] < size) SETERRQ2(comm,PETSC_ERR_ARG_OUTOFRANGE,"More ranks (%d) than elements (%D) specified",size,stag->N[0]);
121: if (!stag->l[0]) {
122: /* Divide equally, giving an extra elements to higher ranks */
123: PetscMalloc1(stag->nRanks[0],&stag->l[0]);
124: for (j=0; j<stag->nRanks[0]; ++j) stag->l[0][j] = stag->N[0]/stag->nRanks[0] + (stag->N[0] % stag->nRanks[0] > j ? 1 : 0);
125: }
126: {
127: PetscInt Nchk = 0;
128: for (j=0; j<size; ++j) Nchk += stag->l[0][j];
129: if (Nchk != stag->N[0]) SETERRQ2(comm,PETSC_ERR_ARG_OUTOFRANGE,"Sum of specified local sizes (%D) is not equal to global size (%D)",Nchk,stag->N[0]);
130: }
131: stag->n[0] = stag->l[0][rank];
133: /* Rank (trivial in 1d) */
134: stag->rank[0] = rank;
135: stag->firstRank[0] = (PetscBool)(rank == 0);
136: stag->lastRank[0] = (PetscBool)(rank == size-1);
138: /* Local (unghosted) numbers of entries */
139: stag->entriesPerElement = stag->dof[0] + stag->dof[1];
140: switch (stag->boundaryType[0]) {
141: case DM_BOUNDARY_NONE:
142: case DM_BOUNDARY_GHOSTED: stag->entries = stag->n[0] * stag->entriesPerElement + (stag->lastRank[0] ? stag->dof[0] : 0); break;
143: case DM_BOUNDARY_PERIODIC: stag->entries = stag->n[0] * stag->entriesPerElement; break;
144: default: SETERRQ1(PetscObjectComm((PetscObject)dm),PETSC_ERR_SUP,"Unsupported x boundary type %s",DMBoundaryTypes[stag->boundaryType[0]]);
145: }
147: /* Starting element */
148: stag->start[0] = 0;
149: for (j=0; j<stag->rank[0]; ++j) stag->start[0] += stag->l[0][j];
151: /* Local/ghosted size and starting element */
152: switch (stag->boundaryType[0]) {
153: case DM_BOUNDARY_NONE :
154: switch (stag->stencilType) {
155: case DMSTAG_STENCIL_NONE : /* Only dummy cells on the right */
156: stag->startGhost[0] = stag->start[0];
157: stag->nGhost[0] = stag->n[0] + (stag->lastRank[0] ? 1 : 0);
158: break;
159: case DMSTAG_STENCIL_STAR :
160: case DMSTAG_STENCIL_BOX :
161: stag->startGhost[0] = stag->firstRank[0] ? stag->start[0]: stag->start[0] - stag->stencilWidth;
162: stag->nGhost[0] = stag->n[0];
163: stag->nGhost[0] += stag->firstRank[0] ? 0 : stag->stencilWidth;
164: stag->nGhost[0] += stag->lastRank[0] ? 1 : stag->stencilWidth;
165: break;
166: default :
167: SETERRQ1(PetscObjectComm((PetscObject)dm),PETSC_ERR_SUP,"Unrecognized ghost stencil type %d",stag->stencilType);
168: }
169: break;
170: case DM_BOUNDARY_GHOSTED:
171: switch (stag->stencilType) {
172: case DMSTAG_STENCIL_NONE :
173: stag->startGhost[0] = stag->start[0];
174: stag->nGhost[0] = stag->n[0] + (stag->lastRank[0] ? 1 : 0);
175: break;
176: case DMSTAG_STENCIL_STAR :
177: case DMSTAG_STENCIL_BOX :
178: stag->startGhost[0] = stag->start[0] - stag->stencilWidth; /* This value may be negative */
179: stag->nGhost[0] = stag->n[0] + 2*stag->stencilWidth + (stag->lastRank[0] && stag->stencilWidth == 0 ? 1 : 0);
180: break;
181: default :
182: SETERRQ1(PetscObjectComm((PetscObject)dm),PETSC_ERR_SUP,"Unrecognized ghost stencil type %d",stag->stencilType);
183: }
184: break;
185: case DM_BOUNDARY_PERIODIC:
186: switch (stag->stencilType) {
187: case DMSTAG_STENCIL_NONE :
188: stag->startGhost[0] = stag->start[0];
189: stag->nGhost[0] = stag->n[0];
190: break;
191: case DMSTAG_STENCIL_STAR :
192: case DMSTAG_STENCIL_BOX :
193: stag->startGhost[0] = stag->start[0] - stag->stencilWidth; /* This value may be negative */
194: stag->nGhost[0] = stag->n[0] + 2*stag->stencilWidth;
195: break;
196: default :
197: SETERRQ1(PetscObjectComm((PetscObject)dm),PETSC_ERR_SUP,"Unrecognized ghost stencil type %d",stag->stencilType);
198: }
199: break;
200: default :
201: SETERRQ1(PetscObjectComm((PetscObject)dm),PETSC_ERR_SUP,"Unsupported x boundary type %s",DMBoundaryTypes[stag->boundaryType[0]]);
202: }
204: /* Total size of ghosted/local representation */
205: stag->entriesGhost = stag->nGhost[0]*stag->entriesPerElement;
207: /* Define neighbors */
208: PetscMalloc1(3,&stag->neighbors);
209: if (stag->firstRank[0]) {
210: switch (stag->boundaryType[0]) {
211: case DM_BOUNDARY_GHOSTED:
212: case DM_BOUNDARY_NONE: stag->neighbors[0] = -1; break;
213: case DM_BOUNDARY_PERIODIC: stag->neighbors[0] = stag->nRanks[0]-1; break;
214: default : SETERRQ1(PetscObjectComm((PetscObject)dm),PETSC_ERR_SUP,"Unsupported x boundary type %s",DMBoundaryTypes[stag->boundaryType[0]]);
215: }
216: } else {
217: stag->neighbors[0] = stag->rank[0]-1;
218: }
219: stag->neighbors[1] = stag->rank[0];
220: if (stag->lastRank[0]) {
221: switch (stag->boundaryType[0]) {
222: case DM_BOUNDARY_GHOSTED:
223: case DM_BOUNDARY_NONE: stag->neighbors[2] = -1; break;
224: case DM_BOUNDARY_PERIODIC: stag->neighbors[2] = 0; break;
225: default : SETERRQ1(PetscObjectComm((PetscObject)dm),PETSC_ERR_SUP,"Unsupported x boundary type %s",DMBoundaryTypes[stag->boundaryType[0]]);
226: }
227: } else {
228: stag->neighbors[2] = stag->rank[0]+1;
229: }
231: if (stag->n[0] < stag->stencilWidth) {
232: SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_SUP,"DMStag 1d setup does not support local sizes (%d) smaller than the elementwise stencil width (%d)",stag->n[0],stag->stencilWidth);
233: }
235: /* Create global->local VecScatter and ISLocalToGlobalMapping */
236: {
237: PetscInt *idxLocal,*idxGlobal,*idxGlobalAll;
238: PetscInt i,iLocal,d,entriesToTransferTotal,ghostOffsetStart,ghostOffsetEnd,nNonDummyGhost;
239: IS isLocal,isGlobal;
241: /* The offset on the right (may not be equal to the stencil width, as we
242: always have at least one ghost element, to account for the boundary
243: point, and may with ghosted boundaries), and the number of non-dummy ghost elements */
244: ghostOffsetStart = stag->start[0] - stag->startGhost[0];
245: ghostOffsetEnd = stag->startGhost[0]+stag->nGhost[0] - (stag->start[0]+stag->n[0]);
246: nNonDummyGhost = stag->nGhost[0] - (stag->lastRank[0] ? ghostOffsetEnd : 0) - (stag->firstRank[0] ? ghostOffsetStart : 0);
248: /* Compute the number of non-dummy entries in the local representation
249: This is equal to the number of non-dummy elements in the local (ghosted) representation,
250: plus some extra entries on the right boundary on the last rank*/
251: switch (stag->boundaryType[0]) {
252: case DM_BOUNDARY_GHOSTED:
253: case DM_BOUNDARY_NONE:
254: entriesToTransferTotal = nNonDummyGhost * stag->entriesPerElement + (stag->lastRank[0] ? stag->dof[0] : 0);
255: break;
256: case DM_BOUNDARY_PERIODIC:
257: entriesToTransferTotal = stag->entriesGhost; /* No dummy points */
258: break;
259: default :
260: SETERRQ1(PetscObjectComm((PetscObject)dm),PETSC_ERR_SUP,"Unsupported x boundary type %s",DMBoundaryTypes[stag->boundaryType[0]]);
261: }
263: PetscMalloc1(entriesToTransferTotal,&idxLocal);
264: PetscMalloc1(entriesToTransferTotal,&idxGlobal);
265: PetscMalloc1(stag->entriesGhost,&idxGlobalAll);
266: if (stag->boundaryType[0] == DM_BOUNDARY_NONE) {
267: PetscInt count = 0,countAll = 0;
268: /* Left ghost points and native points */
269: for (i=stag->startGhost[0], iLocal=0; iLocal<nNonDummyGhost; ++i,++iLocal) {
270: for (d=0; d<stag->entriesPerElement; ++d,++count,++countAll) {
271: idxLocal [count] = iLocal * stag->entriesPerElement + d;
272: idxGlobal[count] = i * stag->entriesPerElement + d;
273: idxGlobalAll[countAll] = i * stag->entriesPerElement + d;
274: }
275: }
276: /* Ghost points on the right
277: Special case for last (partial dummy) element on the last rank */
278: if (stag->lastRank[0]) {
279: i = stag->N[0];
280: iLocal = (stag->nGhost[0]-ghostOffsetEnd);
281: /* Only vertex (0-cell) dofs in global representation */
282: for (d=0; d<stag->dof[0]; ++d,++count,++countAll) {
283: idxGlobal[count] = i * stag->entriesPerElement + d;
284: idxLocal [count] = iLocal * stag->entriesPerElement + d;
285: idxGlobalAll[countAll] = i * stag->entriesPerElement + d;
286: }
287: for (d=stag->dof[0]; d<stag->entriesPerElement; ++d,++countAll) { /* Additional dummy entries */
288: idxGlobalAll[countAll] = -1;
289: }
290: }
291: } else if (stag->boundaryType[0] == DM_BOUNDARY_PERIODIC) {
292: PetscInt count = 0,iLocal = 0; /* No dummy points, so idxGlobal and idxGlobalAll are identical */
293: const PetscInt iMin = stag->firstRank[0] ? stag->start[0] : stag->startGhost[0];
294: const PetscInt iMax = stag->lastRank[0] ? stag->startGhost[0] + stag->nGhost[0] - stag->stencilWidth : stag->startGhost[0] + stag->nGhost[0];
295: /* Ghost points on the left */
296: if (stag->firstRank[0]) {
297: for (i=stag->N[0]-stag->stencilWidth; iLocal<stag->stencilWidth; ++i,++iLocal) {
298: for (d=0; d<stag->entriesPerElement; ++d,++count) {
299: idxGlobal[count] = i * stag->entriesPerElement + d;
300: idxLocal [count] = iLocal * stag->entriesPerElement + d;
301: idxGlobalAll[count] = idxGlobal[count];
302: }
303: }
304: }
305: /* Native points */
306: for (i=iMin; i<iMax; ++i,++iLocal) {
307: for (d=0; d<stag->entriesPerElement; ++d,++count) {
308: idxGlobal[count] = i * stag->entriesPerElement + d;
309: idxLocal [count] = iLocal * stag->entriesPerElement + d;
310: idxGlobalAll[count] = idxGlobal[count];
311: }
312: }
313: /* Ghost points on the right */
314: if (stag->lastRank[0]) {
315: for (i=0; iLocal<stag->nGhost[0]; ++i,++iLocal) {
316: for (d=0; d<stag->entriesPerElement; ++d,++count) {
317: idxGlobal[count] = i * stag->entriesPerElement + d;
318: idxLocal [count] = iLocal * stag->entriesPerElement + d;
319: idxGlobalAll[count] = idxGlobal[count];
320: }
321: }
322: }
323: } else if (stag->boundaryType[0] == DM_BOUNDARY_GHOSTED) {
324: PetscInt count = 0,countAll = 0;
325: /* Dummy elements on the left, on the first rank */
326: if (stag->firstRank[0]) {
327: for (iLocal=0; iLocal<ghostOffsetStart; ++iLocal) {
328: /* Complete elements full of dummy entries */
329: for (d=0; d<stag->entriesPerElement; ++d,++countAll) {
330: idxGlobalAll[countAll] = -1;
331: }
332: }
333: i = 0; /* nonDummy entries start with global entry 0 */
334: } else {
335: /* nonDummy entries start as usual */
336: i = stag->startGhost[0];
337: iLocal = 0;
338: }
340: /* non-Dummy entries */
341: {
342: PetscInt iLocalNonDummyMax = stag->firstRank[0] ? nNonDummyGhost + ghostOffsetStart : nNonDummyGhost;
343: for (; iLocal<iLocalNonDummyMax; ++i,++iLocal) {
344: for (d=0; d<stag->entriesPerElement; ++d,++count,++countAll) {
345: idxLocal [count] = iLocal * stag->entriesPerElement + d;
346: idxGlobal[count] = i * stag->entriesPerElement + d;
347: idxGlobalAll[countAll] = i * stag->entriesPerElement + d;
348: }
349: }
350: }
352: /* (partial) dummy elements on the right, on the last rank */
353: if (stag->lastRank[0]) {
354: /* First one is partial dummy */
355: i = stag->N[0];
356: iLocal = (stag->nGhost[0]-ghostOffsetEnd);
357: for (d=0; d<stag->dof[0]; ++d,++count,++countAll) { /* Only vertex (0-cell) dofs in global representation */
358: idxLocal [count] = iLocal * stag->entriesPerElement + d;
359: idxGlobal[count] = i * stag->entriesPerElement + d;
360: idxGlobalAll[countAll] = i * stag->entriesPerElement + d;
361: }
362: for (d=stag->dof[0]; d<stag->entriesPerElement; ++d,++countAll) { /* Additional dummy entries */
363: idxGlobalAll[countAll] = -1;
364: }
365: for (iLocal = stag->nGhost[0] - ghostOffsetEnd + 1; iLocal < stag->nGhost[0]; ++iLocal) {
366: /* Additional dummy elements */
367: for (d=0; d<stag->entriesPerElement; ++d,++countAll) {
368: idxGlobalAll[countAll] = -1;
369: }
370: }
371: }
372: } else SETERRQ1(PetscObjectComm((PetscObject)dm),PETSC_ERR_SUP,"Unsupported x boundary type %s",DMBoundaryTypes[stag->boundaryType[0]]);
374: /* Create Local IS (transferring pointer ownership) */
375: ISCreateGeneral(PetscObjectComm((PetscObject)dm),entriesToTransferTotal,idxLocal,PETSC_OWN_POINTER,&isLocal);
377: /* Create Global IS (transferring pointer ownership) */
378: ISCreateGeneral(PetscObjectComm((PetscObject)dm),entriesToTransferTotal,idxGlobal,PETSC_OWN_POINTER,&isGlobal);
380: /* Create stag->gtol, which doesn't include dummy entries */
381: {
382: Vec local,global;
383: VecCreateMPIWithArray(PetscObjectComm((PetscObject)dm),1,stag->entries,PETSC_DECIDE,NULL,&global);
384: VecCreateSeqWithArray(PETSC_COMM_SELF,stag->entriesPerElement,stag->entriesGhost,NULL,&local);
385: VecScatterCreate(global,isGlobal,local,isLocal,&stag->gtol);
386: VecDestroy(&global);
387: VecDestroy(&local);
388: }
390: /* In special cases, create a dedicated injective local-to-global map */
391: if (stag->boundaryType[0] == DM_BOUNDARY_PERIODIC && stag->nRanks[0] == 1) {
392: DMStagPopulateLocalToGlobalInjective(dm);
393: }
395: /* Destroy ISs */
396: ISDestroy(&isLocal);
397: ISDestroy(&isGlobal);
399: /* Create local-to-global map (transferring pointer ownership) */
400: ISLocalToGlobalMappingCreate(comm,1,stag->entriesGhost,idxGlobalAll,PETSC_OWN_POINTER,&dm->ltogmap);
401: PetscLogObjectParent((PetscObject)dm,(PetscObject)dm->ltogmap);
402: }
404: /* Precompute location offsets */
405: DMStagComputeLocationOffsets_1d(dm);
407: /* View from Options */
408: DMViewFromOptions(dm,NULL,"-dm_view");
410: return(0);
411: }
413: static PetscErrorCode DMStagComputeLocationOffsets_1d(DM dm)
414: {
415: PetscErrorCode ierr;
416: DM_Stag * const stag = (DM_Stag*)dm->data;
417: const PetscInt epe = stag->entriesPerElement;
420: PetscMalloc1(DMSTAG_NUMBER_LOCATIONS,&stag->locationOffsets);
421: stag->locationOffsets[DMSTAG_LEFT] = 0;
422: stag->locationOffsets[DMSTAG_ELEMENT] = stag->locationOffsets[DMSTAG_LEFT] + stag->dof[0];
423: stag->locationOffsets[DMSTAG_RIGHT] = stag->locationOffsets[DMSTAG_LEFT] + epe;
424: return(0);
425: }
427: PETSC_INTERN PetscErrorCode DMStagPopulateLocalToGlobalInjective_1d(DM dm)
428: {
429: PetscErrorCode ierr;
430: DM_Stag * const stag = (DM_Stag*)dm->data;
431: PetscInt *idxLocal,*idxGlobal;
432: PetscInt i,iLocal,d,count;
433: IS isLocal,isGlobal;
436: PetscMalloc1(stag->entries,&idxLocal);
437: PetscMalloc1(stag->entries,&idxGlobal);
438: count = 0;
439: iLocal = stag->start[0]-stag->startGhost[0];
440: for (i=stag->start[0]; i<stag->start[0]+stag->n[0]; ++i,++iLocal) {
441: for (d=0; d<stag->entriesPerElement; ++d,++count) {
442: idxGlobal[count] = i * stag->entriesPerElement + d;
443: idxLocal [count] = iLocal * stag->entriesPerElement + d;
444: }
445: }
446: if (stag->lastRank[0] && stag->boundaryType[0] != DM_BOUNDARY_PERIODIC) {
447: i = stag->start[0]+stag->n[0];
448: iLocal = stag->start[0]-stag->startGhost[0] + stag->n[0];
449: for (d=0; d<stag->dof[0]; ++d,++count) {
450: idxGlobal[count] = i * stag->entriesPerElement + d;
451: idxLocal [count] = iLocal * stag->entriesPerElement + d;
452: }
453: }
454: ISCreateGeneral(PetscObjectComm((PetscObject)dm),stag->entries,idxLocal,PETSC_OWN_POINTER,&isLocal);
455: ISCreateGeneral(PetscObjectComm((PetscObject)dm),stag->entries,idxGlobal,PETSC_OWN_POINTER,&isGlobal);
456: {
457: Vec local,global;
458: VecCreateMPIWithArray(PetscObjectComm((PetscObject)dm),1,stag->entries,PETSC_DECIDE,NULL,&global);
459: VecCreateSeqWithArray(PETSC_COMM_SELF,stag->entriesPerElement,stag->entriesGhost,NULL,&local);
460: VecScatterCreate(local,isLocal,global,isGlobal,&stag->ltog_injective);
461: VecDestroy(&global);
462: VecDestroy(&local);
463: }
464: ISDestroy(&isLocal);
465: ISDestroy(&isGlobal);
466: return(0);
467: }