<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Tue, 25 Sep 2018 at 13:31, Phil Tooley <<a href="mailto:phil.tooley@sheffield.ac.uk">phil.tooley@sheffield.ac.uk</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div text="#000000" bgcolor="#FFFFFF">
<p>Thanks both,</p>
<p>I now have what I need. For now I am checking that the vector I
am passed has the same local size, global size, and Comm as the
vector provided by DMGetLocalVector, mostly because I already have
a compatibility check function written. (I assume this requires a
malloc and free behind the scenes)<br></p></div></blockquote><div><br></div><div>Not necessarily. The Get/Restore strategy will re-use internally cached vectors.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div text="#000000" bgcolor="#FFFFFF"><p>
</p>
<p>At some point I will likely change to explicitly checking for
comm size of one and appropriate global and local sizes based on
the DMDA properties instead, for now I want to get to an alpha
version I can let people play with.<br>
</p>
<p>Phil<br>
</p>
<br>
<div class="m_5940114058665628236moz-cite-prefix">On 25/09/18 13:07, Dave May wrote:<br>
</div>
<blockquote type="cite">
<div><br>
</div>
<div><br>
<div class="gmail_quote">
<div dir="ltr">On Tue, 25 Sep 2018 at 13:20, Matthew Knepley
<<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>> wrote:<br>
</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_quote">
<div dir="ltr">On Tue, Sep 25, 2018 at 7:03 AM Dave May
<<a href="mailto:dave.mayhem23@gmail.com" target="_blank">dave.mayhem23@gmail.com</a>>
wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div class="gmail_quote">
<div dir="ltr">On Tue, 25 Sep 2018 at 11:49,
Phil Tooley <<a href="mailto:phil.tooley@sheffield.ac.uk" target="_blank">phil.tooley@sheffield.ac.uk</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">Hi all,<br>
<br>
Given a vector I know I can get an
associated DM (if there is one) by<br>
calling VecGetDM, but I need to also be
able to check that<br>
<br>
a) the vector is the localvector of that
DM rather than the global<br>
</blockquote>
<div><br>
</div>
<div>Given the vector, you can check the
communicator size via</div>
<div>PetscObjectGetComm()</div>
<div><br>
</div>
<div> <a href="https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Sys/PetscObjectGetComm.html" target="_blank">https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Sys/PetscObjectGetComm.html</a><br>
</div>
<div>and then MPI_Comm_size()</div>
<div>If the comm size 1, it is local vector.</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
<div><br>
</div>
<div>In serial, both vectors have comm size 1.</div>
</div>
</div>
</blockquote>
<div dir="auto"><br>
</div>
<div dir="auto">Right - and the local and global sizes are the
same.</div>
<div dir="auto"><br>
</div>
<div dir="auto"> My point was to check the comm size first. If
it's 1 then you have a candidate for a local vector. Then
you'd check the vec global size matches the dmda local size.
If the commsize is anything other than 1 then it cannot be a
local vector </div>
<div dir="auto"><br>
</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_quote">
<div><br>
</div>
<div> Matt</div>
</div>
</div>
<div dir="ltr">
<div class="gmail_quote">
<div> </div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div class="gmail_quote">
<div>You can check the size matches your
local DMDA space by using
DMDAGetGhostCorners()</div>
<div><br>
</div>
<div><a href="https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/DMDA/DMDAGetGhostCorners.html" target="_blank">https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/DMDA/DMDAGetGhostCorners.html</a><br>
</div>
<div><br>
</div>
<div>and return the quantities m, n, and p.</div>
<div><br>
</div>
<div>You also need to use DMDAGetInfo()</div>
<div><br>
</div>
<div><a href="https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/DMDA/DMDAGetInfo.html" target="_blank">https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/DMDA/DMDAGetInfo.html</a><br>
</div>
<div><br>
</div>
<div>The important quantity you want
returned is "dof"</div>
<div><br>
</div>
<div>If m x n x p x dof matches the number
returned by VecGetSize() (assuming you
know the vector is sequential) then you
know the local space will fit within your
vector.</div>
<div><br>
</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">
<br>
b) the DM is a DMDA rather than some other
subclass<br>
</blockquote>
<div><br>
</div>
<div>See Matt's answer </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">
<br>
I can't immediately see routines that do
what I need, but I am likely<br>
missing something obvious. Is there a way
to achieve the above?<br>
<br>
Thanks<br>
<br>
Phil<br>
<br>
-- <br>
Phil Tooley<br>
Research Software Engineering<br>
University of Sheffield<br>
<br>
</blockquote>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br clear="all">
<div><br>
</div>
-- <br>
<div dir="ltr" class="m_5940114058665628236m_6062776036647647821gmail_signature" data-smartmail="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/%7Eknepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</blockquote>
<br>
<pre class="m_5940114058665628236moz-signature" cols="72">--
Phil Tooley
Research Software Engineering
University of Sheffield</pre>
</div>
</blockquote></div></div>