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