xref: /petsc/src/vec/vec/utils/vecs.c (revision e8e8640d1cb9a3a2f50c0c0d7b26e5c4d521e2e4)
1 #include <petscvec.h>
2 
VecsDestroy(Vecs x)3 PetscErrorCode VecsDestroy(Vecs x)
4 {
5   PetscFunctionBegin;
6   PetscCall(VecDestroy(&(x)->v));
7   PetscCall(PetscFree(x));
8   PetscFunctionReturn(PETSC_SUCCESS);
9 }
10 
VecsCreateSeq(MPI_Comm comm,PetscInt p,PetscInt m,Vecs * x)11 PetscErrorCode VecsCreateSeq(MPI_Comm comm, PetscInt p, PetscInt m, Vecs *x)
12 {
13   PetscFunctionBegin;
14   PetscCall(PetscNew(x));
15   PetscCall(VecCreateSeq(comm, p * m, &(*x)->v));
16   (*x)->n = m;
17   PetscFunctionReturn(PETSC_SUCCESS);
18 }
19 
VecsCreateSeqWithArray(MPI_Comm comm,PetscInt p,PetscInt m,PetscScalar * a,Vecs * x)20 PetscErrorCode VecsCreateSeqWithArray(MPI_Comm comm, PetscInt p, PetscInt m, PetscScalar *a, Vecs *x)
21 {
22   PetscFunctionBegin;
23   PetscCall(PetscNew(x));
24   PetscCall(VecCreateSeqWithArray(comm, 1, p * m, a, &(*x)->v));
25   (*x)->n = m;
26   PetscFunctionReturn(PETSC_SUCCESS);
27 }
28 
VecsDuplicate(Vecs x,Vecs * y)29 PetscErrorCode VecsDuplicate(Vecs x, Vecs *y)
30 {
31   PetscFunctionBegin;
32   PetscCall(PetscNew(y));
33   PetscCall(VecDuplicate(x->v, &(*y)->v));
34   (*y)->n = x->n;
35   PetscFunctionReturn(PETSC_SUCCESS);
36 }
37