[petsc-users] VecLoad into a SubVector ?
Barry Smith
bsmith at petsc.dev
Mon Jul 27 21:47:21 CDT 2020
I don't understand the logic of VecRestoreSubVector() at all. I don't see how it could work.
} else {
PETSC_UNUSED PetscObjectState dummystate = 0;
PetscBool valid;
ierr = PetscObjectComposedDataGetInt((PetscObject)*Y,VecGetSubVectorSavedStateId,dummystate,valid);CHKERRQ(ierr);
if (!valid) {
VecScatter scatter;
ierr = PetscObjectQuery((PetscObject)*Y,"VecGetSubVector_Scatter",(PetscObject*)&scatter);CHKERRQ(ierr);
if (scatter) {
ierr = VecScatterBegin(scatter,*Y,X,INSERT_VALUES,SCATTER_REVERSE);CHKERRQ(ierr);
ierr = VecScatterEnd(scatter,*Y,X,INSERT_VALUES,SCATTER_REVERSE);CHKERRQ(ierr);
}
}
Seems completely wrong to me. It never compares the saved state of the Y vector with the current vector. Matt is right stepping through with the debugger could should why it is not doing the scatter.
Barry
> On Jul 27, 2020, at 7:06 PM, Matthew Knepley <knepley at gmail.com> wrote:
>
> On Mon, Jul 27, 2020 at 6:09 PM Sajid Ali <sajidsyed2021 at u.northwestern.edu <mailto:sajidsyed2021 at u.northwestern.edu>> wrote:
> Hi PETSc-developers,
>
> When I load data (using VecLoad) into a subvector, the parent vector does not seem to get the data after the subvector is restored. I tried doing a VecSet to verify that the index set (used to select the subvector) is valid and the values set by VecSet are transferred back to the parent vector. Could anyone point out if I'm missing something when I try transferring the data via a VecLoad from a subvector to the parent vector ?
>
> I'm attaching the code for selecting the subvector and loading data along with a test hdf5 file (filled with random values). I expect the output `testload.h5` to be a vector of size 100 with the first 50 being 1 and the rest being the input values.
>
> You should be able to see with the debugger why the update does not happen. My guess is that the state is not updated. It should be updated
> by VecReplaceArray(), so I do not understand, but you should be able to see it clearly in gdb.
>
> Thanks,
>
> Matt
>
> Thank You,
> Sajid Ali | PhD Candidate
> Applied Physics
> Northwestern University
> s-sajid-ali.github.io <http://s-sajid-ali.github.io/>
>
> --
> 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/20200727/842eadff/attachment-0001.html>
More information about the petsc-users
mailing list