[petsc-users] VecSet and VecAssemblyBegin
Barry Smith
bsmith at petsc.dev
Fri Apr 25 16:30:34 CDT 2025
Technically you should not be calling VecSet() with any outstanding arrays but it will probably be fine.
Even though GetArray() does not copy the array values; both GetArray/RestoreArray and Set track the current "state" of the vector and that count might get confused if they are used improperly.
> On Apr 25, 2025, at 4:42 PM, Derek Teaney <derek.teaney at stonybrook.edu> wrote:
>
> Thanks, I am working on providing a standalone code. A related question is - if I did have a view of a local vector provided by:
>
> data_node ***dn_array;
> DMDAVecGetArray(domain, dn_local, &dn_array);
>
> Can I assume through multiple calls to VecSet that the view dn_array is valid, or should this be restored, between calls.
>
> Thanks,
>
> Derek
>
> On Fri, Apr 25, 2025 at 1:26 PM Barry Smith <bsmith at petsc.dev <mailto:bsmith at petsc.dev>> wrote:
>>
>> You absolutely should not need to do an assembly after a VecSet. Please post a full reproducer that demonstrates the problem.
>>
>> Barry
>>
>>
>>> On Apr 25, 2025, at 1:23 PM, Derek Teaney via petsc-users <petsc-users at mcs.anl.gov <mailto:petsc-users at mcs.anl.gov>> wrote:
>>>
>>> Hi,
>>>
>>> I was under the (mistaken) impression that one does not need to due a VecAssemblyBegin etc following a VecSet, e.g.
>>>
>>> VecSet(dn_local, 0.);
>>> VecAssemblyBegin(dn_local) ;
>>> VecAssemblyEnd(dn_local) ;
>>>
>>> Seems to give different results without the Assembly.
>>>
>>> Thanks for clarifying,
>>>
>>> Derek
>>>
>>> --
>>> ------------------------------------------------------------------------
>>> Derek Teaney
>>> Professor and Graduate Program Director
>>> Dept. of Physics & Astronomy
>>> Stony Brook University
>>> Stony Brook, NY 11794-3800
>>> Tel: (631) 632-4489
>>> Fax: (631) 632-9718
>>> e-mail: Derek.Teaney at stonybrook.edu <mailto:Derek.Teaney at stonybrook.edu>
>>> ------------------------------------------------------------------------
>>>
>>
>
>
>
> --
> ------------------------------------------------------------------------
> Derek Teaney
> Professor and Graduate Program Director
> Dept. of Physics & Astronomy
> Stony Brook University
> Stony Brook, NY 11794-3800
> Tel: (631) 632-4489
> Fax: (631) 632-9718
> e-mail: Derek.Teaney at stonybrook.edu <mailto:Derek.Teaney at stonybrook.edu>
> ------------------------------------------------------------------------
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20250425/79ff91f5/attachment-0001.html>
More information about the petsc-users
mailing list