Question on Index Sets and VecScatters

Matthew Knepley knepley at gmail.com
Thu Dec 13 17:46:39 CST 2007


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
>
>



-- 
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




More information about the petsc-users mailing list