[petsc-users] more flexible MatSetValues?

Gong Ding gdiso at ustc.edu
Sat Feb 19 07:43:47 CST 2011


So dynamic array is suitable for acting as a plus to the preallocation.
Only a few extra matrix entries not considered in the preallocation are needed to be processed.
For example, an integral boundary condition with dynamic integration range may have different nonzero entry in a row,
which can be hold by the dynamic array.
 
Values in each location are often set many times. Once per element in FEM, so about 20 times for P1 tets. That uses a lot more memory and you need to sort that beast to count correctly. Using a separate dynamic data structure for each row would be a lot more mallocs, but you could keep the rows sorted and avoid storing 20 copies, however insertion is still expensive. A heap is nice for insertion, but not for searching.
So dynamic data structures could help, but they still cost quite a bit. The preallocation problem is trivial for finite difference methods so any useful solution needs to handle many insertions to the same location.
On Feb 19, 2011 9:35 AM, "Gong Ding" <gdiso at ustc.edu> wrote:
Hi,
 After reading the source code of aij.c, I think the MatSetValues function can be more flexible when preallocation is not correct.
 Why not use a dynamic array such as c++ vector of triple(a, i, j) to buffer the operation?
 And flush the buffer to real a,i,j array when MatAssemblyEnd is called?
 Gong Ding
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20110219/91132aa2/attachment.htm>


More information about the petsc-users mailing list