xref: /petsc/src/vec/is/is/tests/ex5.c (revision a0c7f9aa3b59be96b422b2e54790cd20c111f46e)
1 
2 static char help[] = "Tests ISLocalToGlobalMappingGetInfo.()\n\n";
3 
4 #include <petscis.h>
5 
6 int main(int argc, char **argv)
7 {
8   PetscMPIInt            size, rank;
9   PetscInt               nlocal, local[5], nneigh, *neigh, **ineigh, *numneigh;
10   ISLocalToGlobalMapping mapping;
11 
12   PetscFunctionBeginUser;
13   PetscCall(PetscInitialize(&argc, &argv, (char *)0, help));
14   PetscCallMPI(MPI_Comm_size(PETSC_COMM_WORLD, &size));
15   PetscCheck(size == 3, PETSC_COMM_WORLD, PETSC_ERR_WRONG_MPI_SIZE, "Must run with three processors");
16   PetscCallMPI(MPI_Comm_rank(PETSC_COMM_WORLD, &rank));
17   if (rank == 0) {
18     nlocal   = 4;
19     local[0] = 0;
20     local[1] = 3;
21     local[2] = 2;
22     local[3] = 1;
23   } else if (rank == 1) {
24     nlocal   = 4;
25     local[0] = 3;
26     local[1] = 5;
27     local[2] = 4;
28     local[3] = 2;
29   } else {
30     nlocal   = 4;
31     local[0] = 7;
32     local[1] = 6;
33     local[2] = 5;
34     local[3] = 3;
35   }
36   PetscCall(ISLocalToGlobalMappingCreate(PETSC_COMM_WORLD, 1, nlocal, local, PETSC_COPY_VALUES, &mapping));
37   PetscCall(ISLocalToGlobalMappingGetInfo(mapping, &nneigh, &neigh, &numneigh, &ineigh));
38   PetscCall(ISLocalToGlobalMappingRestoreInfo(mapping, &nneigh, &neigh, &numneigh, &ineigh));
39   PetscCall(ISLocalToGlobalMappingDestroy(&mapping));
40   PetscCall(PetscFinalize());
41   return 0;
42 }
43 
44 /*TEST
45 
46    test:
47       nsize: 3
48       output_file: output/ex1_1.out
49 
50 TEST*/
51