[petsc-users] [petsc-maint] VecGetSubVector causes NaN

Matthew Knepley knepley at gmail.com
Wed Jun 22 11:44:48 CDT 2016


On Wed, Jun 22, 2016 at 9:21 AM, ehsan sadrfaridpour <it.sadr at gmail.com>
wrote:

> Hi,
>
> If I use VecGetSubVector to get a subvector it works fine as far as I
> don't destroy the original vector.
> But, if I destroy the original vector, I get NaN values. So, it is my
> misunderstanding of what the function suppose to do, or is it a problem?
>

You cannot destroy the original vector since you still need to call


http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecRestoreSubVector.html#VecRestoreSubVector


> I do the same thing with MatGetSubMatrix
> <http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatGetSubMatrix.html#MatGetSubMatrix>
> and I haven't had any problem with it.
>

MatGetSubMatrix() is a hybrid since for INITIAL_MATRIX it creates a new
matrix, whereas for REUSE_MATRIX it refills and existing
one. However there is not Restore().

http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatGetSubMatrix.html

   Matt

Best,
> Ehsan
>



-- 
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20160622/b8bde58a/attachment-0001.html>


More information about the petsc-users mailing list