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