Actual source code: ex4.c

petsc-3.7.3 2016-08-01
Report Typos and Errors
  2: static char help[] = "Demonstrates use of PetscDrawZoom()\n";

  4: #if defined(PETSC_APPLE_FRAMEWORK)
  5: #include <PETSc/petscsys.h>
  6: #include <PETSc/petscdraw.h>
  7: #else
  8: #include <petscsys.h>
  9: #include <petscdraw.h>
 10: #endif

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

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

 32: int main(int argc,char **argv)
 33: {
 34:   int            x = 0,y = 0,width = 256,height = 256;
 35:   PetscDraw      draw;

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