petsc-3.6.1 2015-08-06
Report Typos and Errors

MatBlockMatSetPreallocation

For good matrix assembly performance the user should preallocate the matrix storage by setting the parameter nz (or the array nnz). By setting these parameters accurately, performance during matrix assembly can be increased by more than a factor of 50.

Synopsis

#include "petscmat.h" 
PetscErrorCode  MatBlockMatSetPreallocation(Mat B,PetscInt bs,PetscInt nz,const PetscInt nnz[])
Collective on MPI_Comm

Input Parameters

B - The matrix
bs - size of each block in matrix
nz - number of nonzeros per block row (same for all rows)
nnz - array containing the number of nonzeros in the various block rows (possibly different for each row) or NULL

Notes

If nnz is given then nz is ignored

Specify the preallocated storage with either nz or nnz (not both). Set nz=PETSC_DEFAULT and nnz=NULL for PETSc to control dynamic memory allocation. For large problems you MUST preallocate memory or you will get TERRIBLE performance, see the users' manual chapter on matrices.

See Also

MatCreate(), MatCreateBlockMat(), MatSetValues()

Level:intermediate
Location:
src/mat/impls/blockmat/seq/blockmat.c
Index of all Mat routines
Table of Contents for all manual pages
Index of all manual pages