<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On 12 May 2016 at 10:42, Sean Dettrick <span dir="ltr"><<a href="mailto:sdettrick@trialphaenergy.com" target="_blank">sdettrick@trialphaenergy.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

                
        <div style="word-wrap:break-word"><div style="color:rgb(0,0,0);font-family:Calibri,sans-serif;font-size:14px">Hi,</div><div style="color:rgb(0,0,0);font-family:Calibri,sans-serif;font-size:14px"><br></div><div><font face="Calibri,sans-serif">When discussing DMDAVecGetArrayDOF etc in section 2.4.4,  the PETSc 3.7 manual says "</font><span style="color:rgb(0,0,0);font-family:NimbusRomNo9L;font-size:11pt">The </span><span style="color:rgb(0,0,0);font-family:NimbusMonL;font-size:11pt">array </span><span style="color:rgb(0,0,0);font-family:NimbusRomNo9L;font-size:11pt">is accessed using the usual </span><span style="color:rgb(0,0,0);font-family:NimbusRomNo9L;font-size:11pt">global </span><span style="color:rgb(0,0,0);font-family:NimbusRomNo9L;font-size:11pt">indexing on the entire grid,
but the user may </span><span style="color:rgb(0,0,0);font-family:NimbusRomNo9L;font-size:11pt">only </span><font face="NimbusRomNo9L" size="3">refer to the local and ghost entries of this array as all other entries are undefined</font><font face="NimbusRomNo9L"><span style="font-size:15px">”</span></font><font face="NimbusRomNo9L" size="3">.</font></div><div><font face="NimbusRomNo9L" size="3"><br></font></div><div><font face="NimbusRomNo9L" size="3">OK so far.  But how to access the ghost entries?</font></div><div><font face="NimbusRomNo9L" size="3"><br></font></div><div>With a 2D DMDA, I can do this OK:</div><div><p style="margin:0px;font-size:11px;font-family:Menlo"><br></p><p style="margin:0px;font-size:11px;font-family:Menlo">        <span style="color:rgb(53,163,39)">PetscInt</span>    <span style="color:rgb(199,156,36)">xs</span>,<span style="color:rgb(199,156,36)">xm</span>,<span style="color:rgb(199,156,36)">ys</span>,<span style="color:rgb(199,156,36)">ym</span>;</p>
<p style="margin:0px;font-size:11px;font-family:Menlo">        ierr=DMDAGetCorners(da,&xs,&ys,0,&xm,&ym,0);CHKERRQ(ierr);</p>
<p style="margin:0px;font-size:11px;font-family:Menlo">        <span style="color:rgb(53,163,39)">PetscScalar</span> ***<span style="color:rgb(199,156,36)">es</span>;</p>
<p style="margin:0px;font-size:11px;font-family:Menlo">        ierr=DMDAVecGetArrayDOF(da,Es,&es);CHKERRQ(ierr);</p>
<p style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"><br></p>
<p style="margin:0px;font-size:11px;font-family:Menlo">        <span style="color:rgb(208,60,255)">for</span> (<span style="color:rgb(53,163,39)">int</span> <span style="color:rgb(199,156,36)">j</span>=ys; j < ys+ym; j++) {</p>
<p style="margin:0px;font-size:11px;font-family:Menlo">            <span style="color:rgb(208,60,255)">for</span> (<span style="color:rgb(53,163,39)">int</span> <span style="color:rgb(199,156,36)">i</span>=xs; i < xs+xm;i++) {</p>
<p style="margin:0px;font-size:11px;font-family:Menlo"><span style="white-space:pre-wrap">              </span>es[j][i][0]=1.;</p>
<p style="margin:0px;font-size:11px;font-family:Menlo">                es[j][i][1]=1.;</p>
<p style="margin:0px;font-size:11px;font-family:Menlo">            }</p>
<p style="margin:0px;font-size:11px;font-family:Menlo">        }</p>
<p style="margin:0px;font-size:11px;font-family:Menlo">        ierr=DMDAVecRestoreArrayDOF(da,Es,&es);CHKERRQ(ierr);</p></div><div><br></div><div>But if I replace DMDAGetCorners with DMDAGetGhostCorners, then the code crashes with a seg fault, presumably due to out of bounds memory access.</div><div><br></div><div>Is that supposed to happen?  </div></div></blockquote><div><br></div><div><font face="arial, helvetica, sans-serif">If you created the vector Es using the function DM{Get,Create}GlobalVector(), then the answer is yes.</font></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div style="word-wrap:break-word"><div>What’s the remedy?</div></div></blockquote><div><br></div><div>If you want to access the ghost entries, you need to create the vector using the function DM{Get,Create}LocalVector().</div><div><br></div><div>Thanks,</div><div>  Dave</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div style="word-wrap:break-word"><div><br></div><div>Thanks very much!</div><span class=""><font color="#888888"><div><br></div><div>Sean Dettrick</div>
                
        
        
                <div title="Page 52" style="color:rgb(0,0,0);font-family:Calibri,sans-serif;font-size:14px">
                        <div>
                                <div>
                                        <div><div><div><br></div></div></div></div></div></div></font></span></div>
</blockquote></div><br></div></div>