Actual source code: dareg.c

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

      3: PetscErrorCode DMSetUp_DA(DM da)
      4: {
      5:   DM_DA *dd = (DM_DA *)da->data;

      7:   PetscFunctionBegin;
      9:   PetscCheck(dd->w >= 1, PetscObjectComm((PetscObject)da), PETSC_ERR_ARG_OUTOFRANGE, "Must have 1 or more degrees of freedom per node: %" PetscInt_FMT, dd->w);
     10:   PetscCheck(dd->s >= 0, PetscObjectComm((PetscObject)da), PETSC_ERR_ARG_OUTOFRANGE, "Stencil width cannot be negative: %" PetscInt_FMT, dd->s);

     12:   PetscCall(PetscCalloc1(dd->w + 1, &dd->fieldname));
     13:   PetscCall(PetscCalloc1(da->dim, &dd->coordinatename));
     14:   if (da->dim == 1) PetscCall(DMSetUp_DA_1D(da));
     15:   else if (da->dim == 2) PetscCall(DMSetUp_DA_2D(da));
     16:   else {
     17:     PetscCheck(da->dim == 3, PetscObjectComm((PetscObject)da), PETSC_ERR_SUP, "DMs only supported for 1, 2, and 3d");
     18:     PetscCall(DMSetUp_DA_3D(da));
     19:   }
     20:   da->Nf = dd->w;
     21:   PetscCall(DMViewFromOptions(da, NULL, "-dm_view"));
     22:   PetscFunctionReturn(PETSC_SUCCESS);
     23: }