Ok, so you want the unique list of integers sorted from all the seq vectors
on ever MPI rank?
VecScatterCreateToAll() to get all values on all ranks (make the sequential
vectors MPI vectors instead).
create an integer array long enough to hold all of them
Use VecGetArray() and a for loop to copy all the values to the integer
array,
Use PetscSortRemoveDupsInt on the integer array
Now each rank has all the desired values.
> On Dec 9, 2022, at 3:24 PM, Karthikeyan Chockalingam - STFC UKRI
> <[email protected]> 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 <[email protected] <mailto:[email protected]>>
> Date: Friday, 9 December 2022 at 20:04
> To: Chockalingam, Karthikeyan (STFC,DL,HC)
> <[email protected]
> <mailto:[email protected]>>
> Cc: [email protected] <mailto:[email protected]>
> <[email protected] <mailto:[email protected]>>
> 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 <[email protected] <mailto:[email protected]>> 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.
>