[petsc-users] Check vector for zeros

Matthew Knepley knepley at gmail.com
Thu Jan 3 10:12:03 CST 2019


On Thu, Jan 3, 2019 at 11:01 AM Florian Lindner via petsc-users <
petsc-users at mcs.anl.gov> wrote:

> Hello,
>
> Happy New Year Everybody!
>
> I get a vector from a linear solve and is used a divisor in
> VecPointwiseDivide. Clearly, I must check for zero entries before doing the
> division.
>
> What is the best way to do so, especially performance wise?
>
> The only way I come up with so far, is to VecCopy, VecAbs and then check
> for VecMin > eps. The VecCopy kind of scares me for the performance draw
> back. I haven't found something like a VecAbsMin.
>
> Any better ideas?
>

I would write VecAbsMin() yourself,

https://bitbucket.org/petsc/petsc/src/bd27d3f284687498e4c4678d234c0e308a5bc236/src/vec/vec/utils/vinv.c#lines-299
https://bitbucket.org/petsc/petsc/src/bd27d3f284687498e4c4678d234c0e308a5bc236/src/vec/vec/utils/vinv.c#lines-1510

It should only be about 8 lines.

  Thanks,

    Matt


> Thanks,
> Florian
>


-- 
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

https://www.cse.buffalo.edu/~knepley/ <http://www.cse.buffalo.edu/~knepley/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20190103/c4c3f918/attachment.html>


More information about the petsc-users mailing list