petsc-3.7.1 2016-05-15
Report Typos and Errors

DMCreateMatrix

Gets empty Jacobian for a DM

Synopsis

#include "petscdm.h"          
#include "petscdmlabel.h"     
PetscErrorCode  DMCreateMatrix(DM dm,Mat *mat)
Collective on DM Many br

Input Parameter

dm -the DM object Many br

Output Parameter

mat -the empty Jacobian Many br

Many br

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

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

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

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

See Also

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

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/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/ex65.c.html
src/ksp/ksp/examples/tutorials/ex44f.F90.html
src/snes/examples/tutorials/ex12.c.html
src/snes/examples/tutorials/ex14.c.html
src/snes/examples/tutorials/ex15.c.html