[petsc-users] How to do the preallocation and set zeros to rows and columns?

Matthew Knepley knepley at gmail.com
Fri Jun 14 12:08:33 CDT 2019


On Fri, Jun 14, 2019 at 11:40 AM Dongyu Liu - CITG via petsc-users <
petsc-users at mcs.anl.gov> wrote:

> Hi,
>
>
> I am using PETSc to run FEM on domain decomposition. When I assemble the
> matrix, I need to pre-allocate first to get better performance, can you
> recommend how to preallocate in this case?
>
>
> Right now we set big values for the number of nonzeros to preallocate
> memory, but when we do so, the program stuck at setZeroRowColumns. The
> error message is like:
>
> Matrix is missing diagonal entry in row 2.
>
1) Most preconditioners require a diagonal element, even if it is 0. Thus
it might be good to add diagonal elements, even if they are 0.

2) The best way to preallocate in general is to run your assembly twice.
Once to discover all the nonzero locations, and a second time to
    put in the values. Note that in the first pass, you do not have to
compute the entries, only the indices. We have a matrix class which helps
   with this process:
https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatPreallocatorPreallocate.html

  Thanks,

     Matt

> Do you have any idea why this happens?
>
> Note: In the domain decomposition we used, processors share some nodes.
>
>
> Best,
>
> Dongyu
>
>
>

-- 
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/20190614/711dea96/attachment.html>


More information about the petsc-users mailing list