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) {
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: PetscCall(DMViewFromOptions(da, NULL, "-dm_view"));
22: PetscFunctionReturn(PETSC_SUCCESS);
23: }