Actual source code: dascatter.c

      1: /*
      2:   Code for manipulating distributed regular arrays in parallel.
      3: */

      5: #include <petsc/private/dmdaimpl.h>

      7: /*@
      8:   DMDAGetScatter - Gets the global-to-local, and
      9:   local-to-local vector scatter contexts for a `DMDA` distributed array.

     11:   Collective

     13:   Input Parameter:
     14: . da - the `DMDA`

     16:   Output Parameters:
     17: + gtol - global-to-local scatter context (may be `NULL`)
     18: - ltol - local-to-local scatter context (may be `NULL`)

     20:   Level: developer

     22:   Note:
     23:   The output contexts are valid only as long as the input `da` is valid.
     24:   If you delete the `da`, the scatter contexts will become invalid.

     26: .seealso: [](sec_struct), `DM`, `DMDA`, `DMGlobalToLocalBegin()`, `DMGlobalToLocalEnd()`, `DMLocalToGlobalBegin()`
     27: @*/
     28: PetscErrorCode DMDAGetScatter(DM da, PeOp VecScatter *gtol, PeOp VecScatter *ltol)
     29: {
     30:   DM_DA *dd = (DM_DA *)da->data;

     32:   PetscFunctionBegin;
     34:   if (gtol) *gtol = dd->gtol;
     35:   if (ltol) {
     36:     if (!dd->ltol) PetscCall(DMLocalToLocalCreate_DA(da));
     37:     *ltol = dd->ltol;
     38:   }
     39:   PetscFunctionReturn(PETSC_SUCCESS);
     40: }