xref: /petsc/src/dm/impls/da/daghost.c (revision 7087cfbefd1a42b179f217f9994fb6cb0d0c1824)
147c6ae99SBarry Smith #define PETSCDM_DLL
247c6ae99SBarry Smith 
347c6ae99SBarry Smith /*
447c6ae99SBarry Smith   Code for manipulating distributed regular arrays in parallel.
547c6ae99SBarry Smith */
647c6ae99SBarry Smith 
7e1589f56SBarry Smith #include "private/daimpl.h"    /*I   "petscdm.h"   I*/
847c6ae99SBarry Smith 
947c6ae99SBarry Smith #undef __FUNCT__
10aa219208SBarry Smith #define __FUNCT__ "DMDAGetGhostCorners"
1147c6ae99SBarry Smith /*@
12aa219208SBarry Smith    DMDAGetGhostCorners - Returns the global (x,y,z) indices of the lower left
1347c6ae99SBarry Smith    corner of the local region, including ghost points.
1447c6ae99SBarry Smith 
1547c6ae99SBarry Smith    Not Collective
1647c6ae99SBarry Smith 
1747c6ae99SBarry Smith    Input Parameter:
1847c6ae99SBarry Smith .  da - the distributed array
1947c6ae99SBarry Smith 
2047c6ae99SBarry Smith    Output Parameters:
2147c6ae99SBarry Smith +  x,y,z - the corner indices (where y and z are optional; these are used
2247c6ae99SBarry Smith            for 2D and 3D problems)
2347c6ae99SBarry Smith -  m,n,p - widths in the corresponding directions (where n and p are optional;
2447c6ae99SBarry Smith            these are used for 2D and 3D problems)
2547c6ae99SBarry Smith 
2647c6ae99SBarry Smith    Level: beginner
2747c6ae99SBarry Smith 
2847c6ae99SBarry Smith    Note:
2947c6ae99SBarry Smith    The corner information is independent of the number of degrees of
30aa219208SBarry Smith    freedom per node set with the DMDACreateXX() routine. Thus the x, y, z, and
3147c6ae99SBarry Smith    m, n, p can be thought of as coordinates on a logical grid, where each
3247c6ae99SBarry Smith    grid point has (potentially) several degrees of freedom.
3347c6ae99SBarry Smith    Any of y, z, n, and p can be passed in as PETSC_NULL if not needed.
3447c6ae99SBarry Smith 
3547c6ae99SBarry Smith .keywords: distributed array, get, ghost, corners, nodes, local indices
3647c6ae99SBarry Smith 
37aa219208SBarry Smith .seealso: DMDAGetCorners(), DMDACreate1d(), DMDACreate2d(), DMDACreate3d(), DMDAGetOwnershipRanges()
3847c6ae99SBarry Smith 
3947c6ae99SBarry Smith @*/
40*7087cfbeSBarry Smith PetscErrorCode  DMDAGetGhostCorners(DM da,PetscInt *x,PetscInt *y,PetscInt *z,PetscInt *m,PetscInt *n,PetscInt *p)
4147c6ae99SBarry Smith {
4247c6ae99SBarry Smith   PetscInt w;
4347c6ae99SBarry Smith   DM_DA    *dd = (DM_DA*)da->data;
4447c6ae99SBarry Smith 
4547c6ae99SBarry Smith   PetscFunctionBegin;
4647c6ae99SBarry Smith   PetscValidHeaderSpecific(da,DM_CLASSID,1);
4747c6ae99SBarry Smith   /* since the xs, xe ... have all been multiplied by the number of degrees
4847c6ae99SBarry Smith      of freedom per cell, w = dd->w, we divide that out before returning.*/
4947c6ae99SBarry Smith   w = dd->w;
5047c6ae99SBarry Smith   if (x) *x = dd->Xs/w; if (m) *m = (dd->Xe - dd->Xs)/w;
5147c6ae99SBarry Smith   if (y) *y = dd->Ys;   if (n) *n = (dd->Ye - dd->Ys);
5247c6ae99SBarry Smith   if (z) *z = dd->Zs;   if (p) *p = (dd->Ze - dd->Zs);
5347c6ae99SBarry Smith   PetscFunctionReturn(0);
5447c6ae99SBarry Smith }
5547c6ae99SBarry Smith 
56