Actual source code: productutils.c
petsc-3.11.4 2019-09-28
1: /* Additional functions in the DMProduct API, which are not part of the general DM API. */
2: #include <petsc/private/dmproductimpl.h>
4: /*@C
5: DMProductGetDM - Get sub-DM associated with a given slot of a DMProduct
7: Not collective
9: Input Parameters:
10: + dm - the DMProduct
11: - slot - which dimension slot, in the range 0 to dim-1
13: Output Parameter:
14: . subdm - the sub-DM
16: Level: advanced
18: .seealso: DMPRODUCT, DMProductSetDM()
19: @*/
20: PETSC_EXTERN PetscErrorCode DMProductGetDM(DM dm,PetscInt slot,DM *subdm)
21: {
23: DM_Product *product = (DM_Product*)dm->data;
24: PetscInt dim;
28: DMGetDimension(dm,&dim);
29: if (slot >= dim || slot < 0) SETERRQ1(PetscObjectComm((PetscObject)dm),PETSC_ERR_ARG_OUTOFRANGE,"slot number must be in range 0-%D",dim-1);
30: *subdm = product->dm[slot];
31: return(0);
32: }
34: /*@C
35: DMProductSetDM - Set sub-DM associated with a given slot of DMProduct
37: Not collective
39: Input Parameters:
40: + dm - the DMProduct
41: . slot - which dimension slot, in the range 0 to dim-1
42: - subdm - the sub-DM
44: Notes:
45: This function does not destroy the provided sub-DM. You may safely destroy it after calling this function.
47: Level: advanced
49: .seealso: DMPRODUCT, DMProductGetDM(), DMProductSetDimensionIndex()
50: @*/
51: PETSC_EXTERN PetscErrorCode DMProductSetDM(DM dm,PetscInt slot,DM subdm)
52: {
54: DM_Product *product = (DM_Product*)dm->data;
55: PetscInt dim;
59: DMGetDimension(dm,&dim);
60: if (slot >= dim || slot < 0) SETERRQ1(PetscObjectComm((PetscObject)dm),PETSC_ERR_ARG_OUTOFRANGE,"slot number must be in range 0-%D",dim-1);
61: PetscObjectReference((PetscObject)subdm);
62: product->dm[slot] = subdm;
63: return(0);
64: }
66: /*@C
67: DMProductSetDimensionIndex - Set the dimension index associated with a given slot/sub-DM
69: Not collective
71: Input Parameters:
72: + dm - the DMProduct
73: . slot - which dimension slot, in the range 0 to dim-1
74: - idx - the dimension index of the sub-DM
76: Level: advanced
78: .seealso: DMPRODUCT
79: @*/
80: PETSC_EXTERN PetscErrorCode DMProductSetDimensionIndex(DM dm,PetscInt slot,PetscInt idx)
81: {
83: DM_Product *product = (DM_Product*)dm->data;
84: PetscInt dim;
88: DMGetDimension(dm,&dim);
89: if (slot >= dim || slot < 0) SETERRQ1(PetscObjectComm((PetscObject)dm),PETSC_ERR_ARG_OUTOFRANGE,"slot number must be in range 0-%D",dim-1);
90: product->dim[slot] = idx;
91: return(0);
92: }