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