[petsc-users] How to zero entries in a vec, including ghosts?

Matthew Knepley knepley at gmail.com
Thu Dec 1 08:59:17 CST 2016


On Thu, Dec 1, 2016 at 8:48 AM, Eric Chamberland <
Eric.Chamberland at giref.ulaval.ca> wrote:

> Hi,
>
> I try to find how to zeros all vec entries, including ghosts, without
> doing any communications...
>
> Since VecSet does not modify ghost values, we can do
>
> VecGhostUpdateBegin(v,INSERT_VALUES,SCATTER_FORWARD);
> VecGhostUpdateEnd(v,INSERT_VALUES,SCATTER_FORWARD);
>
> But that is somewhat "heavy" just to put zeros in a vec on all processes...
>
> Shouldn't VecZeroEntries be the function that should do the work correctly?
>

How about

VecGhostGetLocalForm(x,&xlocal);
VecZeroEntries(xlocal);
VecGhostRestoreLocalForm(x,&xlocal);

  Thanks,

     Matt


> Thanks,
>
> Eric
>



-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20161201/6eae6558/attachment-0001.html>


More information about the petsc-users mailing list