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

Matthew Knepley knepley at gmail.com
Wed Jun 22 14:03:14 CDT 2016


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

> Thanks a lot for your prompt reply and useful advice.
>
> I have another question. In my current case, I don't change any value in
> the sub-vector and in another words I used it as read-only.
> What should I do after I don't need it anymore?
> Should I call VecRestoreSubVector method or it is faster if I call the
> Destroy method on the sub-vector ?
>

Restore not Destroy for subvec.


> If I understand you correctly, the subvector doesn't have any space for
> itself, in that case Destroy method does not release the memory.
>
> And finally, I destroy the original vector after I call either Restore or
> Destroy on the sub-vector.
>

Yes, after Restore.

  Matt


> Best,
> Ehsan
>
> On Wed, Jun 22, 2016 at 12:44 PM, Matthew Knepley <knepley at gmail.com>
> wrote:
>
>> 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
>>
>
>


-- 
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/9b801f69/attachment.html>


More information about the petsc-users mailing list