2: /* 3: Code for manipulating distributed regular arrays in parallel. 4: */ 6: #include <petsc/private/dmdaimpl.h> 8: PetscErrorCode DMDestroy_DA(DM da) 9: { 11: PetscErrorCode i; 12: DM_DA *dd = (DM_DA*)da->data; 15: /* destroy the external/common part */ 16: for (i=0; i<DMDA_MAX_WORK_ARRAYS; i++) { 17: PetscFree(dd->startghostedout[i]); 18: PetscFree(dd->startghostedin[i]); 19: PetscFree(dd->startout[i]); 20: PetscFree(dd->startin[i]); 21: } 23: VecScatterDestroy(&dd->gtol); 24: VecScatterDestroy(&dd->ltol); 25: VecDestroy(&dd->natural); 26: VecScatterDestroy(&dd->gton); 27: AODestroy(&dd->ao); 28: PetscFree(dd->aotype); 30: PetscFree(dd->lx); 31: PetscFree(dd->ly); 32: PetscFree(dd->lz); 34: PetscFree(dd->refine_x_hier); 35: PetscFree(dd->refine_y_hier); 36: PetscFree(dd->refine_z_hier); 38: if (dd->fieldname) { 39: for (i=0; i<dd->w; i++) { 40: PetscFree(dd->fieldname[i]); 41: } 42: PetscFree(dd->fieldname); 43: } 44: if (dd->coordinatename) { 45: for (i=0; i<da->dim; i++) { 46: PetscFree(dd->coordinatename[i]); 47: } 48: PetscFree(dd->coordinatename); 49: } 50: ISColoringDestroy(&dd->localcoloring); 51: ISColoringDestroy(&dd->ghostedcoloring); 53: PetscFree(dd->neighbors); 54: PetscFree(dd->dfill); 55: PetscFree(dd->ofill); 56: PetscFree(dd->ofillcols); 57: PetscFree(dd->e); 58: ISDestroy(&dd->ecorners); 60: PetscObjectComposeFunction((PetscObject)da,"DMSetUpGLVisViewer_C",NULL); 62: PetscFree(dd); 63: return(0); 64: }