petsc-3.3-p7 2013-05-11

MatSeqSBAIJSetPreallocation

Creates a sparse symmetric matrix in block AIJ (block compressed row) format. 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  MatSeqSBAIJSetPreallocation(Mat B,PetscInt bs,PetscInt nz,const PetscInt nnz[]) 
Collective on Mat

Input Parameters

A - the symmetric matrix
bs - size of block
nz - number of block nonzeros per block row (same for all rows)
nnz - array containing the number of block nonzeros in the upper triangular plus diagonal portion of each block (possibly different for each block row) or PETSC_NULL

Options Database Keys

-mat_no_unroll -uses code that does not unroll the loops in the block calculations (much slower)
-mat_block_size -size of the blocks to use (only works if a negative bs is passed in

Notes

Specify the preallocated storage with either nz or nnz (not both). Set nz=PETSC_DEFAULT and nnz=PETSC_NULL for PETSc to control dynamic memory allocation. See the <a href="../../docs/manual.pdf#nameddest=ch_mat">Mat chapter of the users manual</a> for details.

You can call MatGetInfo() to get information on how effective the preallocation was; for example the fields mallocs,nz_allocated,nz_used,nz_unneeded; You can also run with the option -info and look for messages with the string malloc in them to see if additional memory allocation was needed.

If the nnz parameter is given then the nz parameter is ignored

See Also

MatCreate(), MatCreateSeqAIJ(), MatSetValues(), MatCreateSBAIJ()

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

Examples

src/mat/examples/tutorials/ex17.c.html
src/snes/examples/tutorials/ex48.c.html