petsc-3.9.4 2018-09-11
Report Typos and Errors

DMCreateMatrix

Gets empty Jacobian for a DM

Synopsis

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

Input Parameter

dm -the DM object

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 DMSetMatrixPreallocateOnly()

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(), DMSetMatType()

Level

beginner

Location

src/dm/interface/dm.c

Examples

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

Implementations

DMCreateMatrix_Composite_Nest in src/dm/impls/composite/packm.c
DMCreateMatrix_Composite_AIJ in src/dm/impls/composite/packm.c
DMCreateMatrix_Composite in src/dm/impls/composite/packm.c
DMCreateMatrix_DA in src/dm/impls/da/fdda.c
DMCreateMatrix_DA_IS in src/dm/impls/da/fdda.c
DMCreateMatrix_DA_2d_MPISELL in src/dm/impls/da/fdda.c
DMCreateMatrix_DA_3d_MPISELL in src/dm/impls/da/fdda.c
DMCreateMatrix_DA_2d_MPIAIJ in src/dm/impls/da/fdda.c
DMCreateMatrix_DA_2d_MPIAIJ_Fill in src/dm/impls/da/fdda.c
DMCreateMatrix_DA_3d_MPIAIJ in src/dm/impls/da/fdda.c
DMCreateMatrix_DA_1d_MPIAIJ_Fill in src/dm/impls/da/fdda.c
DMCreateMatrix_DA_1d_MPIAIJ in src/dm/impls/da/fdda.c
DMCreateMatrix_DA_2d_MPIBAIJ in src/dm/impls/da/fdda.c
DMCreateMatrix_DA_3d_MPIBAIJ in src/dm/impls/da/fdda.c
DMCreateMatrix_DA_2d_MPISBAIJ in src/dm/impls/da/fdda.c
DMCreateMatrix_DA_3d_MPISBAIJ in src/dm/impls/da/fdda.c
DMCreateMatrix_DA_3d_MPIAIJ_Fill in src/dm/impls/da/fdda.c
DMCreateMatrix_pforest in src/dm/impls/forest/p4est/pforest.c
DMCreateMatrix_Moab in src/dm/impls/moab/dmmbmat.cxx
DMCreateMatrix_Network in src/dm/impls/network/network.c
DMCreateMatrix_Plex in src/dm/impls/plex/plex.c
DMCreateMatrix_Redundant in src/dm/impls/redundant/dmredundant.c
DMCreateMatrix_Shell in src/dm/impls/shell/dmshell.c
DMCreateMatrix_Sliced in src/dm/impls/sliced/sliced.c

Index of all DM routines
Table of Contents for all manual pages
Index of all manual pages