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