[petsc-users] MatCreateShell with VecCreateGhost

Barry Smith bsmith at mcs.anl.gov
Tue Dec 1 20:04:03 CST 2015


  This is a pretty different thing. DMGetLocalVector(da,localX,ierr) gives a vector back with the correct amount of space for local ghosts and if you use DMDA it this the correct way to go. VecCreateGhost() creates a special vector that actually stores both the ghosted and nonghosted values in overlapping regions, but is totally inappropriate for DMDA.

  Barry

> On Dec 1, 2015, at 7:56 PM, Timothée Nicolas <timothee.nicolas at gmail.com> wrote:
> 
> Btw, 
> 
> If the vector X is created via a DMDA, then the vector localX and the pointer lx obtained via
> 
> call DMGetLocalVector(da,localX,ierr)
> call DMGlobalToLocalBegin(da,X,INSERT_VALUES,localX,ierr)
> call DMGlobalToLocalEnd(da,X,INSERT_VALUES,localX,ierr)
> call VecGetArrayReadF90(localX,lx,ierr)
> 
> are automatically ghosted, right ?
> 
> Thx
> 
> Timothee
> 
> 
> 2015-12-02 10:00 GMT+09:00 Barry Smith <bsmith at mcs.anl.gov>:
> 
>   Sorry, I could not control myself.
> 
>   So long as you pass vectors created with VecCreateGhost() to KSPSolve() the vectors passed to the multiply inside the solver will also be ghosted vectors.
> 
>    Send all output messages etc if it doesn't work for you
> 
>   Barry
> 
> 
> 
> > On Dec 1, 2015, at 6:47 PM, Barry Smith <bsmith at mcs.anl.gov> wrote:
> >
> >
> >> On Dec 1, 2015, at 5:18 PM, Bikash Kanungo <bikash at umich.edu> wrote:
> >>
> >> Hi,
> >>
> >> I want to implement a matrix-free KSP solve using user-defined MATOP_MULT and MATOP_MULT_TRANSPOSE. Each of these user-defined functions take in  Mat A, Vec x and Vec y as arguments and store A*x in y. To perform A*x in the user defined fashion, each processor requires access to some non-local nodes of x. So, is there a way I can create these two vectors (x and y) using VecCreateGhost?
> >
> >   Yes, use VecCreateGhost().
> >
> >   Barry
> >
> >
> >>
> >> Thanks,
> >> Bikash
> >>
> >> --
> >> Bikash S. Kanungo
> >> PhD Student
> >> Computational Materials Physics Group
> >> Mechanical Engineering
> >> University of Michigan
> >>
> >
> 
> 



More information about the petsc-users mailing list