DMGetGlobalVector#

Gets a PETSc vector that may be used with the DM global routines.

Synopsis#

#include "petscdm.h" 
PetscErrorCode DMGetGlobalVector(DM dm, Vec *g)

Collective

Input Parameter#

  • dm - the DM

Output Parameter#

  • g - the global vector

Note#

The vector values are NOT initialized and may have garbage in them, so you may need to zero them.

The output parameter, g, is a regular PETSc vector that should be returned with DMRestoreGlobalVector() DO NOT call VecDestroy() on it.

This is intended to be used for vectors you need for a short time, like within a single function call. For vectors that you intend to keep around (for example in a C struct) or pass around large parts of your code you should use DMCreateGlobalVector().

VecStride*() operations can be useful when using DM with dof > 1

See Also#

DM, DMCreateGlobalVector(), VecDuplicate(), VecDuplicateVecs(), DMDACreate1d(), DMDACreate2d(), DMDACreate3d(), DMGlobalToLocalBegin(), DMGlobalToLocalEnd(), DMLocalToGlobalBegin(), DMCreateLocalVector(), DMRestoreLocalVector() VecStrideMax(), VecStrideMin(), VecStrideNorm(), DMClearGlobalVectors(), DMGetNamedGlobalVector(), DMGetNamedLocalVector()

Level#

beginner

Location#

src/dm/interface/dmget.c

Examples#

src/ts/tutorials/ex52.c
src/snes/tutorials/ex22.c
src/ts/tutorials/ex47.c
src/ts/tutorials/ex18.c
src/snes/tutorials/ex13.c
src/ts/tutorials/ex30.c
src/ts/tutorials/ex53.c
src/ts/tutorials/ex76.c
src/ts/tutorials/ex77.c
src/ksp/ksp/tutorials/ex73.c


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