DMGlobalToLocal/LocalToGlobal doesn't check Vector sizes
Currently, if you run DMGlobalToLocal
or DMLocalToGlobal
, they do not check the size of the vectors before doing the communication. This can cause issues further down the line (via overwriting memory) that make it difficult to track back to the original source.
This is a problem I ran into a few months back, where I copy/pasted a DMGlobalToLocal
line, changed it to DMLocalToGlobal
, but forgot to change the arguments.
A quick sketch of the solution (which I plan to submit a MR for soon): Inside DMGlobalToLocalBegin
and DMLocalToGlobalBegin
, verify that a Vec
's PetscLayout->{n,N}
matches with the PetscSF->{nroots,nleaves}
used for the communication.