Actual source code: ex1.c
1: static char help[] = "Tests repeated VecSetType().\n\n";
3: #include <petscvec.h>
5: int main(int argc, char **argv)
6: {
7: PetscInt n = 5;
8: PetscScalar one = 1.0, two = 2.0;
9: Vec x, y;
11: PetscFunctionBeginUser;
12: PetscCall(PetscInitialize(&argc, &argv, NULL, help));
14: /* create vector */
15: PetscCall(VecCreate(PETSC_COMM_SELF, &x));
16: PetscCall(VecSetSizes(x, n, PETSC_DECIDE));
17: PetscCall(VecSetType(x, "mpi"));
18: PetscCall(VecSetType(x, "seq"));
19: PetscCall(VecDuplicate(x, &y));
20: PetscCall(VecSetType(x, "mpi"));
22: PetscCall(VecSet(x, one));
23: PetscCall(VecSet(y, two));
25: PetscCall(VecDestroy(&x));
26: PetscCall(VecDestroy(&y));
28: PetscCall(PetscFinalize());
29: return 0;
30: }
32: /*TEST
34: test:
35: suffix: 1
37: test:
38: suffix: 2
39: nsize: 2
41: TEST*/