<div dir="ltr"><div dir="ltr">On Wed, Dec 6, 2023 at 5:54 PM Colton Bryant <<a href="mailto:coltonbryant2021@u.northwestern.edu">coltonbryant2021@u.northwestern.edu</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>Hello,</div><div><br></div><div>I am working on a code in which a DMSTAG object is used to solve a fluid flow problem and I need to gather this flow data on a single process to interact with an existing (serial) library at each timestep of my simulation. After looking around the solution I've tried is:</div><div><br></div><div>-use DMStagVecSplitToDMDA to extract vectors of each component of the flow</div><div>-use DMDACreateNaturalVector and DMDAGlobalToNatural to get the components naturally ordered</div><div>-use VecScatterCreateToZero to set up and then do the scatter to gather on the single process</div><div><br></div><div>Unless I'm misunderstanding something this method results in a lot of memory allocation/freeing happening at each step of the evolution and I was wondering if there is a way to directly perform such a scatter from the DMSTAG object without splitting as I'm doing here.</div></div></blockquote><div><br></div><div>1) You can see here:</div><div><br></div><div><a href="https://petsc.org/main/src/dm/impls/stag/stagda.c.html#DMStagVecSplitToDMDA">https://petsc.org/main/src/dm/impls/stag/stagda.c.html#DMStagVecSplitToDMDA</a></div><div><br></div><div>that this function is small. You can do the DMDA creation manually, and then just call <span style="color:rgb(0,0,0)">DMStagMigrateVecDMDA() each time, which will not create anything.</span></div><div><span style="color:rgb(0,0,0)"><br></span></div><div><span style="color:rgb(0,0,0)">2) You can create the natural vector upfront, and just scatter each time.</span></div><div><span style="color:rgb(0,0,0)"><br></span></div><div><span style="color:rgb(0,0,0)">3) You can create the serial vector upfront, and just scatter each time.</span></div><div><span style="color:rgb(0,0,0)"><br></span></div><div><span style="color:rgb(0,0,0)">This is some data movement. You can compress the g2n and 2zero scatters using</span></div><div><span style="color:rgb(0,0,0)"><br></span></div><div><span style="color:rgb(0,0,0)"> </span><a href="https://petsc.org/main/manualpages/PetscSF/PetscSFCompose/">https://petsc.org/main/manualpages/PetscSF/PetscSFCompose/</a></div><div><br></div><div>as an optimization.</div><div><br></div><div> Thanks,</div><div><br></div><div> Matt</div><div> </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>Any advice would be much appreciated!</div><div><br></div><div>Best,</div><div>Colton Bryant <br></div></div>
</blockquote></div><br clear="all"><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><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>