Actual source code: ex2.c

petsc-3.8.3 2017-12-09
Report Typos and Errors

  2: static char help[] = "Demonstrates use of color map\n";

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

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

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