Actual source code: veccreate.c

      1: #define PETSCVEC_DLL
     2:  #include vecimpl.h

      6: /*@C
      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 PETSCVEC_DLLEXPORT 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_COOKIE, -1, "Vec", comm, VecDestroy, VecView);
     40:   PetscLogObjectMemory(v, sizeof(struct _p_Vec));
     41:   PetscMemzero(v->ops, sizeof(struct _VecOps));
     42:   v->bops->publish  = PETSC_NULL /* VecPublish_Petsc */;
     43:   v->type_name      = PETSC_NULL;

     45:   v->map          = PETSC_NULL;
     46:   v->data         = PETSC_NULL;
     47:   v->n            = -1;
     48:   v->N            = -1;
     49:   v->bs           = -1;
     50:   v->mapping      = PETSC_NULL;
     51:   v->bmapping     = PETSC_NULL;
     52:   v->array_gotten = PETSC_FALSE;
     53:   v->petscnative  = PETSC_FALSE;

     55:   *vec = v;
     56:   return(0);
     57: }