[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Question on Index Sets and VecScatters
- To: petsc-users@xxxxxxxxxxx
- Subject: Re: Question on Index Sets and VecScatters
- From: "Matthew Knepley" <knepley@xxxxxxxxx>
- Date: Thu, 13 Dec 2007 17:46:39 -0600
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=1ISkF3ZenXbkNFxd/WUwJmJ6ToLuRFKUkR0mI6YkMck=; b=QqW8SGtKhOECqYLkiYqm2dFyVm/YbsC3jcwCg25ZQxs3TZPfQW+Vsug4q9EpDbv6G/+ah8aRadtBbKaY+nd2N0rRn26aEzAXL1AF2Prn4jode4BK77iHZJn6zMyeuW/8Sa8kLQBFxZLpKnW0LG8bdvXjKNPU10HtjCyjmJRoc/I=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=q6GR9s9/3yt1M0hVIDmd+mM1QkFG5UKLSyZ34vMG7Bb7oxYt/T2gvPV0TwH8ehbu6uzFNd3KeNkj47IzKk/W73MU8jx4WPHApW1lSysSidnMv/FVKGfyyYtspWsN1/V437mVCsvbZhOxwKuC4DBi72YXPSpuGIrQIAHvC+5rF04=
- In-reply-to: <4761C0F0.1070700@geosystem.us>
- References: <4761C0F0.1070700@geosystem.us>
- Reply-to: petsc-users@xxxxxxxxxxx
- Sender: owner-petsc-users@xxxxxxxxxxx
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@xxxxxxxxxxxx> 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