1 2 static char help[] = "Demonstrates use of PetscDrawZoom()\n"; 3 4 #if defined(PETSC_APPLE_FRAMEWORK) 5 6 #include <PETSc/petscsys.h> 7 #include <PETSc/petscdraw.h> 8 #else 9 #include <petscsys.h> 10 #include <petscdraw.h> 11 #endif 12 13 PetscErrorCode zoomfunction(PetscDraw draw,void *dummy) 14 { 15 int i; 16 MPI_Comm comm = PetscObjectComm((PetscObject)draw); 17 PetscMPIInt size,rank; 18 PetscErrorCode ierr; 19 20 ierr = MPI_Comm_size(comm,&size);CHKERRMPI(ierr); 21 ierr = MPI_Comm_rank(comm,&rank);CHKERRMPI(ierr); 22 for (i=rank; i<256; i+=size) { 23 PetscReal y = ((PetscReal)i)/(256-1); 24 ierr = PetscDrawLine(draw,0.0,y,1.0,y,i);CHKERRQ(ierr); 25 } 26 return 0; 27 } 28 29 int main(int argc,char **argv) 30 { 31 int x = 0,y = 0,width = 256,height = 256; 32 PetscDraw draw; 33 PetscErrorCode ierr; 34 35 ierr = PetscInitialize(&argc,&argv,NULL,help);if (ierr) return ierr; 36 ierr = PetscDrawCreate(PETSC_COMM_WORLD,NULL,"Title",x,y,width,height,&draw);CHKERRQ(ierr); 37 ierr = PetscDrawSetFromOptions(draw);CHKERRQ(ierr); 38 ierr = PetscDrawZoom(draw,zoomfunction,NULL);CHKERRQ(ierr); 39 ierr = PetscDrawDestroy(&draw);CHKERRQ(ierr); 40 ierr = PetscFinalize(); 41 return ierr; 42 } 43 44 /*TEST 45 46 build: 47 requires: x 48 49 test: 50 output_file: output/ex1_1.out 51 52 test: 53 suffix: db 54 args: -draw_double_buffer 0 55 output_file: output/ex1_1.out 56 57 test: 58 suffix: df 59 args: -draw_fast 60 output_file: output/ex1_1.out 61 62 test: 63 suffix: dv 64 args: -draw_virtual 65 output_file: output/ex1_1.out 66 67 TEST*/ 68