[petsc-users] DMCloning from a DMPlex has changed in Petsc-3.17.0?

Berend van Wachem berend.vanwachem at ovgu.de
Mon Apr 4 14:38:01 CDT 2022


Dear Petsc team,

Since about 2 years we have been using Petsc with DMPlex, but since 
upgrading our code to Petsc-3.17.0 something has broken.

First we generate a DM from a DMPlex with  DMPlexCreateFromFile or 
creating one with DMPlexCreateBoxMesh. Then the DM is distributed with 
DMPlexDistribute. This DM works fine and we set a numer of fields and 
set a section to it.
However, on the same mesh we also want to solve a problem with a 
different number of fields, and therefore we create a clone of this 
original DM, using the code:

DMClone(OriginalDM, NewDM);
DMClearDS(*NewDM);
PetscCalloc2(1, &NumComp, 4, &NumDof);
NumComp[0] = 1;
NumDof[3] = NFields;
DMSetNumFields(*NewDM, 1);
DMSetFromOptions(*NewDM);
DMPlexCreateSection(*NewDM, NULL, NumComp, NumDof, 0, NULL, NULL, NULL, 
NULL, &section);
DMSetLocalSection(*NewDM, section);
PetscFree2(NumComp, NumDof);
PetscSectionDestroy(&section);

However, with Petsc-3.17.0, the *NewDM is corrupt - When I call 
DMGlobalToLocalBegin with a Global and Local vector created with this 
NewDM, the code crashes. Indeed, the cloned DM seems to be partitioned 
differently than the original DM, as it these two DMs have a different 
number of local cells.

This worked fine in Petsc releases before 3.17 (e.g. 3.16.5). So my 
question is: what has changed? Am I doing something wrong, which should 
be changed for using with Petsc-3.17?

Thanks, best regards,

Berend.


More information about the petsc-users mailing list