[petsc-users] Question Regarding Duplicate Indices in VecSetValues().

Junchao Zhang junchao.zhang at gmail.com
Tue Jan 14 09:10:56 CST 2025


Add Matt mentioned, with ADD_VALUES, the values will be added. But with
INSERT_VALUES,  if it is a sequential vector (VECSEQ),  it will overwrite
with the last value; but if it is an MPI parallel vector (VECMPI),  it is
undetermined, as you could not even define "which is the last" (assuming
duplicate indices over processes)

On Tue, Jan 14, 2025 at 8:32 AM Matthew Knepley <knepley at gmail.com> wrote:

> On Tue, Jan 14, 2025 at 9:06 AM Mark Adams <mfadams at lbl.gov> wrote:
>
>> INSERT_VALUES is clearly an error, but we can't check that easily so you
>> will probably just get the last value, and ADD_VALUES should work.
>>
>
> For INSERT_VALUES, it will overwrite with the last value. For ADD_VALUES,
> it will add.
>
>   Thanks,
>
>     Matt
>
>
>> Mark
>>
>> On Tue, Jan 14, 2025 at 8:20 AM Venkata Narayana Sarma Dhavala <
>> dhavala at udel.edu> wrote:
>>
>>> Dear PETSc Development Team,
>>>
>>> I hope this message finds you well. I am currently working with the
>>> VecSetValues() function in PETSc, and I have a question regarding its
>>> behavior when there are duplicate indices in the input array.
>>>
>>> PetscErrorCode VecSetValues(Vec x, PetscInt ni, const PetscInt ix[],
>>> const PetscScalar y[], InsertMode iora)
>>>
>>> Specifically, what is the expected behavior if the ix[] array passed to
>>> VecSetValues() contains duplicate indices? Does the function overwrite the
>>> value at those indices, or does it handle duplicates differently depending
>>> on the insert mode (INSERT_VALUES or ADD_VALUES)?
>>>
>>> I would greatly appreciate any clarification on this matter, as it will
>>> help me better understand how to manage values when working with
>>> potentially repeated indices in the input.
>>>
>>> Thank you for your time and assistance.
>>>
>>> Best regards,
>>>
>>> Narayana Dhavala.
>>>
>>
>
> --
> 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://urldefense.us/v3/__https://www.cse.buffalo.edu/*knepley/__;fg!!G_uCfscf7eWS!Z95-0RaOBkv4OPWEhDVpjsxVHdbBYAaeEveINBQxauPWYvZFu10IaTecVDMfntqt_aYIsy095Bdr3LGU8PE44g8AsyS3$ 
> <https://urldefense.us/v3/__http://www.cse.buffalo.edu/*knepley/__;fg!!G_uCfscf7eWS!ZrWqm3ouVJY_jjPcpNhmzIsTmWA-OY60MzKAlKcDJ5o_jUPAhxhaQ3iueKObVE-ZlFN2Au1qH1z2PiuXkG3q$>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20250114/3527b9ca/attachment.html>


More information about the petsc-users mailing list