Actual source code: veccreate.c

petsc-3.5.2 2014-09-08
Report Typos and Errors
  2: #include <petsc-private/vecimpl.h>           /*I  "petscvec.h"   I*/

  6: /*@
  7:   VecCreate - Creates an empty vector object. The type can then be set with VecSetType(),
  8:   or VecSetFromOptions().

 10:    If you never  call VecSetType() or VecSetFromOptions() it will generate an
 11:    error when you try to use the vector.

 13:   Collective on MPI_Comm

 15:   Input Parameter:
 16: . comm - The communicator for the vector object

 18:   Output Parameter:
 19: . vec  - The vector object

 21:   Level: beginner

 23: .keywords: vector, create
 24: .seealso: VecSetType(), VecSetSizes(), VecCreateMPIWithArray(), VecCreateMPI(), VecDuplicate(),
 25:           VecDuplicateVecs(), VecCreateGhost(), VecCreateSeq(), VecPlaceArray()
 26: @*/
 27: PetscErrorCode  VecCreate(MPI_Comm comm, Vec *vec)
 28: {
 29:   Vec            v;

 34:   *vec = NULL;
 35:   VecInitializePackage();

 37:   PetscHeaderCreate(v, _p_Vec, struct _VecOps, VEC_CLASSID,  "Vec", "Vector", "Vec", comm, VecDestroy, VecView);
 38:   PetscMemzero(v->ops, sizeof(struct _VecOps));

 40:   PetscLayoutCreate(comm,&v->map);
 41:   v->array_gotten = PETSC_FALSE;
 42:   v->petscnative  = PETSC_FALSE;

 44:   *vec = v;
 45:   return(0);
 46: }