[petsc-users] DAGetMatrix with extra nonzeros: memory preallocation

Jed Brown jedbrown at mcs.anl.gov
Sat Sep 10 16:15:12 CDT 2011


On Sat, Sep 10, 2011 at 23:03, Mohamad M. Nasr-Azadani <mmnasr at gmail.com>wrote:

> Is there any example that could guide me on that?


Unfortunately there is not. You can read the man page for
MatMPIAIJSetPreallocation() and look at the implementations in DMDA that use
this API (e.g. DMGetMatrix_DA_2d_MPIAIJ in src/dm/impls/da/fdda.c -- your
implementation should be somewhat simpler because you only need one stencil
in the interior).

It would be good to have an example of preallocating for something
nontrivial, so if you write one, we can add it (and help debug if you get
stuck).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20110910/70f5fb44/attachment.htm>


More information about the petsc-users mailing list