<br><br>On Wednesday, 4 February 2015, bichinhoverde <<a href="mailto:bichinhoverde@spwinternet.com.br">bichinhoverde@spwinternet.com.br</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Ok, but from a PETSc user perspective, what is the difference between create and get?</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">When should I use get and when should I use create?</div></div></blockquote><div><br></div><div>It's a memory saving optimization.</div><div>It's a cache of vectors you can use. It's clever as it lets you reuse data rather always create/destroying objects.</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Can I call create several times to create several vectors? Is it the same as creating one and then duplicating?</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div></div></blockquote><div>Yes to both</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Can I call get several times to get several vectors? Is it the same as getting one and then duplicating?</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div></div></blockquote><div><br></div><div>Functionally, both approaches are equivalent. However duplicating always allocated new memory thus the total memory footprint will increase.</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">If I replace all gets with creates, or all creates with gets in my code, what will change?</div></div></blockquote><div><br></div><div>If you change all creates to gets, probably the most notable difference would be the memory usage. <font><span style="background-color:rgba(255,255,255,0)"> Plus whatever extra time is required for creating which isn't incurred when you re use vectors.</span></font></div><div><br></div><div>Note that the DMGetVec will NOT initialize the entries to zero (unlike the Create variants). The user is responsible for that task.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Feb 4, 2015 at 5:16 AM, Jed Brown <span dir="ltr"><<a href="javascript:_e(%7B%7D,'cvml','jed@jedbrown.org');" target="_blank">jed@jedbrown.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">bichinhoverde <<a href="javascript:_e(%7B%7D,'cvml','bichinhoverde@spwinternet.com.br');" target="_blank">bichinhoverde@spwinternet.com.br</a>> writes:<br>
<br>
> Hi. I have some questions.<br>
><br>
> What is the difference between DMCreateGlobalVector and DMGetGlobalVector<br>
> (and the local counterparts)?<br>
<br>
Create creates a vector that the caller owns.  Get merely gets access to<br>
a vector from a managed pool (creating it if necessary), to be returned<br>
via DMRestoreGlobalVector().<br>
<br>
> What happens when one calls SNESSolve with NULL for the solution vector, as<br>
> in src/snes/examples/tutorials/ex7.c:158? SNESSolve(snes,NULL,NULL);<br>
<br>
A vector is created automatically.  You can get access to it with<br>
SNESGetSolution.<br>
</blockquote></div><br></div></div>
</blockquote>