<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sat, Apr 16, 2016 at 4:51 AM, Jed Brown <span dir="ltr"><<a href="mailto: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"><span class="">Matthew Kury <<a href="mailto:mkury@berkeley.edu">mkury@berkeley.edu</a>> writes:<br>
<br>
> Yes you are correct I am sorry about that. I meant DMGetLocalVector, and the ilk.<br>
><br>
> here is a dummy function I am working on to try to figure out what is going wrong:<br>
>   /////////////////////////////////////////////<br>
>   //    Get the information to operate on<br>
>   // Make Local Versions<br>
>   Vec             XLoc;<br>
>   DM              Xdm;<br>
>   PetscSection    XSec;<br>
>   PetscReal *XPoints=NULL;<br>
><br>
>   PetscErrorCode    ierr;<br>
><br>
><br>
>   ierr = DMGetLocalVector(<a href="http://msh.dm" rel="noreferrer" target="_blank">msh.dm</a>,&XLoc);chk;<br>
<br>
</span>Here, you get XLoc from <a href="http://msh.dm" rel="noreferrer" target="_blank">msh.dm</a>.<br>
<span class=""><br>
>   ierr = DMGetCoordinateDM(<a href="http://msh.dm" rel="noreferrer" target="_blank">msh.dm</a>,&Xdm);chk;<br>
>   ierr = DMGetCoordinatesLocal(<a href="http://msh.dm" rel="noreferrer" target="_blank">msh.dm</a>, &XLoc);chk;<br>
>   VecView(XLoc,pview);<br>
><br>
>   ierr = DMDAVecGetArrayRead(Xdm,XLoc,&XPoints);chk;<br></span></blockquote><div><br></div><div>Also here Xdm is supposed to be a DMDA. Is it?</div><div><br></div><div>  Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
>   ierr = DMDAVecRestoreArrayRead(Xdm,XLoc,&XPoints);chk;<br>
><br>
>   ierr = DMRestoreLocalVector(Xdm,&XLoc);chk;<br>
<br>
</span>Here, you return it to Xdm.<br>
<span class=""><br>
> //////////// end of function<br>
><br>
> the error I get that seems to appear after the 2nd call or so is:<br>
> 0]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------<br>
> [0]PETSC ERROR: Invalid argument<br>
> [0]PETSC ERROR: Wrong type of object: Parameter # 2<br>
> [0]PETSC ERROR: See <a href="http://www.mcs.anl.gov/petsc/documentation/faq.html" rel="noreferrer" target="_blank">http://www.mcs.anl.gov/petsc/documentation/faq.html</a> for trouble shooting.<br>
> [0]PETSC ERROR: Petsc Release Version 3.6.1, Jul, 22, 2015<br>
> [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<br>
> [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<br>
> [0]PETSC ERROR: #2294 DMDAVecGetArrayRead() line 299 in /usr/local/petsc-3.6.1/src/dm/impls/da/dagetarray.c<br>
<br>
</span>This #2294 is nowhere near the top of your stack.  Please check error<br>
codes.  Running in a debugger would help you understand what is wrong.<br>
<div class="HOEnZb"><div class="h5"><br>
> [0]PETSC ERROR: #2295 Element_Investigation_TEST() line 248 in /Users/mkury/Documents/Code/petFEM/src/elementFunctions.c<br>
><br>
><br>
><br>
><br>
><br>
><br>
> thanks again,<br>
><br>
> Matt<br>
> On Apr 16, 2016, at 1:21 AM, Jed Brown <<a href="mailto:jed@jedbrown.org">jed@jedbrown.org</a>> wrote:<br>
><br>
>> Matthew Kury <<a href="mailto:mkury@berkeley.edu">mkury@berkeley.edu</a>> writes:<br>
>><br>
>>> Hello,<br>
>>><br>
>>>     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>
>>>     If I have a function that passes in dm and V then:<br>
>>> +++<br>
>>>             DMPlexGetLocalVec(dm, &VLocal) ;<br>
>><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>
>>>             DMGlobalToLocalBegin(dm,V,INSERT_VALUES,VLocal);<br>
>>>             DMGlobalToLocalEnd(dm,V,INSERT_VALUES,VLocal) ;<br>
>>><br>
>>>             VecGetArray(VLoc,VLocalArray);<br>
>>><br>
>>>             “Stuff with VLocalArray”<br>
>>><br>
>>>             VecRestoreArray(VLoc,VLocalArray);<br>
>>><br>
>>>             DMLocalToGlobalBegin(dm,VLocal,ADD_VALUES,V);<br>
>>>             DMLocalToGlobalEnd(dm,VLocal,ADD_VALUES,V);<br>
>>><br>
>>>             DMRestoreLocalVector(dm,&VLocal);<br>
>>> +++<br>
>>><br>
>>>     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>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">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></div>