Actual source code: dareg.c
petsc-3.10.5 2019-03-28
2: #include <petsc/private/dmdaimpl.h>
4: extern PetscErrorCode DMSetUp_DA_1D(DM);
5: extern PetscErrorCode DMSetUp_DA_2D(DM);
6: extern PetscErrorCode DMSetUp_DA_3D(DM);
8: PetscErrorCode DMSetUp_DA(DM da)
9: {
11: DM_DA *dd = (DM_DA*)da->data;
15: 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);
16: if (dd->s < 0) SETERRQ1(PetscObjectComm((PetscObject)da),PETSC_ERR_ARG_OUTOFRANGE,"Stencil width cannot be negative: %D",dd->s);
18: PetscCalloc1(dd->w+1,&dd->fieldname);
19: PetscCalloc1(da->dim,&dd->coordinatename);
20: if (da->dim == 1) {
21: DMSetUp_DA_1D(da);
22: } else if (da->dim == 2) {
23: DMSetUp_DA_2D(da);
24: } else if (da->dim == 3) {
25: DMSetUp_DA_3D(da);
26: } else SETERRQ(PetscObjectComm((PetscObject)da),PETSC_ERR_SUP,"DMs only supported for 1, 2, and 3d");
27: DMViewFromOptions(da,NULL,"-dm_view");
28: return(0);
29: }