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 PetscDraw draw; 9 PetscMPIInt size, rank; 10 int x = 0, y = 0, width = 256, height = 256, i; 11 12 PetscFunctionBeginUser; 13 PetscCall(PetscInitialize(&argc, &argv, NULL, help)); 14 PetscCall(PetscDrawCreate(PETSC_COMM_WORLD, 0, "Title", x, y, width, height, &draw)); 15 PetscCall(PetscDrawSetFromOptions(draw)); 16 PetscCallMPI(MPI_Comm_size(PETSC_COMM_WORLD, &size)); 17 PetscCallMPI(MPI_Comm_rank(PETSC_COMM_WORLD, &rank)); 18 for (i = rank; i < height; i += size) { 19 PetscReal y = ((PetscReal)i) / (height - 1); 20 PetscCall(PetscDrawLine(draw, 0.0, y, 1.0, y, i % 256)); 21 } 22 PetscCall(PetscDrawFlush(draw)); 23 PetscCall(PetscDrawPause(draw)); 24 PetscCall(PetscDrawSave(draw)); 25 PetscCall(PetscDrawDestroy(&draw)); 26 PetscCall(PetscFinalize()); 27 return 0; 28 } 29 30 /*TEST 31 32 build: 33 requires: x 34 35 test: 36 output_file: output/ex1_1.out 37 38 TEST*/ 39