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