<div dir="ltr">Thanks Barry -- this solved the issue. <div><br></div><div>"probably will be fine" was fine with 3.17 and maybe 3.19, but definitely not fine with 3.20. </div><div><br></div><div>For others the faulty logic is:</div><div><br></div><div>GetArray(dn_local, &dn) //WRONG</div><div>Loop over cases </div><div> VecSet(dn_local, 0.)</div><div> Fill up dn </div><div> LocalToGlobal</div><div>RestoreArray</div><div><br></div><div>Where as one should do: </div><div><div><br></div><div>Loop over cases </div><div> VecSet(dn_local, 0.)</div><div> GetArray(dn_local, &dn) // RIGHT</div><div> Fill up dn </div><div> LocalToGlobal</div><div> RestoreArray</div><div><br></div></div><div>So, while nothing is copied, if I think of dn as a copy (and not a view) the logic will always be correct. </div><div><br></div><div>Now I have a related question about "Technically you should not be calling VecSet() with any outstanding arrays but it will probably be fine."</div><div>What about GlobalToLocal? should I always GetArray for the local array after the GlobalToLocal</div><div><br></div><div>So, is this also bad logic:</div><div><br></div><div>GetArray(n_local, &n) </div><div>Loop over cases:</div><div> GlobalToLocal(n_global, &n_local)</div><div> do stuff with n</div><div> LocalToGlobal(n_local, n_global)</div><div> RestoreArray</div><div><br></div><div>as opposed to</div><div><br></div><div><div>Loop over cases:</div><div> GlobalToLocal(n_global, &n_local)</div><div> GetArray(n_local, &n) </div><div> do stuff with n</div><div> LocalToGlobal(n_local, n_global)</div><div> RestoreArray</div></div><div><br></div><div>Thanks again for all your help,</div><div><br></div><div>Derek</div><div><br></div><div><br></div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Fri, Apr 25, 2025 at 5:30 PM Barry Smith <<a href="mailto:bsmith@petsc.dev">bsmith@petsc.dev</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div style="line-break:after-white-space"><div><br></div> Technically you should not be calling VecSet() with any outstanding arrays but it will probably be fine.<div><br></div><div> Even though GetArray() does not copy the array values; both GetArray/RestoreArray and Set track the current "state" of the vector and that count might get confused if they are used improperly.</div><div><br></div><div><br id="m_-7042047038681105189lineBreakAtBeginningOfMessage"><div><br><blockquote type="cite"><div>On Apr 25, 2025, at 4:42 PM, Derek Teaney <<a href="mailto:derek.teaney@stonybrook.edu" target="_blank">derek.teaney@stonybrook.edu</a>> wrote:</div><br><div><div dir="ltr">Thanks, I am working on providing a standalone code. A related question is - if I did have a view of a local vector provided by:<div><br></div><div>data_node ***dn_array;<br></div><div>DMDAVecGetArray(domain, dn_local, &dn_array);<br><br></div><div>Can I assume through multiple calls to VecSet that the view dn_array is valid, or should this be restored, between calls.</div><div><br></div><div>Thanks, </div><div><br></div><div>Derek</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Apr 25, 2025 at 1:26 PM Barry Smith <<a href="mailto:bsmith@petsc.dev" target="_blank">bsmith@petsc.dev</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div style="line-break:after-white-space"> <div> You absolutely should not need to do an assembly after a VecSet. Please post a full reproducer that demonstrates the problem.</div><div><br></div><div> Barry</div><div><br id="m_-7042047038681105189m_2436412066008797061lineBreakAtBeginningOfMessage"><div><br><blockquote type="cite"><div>On Apr 25, 2025, at 1:23 PM, Derek Teaney via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a>> wrote:</div><br><div><div dir="ltr"><div>Hi, </div><div><br></div><div>I was under the (mistaken) impression that one does not need to due a VecAssemblyBegin etc following a VecSet, e.g. </div><div><br></div><div> VecSet(dn_local, 0.);<br> VecAssemblyBegin(dn_local) ;<br> VecAssemblyEnd(dn_local) ;<br></div><div><br></div><div>Seems to give different results without the Assembly. </div><div><br></div><div>Thanks for clarifying, </div><div><br></div><div>Derek</div><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr"><span style="font-family:Helvetica;font-size:12px">------------------------------------------------------------------------</span><br style="font-family:Helvetica;font-size:12px"><span style="font-family:Helvetica;font-size:12px"><font>Derek Teaney</font></span><div><font>Professor and Graduate Program Director<br style="font-family:Helvetica;font-size:12px"><span style="font-family:Helvetica;font-size:12px">Dept. of Physics & Astronomy</span><br style="font-family:Helvetica;font-size:12px"><span style="font-family:Helvetica;font-size:12px">Stony Brook University</span><br style="font-family:Helvetica;font-size:12px"><span style="font-family:Helvetica;font-size:12px">Stony Brook, NY 11794-3800</span><br style="font-family:Helvetica;font-size:12px"><span style="font-family:Helvetica;font-size:12px">Tel: (631) 632-4489</span><br style="font-family:Helvetica;font-size:12px"><span style="font-family:Helvetica;font-size:12px">Fax: (631) 632-9718</span></font><br style="font-family:Helvetica;font-size:12px"><span style="font-family:Helvetica;font-size:12px">e-mail: <a href="mailto:Derek.Teaney@stonybrook.edu" target="_blank">Derek.Teaney@stonybrook.edu</a></span><br style="font-family:Helvetica;font-size:12px"><span style="font-family:Helvetica;font-size:12px">------------------------------------------------------------------------</span><br style="font-family:Helvetica;font-size:12px"><div><span style="font-family:Helvetica;font-size:12px"><br></span></div></div></div></div></div>
</div></blockquote></div><br></div></div></blockquote></div><div><br clear="all"></div><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr"><span style="font-family:Helvetica;font-size:12px">------------------------------------------------------------------------</span><br style="font-family:Helvetica;font-size:12px"><span style="font-family:Helvetica;font-size:12px"><font>Derek Teaney</font></span><div><font>Professor and Graduate Program Director<br style="font-family:Helvetica;font-size:12px"><span style="font-family:Helvetica;font-size:12px">Dept. of Physics & Astronomy</span><br style="font-family:Helvetica;font-size:12px"><span style="font-family:Helvetica;font-size:12px">Stony Brook University</span><br style="font-family:Helvetica;font-size:12px"><span style="font-family:Helvetica;font-size:12px">Stony Brook, NY 11794-3800</span><br style="font-family:Helvetica;font-size:12px"><span style="font-family:Helvetica;font-size:12px">Tel: (631) 632-4489</span><br style="font-family:Helvetica;font-size:12px"><span style="font-family:Helvetica;font-size:12px">Fax: (631) 632-9718</span></font><br style="font-family:Helvetica;font-size:12px"><span style="font-family:Helvetica;font-size:12px">e-mail: <a href="mailto:Derek.Teaney@stonybrook.edu" target="_blank">Derek.Teaney@stonybrook.edu</a></span><br style="font-family:Helvetica;font-size:12px"><span style="font-family:Helvetica;font-size:12px">------------------------------------------------------------------------</span><br style="font-family:Helvetica;font-size:12px"><div><span style="font-family:Helvetica;font-size:12px"><br></span></div></div></div></div>
</div></blockquote></div><br></div></div></blockquote></div><div><br clear="all"></div><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr"><span style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px">------------------------------------------------------------------------</span><br style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px"><span style="font-family:Helvetica;font-size:12px"><font color="#000000">Derek Teaney</font></span><div><font color="#000000">Professor and Graduate Program Director<br style="font-family:Helvetica;font-size:12px"><span style="font-family:Helvetica;font-size:12px">Dept. of Physics & Astronomy</span><br style="font-family:Helvetica;font-size:12px"><span style="font-family:Helvetica;font-size:12px">Stony Brook University</span><br style="font-family:Helvetica;font-size:12px"><span style="font-family:Helvetica;font-size:12px">Stony Brook, NY 11794-3800</span><br style="font-family:Helvetica;font-size:12px"><span style="font-family:Helvetica;font-size:12px">Tel: (631) 632-4489</span><br style="font-family:Helvetica;font-size:12px"><span style="font-family:Helvetica;font-size:12px">Fax: (631) 632-9718</span></font><br style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px"><span style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px">e-mail: <a href="mailto:Derek.Teaney@stonybrook.edu" target="_blank">Derek.Teaney@stonybrook.edu</a></span><br style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px"><span style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px">------------------------------------------------------------------------</span><br style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px"><div><span style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px"><br></span></div></div></div></div>