Actual source code: ex1.c


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

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

  7: int main(int argc, char **argv)
  8: {
  9:   PetscInt               bs = 2, n = 3, ix[3] = {1, 7, 9}, iy[2] = {0, 2}, mp[2];
 10:   IS                     isx;
 11:   ISLocalToGlobalMapping ltog;

 13:   PetscFunctionBeginUser;
 14:   PetscCall(PetscInitialize(&argc, &argv, (char *)0, help));

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

 19:   PetscCall(PetscIntView(2, iy, PETSC_VIEWER_STDOUT_WORLD));
 20:   PetscCall(ISLocalToGlobalMappingApply(ltog, 2, iy, mp));
 21:   PetscCall(PetscIntView(2, mp, PETSC_VIEWER_STDOUT_WORLD));

 23:   PetscCall(PetscIntView(2, iy, PETSC_VIEWER_STDOUT_WORLD));
 24:   PetscCall(ISLocalToGlobalMappingApplyBlock(ltog, 2, iy, mp));
 25:   PetscCall(PetscIntView(2, mp, PETSC_VIEWER_STDOUT_WORLD));

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

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

 34: /*TEST

 36:    test:

 38: TEST*/