1 /*
2 Code for manipulating distributed regular arrays in parallel.
3 */
4
5 #include <petsc/private/dmdaimpl.h> /*I "petscdmda.h" I*/
6
7 /*@
8 DMDAGetGhostCorners - Returns the global (`i`,`j`,`k`) indices of the lower left
9 corner and size of the local region, including ghost points.
10
11 Not Collective
12
13 Input Parameter:
14 . da - the `DMDA`
15
16 Output Parameters:
17 + x - the corner index for the first dimension
18 . y - the corner index for the second dimension (only used in 2D and 3D problems)
19 . z - the corner index for the third dimension (only used in 3D problems)
20 . m - the width in the first dimension
21 . n - the width in the second dimension (only used in 2D and 3D problems)
22 - p - the width in the third dimension (only used in 3D problems)
23
24 Level: beginner
25
26 Notes:
27 Any of `y`, `z`, `n`, and `p` can be passed in as `NULL` if not needed.
28
29 The corner information is independent of the number of degrees of
30 freedom per node set with the `DMDACreateXX()` routine. Thus the `x`, `y`, and `z`
31 can be thought of as the lower left coordinates of the patch of values on process on a logical grid and `m`, `n`, and `p` as the
32 extent of the patch. Where
33 grid point has (potentially) several degrees of freedom.
34
35 .seealso: [](sec_struct), `DM`, `DMDA`, `DMDAGetCorners()`, `DMDACreate1d()`, `DMDACreate2d()`, `DMDACreate3d()`, `DMDAGetOwnershipRanges()`, `DMStagGetGhostCorners()`, `DMSTAG`
36 @*/
DMDAGetGhostCorners(DM da,PeOp PetscInt * x,PeOp PetscInt * y,PeOp PetscInt * z,PeOp PetscInt * m,PeOp PetscInt * n,PeOp PetscInt * p)37 PetscErrorCode DMDAGetGhostCorners(DM da, PeOp PetscInt *x, PeOp PetscInt *y, PeOp PetscInt *z, PeOp PetscInt *m, PeOp PetscInt *n, PeOp PetscInt *p)
38 {
39 PetscInt w;
40 DM_DA *dd = (DM_DA *)da->data;
41
42 PetscFunctionBegin;
43 PetscValidHeaderSpecificType(da, DM_CLASSID, 1, DMDA);
44 /* since the xs, xe ... have all been multiplied by the number of degrees
45 of freedom per cell, w = dd->w, we divide that out before returning.*/
46 w = dd->w;
47 if (x) *x = dd->Xs / w + dd->xo;
48 if (y) *y = dd->Ys + dd->yo;
49 if (z) *z = dd->Zs + dd->zo;
50 if (m) *m = (dd->Xe - dd->Xs) / w;
51 if (n) *n = (dd->Ye - dd->Ys);
52 if (p) *p = (dd->Ze - dd->Zs);
53 PetscFunctionReturn(PETSC_SUCCESS);
54 }
55