xref: /petsc/src/vec/is/tests/ex3.c (revision 40badf4fbc550ac1f60bd080eaff6de6d55b946d)
1 
2 static char help[]= "Tests ISSetBlockSize() on ISBlock().\n\n";
3 
4 #include <petscis.h>
5 #include <petscviewer.h>
6 
7 int main(int argc,char **argv)
8 {
9   PetscErrorCode         ierr;
10   PetscInt               bs = 2,n = 3,ix[3] = {1,7,9};
11   const PetscInt         *indices;
12   IS                     is;
13   PetscBool              broken = PETSC_FALSE;
14 
15   ierr = PetscInitialize(&argc,&argv,(char*)0,help);if (ierr) return ierr;
16   CHKERRQ(PetscOptionsGetBool(NULL,NULL,"-broken",&broken,NULL));
17   CHKERRQ(ISCreateBlock(PETSC_COMM_SELF,bs,n,ix,PETSC_COPY_VALUES,&is));
18   CHKERRQ(ISGetIndices(is,&indices));
19   CHKERRQ(PetscIntView(bs*3,indices,NULL));
20   CHKERRQ(ISRestoreIndices(is,&indices));
21   if (broken) {
22     CHKERRQ(ISSetBlockSize(is,3));
23     CHKERRQ(ISGetIndices(is,&indices));
24     CHKERRQ(PetscIntView(bs*3,indices,NULL));
25     CHKERRQ(ISRestoreIndices(is,&indices));
26   }
27   CHKERRQ(ISDestroy(&is));
28 
29   ierr = PetscFinalize();
30   return ierr;
31 }
32 
33 /*TEST
34 
35    test:
36 
37    test:
38      suffix: 2
39      args:  -broken
40      filter: Error: grep -o  "[0]PETSC ERROR: Object is in wrong state"
41 
42 TEST*/
43