Actual source code: ex4.c


  2: static char help[] = "Demonstrates use of PetscDrawZoom()\n";

  4: #if defined(PETSC_APPLE_FRAMEWORK)

  6:   #include <PETSc/petscsys.h>
  7:   #include <PETSc/petscdraw.h>
  8: #else
  9: #include <petscsys.h>
 10: #include <petscdraw.h>
 11: #endif

 13: PetscErrorCode zoomfunction(PetscDraw draw, void *dummy)
 14: {
 15:   MPI_Comm    comm;
 16:   PetscMPIInt size, rank;

 18:   PetscFunctionBeginUser;
 19:   PetscCall(PetscObjectGetComm((PetscObject)draw, &comm));
 20:   PetscCallMPI(MPI_Comm_size(comm, &size));
 21:   PetscCallMPI(MPI_Comm_rank(comm, &rank));
 22:   for (int i = rank; i < 256; i += size) {
 23:     PetscReal y = ((PetscReal)i) / (256 - 1);
 24:     PetscCall(PetscDrawLine(draw, 0.0, y, 1.0, y, i));
 25:   }
 26:   PetscFunctionReturn(PETSC_SUCCESS);
 27: }

 29: int main(int argc, char **argv)
 30: {
 31:   int       x = 0, y = 0, width = 256, height = 256;
 32:   PetscDraw draw;

 34:   PetscFunctionBeginUser;
 35:   PetscCall(PetscInitialize(&argc, &argv, NULL, help));
 36:   PetscCall(PetscDrawCreate(PETSC_COMM_WORLD, NULL, "Title", x, y, width, height, &draw));
 37:   PetscCall(PetscDrawSetFromOptions(draw));
 38:   PetscCall(PetscDrawZoom(draw, zoomfunction, NULL));
 39:   PetscCall(PetscDrawDestroy(&draw));
 40:   PetscCall(PetscFinalize());
 41:   return 0;
 42: }

 44: /*TEST

 46:    build:
 47:      requires: x

 49:    test:
 50:      output_file: output/ex1_1.out

 52:    test:
 53:      suffix: db
 54:      args: -draw_double_buffer 0
 55:      output_file: output/ex1_1.out

 57:    test:
 58:      suffix: df
 59:      args: -draw_fast
 60:      output_file: output/ex1_1.out

 62:    test:
 63:      suffix: dv
 64:      args: -draw_virtual
 65:      output_file: output/ex1_1.out

 67: TEST*/