Actual source code: dareg.c
petsc-3.11.4 2019-09-28
1: #include <petsc/private/dmdaimpl.h>
3: extern PetscErrorCode DMSetUp_DA_1D(DM);
4: extern PetscErrorCode DMSetUp_DA_2D(DM);
5: extern PetscErrorCode DMSetUp_DA_3D(DM);
7: PetscErrorCode DMSetUp_DA(DM da)
8: {
10: DM_DA *dd = (DM_DA*)da->data;
14: if (dd->w < 1) SETERRQ1(PetscObjectComm((PetscObject)da),PETSC_ERR_ARG_OUTOFRANGE,"Must have 1 or more degrees of freedom per node: %D",dd->w);
15: if (dd->s < 0) SETERRQ1(PetscObjectComm((PetscObject)da),PETSC_ERR_ARG_OUTOFRANGE,"Stencil width cannot be negative: %D",dd->s);
17: PetscCalloc1(dd->w+1,&dd->fieldname);
18: PetscCalloc1(da->dim,&dd->coordinatename);
19: if (da->dim == 1) {
20: DMSetUp_DA_1D(da);
21: } else if (da->dim == 2) {
22: DMSetUp_DA_2D(da);
23: } else if (da->dim == 3) {
24: DMSetUp_DA_3D(da);
25: } else SETERRQ(PetscObjectComm((PetscObject)da),PETSC_ERR_SUP,"DMs only supported for 1, 2, and 3d");
26: DMViewFromOptions(da,NULL,"-dm_view");
27: return(0);
28: }