<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<span style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt">Hi,</span><br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
<div style="background-color: rgb(255, 255, 255); color: rgb(0, 0, 0);"><font face="Calibri, Arial, Helvetica, sans-serif"><span style="font-size:12pt">I need to compute the permutations to sort scalar values of a Vec object in decreasing order. I've been
</span>developing<span style="font-size:12pt"> on a single process for now, using
</span></font><span style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt">VecGetArrayRead</span><span style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt">() to extract the values and PetscSortRealWithPermutation() to get
the permutations.</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
I would like to run the code on multiple processes. From these links, I can see it's an issue : </div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<a href="https://lists.mcs.anl.gov/pipermail/petsc-users/2013-November/019628.html">https://lists.mcs.anl.gov/pipermail/petsc-users/2013-November/019628.html</a><br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<a href="https://lists.mcs.anl.gov/pipermail/petsc-users/2009-June/004621.html">https://lists.mcs.anl.gov/pipermail/petsc-users/2009-June/004621.html</a></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
One work around I've been considering : get the max scalar value using VecMax() ; compute a scaling factor that makes this max value equals the largest integer value tolerated by PetscInt ; scale all values of Vec and convert them to integers ; use PetscParallelSortInt()
; inverse the scaling on (now sorted) integers values and convert them back to scalars.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
This is only a patch really, the main issues being : <span style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt">(1) I would get a sorted Vec, not the permutations and (2) there would be a lost of information when converting scalars to int
values.</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<span style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt"><br>
</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<span style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt">Isn't there a way to parallel sort real values using Petsc?<br>
</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<span style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt"><br>
</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<span style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt">Thank you very much!</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<span style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt"><br>
</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<span style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt">Antoine Côté</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
</body>
</html>