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