<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Yes you are correct I am sorry about that. I meant DMGetLocalVector, and the ilk. <div><br></div><div>here is a dummy function I am working on to try to figure out what is going wrong:</div><div><div style="margin: 0px; font-size: 11px; font-family: Menlo; color: rgb(0, 132, 0);"><span style="color: #000000">  </span>/////////////////////////////////////////////</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; color: rgb(0, 132, 0);"><span style="color: #000000">  </span>//    Get the information to operate on</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; color: rgb(0, 132, 0);"><span style="color: #000000">  </span>// Make Local Versions</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">  Vec             XLoc;</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">  DM              Xdm;</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">  PetscSection    XSec;</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">  PetscReal *XPoints=<span style="color: #bb2ca2">NULL</span>;</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; min-height: 13px;"><br></div><div style="margin: 0px; font-size: 11px; font-family: Menlo; color: rgb(0, 132, 0);">  PetscErrorCode    ierr;</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; min-height: 13px;"><br></div><div style="margin: 0px; font-size: 11px; font-family: Menlo; color: rgb(0, 132, 0);"><br></div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">  ierr = DMGetLocalVector(msh.dm,&XLoc);chk;</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; min-height: 13px;"><br></div><div style="margin: 0px; font-size: 11px; font-family: Menlo; min-height: 13px;"><br></div><div style="margin: 0px; font-size: 11px; font-family: Menlo; min-height: 13px;"><br></div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">  ierr = DMGetCoordinateDM(msh.dm,&Xdm);chk;</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">  ierr = DMGetCoordinatesLocal(msh.dm, &XLoc);chk;</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">  VecView(XLoc,pview);</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><br></div><div style="margin: 0px; font-size: 11px; font-family: Menlo; color: rgb(0, 132, 0);">  ierr = DMDAVecGetArrayRead(Xdm,XLoc,&XPoints);chk;</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; min-height: 13px;"><br></div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">  ierr = DMDAVecRestoreArrayRead(Xdm,XLoc,&XPoints);chk;</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; min-height: 13px;"><br></div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">  ierr = DMRestoreLocalVector(Xdm,&XLoc);chk;</div></div><div><br></div><div>//////////// end of function </div><div><br></div><div>the error I get that seems to appear after the 2nd call or so is:</div><div><div>0]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------</div><div>[0]PETSC ERROR: Invalid argument</div><div>[0]PETSC ERROR: Wrong type of object: Parameter # 2</div><div>[0]PETSC ERROR: See <a href="http://www.mcs.anl.gov/petsc/documentation/faq.html">http://www.mcs.anl.gov/petsc/documentation/faq.html</a> for trouble shooting.</div><div>[0]PETSC ERROR: Petsc Release Version 3.6.1, Jul, 22, 2015</div><div>[0]PETSC ERROR: ./net.out on a arch-darwin-c-debug named Matthews-MacBook-Pro-2.local by mkury Sat Apr 16 01:33:34 2016</div><div>[0]PETSC ERROR: Configure options --with-cc=gcc --with-cxx=g++ --with-fc=gfortran --download-fblaslapack --download-mpich --download-petsc4py --download-triangle --download-chaco --download-metis --download-parmetis --download-ctetgen</div><div>[0]PETSC ERROR: #2294 DMDAVecGetArrayRead() line 299 in /usr/local/petsc-3.6.1/src/dm/impls/da/dagetarray.c</div><div>[0]PETSC ERROR: #2295 Element_Investigation_TEST() line 248 in /Users/mkury/Documents/Code/petFEM/src/elementFunctions.c</div></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div>thanks again, </div><div><br></div><div>Matt<br><div><div>On Apr 16, 2016, at 1:21 AM, Jed Brown <<a href="mailto:jed@jedbrown.org">jed@jedbrown.org</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Matthew Kury <<a href="mailto:mkury@berkeley.edu">mkury@berkeley.edu</a>> writes:<br><br><blockquote type="cite">Hello, <br><br><span class="Apple-tab-span" style="white-space:pre">  </span>I have done some reading and I have not been able to find out what the proper way to create and use vectors within a function.<br><br><span class="Apple-tab-span" style="white-space:pre">  </span>If I have a function that passes in dm and V then: <br>+++<br><span class="Apple-tab-span" style="white-space:pre">  </span><span class="Apple-tab-span" style="white-space:pre">    </span>DMPlexGetLocalVec(dm, &VLocal) ;<br></blockquote><br>This function doesn't exist, and neither does DMPlexCreateLocalVec (from<br>the subject of your email), but when I gaze into my crystal ball, it<br>says you're probably spelling it DMGetLocalVector.  Please send the full<br>error message.<br><br><blockquote type="cite"><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">    </span>DMGlobalToLocalBegin(dm,V,INSERT_VALUES,VLocal); <br><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre">    </span>DMGlobalToLocalEnd(dm,V,INSERT_VALUES,VLocal) ;<br><br><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre">    </span>VecGetArray(VLoc,VLocalArray);<br><br><span class="Apple-tab-span" style="white-space:pre">  </span><span class="Apple-tab-span" style="white-space:pre">    </span>“Stuff with VLocalArray”<br><br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">    </span>VecRestoreArray(VLoc,VLocalArray);<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">    </span><br><span class="Apple-tab-span" style="white-space:pre">  </span><span class="Apple-tab-span" style="white-space:pre">    </span>DMLocalToGlobalBegin(dm,VLocal,ADD_VALUES,V);<br><span class="Apple-tab-span" style="white-space:pre">     </span><span class="Apple-tab-span" style="white-space:pre">    </span>DMLocalToGlobalEnd(dm,VLocal,ADD_VALUES,V);<br><br><span class="Apple-tab-span" style="white-space:pre">     </span><span class="Apple-tab-span" style="white-space:pre">    </span>DMRestoreLocalVector(dm,&VLocal);<br>+++<br><br><span class="Apple-tab-span" style="white-space:pre">      </span>The second time I call the function I get errors with the VecGetArray() function.  I would appreciate any advice as to what is going wrong. <br><br>Thank you, <br><br>Matthew<br></blockquote></blockquote></div><br></div></body></html>