Actual source code: ex21.c
1: static const char help[] = "Test VecScatterCopy() on an SF with duplicated leaves \n\n";
3: #include <petscvec.h>
4: #include <petscsf.h>
6: /*
7: Contributed-by: "Hammond, Glenn E" <glenn.hammond@pnnl.gov>
8: */
9: int main(int argc, char *argv[])
10: {
11: PetscMPIInt size;
12: PetscInt n;
13: PetscInt *indices;
14: Vec vec;
15: Vec vec2;
16: IS is;
17: IS is2;
18: VecScatter scatter;
19: VecScatter scatter2;
22: PetscInitialize(&argc, &argv, NULL, help);
23: MPI_Comm_size(PETSC_COMM_WORLD, &size);
26: n = 4;
27: PetscMalloc1(n, &indices);
28: indices[0] = 0;
29: indices[1] = 1;
30: indices[2] = 2;
31: indices[3] = 3;
32: ISCreateGeneral(PETSC_COMM_WORLD, n, indices, PETSC_COPY_VALUES, &is);
33: PetscFree(indices);
34: VecCreateMPI(PETSC_COMM_WORLD, n, n, &vec);
36: n = 4;
37: PetscMalloc1(n, &indices);
38: indices[0] = 0;
39: indices[1] = 0;
40: indices[2] = 1;
41: indices[3] = 1;
42: ISCreateGeneral(PETSC_COMM_WORLD, n, indices, PETSC_COPY_VALUES, &is2);
43: PetscFree(indices);
44: VecCreateMPI(PETSC_COMM_WORLD, n / 2, n / 2, &vec2);
46: VecScatterCreate(vec, is, vec2, is2, &scatter);
47: ISDestroy(&is);
48: ISDestroy(&is2);
50: VecScatterCopy(scatter, &scatter2);
52: VecDestroy(&vec);
53: VecDestroy(&vec2);
54: VecScatterDestroy(&scatter);
55: VecScatterDestroy(&scatter2);
56: PetscFinalize();
57: }
59: /*TEST
60: test:
61: nsize: 1
62: output_file: output/empty.out
63: TEST*/