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