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

Matthew Knepley knepley at gmail.com
Mon Apr 4 16:05:04 CDT 2022


On Mon, Apr 4, 2022 at 3:36 PM Berend van Wachem <berend.vanwachem at ovgu.de>
wrote:

> 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.
>

The cloned DM will have exactly the same topology and distribution. This
must be a misinterpretation
of what is happening. We can do a few things:

1) Make a small example to show what you are talking about

2) Look at a PETSc example that does something similar

3) Look directly at your code if I can somehow run it here

4) Start doing diagnostics on your code to see what is going on

Which one do you prefer?


> 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?
>

I don't think any of this should have changed, so this should be something
simple.

  Thanks,

     Matt


> Thanks, best regards,
>
> Berend.
>


-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener

https://www.cse.buffalo.edu/~knepley/ <http://www.cse.buffalo.edu/~knepley/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20220404/81e7ce5f/attachment.html>


More information about the petsc-users mailing list