static char help[] = "Demonstrates named colormaps\n"; #include #include typedef PetscReal (*Function)(PetscReal,PetscReal); typedef struct { Function function; } FunctionCtx; #define Exp PetscExpReal #define Pow PetscPowReal static PetscReal Peaks(PetscReal x,PetscReal y) { return 3 * Pow(1-x,2) * Exp(-Pow(x,2) - Pow(y+1,2)) - 10 * (x/5 - Pow(x,3) - Pow(y,5)) * Exp(-Pow(x,2) - Pow(y,2)) - 1./3 * Exp(-Pow(x+1,2) - Pow(y,2)); } static PetscErrorCode DrawFunction(PetscDraw draw,void *ctx) { int i,j,w,h; Function function = ((FunctionCtx*)ctx)->function; PetscReal min = PETSC_MAX_REAL, max = PETSC_MIN_REAL; MPI_Comm comm = PetscObjectComm((PetscObject)draw); PetscMPIInt size,rank; PetscDraw popup; PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscDrawGetWindowSize(draw,&w,&h);CHKERRQ(ierr); ierr = MPI_Comm_size(comm,&size);CHKERRMPI(ierr); ierr = MPI_Comm_rank(comm,&rank);CHKERRMPI(ierr); ierr = PetscDrawCollectiveBegin(draw);CHKERRQ(ierr); for (j=rank; j