petsc-3.3-p7 2013-05-11

DMCreateMatrix

Gets empty Jacobian for a DMDA or DMComposite

Synopsis

#include "petscdm.h"     
PetscErrorCode  DMCreateMatrix(DM dm,const MatType mtype,Mat *mat)
Collective on DM

Input Parameter

dm - the DM object
mtype - Supported types are MATSEQAIJ, MATMPIAIJ, MATSEQBAIJ, MATMPIBAIJ, or any type which inherits from one of these (such as MATAIJ)

Output Parameter

mat -the empty Jacobian

Notes: This properly preallocates the number of nonzeros in the sparse matrix so you do not need to do it yourself.

By default it also sets the nonzero structure and puts in the zero entries. To prevent setting the nonzero pattern call DMDASetMatPreallocateOnly()

For structured grid problems, when you call MatView() on this matrix it is displayed using the global natural ordering, NOT in the ordering used internally by PETSc.

For structured grid problems, in general it is easiest to use MatSetValuesStencil() or MatSetValuesLocal() to put values into the matrix because MatSetValues() requires the indices for the global numbering for DMDAs which is complicated.

See Also

DMDestroy(), DMView(), DMCreateGlobalVector(), DMCreateInterpolation()

Level:beginner
Location:
src/dm/interface/dm.c
Index of all DM routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/ksp/ksp/examples/tutorials/ex4.c.html
src/ksp/ksp/examples/tutorials/ex31.c.html
src/ksp/ksp/examples/tutorials/ex39.c.html
src/ksp/ksp/examples/tutorials/ex40.c.html
src/ksp/ksp/examples/tutorials/ex42.c.html
src/ksp/ksp/examples/tutorials/ex43.c.html
src/ksp/ksp/examples/tutorials/ex46.c.html
src/ksp/ksp/examples/tutorials/ex49.c.html
src/ksp/ksp/examples/tutorials/ex44f.F90.html
src/snes/examples/tutorials/ex10.c.html
src/snes/examples/tutorials/ex12.c.html