Actual source code: ex4.c

petsc-3.10.5 2019-03-28
Report Typos and Errors

  2: static char help[] = "Demonstrates use of PetscDrawZoom()\n";

  4: #if defined(PETSC_APPLE_FRAMEWORK)

  6: #include <PETSc/petscsys.h>
  7: #include <PETSc/petscdraw.h>
  8: #else
  9:  #include <petscsys.h>
 10:  #include <petscdraw.h>
 11: #endif

 13: PetscErrorCode zoomfunction(PetscDraw draw,void *dummy)
 14: {
 15:   int            i;
 16:   MPI_Comm       comm = PetscObjectComm((PetscObject)draw);
 17:   PetscMPIInt    size,rank;

 20:   MPI_Comm_size(comm,&size);
 21:   MPI_Comm_rank(comm,&rank);
 22:   for (i=rank; i<256; i+=size) {
 23:     PetscReal y = ((PetscReal)i)/(256-1);
 24:     PetscDrawLine(draw,0.0,y,1.0,y,i);
 25:   }
 26:   return 0;
 27: }

 29: int main(int argc,char **argv)
 30: {
 31:   int            x = 0,y = 0,width = 256,height = 256;
 32:   PetscDraw      draw;

 35:   PetscInitialize(&argc,&argv,NULL,help);
 36:   PetscDrawCreate(PETSC_COMM_WORLD,NULL,"Title",x,y,width,height,&draw);
 37:   PetscDrawSetFromOptions(draw);
 38:   PetscDrawZoom(draw,zoomfunction,NULL);
 39:   PetscDrawDestroy(&draw);
 40:   PetscFinalize();
 41:   return ierr;
 42: }




 47: /*TEST

 49:    build:
 50:      requires: x

 52:    test:
 53:      output_file: output/ex1_1.out

 55:    test:
 56:      suffix: db
 57:      args: -draw_double_buffer 0
 58:      output_file: output/ex1_1.out

 60:    test:
 61:      suffix: df
 62:      args: -draw_fast
 63:      output_file: output/ex1_1.out

 65:    test:
 66:      suffix: dv
 67:      args: -draw_virtual
 68:      output_file: output/ex1_1.out

 70: TEST*/