[petsc-users] DMPlexCreateLocalVec Within a function
Jed Brown
jed at jedbrown.org
Sat Apr 16 03:51:12 CDT 2016
Matthew Kury <mkury at berkeley.edu> writes:
> Yes you are correct I am sorry about that. I meant DMGetLocalVector, and the ilk.
>
> here is a dummy function I am working on to try to figure out what is going wrong:
> /////////////////////////////////////////////
> // Get the information to operate on
> // Make Local Versions
> Vec XLoc;
> DM Xdm;
> PetscSection XSec;
> PetscReal *XPoints=NULL;
>
> PetscErrorCode ierr;
>
>
> ierr = DMGetLocalVector(msh.dm,&XLoc);chk;
Here, you get XLoc from msh.dm.
> ierr = DMGetCoordinateDM(msh.dm,&Xdm);chk;
> ierr = DMGetCoordinatesLocal(msh.dm, &XLoc);chk;
> VecView(XLoc,pview);
>
> ierr = DMDAVecGetArrayRead(Xdm,XLoc,&XPoints);chk;
> ierr = DMDAVecRestoreArrayRead(Xdm,XLoc,&XPoints);chk;
>
> ierr = DMRestoreLocalVector(Xdm,&XLoc);chk;
Here, you return it to Xdm.
> //////////// end of function
>
> the error I get that seems to appear after the 2nd call or so is:
> 0]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------
> [0]PETSC ERROR: Invalid argument
> [0]PETSC ERROR: Wrong type of object: Parameter # 2
> [0]PETSC ERROR: See http://www.mcs.anl.gov/petsc/documentation/faq.html for trouble shooting.
> [0]PETSC ERROR: Petsc Release Version 3.6.1, Jul, 22, 2015
> [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
> [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
> [0]PETSC ERROR: #2294 DMDAVecGetArrayRead() line 299 in /usr/local/petsc-3.6.1/src/dm/impls/da/dagetarray.c
This #2294 is nowhere near the top of your stack. Please check error
codes. Running in a debugger would help you understand what is wrong.
> [0]PETSC ERROR: #2295 Element_Investigation_TEST() line 248 in /Users/mkury/Documents/Code/petFEM/src/elementFunctions.c
>
>
>
>
>
>
> thanks again,
>
> Matt
> On Apr 16, 2016, at 1:21 AM, Jed Brown <jed at jedbrown.org> wrote:
>
>> Matthew Kury <mkury at berkeley.edu> writes:
>>
>>> Hello,
>>>
>>> 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.
>>>
>>> If I have a function that passes in dm and V then:
>>> +++
>>> DMPlexGetLocalVec(dm, &VLocal) ;
>>
>> This function doesn't exist, and neither does DMPlexCreateLocalVec (from
>> the subject of your email), but when I gaze into my crystal ball, it
>> says you're probably spelling it DMGetLocalVector. Please send the full
>> error message.
>>
>>> DMGlobalToLocalBegin(dm,V,INSERT_VALUES,VLocal);
>>> DMGlobalToLocalEnd(dm,V,INSERT_VALUES,VLocal) ;
>>>
>>> VecGetArray(VLoc,VLocalArray);
>>>
>>> “Stuff with VLocalArray”
>>>
>>> VecRestoreArray(VLoc,VLocalArray);
>>>
>>> DMLocalToGlobalBegin(dm,VLocal,ADD_VALUES,V);
>>> DMLocalToGlobalEnd(dm,VLocal,ADD_VALUES,V);
>>>
>>> DMRestoreLocalVector(dm,&VLocal);
>>> +++
>>>
>>> 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.
>>>
>>> Thank you,
>>>
>>> Matthew
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 818 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20160416/1171bb3e/attachment.pgp>
More information about the petsc-users
mailing list