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