[petsc-users] VecScatter Question

Mohammad Mirzadeh mirzadeh at gmail.com
Thu Feb 9 18:07:20 CST 2012


Alright just got it :D The IS needs to be build in serial otherwise each
processor only copies the portion it owns!

Thanks,
Mohammad

On Thu, Feb 9, 2012 at 3:52 PM, Mohammad Mirzadeh <mirzadeh at gmail.com>wrote:

> Thanks Satish. That all makes sense.
>
> Truth is I am trying to move data from a parallel vector to a serial one
> on rank 0. I make an index set, in parallel, with stride 1 and use it for
> both source and destination and i believe that should do the job ... but it
> does not. Somehow it seems that the values from other processors do not get
> inserted in the serial vector on rank 0!
>
> This seems it should be so simple and I'm not sure if there is a bug
> somewhere in my code or I'm still confused about IS and VecScatter!
>
> Mohammad
>
>
> On Thu, Feb 9, 2012 at 3:42 PM, Satish Balay <balay at mcs.anl.gov> wrote
>
> On Thu, 9 Feb 2012, Mohammad Mirzadeh wrote:
>>
>> > So this actually means it somehow matches the local indices?
>>
>> Hm - no local indices here.
>>
>> > What i mean by that is,
>> >
>> > y[ iy[i] ] = x[ ix[i] ].
>>
>> Sure - with global indices.
>>
>> >
>> > Is that why ix and iy should have the same size?
>>
>> When you specify data movement - you specify both source and
>> destination for each element that is to be moved. If you are moving n
>> elements - you have n sources, and n destination values - hence ix[n],
>> iy[n]
>>
>> Satish
>>
>> >
>> > Mohammad
>> >
>> > On Thu, Feb 9, 2012 at 3:17 PM, Satish Balay <balay at mcs.anl.gov> wrote:
>> >
>> > > On Thu, 9 Feb 2012, Mohammad Mirzadeh wrote:
>> > >
>> > > > Hi guys,
>> > > >
>> > > > I'm just wondering if I understand how the VecScatter works.
>> Considering
>> > > > (petsc 3.2-p6 manual page 53):
>> > > >
>> > > > VecScatterCreate(Vec x,IS ix,Vec y,IS iy,VecScatter *ctx);
>> > > > VecScatterBegin(VecScatter ctx,Vec x,Vec y,INSERT VALUES,SCATTER
>> > > FORWARD);
>> > > > VecScatterEnd(VecScatter ctx,Vec x,Vec y,INSERT VALUES,SCATTER
>> FORWARD);
>> > > > VecScatterDestroy(VecScatter *ctx);
>> > > >
>> > > > is the following statement correct?
>> > > >
>> > > > VecScatter looks into "ix" and "iy" index sets and `matches' the
>> global
>> > > > indecies between the two to copy data from vector "x" to vector
>> "y". For
>> > > > example, if "ix" maps local index "1" to global index "10",
>> VecScatter
>> > > > looks inside "iy" to find a local index that is mapped to global
>> index
>> > > "10"
>> > > > and sends the data accordingly to the correct processor.
>> > >
>> > > nope - it means - if you have x[10],y[10]:
>> > >
>> > > ix = {1,5,9}
>> > > iy = {0,2,1}
>> > >
>> > >
>> > > Then you get:
>> > > y[0] = x[1]
>> > > y[2] = x[5]
>> > > y[1] = x[9]
>> > >
>> > > [all numbers above are global indices]
>> > >
>> > > Satish
>> > >
>> > > >
>> > > > Thanks,
>> > > > Mohammad
>> > > >
>> > >
>> > >
>> >
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20120209/29101fbf/attachment.htm>


More information about the petsc-users mailing list