Question on Index Sets and VecScatters
Randall Mackie
randy at geosystem.us
Tue Dec 18 13:43:25 CST 2007
Matt,
Just a quick follow up question. The local vectors created in (1)
are SEQ vectors on PETSC_COMM_SELF. To create the index sets, it
seems like I should just use ISCreateStride, using 0, m for start
and length of the index set. My question is should the communicator
be PETSC_COMM_SELF or PETSC_COMM_WORLD?
Similarly, the index set for the global vector should also be
created with ISCreateStride, using k_0 and m for start and lengths.
Same question about the communicator.
Thanks, Randy
Matthew Knepley wrote:
> You could do it like that, but it seems pretty wasteful, especially in parallel
> where you might be sending a considerable amount of data. Why not do
> something like this:
>
> 1) Average all slabs into a local vector, indexed by the given k value,
> meaning you have a map {k_0, k_1, ..., k_m} --> {0,1, ...,m}.
>
> 2) Now construct a scatter that maps each local vector into a parallel
> vector of all the ks. The IndexSet for the from (local) vector will be
> {0, 1, ..., m} and the IndexSet for the to (global) vector will be
> {k_0, k_1, ... , k_m} on each process.
>
> 3) When you scatter use ADD_VALUES. Then you will have the sum, and
> just scale the vector by the slab size.
>
> Does this makes sense to you?
>
> Thanks,
>
> Matt
>
> On Dec 13, 2007 5:32 PM, Randall Mackie <randy at geosystem.us> wrote:
>> I have a situation where I've put a model vector m(i,j,k) into a parallel
>> PETSc vector for use in my modeling code. However, I'm now adding a bit of code
>> where I want to do some calculations based on the 1D average of the model.
>> In other words, for each k, I want to average m(i,j), and so produce a new
>> model vector m_avg(k).
>>
>> So, to do this, it would seem that I need to create a VecScatter that will,
>> for each layer, scatter all the m(i,j) into a 2D vector, then I can take
>> the average. It would seem that I need to create an Index Set to do this,
>> but I'm a bit confused as to how to go about it actually, since I've never
>> used Index Sets.
>>
>> Can someone outline the basic steps given my description above?
>>
>> Thanks, Randy
>>
>> --
>> Randall Mackie
>> GSY-USA, Inc.
>> PMB# 643
>> 2261 Market St.,
>> San Francisco, CA 94114-1600
>> Tel (415) 469-8649
>> Fax (415) 469-5044
>>
>> California Registered Geophysicist
>> License No. GP 1034
>>
>>
>
>
>
--
Randall Mackie
GSY-USA, Inc.
PMB# 643
2261 Market St.,
San Francisco, CA 94114-1600
Tel (415) 469-8649
Fax (415) 469-5044
California Registered Geophysicist
License No. GP 1034
More information about the petsc-users
mailing list