Actual source code: ex1.c

  1: static char help[] = "Tests ISLocalToGlobalMappingCreateIS() for bs > 1.\n\n";

  3: #include <petscis.h>
  4: #include <petscviewer.h>

  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;

 12:   PetscFunctionBeginUser;
 13:   PetscCall(PetscInitialize(&argc, &argv, NULL, help));

 15:   PetscCall(ISCreateBlock(PETSC_COMM_SELF, bs, n, ix, PETSC_COPY_VALUES, &isx));
 16:   PetscCall(ISLocalToGlobalMappingCreateIS(isx, &ltog));

 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));

 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));

 26:   PetscCall(ISLocalToGlobalMappingDestroy(&ltog));
 27:   PetscCall(ISDestroy(&isx));

 29:   PetscCall(PetscFinalize());
 30:   return 0;
 31: }

 33: /*TEST

 35:    test:

 37: TEST*/