<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p>Dear Junchao Zhang</p>
<p><br>
</p>
<p>I'm distributing a set of independent tasks over different processes, so I'm afraid sending everything to the zeroth process would rather thoroughly defeat the purpose of what I'm doing.</p>
<p><br>
</p>
<p>Med venlig hilsen / Best regards</p>
<p>Peder</p>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>Fra:</b> Junchao Zhang <junchao.zhang@gmail.com><br>
<b>Sendt:</b> 30. juni 2021 16:00:25<br>
<b>Til:</b> Peder Jørgensgaard Olesen<br>
<b>Cc:</b> Matthew Knepley; petsc-users@mcs.anl.gov<br>
<b>Emne:</b> Re: [petsc-users] Scatter parallel Vec to sequential Vec on non-zeroth process</font>
<div> </div>
</div>
<div>
<div dir="ltr">That should work. But VecScatterCreateToZero() is more efficient. So if possible, better refactor your code in such a way. 
<div><br clear="all">
<div>
<div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">
<div dir="ltr">--Junchao Zhang</div>
</div>
</div>
</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Wed, Jun 30, 2021 at 7:13 AM Peder Jørgensgaard Olesen via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov">petsc-users@mcs.anl.gov</a>> wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div>
<div id="gmail-m_6232111265244509509divtagdefaultwrapper" style="font-size:12pt;color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif" dir="ltr">
<p>Dear Matt</p>
<p><br>
</p>
<p>Thank you for your reply. I'm guessing that the line</p>
<pre width="80"><font color="#4169E1">if</font> (rank) N = 0;</pre>
should be changed to something like
<p></p>
<p></p>
<pre width="80"><font color="#4169E1">if</font> (rank != target_rank) N = 0;</pre>
such that an empty SEQVEC and scatter are created on each rank other than target_rank.
<p></p>
<p><br>
</p>
<p>Med venlig hilsen / Best regards</p>
<p>Peder</p>
</div>
<hr style="display:inline-block;width:98%">
<div id="gmail-m_6232111265244509509divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>Fra:</b> Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>><br>
<b>Sendt:</b> 30. juni 2021 13:58:49<br>
<b>Til:</b> Peder Jørgensgaard Olesen<br>
<b>Cc:</b> <a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a><br>
<b>Emne:</b> Re: [petsc-users] Scatter parallel Vec to sequential Vec on non-zeroth process</font>
<div> </div>
</div>
<div>
<div dir="ltr">
<div dir="ltr">On Wed, Jun 30, 2021 at 6:49 AM Peder Jørgensgaard Olesen via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a>> wrote:<br>
</div>
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr">
<div id="gmail-m_6232111265244509509gmail-m_-8023515525886516286divtagdefaultwrapper" style="font-size:12pt;color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif" dir="ltr">
<p>Hello</p>
<p><br>
</p>
<p>I have a parallel vector, and I'd like to copy its data to a sequential vector located on a given process that is not necessarily the 0th process, so using VecScatterCreateToZero wouldn't do here.</p>
<p><br>
</p>
<p>How might one approach this?</p>
</div>
</div>
</blockquote>
<div>The function is very short: <a href="https://www.mcs.anl.gov/petsc/petsc-current/src/vec/is/sf/interface/vscat.c.html#VecScatterCreateToZero" target="_blank">https://www.mcs.anl.gov/petsc/petsc-current/src/vec/is/sf/interface/vscat.c.html#VecScatterCreateToZero</a></div>
<div>Just go in and replace '0' by the rank you want.</div>
<div><br>
</div>
<div>  Thanks,</div>
<div><br>
</div>
<div>     Matt </div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr">
<div id="gmail-m_6232111265244509509gmail-m_-8023515525886516286divtagdefaultwrapper" style="font-size:12pt;color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif" dir="ltr">
<div id="gmail-m_6232111265244509509gmail-m_-8023515525886516286Signature">
<div id="gmail-m_6232111265244509509gmail-m_-8023515525886516286divtagdefaultwrapper" dir="ltr" style="font-size:12pt;color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols">
<p>Med venlig hilsen / Best Regards</p>
<p><br>
</p>
<p>Peder Jørgensgaard Olesen</p>
<p><span style="font-size:10pt;color:rgb(117,123,128)">PhD Student, Turbulence Research Lab</span></p>
<p><span style="font-size:10pt;color:rgb(117,123,128)">Dept. of Mechanical Engineering</span></p>
<p><span style="font-size:10pt;color:rgb(117,123,128)">Technical University of Denmark</span></p>
<p><span style="font-size:10pt;color:rgb(117,123,128)">Koppels Allé</span></p>
<p><span style="font-size:10pt;color:rgb(117,123,128)">Bygning 403, Rum 105</span></p>
<p><span style="font-size:10pt;color:rgb(117,123,128)">DK-2800 Kgs. Lyngby</span></p>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br clear="all">
<div><br>
</div>
-- <br>
<div dir="ltr">
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
-- Norbert Wiener</div>
<div><br>
</div>
<div><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</body>
</html>