1: #include <petsc/private/dmproductimpl.h> 3: static PetscErrorCode DMDestroy_Product(DM dm) 4: { 5: DM_Product *product = (DM_Product *)dm->data; 6: PetscInt d; 8: PetscFunctionBeginUser; 9: for (d = 0; d < DMPRODUCT_MAX_DIM; ++d) PetscCall(DMDestroy(&product->dm[d])); 10: PetscCall(PetscFree(product)); 11: PetscFunctionReturn(PETSC_SUCCESS); 12: } 14: /*MC 15: DMPRODUCT = "product" - a DM representing a local Cartesian product of other DMs 17: For each of dim dimensions, stores a sub-DM (need not be unique) and a dimension index. This specifies 18: which dimension of the sub-DM corresponds to each dimension of the DMProduct. 20: Level: advanced 22: .seealso: `DM`, `DMSTAG`, `DMProductGetDM()`, `DMProductSetDimensionIndex()`, `DMProductSetDM()`, `DMStagSetUniformCoordinatesProduct()`, 23: `DMStagGetProductCoordinateArrays()`, `DMStagGetProductCoordinateArraysRead()` 24: M*/ 26: PETSC_EXTERN PetscErrorCode DMCreate_Product(DM dm) 27: { 28: DM_Product *product; 29: PetscInt d; 31: PetscFunctionBegin; 32: PetscAssertPointer(dm, 1); 33: PetscCall(PetscNew(&product)); 34: dm->data = product; 36: for (d = 0; d < DMPRODUCT_MAX_DIM; ++d) product->dm[d] = NULL; 37: for (d = 0; d < DMPRODUCT_MAX_DIM; ++d) product->dim[d] = -1; 39: dm->ops->destroy = DMDestroy_Product; 40: PetscFunctionReturn(PETSC_SUCCESS); 41: }