Actual source code: veccreate.c

petsc-3.3-p7 2013-05-11
  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 = PETSC_NULL;
 35: #ifndef PETSC_USE_DYNAMIC_LIBRARIES
 36:   VecInitializePackage(PETSC_NULL);
 37: #endif

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

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

 46:   *vec = v;
 47:   return(0);
 48: }