xref: /petsc/src/vec/is/tests/ex1.c (revision 732aec7a18f2199fb53bb9a2f3aef439a834ce31)
1 static char help[] = "Tests ISLocalToGlobalMappingCreateIS() for bs > 1.\n\n";
2 
3 #include <petscis.h>
4 #include <petscviewer.h>
5 
main(int argc,char ** argv)6 int main(int argc, char **argv)
7 {
8   PetscInt               bs = 2, n = 3, ix[3] = {1, 7, 9}, iy[2] = {0, 2}, mp[2];
9   IS                     isx;
10   ISLocalToGlobalMapping ltog;
11 
12   PetscFunctionBeginUser;
13   PetscCall(PetscInitialize(&argc, &argv, NULL, help));
14 
15   PetscCall(ISCreateBlock(PETSC_COMM_SELF, bs, n, ix, PETSC_COPY_VALUES, &isx));
16   PetscCall(ISLocalToGlobalMappingCreateIS(isx, &ltog));
17 
18   PetscCall(PetscIntView(2, iy, PETSC_VIEWER_STDOUT_WORLD));
19   PetscCall(ISLocalToGlobalMappingApply(ltog, 2, iy, mp));
20   PetscCall(PetscIntView(2, mp, PETSC_VIEWER_STDOUT_WORLD));
21 
22   PetscCall(PetscIntView(2, iy, PETSC_VIEWER_STDOUT_WORLD));
23   PetscCall(ISLocalToGlobalMappingApplyBlock(ltog, 2, iy, mp));
24   PetscCall(PetscIntView(2, mp, PETSC_VIEWER_STDOUT_WORLD));
25 
26   PetscCall(ISLocalToGlobalMappingDestroy(&ltog));
27   PetscCall(ISDestroy(&isx));
28 
29   PetscCall(PetscFinalize());
30   return 0;
31 }
32 
33 /*TEST
34 
35    test:
36 
37 TEST*/
38