Actual source code: vmpicr.c

      1: /*
      2:    This file contains routines for Parallel vector operations.
      3:  */

      5: #include <petscvec.h>

      7: /*@
      8:   VecCreateMPI - Creates a parallel vector.

     10:   Collective

     12:   Input Parameters:
     13: + comm - the MPI communicator to use
     14: . n    - local vector length (or `PETSC_DECIDE` to have calculated if `N` is given)
     15: - N    - global vector length (or `PETSC_DETERMINE` to have calculated if `n` is given)

     17:   Output Parameter:
     18: . v - the vector

     20:   Level: intermediate

     22:   Notes:
     23:   It is recommended to use `VecCreateFromOptions()` instead of this routine

     25:   Use `VecDuplicate()` or `VecDuplicateVecs()` to form additional vectors of the
     26:   same type as an existing vector.

     28:   If `n` is not `PETSC_DECIDE`, then the value determines the `PetscLayout` of the vector and the ranges returned by
     29:   `VecGetOwnershipRange()` and `VecGetOwnershipRanges()`

     31: .seealso: [](ch_vectors), `Vec`, `VecType`, `VecCreateSeq()`, `VecCreate()`, `VecDuplicate()`, `VecDuplicateVecs()`, `VecCreateGhost()`,
     32:           `VecCreateMPIWithArray()`, `VecCreateGhostWithArray()`, `VecMPISetGhost()`, `PetscLayout`,
     33:           `VecGetOwnershipRange()`, `VecGetOwnershipRanges()`
     34: @*/
     35: PetscErrorCode VecCreateMPI(MPI_Comm comm, PetscInt n, PetscInt N, Vec *v)
     36: {
     37:   PetscFunctionBegin;
     38:   PetscCall(VecCreate(comm, v));
     39:   PetscCall(VecSetSizes(*v, n, N));
     40:   PetscCall(VecSetType(*v, VECMPI));
     41:   PetscFunctionReturn(PETSC_SUCCESS);
     42: }