xref: /petsc/src/dm/impls/da/dascatter.c (revision 5b6bfdb9644f185dbf5e5a09b808ec241507e1e7)
1 
2 /*
3   Code for manipulating distributed regular arrays in parallel.
4 */
5 
6 #include <petsc/private/dmdaimpl.h>    /*I   "petscdmda.h"   I*/
7 extern PetscErrorCode DMLocalToLocalCreate_DA(DM);
8 
9 /*@C
10    DMDAGetScatter - Gets the global-to-local, and
11    local-to-local vector scatter contexts for a distributed array.
12 
13    Collective on DMDA
14 
15    Input Parameter:
16 .  da - the distributed array
17 
18    Output Parameters:
19 +  gtol - global-to-local scatter context (may be NULL)
20 -  ltol - local-to-local scatter context (may be NULL)
21 
22    Level: developer
23 
24    Notes:
25    The output contexts are valid only as long as the input da is valid.
26    If you delete the da, the scatter contexts will become invalid.
27 
28 .keywords: distributed array, get, scatter, context, global-to-local,
29            local-to-global, local-to-local
30 
31 .seealso: DMGlobalToLocalBegin(), DMGlobalToLocalEnd(), DMLocalToGlobalBegin()
32 @*/
33 PetscErrorCode  DMDAGetScatter(DM da,VecScatter *gtol,VecScatter *ltol)
34 {
35   PetscErrorCode ierr;
36   DM_DA          *dd = (DM_DA*)da->data;
37 
38   PetscFunctionBegin;
39   PetscValidHeaderSpecific(da,DM_CLASSID,1);
40   if (gtol) *gtol = dd->gtol;
41   if (ltol) {
42     if (!dd->ltol) {
43       ierr = DMLocalToLocalCreate_DA(da);CHKERRQ(ierr);
44     }
45     *ltol = dd->ltol;
46   }
47   PetscFunctionReturn(0);
48 }
49 
50