xref: /petsc/src/dm/impls/da/daghost.c (revision dce8aeba1c9b69b19f651c53d8a6b674bd7e9cbd)
147c6ae99SBarry Smith 
247c6ae99SBarry Smith /*
347c6ae99SBarry Smith   Code for manipulating distributed regular arrays in parallel.
447c6ae99SBarry Smith */
547c6ae99SBarry Smith 
6af0996ceSBarry Smith #include <petsc/private/dmdaimpl.h> /*I   "petscdmda.h"   I*/
747c6ae99SBarry Smith 
8a5d1443cSVincent Le Chenadec /*@C
9aa219208SBarry Smith    DMDAGetGhostCorners - Returns the global (x,y,z) indices of the lower left
1059f3ab6dSMatthew G. Knepley    corner and size of the local region, including ghost points.
1147c6ae99SBarry Smith 
1247c6ae99SBarry Smith    Not Collective
1347c6ae99SBarry Smith 
1447c6ae99SBarry Smith    Input Parameter:
1547c6ae99SBarry Smith .  da - the distributed array
1647c6ae99SBarry Smith 
1747c6ae99SBarry Smith    Output Parameters:
186b867d5aSJose E. Roman +  x - the corner index for the first dimension
196b867d5aSJose E. Roman .  y - the corner index for the second dimension (only used in 2D and 3D problems)
206b867d5aSJose E. Roman .  z - the corner index for the third dimension (only used in 3D problems)
216b867d5aSJose E. Roman .  m - the width in the first dimension
226b867d5aSJose E. Roman .  n - the width in the second dimension (only used in 2D and 3D problems)
236b867d5aSJose E. Roman -  p - the width in the third dimension (only used in 3D problems)
2447c6ae99SBarry Smith 
2547c6ae99SBarry Smith    Level: beginner
2647c6ae99SBarry Smith 
2747c6ae99SBarry Smith    Note:
2847c6ae99SBarry Smith    The corner information is independent of the number of degrees of
29*dce8aebaSBarry Smith    freedom per node set with the `DMDACreateXX()` routine. Thus the x, y, z, and
3047c6ae99SBarry Smith    m, n, p can be thought of as coordinates on a logical grid, where each
3147c6ae99SBarry Smith    grid point has (potentially) several degrees of freedom.
320298fd71SBarry Smith    Any of y, z, n, and p can be passed in as NULL if not needed.
3347c6ae99SBarry Smith 
34*dce8aebaSBarry Smith .seealso: `DM`, `DMDA`, `DMDAGetCorners()`, `DMDACreate1d()`, `DMDACreate2d()`, `DMDACreate3d()`, `DMDAGetOwnershipRanges()`, `DMStagGetGhostCorners()`
3547c6ae99SBarry Smith @*/
36d71ae5a4SJacob Faibussowitsch PetscErrorCode DMDAGetGhostCorners(DM da, PetscInt *x, PetscInt *y, PetscInt *z, PetscInt *m, PetscInt *n, PetscInt *p)
37d71ae5a4SJacob Faibussowitsch {
3847c6ae99SBarry Smith   PetscInt w;
3947c6ae99SBarry Smith   DM_DA   *dd = (DM_DA *)da->data;
4047c6ae99SBarry Smith 
4147c6ae99SBarry Smith   PetscFunctionBegin;
42a9a02de4SBarry Smith   PetscValidHeaderSpecificType(da, DM_CLASSID, 1, DMDA);
4347c6ae99SBarry Smith   /* since the xs, xe ... have all been multiplied by the number of degrees
4447c6ae99SBarry Smith      of freedom per cell, w = dd->w, we divide that out before returning.*/
4547c6ae99SBarry Smith   w = dd->w;
4659bc5b24SSatish Balay   if (x) *x = dd->Xs / w + dd->xo;
4759bc5b24SSatish Balay   if (y) *y = dd->Ys + dd->yo;
4859bc5b24SSatish Balay   if (z) *z = dd->Zs + dd->zo;
4959bc5b24SSatish Balay   if (m) *m = (dd->Xe - dd->Xs) / w;
5059bc5b24SSatish Balay   if (n) *n = (dd->Ye - dd->Ys);
5159bc5b24SSatish Balay   if (p) *p = (dd->Ze - dd->Zs);
5247c6ae99SBarry Smith   PetscFunctionReturn(0);
5347c6ae99SBarry Smith }
54