:orphan: # DMGetCompatibility determine if two `DM`s are compatible ## Synopsis ``` #include "petscdm.h" #include "petscdmlabel.h" #include "petscds.h" PetscErrorCode DMGetCompatibility(DM dm1, DM dm2, PetscBool *compatible, PetscBool *set) ``` Collective ## Input Parameters - ***dm1 -*** the first `DM` - ***dm2 -*** the second `DM` ## Output Parameters - ***compatible -*** whether or not the two `DM`s are compatible - ***set -*** whether or not the compatible value was actually determined and set ## Notes Two `DM`s are deemed compatible if they represent the same parallel decomposition of the same topology. This implies that the section (field data) on one "makes sense" with respect to the topology and parallel decomposition of the other. Loosely speaking, compatible `DM`s represent the same domain and parallel decomposition, but hold different data. Typically, one would confirm compatibility if intending to simultaneously iterate over a pair of vectors obtained from different `DM`s. For example, two `DMDA` objects are compatible if they have the same local and global sizes and the same stencil width. They can have different numbers of degrees of freedom per node. Thus, one could use the node numbering from either `DM` in bounds for a loop over vectors derived from either `DM`. Consider the operation of summing data living on a 2-dof `DMDA` to data living on a 1-dof `DMDA`, which should be compatible, as in the following snippet. ```none ... PetscCall(DMGetCompatibility(da1,da2,&compatible,&set)); if (set && compatible) { PetscCall(DMDAVecGetArrayDOF(da1,vec1,&arr1)); PetscCall(DMDAVecGetArrayDOF(da2,vec2,&arr2)); PetscCall(DMDAGetCorners(da1,&x,&y,NULL,&m,&n,NULL)); for (j=y; jsrc/dm/interface/dm.c ## Implementations DMGetCompatibility_DA in src/dm/impls/da/da.c
DMGetCompatibility_Stag in src/dm/impls/stag/stag.c
--- [Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/dm/interface/dm.c) [Index of all DM routines](index.md) [Table of Contents for all manual pages](/manualpages/index.md) [Index of all manual pages](/manualpages/singleindex.md)