[petsc-users] info about MatPreallocateInitialize/Finalize
Barry Smith
bsmith at mcs.anl.gov
Fri Jun 23 11:05:22 CDT 2017
You are correct, there are no could uses of it in examples. The best way to understand its use is to look at where it is used in PETSc. For example in src/dm/impls/da/fdda.c the function DMCreateMatrix_DA_2d_MPIAIJ(). You will see that it is your job to call MatPreallocateSetLocal() (or one of the other family of functions) to provide the information about nonzero columns for each row.
Note that this tool is very useful for some preallocations, like finite differences, it may not be useful for other discretizations and it may be better to compute the values for dnz and onz your self without using MatPreallocateInitialize
Barry
> On Jun 23, 2017, at 7:46 AM, Barletta, Ivano <ibarletta at inogs.it> wrote:
>
> Dear all
>
> How does MatPreallocateInitialize/Finalize work?
>
> I don't see any reference for examples in the
> online manual, soI've browsed the source code
> to see whetherthe routine is used and how
>
> As far as I understood it works this way:
>
> call MatPreallocateInitialize(comm, rows, cols, d_nz,o_nz,ierr)
>
> ! do something to calculate d_nz and o_nz
>
> call MatXXXSetPreallocation
> call MatPreallocateFinalize
>
> It is not that clear the way d_nz and o_nz are
> computed. Do I need to provide them myself?
> (in that case what would be the point of using
> MatPreallocateInitialize/Finalize?)
>
> Thanks
> Ivano
>
>
>
More information about the petsc-users
mailing list