[petsc-users] Insertion mode for Scatter

SCOTTO Alexandre alexandre.scotto at irt-saintexupery.com
Fri Jun 13 04:32:40 CDT 2025


Dear PETSc community,

I am currently struggling with the ADD_VALUE mode of the Scatter object. Here is a simple piece of (Python) code to illustrate the issue:

vec_1 = PETSc.Vec().createMPI(size=10)
vec_1.shift(2.0)

vec_2 = PETSc.Vec().createMPI(size=10)
vec_2.shift(1.0)

index_set = PETSc.IS().createStride(10, step=1)

scatter = PETSc.Scatter().create(vec_1, index_set, vec_2, index_set)
scatter.scatter(vec_1, vec_2, addv=True)

Vectors vec_1 and vec_2 are respectively filled-in with 2.0 and 1.0. After the scattering, I would expect to have in vec_2 the sum of the values initially in vec_2 (that is  1.0) plus the values coming from vec_1 (that is 2.0).

But instead of having vec_2 filled in with 3.0 it is filled-in with 9.0. My understanding is that the number of processes (here 4 processes) plays a role since 9.0 = 1.0 (initial value) + 2.0 (values coming from vec_1) x 4 (number of processes).

Is there a way to have simply 3.0 as a result?

Hoping to have been clear enough, best regards,
Alexandre.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20250613/62bc87a2/attachment.html>


More information about the petsc-users mailing list