Actual source code: ex2.c

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

  4: #include <petscsys.h>
  5: #include <petscdraw.h>

  9: int main(int argc,char **argv)
 10: {
 11:   PetscDraw      draw;
 12:   PetscMPIInt    size,rank;
 14:   int            x = 0,y = 0,width = 256,height = 256,i;

 16:   PetscInitialize(&argc,&argv,NULL,help);
 17:   PetscDrawCreate(PETSC_COMM_WORLD,0,"Title",x,y,width,height,&draw);
 18:   PetscDrawSetFromOptions(draw);
 19:   MPI_Comm_size(PETSC_COMM_WORLD,&size);
 20:   MPI_Comm_rank(PETSC_COMM_WORLD,&rank);
 21:   for (i=rank; i<height; i+=size) {
 22:     PetscReal y = ((PetscReal)i)/(height-1);
 23:     PetscDrawLine(draw,0.0,y,1.0,y,i%256);
 24:   }
 25:   PetscDrawFlush(draw);
 26:   PetscDrawPause(draw);
 27:   PetscDrawSave(draw);
 28:   PetscDrawDestroy(&draw);
 29:   PetscFinalize();
 30:   return 0;
 31: }