Actual source code: dareg.c
petsc-3.7.1 2016-05-15
Report Typos and Errors

      2: #include <petsc/private/dmdaimpl.h>    /*I "petscdmda.h"  I*/

      4: extern PetscErrorCode  DMSetUp_DA_1D(DM);
      5: extern PetscErrorCode  DMSetUp_DA_2D(DM);
      6: extern PetscErrorCode  DMSetUp_DA_3D(DM);

     10: PetscErrorCode  DMSetUp_DA(DM da)
     11: {
     13:   DM_DA          *dd = (DM_DA*)da->data;

     17:   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);
     18:   if (dd->s < 0) SETERRQ1(PetscObjectComm((PetscObject)da),PETSC_ERR_ARG_OUTOFRANGE,"Stencil width cannot be negative: %D",dd->s);

     20:   PetscCalloc1(dd->w+1,&dd->fieldname);
     21:   PetscCalloc1(da->dim,&dd->coordinatename);
     22:   if (da->dim == 1) {
     23:     DMSetUp_DA_1D(da);
     24:   } else if (da->dim == 2) {
     25:     DMSetUp_DA_2D(da);
     26:   } else if (da->dim == 3) {
     27:     DMSetUp_DA_3D(da);
     28:   } else SETERRQ(PetscObjectComm((PetscObject)da),PETSC_ERR_SUP,"DMs only supported for 1, 2, and 3d");
     29:   DMViewFromOptions(da,NULL,"-dm_view");
     30:   return(0);
     31: }