1 2 static char help[] = "Demonstrates use of color map\n"; 3 4 #include <petscsys.h> 5 #include <petscdraw.h> 6 7 int main(int argc,char **argv) 8 { 9 PetscDraw draw; 10 PetscMPIInt size,rank; 11 int x = 0,y = 0,width = 256,height = 256,i; 12 13 PetscFunctionBeginUser; 14 PetscCall(PetscInitialize(&argc,&argv,NULL,help)); 15 PetscCall(PetscDrawCreate(PETSC_COMM_WORLD,0,"Title",x,y,width,height,&draw)); 16 PetscCall(PetscDrawSetFromOptions(draw)); 17 PetscCallMPI(MPI_Comm_size(PETSC_COMM_WORLD,&size)); 18 PetscCallMPI(MPI_Comm_rank(PETSC_COMM_WORLD,&rank)); 19 for (i=rank; i<height; i+=size) { 20 PetscReal y = ((PetscReal)i)/(height-1); 21 PetscCall(PetscDrawLine(draw,0.0,y,1.0,y,i%256)); 22 } 23 PetscCall(PetscDrawFlush(draw)); 24 PetscCall(PetscDrawPause(draw)); 25 PetscCall(PetscDrawSave(draw)); 26 PetscCall(PetscDrawDestroy(&draw)); 27 PetscCall(PetscFinalize()); 28 return 0; 29 } 30 31 /*TEST 32 33 build: 34 requires: x 35 36 test: 37 output_file: output/ex1_1.out 38 39 TEST*/ 40