xref: /petsc/src/vec/is/tests/ex3.c (revision 0e03b746557e2551025fde0294144c0532d12f68)
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   ierr = PetscOptionsGetBool(NULL,NULL,"-broken",&broken,NULL);CHKERRQ(ierr);
17   ierr = ISCreateBlock(PETSC_COMM_SELF,bs,n,ix,PETSC_COPY_VALUES,&is);CHKERRQ(ierr);
18   ierr = ISGetIndices(is,&indices);CHKERRQ(ierr);
19   ierr = PetscIntView(bs*3,indices,NULL);CHKERRQ(ierr);
20   ierr = ISRestoreIndices(is,&indices);CHKERRQ(ierr);
21   if (broken) {
22     ierr = ISSetBlockSize(is,3);CHKERRQ(ierr);
23     ierr = ISGetIndices(is,&indices);CHKERRQ(ierr);
24     ierr = PetscIntView(bs*3,indices,NULL);CHKERRQ(ierr);
25     ierr = ISRestoreIndices(is,&indices);CHKERRQ(ierr);
26   }
27   ierr = ISDestroy(&is);CHKERRQ(ierr);
28 
29   ierr = PetscFinalize();
30   return ierr;
31 }
32 
33 
34 
35 /*TEST
36 
37    test:
38 
39    test:
40      suffix: 2
41      args:  -broken
42      filter: Error: grep -o  "[0]PETSC ERROR: Object is in wrong state"
43 
44 TEST*/
45