1 #include <petsc/private/dmdaimpl.h> /*I "petscdmda.h" I*/ 2 3 PetscErrorCode DMSetUp_DA(DM da) 4 { 5 DM_DA *dd = (DM_DA *)da->data; 6 7 PetscFunctionBegin; 8 PetscValidHeaderSpecific(da, DM_CLASSID, 1); 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); 11 12 PetscCall(PetscCalloc1(dd->w + 1, &dd->fieldname)); 13 PetscCall(PetscCalloc1(da->dim, &dd->coordinatename)); 14 if (da->dim == 1) { 15 PetscCall(DMSetUp_DA_1D(da)); 16 } else if (da->dim == 2) { 17 PetscCall(DMSetUp_DA_2D(da)); 18 } else if (da->dim == 3) { 19 PetscCall(DMSetUp_DA_3D(da)); 20 } else SETERRQ(PetscObjectComm((PetscObject)da), PETSC_ERR_SUP, "DMs only supported for 1, 2, and 3d"); 21 da->Nf = dd->w; 22 PetscCall(DMViewFromOptions(da, NULL, "-dm_view")); 23 PetscFunctionReturn(PETSC_SUCCESS); 24 } 25