[petsc-users] Union of sequential vecs

Mark Adams mfadams at lbl.gov
Fri Dec 9 15:08:06 CST 2022


If your space is pretty compact, eg, (0,12), you could create an MPI vector
Q of size 13, say, and each processor can add 1.0 to Q[Vec[i]], for all "i"
in my local "Vec".
Then each processor can count the number of local nonzeros in Q, call it n,
create a new vector, R, with local size n, then set R[i] = global index of
the nonzero for each nonzero in Q, i=0:n.
Do some sort of vec-scatter-to-all with R to get what you want.

Does that work?

Mark


On Fri, Dec 9, 2022 at 3:25 PM Karthikeyan Chockalingam - STFC UKRI via
petsc-users <petsc-users at mcs.anl.gov> wrote:

> That is where I am stuck, *I don’t know* who to combine them to get Vec =
> {2,5,7,8,10,11,12}.
>
> I just want them in an MPI vector.
>
>
>
> I finally plan to call VecScatterCreateToAll so that all processor gets a
> copy.
>
>
>
> Thank you.
>
>
>
> Kind regards,
>
> Karthik.
>
>
>
> *From: *Barry Smith <bsmith at petsc.dev>
> *Date: *Friday, 9 December 2022 at 20:04
> *To: *Chockalingam, Karthikeyan (STFC,DL,HC) <
> karthikeyan.chockalingam at stfc.ac.uk>
> *Cc: *petsc-users at mcs.anl.gov <petsc-users at mcs.anl.gov>
> *Subject: *Re: [petsc-users] Union of sequential vecs
>
>
>
>   How are you combining them to get Vec = {2,5,7,8,10,11,12}?
>
>
>
>   Do you want the values to remain on the same MPI rank as before, just in
> an MPI vector?
>
>
>
>
>
>
>
> On Dec 9, 2022, at 2:28 PM, Karthikeyan Chockalingam - STFC UKRI via
> petsc-users <petsc-users at mcs.anl.gov> wrote:
>
>
>
> Hi,
>
>
>
> I want to take the union of a set of sequential vectors, each living in a
> different processor.
>
>
>
> Say,
>
> Vec_Seq1 = {2,5,7}
>
> Vec_Seq2 = {5,8,10,11}
>
> Vec_Seq3 = {5,2,12}.
>
>
>
> Finally, get the union of all them Vec = {2,5,7,8,10,11,12}.
>
>
>
> I initially wanted to create a parallel vector and insert the (sequential
> vector) values but I do not know, to which index to insert the values to.
> But I do know the total size of Vec (which in this case is 7).
>
>
>
> Any help is much appreciated.
>
>
>
> Kind regards,
>
> Karthik.
>
>
>
>
>
>
>
> This email and any attachments are intended solely for the use of the
> named recipients. If you are not the intended recipient you must not use,
> disclose, copy or distribute this email or any of its attachments and
> should notify the sender immediately and delete this email from your
> system. UK Research and Innovation (UKRI) has taken every reasonable
> precaution to minimise risk of this email or any attachments containing
> viruses or malware but the recipient should carry out its own virus and
> malware checks before opening the attachments. UKRI does not accept any
> liability for any losses or damages which the recipient may sustain due to
> presence of any viruses.
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20221209/96925684/attachment.html>


More information about the petsc-users mailing list